/* iCan CGM web app. Visual language: Apple HIG, iOS 26 (Liquid Glass for the
   navigation layer, standard materials and grouped lists for content). */

:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.2);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --blue: #0088ff;
  --green: #34c759;
  --red: #ff383c;
  --orange: #ff8d28;
  --yellow: #ffcc00;
  --yellow-ink: #b38600;
  --purple: #cb30e0;
  --indigo: #6155f5;
  --pink: #ff2d55;
  --teal: #00c3d0;
  --mint: #00c8b3;
  --gray: #8e8e93;
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 10px 34px rgba(0, 0, 0, 0.13), 0 1px 3px rgba(0, 0, 0, 0.06);
  --lens: rgba(0, 0, 0, 0.055);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03);
  --zone: var(--green);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro", system-ui, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --radius-card: 26px;
  --radius-row: 26px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-space: calc(96px + var(--safe-bottom));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.32);
    --blue: #0091ff;
    --green: #30d158;
    --red: #ff4245;
    --orange: #ff9230;
    --yellow: #ffd600;
    --yellow-ink: #ffd600;
    --purple: #db34f2;
    --indigo: #6d7cff;
    --pink: #ff375f;
    --teal: #00d2e0;
    --mint: #00dac3;
    --glass-bg: rgba(44, 44, 48, 0.58);
    --glass-edge: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 12px 38px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
    --lens: rgba(255, 255, 255, 0.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.29;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; overflow-x: hidden; }

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { outline: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 60%, transparent); outline-offset: 2px; border-radius: 12px; }

svg.icon { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.fill { fill: currentColor; stroke: none; }

/* Ambient tint: the page quietly takes on the colour of the current glucose zone. */
#ambient {
  position: fixed;
  inset: 0 0 auto 0;
  height: 70vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 60% at 20% -10%, color-mix(in srgb, var(--zone) 22%, transparent), transparent 70%),
    radial-gradient(90% 50% at 100% 0%, color-mix(in srgb, var(--zone) 12%, transparent), transparent 70%);
  transition: background 1.2s ease;
}
body[data-zone="none"] #ambient { opacity: 0.35; }

.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; }

/* ---------- Views & navigation bar ---------- */

.view {
  display: none;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 8px) 0 var(--tabbar-space);
}
.view.active { display: block; animation: viewIn 0.42s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.navbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px 10px;
  min-height: 52px;
}
.navbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.012em;
}
.navbar .actions { display: flex; gap: 8px; align-items: center; padding-bottom: 4px; }

/* Compact bar that fades in when the large title scrolls away (scroll edge effect). */
.compactbar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  z-index: 20;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), color-mix(in srgb, var(--bg) 60%, transparent) 70%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.compactbar.show { opacity: 1; }

.glass-btn {
  height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 590;
  color: var(--label);
}

/* ---------- Liquid Glass (navigation layer only) ---------- */

.glass {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(190%);
  backdrop-filter: blur(22px) saturate(190%);
  box-shadow: var(--glass-shadow), inset 0 0 0 0.5px var(--glass-edge);
  isolation: isolate;
}
.glass::before {
  /* specular rim: brighter top edge, soft inner glow */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 38%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 30%);
  mix-blend-mode: soft-light;
  z-index: -1;
}
.glass:active { transform: scale(0.97); }

.tabbar-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  pointer-events: none;
  padding: 0 16px calc(var(--safe-bottom) + 10px);
  display: flex;
  justify-content: center;
}
.tabbar-inner { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 528px; pointer-events: auto; }
.tabbar-wrap::before {
  /* scroll edge effect: content fades under the bar */
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--safe-bottom) + 110px);
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 85%, transparent), transparent);
  pointer-events: none;
  z-index: -1;
}

.tabbar {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 62px;
  border-radius: 31px;
  padding: 4px;
  transition: transform 0.25s var(--spring);
}
.tabbar:active { transform: none; }
.tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 27px;
  color: var(--label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.25s ease, transform 0.25s var(--spring);
}
.tab svg.icon { width: 25px; height: 25px; }
.tab:active { transform: scale(0.92); }
.tab[aria-selected="true"] { color: var(--blue); }
.tab-lens {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 4);
  border-radius: 27px;
  background: var(--lens);
  transition: transform 0.45s var(--spring);
}
.tab-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 20px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  font-weight: 700;
  text-align: center;
}
.fab {
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 31px;
  display: grid;
  place-items: center;
  color: var(--label);
  transition: transform 0.3s var(--spring);
}
.fab svg.icon { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- Content layer ---------- */

.section { margin: 0 16px 22px; }
.section-title {
  margin: 0 20px 7px;
  font-size: 13px;
  line-height: 18px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--label-2);
}
.section-title.big { text-transform: none; font-size: 20px; font-weight: 700; color: var(--label); letter-spacing: -0.01em; margin: 0 4px 10px; }
.section-footer { margin: 7px 20px 0; font-size: 13px; line-height: 18px; color: var(--label-2); letter-spacing: -0.005em; }

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card.pad { padding: 16px; }

.list { background: var(--card); border-radius: var(--radius-row); overflow: hidden; }
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  width: 100%;
  text-align: left;
  color: var(--label);
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--sep-inset, 16px);
  border-top: 0.5px solid var(--sep);
}
.row.has-icon { --sep-inset: 60px; }
button.row:active, a.row:active { background: var(--fill); }
.row .title { flex: 1; min-width: 0; }
.row .title small { display: block; font-size: 13px; color: var(--label-2); margin-top: 1px; letter-spacing: -0.005em; }
.row .detail { color: var(--label-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--label-3); width: 14px; height: 14px; stroke-width: 3; }
.row.link { color: var(--blue); }
.row.destructive { color: var(--red); }
.row.center { justify-content: center; }
.row-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
  background: var(--c, var(--gray));
}
.row-icon svg.icon { width: 18px; height: 18px; stroke-width: 2.2; }
.row-icon.round { border-radius: 50%; }

.muted { color: var(--label-2); }
.num { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }

/* ---------- Controls ---------- */

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch .track { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background 0.25s ease; }
.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s var(--spring), width 0.2s ease;
}
.switch input:checked ~ .track { background: var(--green); }
.switch input:checked ~ .knob { transform: translateX(20px); }
.switch input:active ~ .knob { width: 33px; }
.switch input:checked:active ~ .knob { transform: translateX(14px); }
.switch input:disabled { cursor: default; }
.switch input:disabled ~ .track { opacity: 0.5; }

.segmented {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: 20px;
  background: var(--fill);
  isolation: isolate;
}
.segmented button {
  position: relative;
  z-index: 1;
  height: 32px;
  border-radius: 17px;
  font-size: 14px;
  font-weight: 500;
  color: var(--label);
  transition: font-weight 0.2s;
}
.segmented button[aria-pressed="true"] { font-weight: 600; }
.segmented .thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  border-radius: 17px;
  background: var(--card);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.4s var(--spring);
}
@media (prefers-color-scheme: dark) { .segmented .thumb { background: #636366; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 22px;
  border-radius: 25px;
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.2s var(--spring), opacity 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.secondary { background: var(--fill); color: var(--blue); }
.btn.danger { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.btn.small { height: 36px; font-size: 15px; padding: 0 16px; width: auto; border-radius: 18px; }
.btn:disabled { opacity: 0.4; }
.btn-stack { display: grid; gap: 10px; }

.stepper { display: inline-flex; border-radius: 10px; background: var(--fill); overflow: hidden; flex: none; }
.stepper button { width: 46px; height: 32px; display: grid; place-items: center; font-size: 20px; font-weight: 400; color: var(--label); }
.stepper button + button { border-left: 0.5px solid var(--sep); }
.stepper button:active { background: var(--fill-2); }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 16px;
}
.field + .field { border-top: 0.5px solid var(--sep); }
.field label { width: 42%; flex: none; }
.field input, .field select, .field textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 14px 0;
}
.field textarea { text-align: left; resize: none; min-height: 80px; }
.field input::placeholder, .field textarea::placeholder { color: var(--label-3); }
.textfield {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  border: 0;
  padding: 0 16px;
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 19px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sheet .textfield { background: var(--card-2); }

/* ---------- Home: glucose hero ---------- */

.hero {
  position: relative;
  padding: 18px 20px 20px;
  overflow: hidden;
  isolation: isolate;
}
.hero::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 90%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--zone) 30%, transparent), transparent 65%);
  z-index: -1;
  transition: background 1s ease;
}
.hero-status { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--label-2); letter-spacing: -0.005em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent); }
.dot.busy { background: var(--orange); animation: pulse 1.4s ease-in-out infinite; }
.dot.off { background: var(--label-3); }
@keyframes pulse { 50% { opacity: 0.35; } }

.hero-main { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.hero-value { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.hero-value .value {
  font-family: var(--font-rounded);
  font-size: clamp(72px, 24vw, 92px);
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.hero-value .value.word { font-size: 64px; letter-spacing: -0.02em; }
.hero-value .unit { font-size: 17px; font-weight: 600; color: var(--label-2); }
.hero.stale .value { color: var(--label-3); }
.trend-disc {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
  background: var(--zone);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--zone) 38%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: background 0.6s ease, box-shadow 0.6s ease;
}
body[data-zone="high"] .trend-disc { color: #000; }
.trend-disc svg { width: 40px; height: 40px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.6s var(--spring); }
.trend-disc.none svg { opacity: 0; }
.hero.stale .trend-disc { background: var(--fill-2); box-shadow: none; color: var(--label-2); }
.hero-sub { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--fill);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.demo-pill { background: var(--purple); color: #fff; height: 30px; }
.pill.zone { background: color-mix(in srgb, var(--zone) 18%, transparent); color: var(--zone-ink, var(--label)); }
body[data-zone="high"] { --zone-ink: var(--yellow-ink); }
body[data-zone="range"] { --zone-ink: color-mix(in srgb, var(--green) 70%, var(--label)); }
body[data-zone="low"] { --zone-ink: color-mix(in srgb, var(--orange) 80%, var(--label)); }
body[data-zone="urgent"] { --zone-ink: var(--red); }

.hero-empty { text-align: center; padding: 28px 22px 22px; }
.hero-empty h2 { margin: 14px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.hero-empty p { margin: 0 auto 20px; color: var(--label-2); font-size: 15px; max-width: 32ch; line-height: 1.35; }
.sensor-art { width: 92px; height: 92px; margin: 0 auto; display: block; }

.warmup-ring { position: relative; width: 132px; height: 132px; margin: 6px auto 4px; }
.warmup-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.warmup-ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.warmup-ring .bg { stroke: var(--fill); }
.warmup-ring .fg { stroke: var(--blue); transition: stroke-dashoffset 1s var(--ease); }
.warmup-ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.warmup-ring .label b { font-family: var(--font-rounded); font-size: 30px; font-variant-numeric: tabular-nums; }
.warmup-ring .label span { font-size: 12px; color: var(--label-2); font-weight: 600; }

/* ---------- Chart ---------- */

.chart-card { padding: 14px 0 6px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 8px; gap: 10px; }
.chart-head .segmented { flex: 1; max-width: 250px; }
.chart-readout { font-size: 13px; color: var(--label-2); font-weight: 600; font-variant-numeric: tabular-nums; min-height: 18px; text-align: right; }
.chart-readout b { color: var(--label); font-family: var(--font-rounded); font-size: 15px; }
.chart { position: relative; height: 230px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--sep); stroke-width: 0.5; }
.chart .grid.dash { stroke-dasharray: 3 4; }
.chart .axis { fill: var(--label-2); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.chart .band { fill: color-mix(in srgb, var(--green) 12%, transparent); }
.chart .limit-high { stroke: var(--yellow); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.9; }
.chart .limit-low { stroke: var(--orange); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.9; }
.chart .now-line { stroke: var(--label-3); stroke-width: 1; }
.chart .scrub-line { stroke: var(--label); stroke-width: 1; opacity: 0.35; }
.chart .scrub-dot { fill: var(--card); stroke: var(--label); stroke-width: 2.5; }
.chart .agp-outer { fill: color-mix(in srgb, var(--blue) 14%, transparent); }
.chart .agp-inner { fill: color-mix(in srgb, var(--blue) 30%, transparent); }
.chart .agp-median { stroke: var(--blue); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.chart .event-dot { stroke: var(--card); stroke-width: 1.5; }
.chart .finger { stroke: var(--card); stroke-width: 1.5; fill: var(--red); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--label-2); font-size: 15px; }
@media (orientation: landscape) and (max-height: 500px) {
  .chart { height: calc(100dvh - 150px); }
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 16px 22px; }
.tile { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; min-height: 128px; text-align: left; }
.tile-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--label-2); letter-spacing: -0.005em; }
.tile-label svg.icon { width: 16px; height: 16px; stroke-width: 2.4; }
.tile-value { white-space: nowrap; font-family: var(--font-rounded); font-size: clamp(21px, 7.2vw, 28px); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile-value small { font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--label-2); letter-spacing: -0.01em; }
.tile-foot { margin-top: auto; font-size: 13px; color: var(--label-2); letter-spacing: -0.005em; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--c, var(--blue)); transition: width 0.8s var(--ease); }

.tir-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; gap: 2px; }
.tir-bar > i { display: block; min-width: 3px; transition: flex-grow 0.8s var(--ease); }
.tir-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { padding: 14px 16px; }
.metric .k { font-size: 13px; font-weight: 600; color: var(--label-2); }
.metric .v { font-family: var(--font-rounded); font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .v small { font-family: var(--font); font-size: 14px; color: var(--label-2); font-weight: 600; }
.metric .h { font-size: 12px; color: var(--label-2); margin-top: 2px; }

.date-nav { display: flex; align-items: center; justify-content: space-between; padding: 6px; }
.date-nav button.arrow { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; color: var(--blue); }
.date-nav button.arrow:disabled { color: var(--label-3); }
.date-nav .d { font-weight: 600; text-align: center; }
.date-nav .d small { display: block; font-weight: 400; font-size: 13px; color: var(--label-2); }

.banner-card { padding: 16px; display: flex; gap: 14px; align-items: flex-start; }
.banner-card .row-icon { width: 36px; height: 36px; border-radius: 10px; }
.banner-card h3 { margin: 0 0 3px; font-size: 17px; font-weight: 600; }
.banner-card p { margin: 0 0 12px; font-size: 15px; color: var(--label-2); line-height: 1.35; }

.empty { text-align: center; padding: 46px 30px; color: var(--label-2); }
.empty svg.icon { width: 44px; height: 44px; stroke-width: 1.6; color: var(--label-3); }
.empty h3 { color: var(--label); margin: 12px 0 4px; font-size: 20px; }
.empty p { margin: 0; font-size: 15px; line-height: 1.35; }

.log-view {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0;
  white-space: pre-wrap;
  word-break: break-all;
  padding: 12px 14px;
  max-height: 55vh;
  overflow: auto;
  color: var(--label-2);
}

/* ---------- Sheets, dialogs, banners, toasts ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed;
  z-index: 51;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  transform: translate(-50%, 105%);
  transition: transform 0.5s var(--ease);
  background: var(--bg);
  border-radius: 34px 34px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
}
@media (prefers-color-scheme: dark) { .sheet { background: #1c1c1e; } .sheet .list, .sheet .card { background: #2c2c2e; } .sheet .textfield { background: #2c2c2e; } }
.sheet.show { transform: translate(-50%, 0); }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 6px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; flex: 1; }
.sheet-head .glass-btn { background: var(--fill); box-shadow: none; }
.sheet-head .glass-btn.confirm { background: var(--blue); color: #fff; }
.sheet-head .glass-btn:disabled { opacity: 0.4; }
.sheet-body { overflow-y: auto; padding: 10px 0 calc(var(--safe-bottom) + 24px); -webkit-overflow-scrolling: touch; }
.sheet-body .section:last-child { margin-bottom: 0; }
.sheet-intro { text-align: center; padding: 4px 28px 18px; }
.sheet-intro h3 { margin: 12px 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.sheet-intro p { margin: 0; color: var(--label-2); font-size: 15px; line-height: 1.38; }

.dialog {
  position: fixed;
  z-index: 61;
  left: 50%;
  top: 50%;
  width: min(300px, calc(100% - 60px));
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0;
  transition: transform 0.35s var(--spring), opacity 0.2s ease;
  border-radius: 30px;
  padding: 22px 18px 16px;
  text-align: center;
}
.dialog.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.dialog h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.dialog p { margin: 0 0 18px; font-size: 14px; line-height: 1.38; color: var(--label-2); }
.dialog .btn-row { display: flex; gap: 10px; }
.dialog .btn { height: 44px; border-radius: 22px; font-size: 16px; }
.backdrop.dialog-bd { z-index: 60; }

.banner-root { position: fixed; z-index: 70; top: 0; left: 50%; width: 100%; max-width: 560px; transform: translateX(-50%); padding: calc(var(--safe-top) + 8px) 10px 0; pointer-events: none; }
.alert-banner {
  pointer-events: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 26px;
  margin-bottom: 8px;
  transform: translateY(-130%);
  transition: transform 0.55s var(--spring);
  width: 100%;
  text-align: left;
}
.alert-banner.show { transform: none; }
.alert-banner .row-icon { width: 38px; height: 38px; border-radius: 10px; }
.alert-banner b { display: block; font-size: 15px; }
.alert-banner span { font-size: 14px; color: var(--label-2); }
.alert-banner.urgent { box-shadow: var(--glass-shadow), inset 0 0 0 2px var(--red); }

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(var(--tabbar-space) + 8px);
  transform: translate(-50%, 20px);
  opacity: 0;
  transition: transform 0.4s var(--spring), opacity 0.25s ease;
  padding: 12px 18px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 600;
  max-width: calc(100% - 40px);
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 16px 22px; }
.type-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  border-radius: 20px;
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.type-grid button .row-icon { width: 40px; height: 40px; border-radius: 12px; }
.type-grid button .row-icon svg.icon { width: 22px; height: 22px; }
.type-grid button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--blue); }
.type-grid button:active { transform: scale(0.95); }

.steps { display: grid; gap: 0; }
.step-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-size: 16px; }
.step-row + .step-row { border-top: 0.5px solid var(--sep); }
.step-row .state { width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.step-row.done .state { color: var(--green); }
.step-row.active .state::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--fill-2); border-top-color: var(--blue); animation: spin 0.8s linear infinite; }
.step-row.todo { color: var(--label-3); }
.step-row.fail .state { color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

.qr-video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 22px; background: #000; display: block; }

.hold-btn { position: relative; overflow: hidden; }
.hold-btn .fillbar { position: absolute; inset: 0; background: color-mix(in srgb, var(--red) 28%, transparent); transform-origin: left; transform: scaleX(0); }
.hold-btn.holding .fillbar { transform: scaleX(1); transition: transform 3s linear; }
.hold-btn span { position: relative; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--label-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-all; }

@media (prefers-reduced-transparency: reduce) {
  .glass, .compactbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--card); }
  .glass::before { display: none; }
}
@media (prefers-contrast: more) {
  .glass { box-shadow: var(--glass-shadow), inset 0 0 0 1.5px var(--label-2); }
  .row + .row::before { border-top-color: var(--label-2); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 700px) {
  body { background: var(--bg); }
  .view { padding-top: 28px; }
}
