/* iPhone block: Kelvin for iPhone, its Lab tab in iOS light mode (ios/Kelvin/LabView.swift), on a modern iPhone.
   The device is sized from the phone's width (--pw). Inside the screen, sizes are in em of a font that follows the
   screen's width (cqw), so the app scales like a screenshot; small text never drops below 11px. */

.kd-phone {
  --ip-bg: #f2f2f7;
  --ip-card: #fff;
  --ip-label: #000;
  --ip-label-2: #6e6e73;
  --ip-label-3: #a1a1a6;
  --ip-sep: rgba(60, 60, 67, 0.17);
  --ip-fill: rgba(120, 120, 128, 0.12);
  --ip-accent: #2f6fb0;
  --ip-tab-on: #33609e;
  --ip-red: #ff3b30;
  --ip-red-ink: #d70015;
  --ip-badge: #e0242b;
  --ip-orange: #ff9500;
  --ip-green: #34c759;
  --ip-green-ink: #23803b;
  --ip-font: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --ip-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ip-scroll: cubic-bezier(0.45, 0, 0.2, 1);

  position: relative;
  container-type: inline-size;
  text-align: left;
}
.kd-phone [hidden] { display: none !important; }
.kd-phone svg { display: inline-block; flex: none; max-width: none; }
.kd-phone p { margin: 0; }
.kd-phone.is-instant *, .kd-phone.is-instant *::before, .kd-phone.is-instant *::after {
  transition: none !important; animation: none !important;
}

/* ---------- the stage and the device ---------- */

.kd-phone-stage {
  --pw: clamp(260px, 80cqw, 306px);
  --pad: clamp(16px, 4.5cqw, 30px);
  position: relative;
  height: calc(var(--pw) * 2.1007 + 2 * var(--pad));
  display: grid; place-items: center;
}
.kd-phone-glow {
  position: absolute; left: 50%; top: 50%;
  width: min(100%, calc(var(--pw) * 2.1)); height: calc(var(--pw) * 2.3);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(90, 162, 230, 0.5), rgba(58, 126, 200, 0.3) 46%,
    rgba(47, 111, 176, 0.1) 72%, rgba(47, 111, 176, 0) 100%);
  filter: blur(22px);
  pointer-events: none;
}
.kd-phone-device {
  position: relative; isolation: isolate;
  width: var(--pw); height: calc(var(--pw) * 2.1007);
  border-radius: calc(var(--pw) * 0.163);
  /* dark titanium: a thin brushed band around the glass */
  background: linear-gradient(140deg, #7a7c81 0%, #404246 7%, #26272a 26%, #1c1d20 52%, #2c2e31 80%, #5d5f64 94%, #84868b 100%);
  box-shadow:
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(0, 0, 0, 0.7),
    0 26px 56px -18px rgba(0, 0, 0, 0.8),
    0 46px 100px -36px rgba(6, 20, 40, 0.9);
}
.kd-phone-key {
  position: absolute; z-index: -1;
  width: calc(var(--pw) * 0.013); border-radius: 2px;
  background: linear-gradient(90deg, #1d1e21, #54565a 55%, #2a2b2e);
}
.kd-phone-key.l { left: calc(var(--pw) * -0.0095); }
.kd-phone-key.r { right: calc(var(--pw) * -0.0095); }
.kd-phone-key.k1 { top: 18.6%; height: 3.4%; }   /* action button */
.kd-phone-key.k2 { top: 25.4%; height: 6.6%; }   /* volume up */
.kd-phone-key.k3 { top: 33.6%; height: 6.6%; }   /* volume down */
.kd-phone-key.k4 { top: 28%; height: 10.4%; }    /* side button */
.kd-phone-bezel {
  position: absolute; inset: calc(var(--pw) * 0.0085);
  border-radius: calc(var(--pw) * 0.1545);
  background: #040405;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.kd-phone-screen {
  position: absolute; inset: calc(var(--pw) * 0.0288);
  border-radius: calc(var(--pw) * 0.1342);
  overflow: hidden; isolation: isolate;
  container-type: inline-size;
  background: var(--ip-bg);
  transform: translateZ(0);
}

/* ---------- the app: everything below is in em of the screen's font ---------- */

.kd-phone-ui {
  position: absolute; inset: 0;
  font: 400 clamp(11.5px, 4.86cqw, 15px) / 1.3 var(--ip-font);
  letter-spacing: -0.012em;
  color: var(--ip-label);
  -webkit-font-smoothing: antialiased;
}
.kd-phone-ico {
  width: 1em; height: 1em;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.kd-phone-view { position: absolute; inset: 0; transition: opacity 0.45s ease; }
.kd-phone-view.is-off { opacity: 0; }

/* the list, moved as one piece when it scrolls */
.kd-phone-scroll {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 24.9cqw 0 34cqw;
  transition: transform 1.5s var(--ip-scroll);
  will-change: transform;
}
.kd-phone-large {
  margin: 0; padding: 0 0.47em;
  font-size: 2em; font-weight: 700; line-height: 1.22; letter-spacing: 0.006em;
}
.kd-phone-sec { margin: 1.4em 0.94em 0; }
.kd-phone-sec.first { margin-top: 0.45em; }
.kd-phone-head { margin: 0 1.18em 0.42em; font-weight: 600; color: var(--ip-label-2); }
.kd-phone-card { background: var(--ip-card); border-radius: 1.12em; overflow: hidden; }
.kd-phone-row { position: relative; padding: 0.74em 1.18em; }
.kd-phone-row + .kd-phone-row::before {
  content: ""; position: absolute; top: 0; left: 1.18em; right: 1.18em; border-top: 1px solid var(--ip-sep);
}

/* type, after iOS: headline, subheadline, footnote, caption */
.kd-phone-b { font-weight: 600; }
.kd-phone-sub { font-size: max(11px, 0.882em); }
.kd-phone-foot { margin-top: 0.32em; font-size: max(11px, 0.765em); line-height: 1.32; color: var(--ip-label-2); letter-spacing: 0; }
.kd-phone-cap { margin-top: 0.32em; font-size: max(11px, 0.706em); line-height: 1.3; color: var(--ip-label-2); letter-spacing: 0; }
.kd-phone-num { font-variant-numeric: tabular-nums; }
.kd-phone-label { display: flex; align-items: flex-start; gap: 0.42em; font-weight: 600; }
.kd-phone-label .kd-phone-ico { width: 1.14em; height: 1.14em; margin-top: 0.05em; }

/* status: the coloured dot, what Kelvin is doing, the route */
.kd-phone-state { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.72em; }
.kd-phone-dot {
  width: 0.6em; height: 0.6em; margin-top: 0.36em; border-radius: 50%;
  background: var(--ip-red); transition: background-color 0.45s ease;
}
.kd-phone-state.ok .kd-phone-dot { background: var(--ip-green); }
.kd-phone-state b { display: block; font-weight: 600; }
.kd-phone-route {
  display: flex; align-items: center; gap: 0.32em; margin-top: 0.36em;
  font-size: max(11px, 0.706em); color: var(--ip-green-ink); letter-spacing: 0;
}
.kd-phone-route .kd-phone-ico { width: 1.3em; height: 1.3em; stroke-width: 1.7; }

/* alarm: red while on; grey once someone says Got it */
.kd-phone-alarm .kd-phone-label { color: var(--ip-red-ink); transition: color 0.28s ease; }
.kd-phone-alarm.is-ack .kd-phone-label { color: var(--ip-label-2); }
.kd-phone-alarm.is-ack .kd-phone-btn { color: var(--ip-label-3); background: rgba(120, 120, 128, 0.07); }

/* the request: Approve asks once more in a sheet, then the card ends in Approved */
.kd-phone-ask .kd-phone-label .kd-phone-ico { color: var(--ip-orange); }
.kd-phone-item { margin-top: 0.42em; font-size: max(11px, 0.882em); font-variant-numeric: tabular-nums; letter-spacing: -0.006em; }
.kd-phone-fold {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows 0.45s var(--ip-ease) 0.1s, opacity 0.25s ease;
}
.kd-phone-fold > div { min-height: 0; overflow: hidden; }
.kd-phone-fold .kd-phone-cap { margin-top: 0.45em; }
.kd-phone-ask.is-approved .kd-phone-fold { grid-template-rows: 0fr; opacity: 0; }
.kd-phone-answer { display: grid; align-items: center; padding-top: 0.62em; }
.kd-phone-answer > * { grid-area: 1 / 1; transition: opacity 0.18s ease, transform 0.4s var(--ip-ease); }
.kd-phone-btns { display: flex; flex-wrap: wrap; gap: 0.6em; }
.kd-phone-approved {
  display: flex; align-items: center; gap: 0.32em;
  color: var(--ip-green-ink); font-weight: 500;
  opacity: 0; transform: translateY(0.3em);
}
.kd-phone-approved .kd-phone-ico { width: 1.05em; height: 1.05em; stroke-width: 2.4; }
.kd-phone-ask.is-approved .kd-phone-btns { opacity: 0; }
.kd-phone-ask.is-approved .kd-phone-approved { opacity: 1; transform: none; transition-duration: 0.3s, 0.4s; transition-delay: 0.2s; }

/* buttons: iOS bordered capsules */
.kd-phone-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.36em;
  height: 2.05em; padding: 0 0.95em; border-radius: 999px;
  background: var(--ip-fill); color: var(--ip-accent); white-space: nowrap;
  transition: opacity 0.15s ease, color 0.45s ease, background-color 0.45s ease;
}
.kd-phone-btn .kd-phone-ico { width: 1.08em; height: 1.08em; }
.kd-phone-btn.primary { background: var(--ip-accent); color: #fff; font-weight: 600; }
.kd-phone-btn.stop { background: rgba(255, 59, 48, 0.12); color: var(--ip-red-ink); }
.kd-phone-btn.pressed { opacity: 0.5; }
.kd-phone-act { padding-top: 0.62em; }

/* sample */
.kd-phone-sample { display: flex; align-items: baseline; gap: 0.5em; }
.kd-phone-sample .proj { font-size: max(11px, 0.882em); color: var(--ip-label-2); }
.kd-phone-prot {
  margin-left: auto; align-self: center; display: inline-flex; align-items: center; gap: 0.24em;
  font-size: max(11px, 0.706em); font-weight: 600; color: var(--ip-green-ink); letter-spacing: 0;
}
.kd-phone-prot .kd-phone-ico { width: 1.1em; height: 1.1em; }

/* run: progress, Stop, and the live plot */
.kd-phone-runtop { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6em; }
.kd-phone-pct { font-size: max(11px, 0.882em); color: var(--ip-label-2); font-variant-numeric: tabular-nums; }
.kd-phone-bar { height: 0.3em; margin: 0.62em 0 0.42em; border-radius: 999px; background: rgba(120, 120, 128, 0.2); overflow: hidden; }
.kd-phone-bar i {
  display: block; height: 100%; border-radius: inherit; background: var(--ip-accent);
  transform-origin: 0 50%; transition: transform 0.76s linear;
}
.kd-phone-menu { display: inline-flex; align-items: center; gap: 0.22em; font-size: max(11px, 0.882em); color: var(--ip-accent); }
.kd-phone-menu .kd-phone-ico { width: 1.05em; height: 1.05em; stroke-width: 2; }
.kd-phone-chart { position: relative; height: max(9.4em, 118px); margin-top: 0.4em; }
.kd-phone-chart svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; font-size: max(11px, 0.68em); letter-spacing: 0; }
.kd-phone-chart .grid { stroke: rgba(60, 60, 67, 0.13); stroke-width: 1; shape-rendering: crispEdges; }
.kd-phone-chart text { fill: var(--ip-label-2); font-variant-numeric: tabular-nums; }
.kd-phone-chart .line {
  fill: none; stroke: var(--ip-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke-dashoffset 0.76s linear;
}

/* instruments: name, the orange dot for a drive away from safe, the first reading */
.kd-phone-inst { display: flex; align-items: center; gap: 0.5em; }
.kd-phone-inst .name { margin-right: auto; }
.kd-phone-odot { flex: none; width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--ip-orange); }
.kd-phone-inst .v { font-size: max(11px, 0.882em); color: var(--ip-label-2); font-variant-numeric: tabular-nums; }
.kd-phone-inst .kd-phone-ico { width: 0.78em; height: 0.78em; color: #3a3a3c; stroke-width: 2.6; }

/* recent notices */
.kd-phone-note { display: flex; align-items: baseline; gap: 0.6em; }
.kd-phone-note .t { flex: none; font-size: max(11px, 0.706em); color: var(--ip-label-2); font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ---------- bars over the list ---------- */

/* the inline title and the soft edge under the status bar, once the large title has scrolled away */
.kd-phone-nav { position: absolute; left: 0; right: 0; top: 0; height: 24.9cqw; z-index: 6; pointer-events: none; }
.kd-phone-nav::before {
  content: ""; position: absolute; inset: 0 0 -1.4em;
  background: linear-gradient(var(--ip-bg) 0%, var(--ip-bg) 60%, rgba(242, 242, 247, 0.9) 78%, rgba(242, 242, 247, 0));
  opacity: 0; transition: opacity 0.3s ease;
}
.kd-phone-nav b {
  position: absolute; left: 0; right: 0; top: 13.7cqw; height: 11.2cqw;
  display: grid; place-items: center; font-weight: 600;
  opacity: 0; transform: translateY(0.3em); transition: opacity 0.25s ease, transform 0.25s ease;
}
.kd-phone-ui.is-scrolled .kd-phone-nav::before { opacity: 1; }
.kd-phone-ui.is-titled .kd-phone-nav b { opacity: 1; transform: none; }
.kd-phone-thumb {
  position: absolute; right: 0.2em; top: 0; z-index: 7; width: 0.2em; height: 3em;
  border-radius: 999px; background: rgba(0, 0, 0, 0.34);
  opacity: 0; transition: opacity 0.4s ease;
}
.kd-phone-thumb.on { opacity: 1; }

.kd-phone-edge {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34cqw; z-index: 8; pointer-events: none;
  background: linear-gradient(rgba(242, 242, 247, 0), rgba(242, 242, 247, 0.88) 52%, rgba(242, 242, 247, 0.98) 80%);
}

/* the floating tab bar */
.kd-phone-tabs {
  position: absolute; left: 3.9cqw; right: 3.9cqw; bottom: 5.2cqw; z-index: 9;
  height: calc(12cqw + 12px); padding: 1.15cqw;
  display: flex; gap: 0.5cqw;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(12px) saturate(170%); backdrop-filter: blur(12px) saturate(170%);
  box-shadow: 0 0.35em 1.3em rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.08), inset 0 0.5px 0 rgba(255, 255, 255, 0.9);
}
.kd-phone-tab {
  position: relative; flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1em;
  border-radius: 999px; color: #1c1c1e;
}
.kd-phone-tab .kd-phone-ico { width: 1.45em; height: 1.45em; stroke-width: 1.65; }
.kd-phone-tab span { font-size: max(11px, 0.62em); font-weight: 500; line-height: 1.1; letter-spacing: 0; white-space: nowrap; }
.kd-phone-tab.on { flex-grow: 1.7; background: rgba(120, 120, 128, 0.11); color: var(--ip-tab-on); }
.kd-phone-tab.on span { font-weight: 600; }
.kd-phone-badge {
  position: absolute; top: 0.08em; left: calc(50% + 0.42em);
  min-width: 1.6em; height: 1.6em; padding: 0 0.42em; border-radius: 999px;
  display: grid; place-items: center;
  font: 600 max(11px, 0.72em) / 1 var(--ip-font); font-style: normal; letter-spacing: 0;
  background: var(--ip-badge); color: #fff;
  transition: transform 0.35s var(--ip-ease), opacity 0.3s ease;
}
.kd-phone-badge.is-gone { opacity: 0; transform: scale(0.4); }
.kd-phone-homebar {
  position: absolute; left: 50%; bottom: 2.1cqw; z-index: 9;
  width: 34cqw; height: 1.35cqw; margin-left: -17cqw; border-radius: 999px; background: #0d0d0e;
}

/* the status bar and the Dynamic Island */
.kd-phone-status { position: absolute; left: 0; right: 0; top: 0; height: 13.7cqw; z-index: 10; pointer-events: none; color: #000; }
.kd-phone-time {
  position: absolute; left: 5.4cqw; top: 7.6cqw; width: 18cqw; transform: translateY(-50%);
  text-align: center; font-size: max(11px, 4.3cqw); font-weight: 600; line-height: 1; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.kd-phone-glyphs {
  position: absolute; right: 6.4cqw; top: 7.6cqw; transform: translateY(-50%);
  display: flex; align-items: center; gap: 1.3cqw;
}
.kd-phone-glyphs svg { fill: currentColor; }
.kd-phone-glyphs .cell { width: 4.5cqw; height: 3cqw; }
.kd-phone-glyphs .wifi { width: 4.1cqw; height: 3.1cqw; }
.kd-phone-glyphs .batt { width: 6.7cqw; height: 3.25cqw; }
.kd-phone-island {
  position: absolute; left: 50%; top: 2.8cqw; z-index: 11;
  width: 32cqw; height: 9.4cqw; margin-left: -16cqw; border-radius: 999px; background: #000;
}

/* ---------- the confirmation sheet ---------- */

.kd-phone-dim {
  position: absolute; inset: 0; z-index: 20; pointer-events: none;
  background: rgba(0, 0, 0, 0.24); opacity: 0; transition: opacity 0.3s ease;
}
.kd-phone-sheet {
  position: absolute; left: 0.55em; right: 0.55em; bottom: 8.4cqw; z-index: 21;
  display: grid; gap: 0.5em;
  transform: translateY(calc(100% + 9cqw)); transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.kd-phone-ui.is-sheet .kd-phone-dim { opacity: 1; }
.kd-phone-ui.is-sheet .kd-phone-sheet { transform: none; }
.kd-phone-sgroup {
  overflow: hidden; border-radius: 0.95em; text-align: center;
  background: rgba(250, 250, 252, 0.95);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
}
.kd-phone-shead {
  display: grid; gap: 0.3em; padding: 0.9em 1.1em 0.95em;
  font-size: max(11px, 0.765em); line-height: 1.3; color: var(--ip-label-2); letter-spacing: 0;
}
.kd-phone-shead b { font-weight: 600; }
.kd-phone-sbtn {
  display: grid; place-items: center; height: 2.75em;
  border-top: 1px solid var(--ip-sep);
  font-size: 1.15em; color: var(--ip-accent);
  transition: background-color 0.15s ease;
}
.kd-phone-sbtn.cancel { border-top: 0; background: #fff; font-weight: 600; }
.kd-phone-sbtn.pressed { background-color: rgba(0, 0, 0, 0.08); }

/* ---------- the finger ---------- */

.kd-phone-finger {
  position: absolute; left: 0; top: 0; z-index: 30;
  width: 2.7em; height: 2.7em; margin: -1.35em 0 0 -1.35em;
  opacity: 0; pointer-events: none;
  transition: transform 0.7s cubic-bezier(0.45, 0.05, 0.25, 1), opacity 0.3s ease;
}
.kd-phone-finger.on { opacity: 1; }
.kd-phone-finger i {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: rgba(120, 120, 128, 0.34);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.75), 0 0.25em 0.9em rgba(0, 0, 0, 0.16);
  transition: transform 0.16s ease, background-color 0.16s ease;
}
.kd-phone-finger.down i { transform: scale(0.84); background: rgba(98, 98, 106, 0.48); }

@media (prefers-reduced-motion: reduce) {
  .kd-phone *, .kd-phone *::before, .kd-phone *::after { transition: none !important; animation: none !important; }
}
