/* Circadian Ledger — dark by design: a sleep app gets opened at night. */
:root {
  --bg: #070911;
  --bg-soft: #0C0F1A;
  --card: rgba(255, 255, 255, .038);
  --card-2: rgba(255, 255, 255, .062);
  --stroke: rgba(255, 255, 255, .065);
  --stroke-2: rgba(255, 255, 255, .13);
  --text: #F1F3F9;
  --dim: #9BA3B9;
  --faint: #626B82;

  --blue: #79A9FF;
  --blue-deep: #3D74F0;
  --amber: #F3B15C;
  --violet: #A99CFF;
  --good: #57CE9E;
  --crit: #FF7E6E;

  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;
  --ease: cubic-bezier(.22, .78, .24, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 70px;
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
}
body {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3 { text-wrap: balance; }

/* ---------- ambient wash, tinted by where you are in your day ---------- */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.glow {
  position: absolute; left: 50%; top: -32vh;
  width: 150vw; max-width: 1000px; height: 74vh;
  border-radius: 50%;
  transform: translate3d(-50%, 0, 0);
  opacity: 0;
  transition: opacity 1.4s ease;
}
.g-day   { background: radial-gradient(closest-side, rgba(61, 116, 240, .30), rgba(61, 116, 240, 0)); }
.g-dusk  { background: radial-gradient(closest-side, rgba(233, 150, 55, .24), rgba(233, 150, 55, 0)); }
.g-night { background: radial-gradient(closest-side, rgba(116, 100, 255, .26), rgba(116, 100, 255, 0)); }
body.tone-day .g-day, body.tone-dusk .g-dusk, body.tone-night .g-night { opacity: 1; }

/* ---------- shell ---------- */
.app { position: relative; z-index: 1; height: 100%; max-width: 560px; margin: 0 auto; }
.views { position: absolute; inset: 0; }
.view {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 0 18px calc(var(--safe-b) + var(--tabbar-h) + 32px);
  opacity: 0; visibility: hidden;
  transform: translate3d(0, 12px, 0);
  transition: opacity .26s ease, transform .42s var(--ease), visibility 0s linear .42s;
}
.view::-webkit-scrollbar { display: none; }
.view.active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .32s ease, transform .5s var(--ease), visibility 0s;
}
.view.enter .reveal { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } }

/* sticky compact title, fades in once you scroll past the big one */
.viewbar {
  position: sticky; top: 0; z-index: 8;
  margin: 0 -18px 0; padding: calc(var(--safe-t) + 10px) 18px 10px;
  font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  background: linear-gradient(var(--bg) 62%, rgba(7, 9, 17, 0));
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .28s ease, transform .28s var(--ease);
}
.view.scrolled .viewbar { opacity: 1; transform: none; }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 2px 18px; padding-top: 6px; }
.view:not(.scrolled) .top { padding-top: calc(var(--safe-t) + 14px); }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; color: var(--dim); }
.title { margin: 2px 0 0; font: 700 33px/1.08 var(--font); letter-spacing: -.03em; }
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--text);
  transition: transform .22s var(--ease), background .2s;
}
.icon-btn:active { transform: scale(.88); background: rgba(255, 255, 255, .15); }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 12px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.aside { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.k { font-size: 12.5px; font-weight: 600; color: var(--dim); }

/* ---------- hero ring ---------- */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 18px 22px; overflow: hidden; }
.ring-wrap { position: relative; width: min(58vw, 224px); aspect-ratio: 1; max-width: 100%; }
.ring-halo {
  position: absolute; inset: 24%; border-radius: 50%;
  background-color: var(--blue); opacity: .18; filter: blur(32px);
  transition: background-color .9s ease;
}
.ring { position: relative; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 12; }
.ring-fg {
  fill: none; stroke: var(--blue); stroke-width: 12; stroke-linecap: round;
  transition: stroke-dashoffset 1.2s var(--ease), stroke .9s ease;
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font: 700 64px/1 var(--font-round); letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.ring-label { margin-top: 6px; font-size: 11px; font-weight: 650; letter-spacing: .17em; text-transform: uppercase; color: var(--dim); }
.state { margin: 18px 0 3px; font: 650 22px/1.2 var(--font); letter-spacing: -.02em; }
.next { margin: 0; font-size: 15px; color: var(--dim); }
.next b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- tonight ---------- */
.tonight-row { display: flex; align-items: center; gap: 10px; }
.tn { flex: 1; min-width: 0; background: var(--card-2); border-radius: var(--r-md); padding: 13px 14px; }
.tn-v { display: block; margin-top: 4px; font: 700 25px/1.1 var(--font-round); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tn-arrow { flex: none; width: 22px; color: var(--faint); }
.tn-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tonight-note { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--dim); }
.tonight-note b { color: var(--text); font-weight: 650; }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0;
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r-md);
  padding: 13px 12px 12px; text-align: left; appearance: none;
  transition: transform .22s var(--ease), background .2s;
}
button.stat:active { transform: scale(.96); background: var(--card-2); }
.stat .k { font-size: 11.5px; }
.stat .v {
  margin-top: 6px; font: 700 22px/1.15 var(--font-round); letter-spacing: -.028em;
  font-variant-numeric: tabular-nums; white-space: nowrap; transition: color .6s ease;
}
.stat .v small, .debt-big small, .tn-v small { font-size: 13px; font-weight: 650; color: var(--dim); margin-left: 1px; letter-spacing: 0; }
.stat .s { margin-top: 2px; font-size: 11.5px; color: var(--faint); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.good { color: var(--good); } .warn { color: var(--amber); } .crit { color: var(--crit); }

/* ---------- onboarding / install / insight ---------- */
.onboard strong, .install strong { display: block; font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.onboard p { margin: 0 0 14px; font-size: 14.5px; color: var(--dim); }
.install {
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(135deg, rgba(61, 116, 240, .19), rgba(169, 156, 255, .07));
  border-color: rgba(121, 169, 255, .24);
}
.install p { margin: 2px 0 0; font-size: 14px; color: var(--dim); }
.install b { color: var(--text); font-weight: 600; }
.share-glyph { display: inline-block; width: 15px; height: 15px; vertical-align: -2px; color: var(--blue); }
.x-btn { flex: none; margin-left: auto; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .09); color: var(--dim); font-size: 19px; line-height: 1; }
.insight p { margin: 0; font-size: 15px; line-height: 1.55; color: #CED3E0; }
.insight b { color: var(--text); font-weight: 650; }

/* ---------- trip chip on Today ---------- */
.trip-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 12px;
  padding: 12px 14px; border-radius: var(--r-md); text-align: left;
  border: 1px solid rgba(169, 156, 255, .3);
  background: linear-gradient(135deg, rgba(169, 156, 255, .16), rgba(169, 156, 255, .05));
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: transform .22s var(--ease);
}
.trip-chip:active { transform: scale(.98); }
.trip-chip .chev { margin-left: auto; }
.tc-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 0 4px rgba(169, 156, 255, .18); }

/* ---------- legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; color: var(--dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.sw-blue { background: var(--blue); } .sw-amber { background: var(--amber); } .sw-violet { background: var(--violet); }

/* ---------- curve ---------- */
.curve { position: relative; margin: 0 -2px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.curve svg, .rail svg, .bars svg { display: block; width: 100%; height: auto; overflow: visible; }
.band-sleep { fill: var(--violet); fill-opacity: .12; }
.band-mel { fill: var(--amber); fill-opacity: .16; }
.grid { stroke: rgba(255, 255, 255, .055); stroke-width: 1; }
.tick { fill: var(--faint); font: 600 10.5px var(--font-round); }
.curve-line { fill: none; stroke: var(--blue); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.feat { transition: opacity .25s; }
.feat circle { stroke: #0A0C14; stroke-width: 1.5; }
.feat text { font: 650 10.5px var(--font); paint-order: stroke; stroke: #0A0C14; stroke-width: 3px; stroke-linejoin: round; }
.f-day circle, .f-day text { fill: var(--blue); }
.f-dusk circle, .f-dusk text { fill: var(--amber); }
.nowmark { transition: opacity .25s; }
.nowmark line { stroke: rgba(255, 255, 255, .42); stroke-width: 1; stroke-dasharray: 2 3; }
.now-dot { fill: #fff; stroke: var(--blue); stroke-width: 2; }
.now-pulse { fill: #fff; transform-box: fill-box; transform-origin: center; animation: pulse 2.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .45; } 100% { transform: scale(3.4); opacity: 0; } }
.scrub { opacity: 0; transition: opacity .2s; }
.scrub line { stroke: rgba(255, 255, 255, .8); stroke-width: 1.2; }
.scrub circle { fill: #fff; stroke: var(--blue); stroke-width: 3; }
.curve.scrubbing .scrub { opacity: 1; }
.curve.scrubbing .nowmark, .curve.scrubbing .feat { opacity: .18; }

/* ---------- rail ---------- */
.rail-track { fill: rgba(255, 255, 255, .055); }
.r-day { fill: var(--blue); }
.r-dusk { fill: var(--amber); fill-opacity: .45; }
.r-dusk.r-mel { fill-opacity: 1; }
.r-night { fill: var(--violet); fill-opacity: .5; }
.r-pt { fill-opacity: 1; }
.rail-now { fill: #fff; stroke: #0A0C14; stroke-width: 3; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 6px 0 0; padding: 0; }
.tl { display: grid; grid-template-columns: 64px 20px minmax(0, 1fr); column-gap: 8px; }
.tl-time { padding-top: 14px; text-align: right; font: 650 14px/1.2 var(--font-round); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-time small { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--faint); }
.tl-mark { position: relative; display: flex; justify-content: center; }
.tl-mark::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--stroke); }
.tl:first-child .tl-mark::before { top: 20px; }
.tl:last-child .tl-mark::before { bottom: auto; height: 20px; }
.tl-mark i { position: relative; margin-top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2.5px solid var(--c); transition: background .4s, box-shadow .4s; }
.tl.now .tl-mark i { background: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent); }
.tl-body { margin: 4px 0 8px; padding: 11px 14px 12px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--stroke); transition: background .4s, border-color .4s; }
.tl.now .tl-body { background: color-mix(in srgb, var(--c) 10%, transparent); border-color: color-mix(in srgb, var(--c) 32%, transparent); }
.tl.past { opacity: .38; }
.tl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tl-label { font-size: 15.5px; font-weight: 650; letter-spacing: -.012em; }
.tl-sub { margin: 3px 0 0; font-size: 13.5px; line-height: 1.42; color: var(--dim); }
.chip { flex: none; padding: 5px 8px; border-radius: 999px; font: 650 11.5px/1 var(--font-round); font-variant-numeric: tabular-nums; white-space: nowrap; background: rgba(255, 255, 255, .07); color: var(--dim); }
.tl.now .chip { background: var(--c); color: #090B12; }
.t-day { --c: var(--blue); } .t-dusk { --c: var(--amber); } .t-night { --c: var(--violet); }

/* ---------- sleep ---------- */
.debt-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.debt-big { margin-top: 4px; font: 700 52px/1 var(--font-round); letter-spacing: -.045em; font-variant-numeric: tabular-nums; transition: color .6s; }
.debt-big small { font-size: 22px; }
.debt-side { text-align: right; }
.debt-side .v { display: block; margin-top: 4px; font: 700 20px/1.2 var(--font-round); font-variant-numeric: tabular-nums; }
.debt-note { margin: 8px 0 16px; font-size: 14px; color: var(--dim); }
.bar { transform-box: fill-box; transform-origin: 50% 100%; }
.b-ok { fill: var(--blue); } .b-short { fill: var(--amber); } .b-none { fill: rgba(255, 255, 255, .14); }
.need { stroke: rgba(255, 255, 255, .34); stroke-width: 1; stroke-dasharray: 3 4; }
.need-label { fill: var(--dim); font: 650 10.5px var(--font-round); paint-order: stroke; stroke: #0B0D15; stroke-width: 4px; stroke-linejoin: round; }
.tick.today { fill: var(--text); }
.view.enter .bar { animation: grow .85s var(--ease) both; animation-delay: calc(var(--i) * 32ms + 160ms); }
@keyframes grow { from { transform: scaleY(0); } }

.acto { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.a-row, .a-axis { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; align-items: center; }
.a-lab { font: 600 10.5px var(--font-round); color: var(--faint); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.a-track { position: relative; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .04); overflow: hidden; }
.a-row.empty .a-track { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 3px, transparent 3px 7px); }
.a-bar { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: linear-gradient(90deg, #8076F5, #B0A8FF); transform-origin: left center; }
.a-cbt { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--amber); opacity: .85; }
.a-axis { margin-top: 6px; }
.a-ticks { display: flex; justify-content: space-between; font: 600 10px var(--font-round); color: var(--faint); }
.view.enter .a-bar { animation: sweep .75s var(--ease) both; animation-delay: calc(var(--i) * 26ms + 110ms); }
@keyframes sweep { from { transform: scaleX(0); opacity: 0; } }
.fine { margin: 12px 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--faint); }
.fine.center { margin: 20px 0 6px; text-align: center; }

/* ---------- trip ---------- */
.trip-summary { background: linear-gradient(150deg, rgba(169, 156, 255, .13), rgba(255, 255, 255, .03)); border-color: rgba(169, 156, 255, .22); }
.ts-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ts-big { margin-top: 4px; font: 700 38px/1 var(--font-round); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.ts-dir { display: block; margin-top: 4px; font-size: 13px; line-height: 1.4; color: var(--dim); max-width: 22ch; }
.ts-right { flex: none; max-width: 46%; text-align: right; }
.ts-v { display: block; margin-top: 4px; font: 700 18px/1.25 var(--font-round); }
.ts-sub { display: block; margin-top: 3px; font-size: 11.5px; line-height: 1.35; color: var(--faint); }
.ts-bar { height: 6px; margin: 16px 0 0; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.ts-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--violet), var(--blue)); transition: width .9s var(--ease); }
.trip-days { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.tday { padding: 14px 16px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--stroke); }
.tday.is-today { background: color-mix(in srgb, var(--violet) 10%, transparent); border-color: color-mix(in srgb, var(--violet) 32%, transparent); }
.tday.done { opacity: .42; }
.tday-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tday-date { font-size: 15px; font-weight: 650; }
.tday-where { font-size: 12px; font-weight: 600; color: var(--dim); }
.tday-sleep { margin-top: 6px; font: 650 17px/1.2 var(--font-round); font-variant-numeric: tabular-nums; }
.tday-tips { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.tday-tips li { display: flex; gap: 8px; font-size: 13.5px; line-height: 1.4; color: var(--dim); }
.tday-tips i { flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; }
.i-light { background: var(--blue); } .i-dark { background: var(--amber); } .i-note { background: var(--faint); }
.tday-tips b { color: var(--text); font-weight: 600; }
.trip-preview { margin: 14px 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--dim); text-align: center; }
.trip-preview b { color: var(--text); font-weight: 650; }
.group-label.tight { margin-top: 18px; }

/* ---------- grouped lists ---------- */
.group-label { margin: 4px 6px 8px; font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.list, .group { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r-md); overflow: hidden; margin-bottom: 22px; }
.group.flush { margin-bottom: 0; background: none; border: 0; border-radius: 0; }
.group.flush .row { padding-left: 0; padding-right: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px;
  padding: 9px 16px; background: none; border: 0; border-top: 1px solid var(--stroke);
  text-align: left; transition: background .2s;
}
.row:first-child { border-top: 0; }
button.row:active, label.row:active { background: rgba(255, 255, 255, .05); }
label.row { cursor: pointer; }
.row-label { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; }
.row-label small { display: block; margin-top: 1px; font-size: 13px; font-weight: 400; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.night-dur { font: 650 16px var(--font-round); font-variant-numeric: tabular-nums; white-space: nowrap; }
.night-dur.short { color: var(--amber); } .night-dur.long { color: var(--good); }
.row.danger { justify-content: center; }
.row.danger .row-label { flex: none; color: var(--crit); font-weight: 600; }
.empty-state { padding: 24px 18px; text-align: center; color: var(--dim); }
.empty-state p { margin: 0 0 14px; }
.about p { margin: 0 0 10px; font-size: 14px; line-height: 1.55; color: var(--dim); }
.about p:last-child { margin-bottom: 0; }
.about b { color: var(--text); font-weight: 600; }

/* ---------- controls ---------- */
.field-input {
  appearance: none; -webkit-appearance: none;
  min-height: 36px; padding: 6px 11px; border: 0; border-radius: 11px;
  background: rgba(255, 255, 255, .075); color: var(--text);
  font: 600 16px var(--font-round); font-variant-numeric: tabular-nums; text-align: right;
  color-scheme: dark; max-width: 60%;
}
.field-input.wide { max-width: 64%; text-align: right; text-overflow: ellipsis; }
select.field-input { padding-right: 8px; }
.field-input::-webkit-date-and-time-value { text-align: right; }
.stepper { flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 13px; background: rgba(255, 255, 255, .07); }
.stepper button { width: 36px; height: 32px; border: 0; border-radius: 10px; background: transparent; font-size: 20px; line-height: 1; transition: background .15s, transform .15s; }
.stepper button:active { background: rgba(255, 255, 255, .12); transform: scale(.92); }
.stepper output { display: inline-block; min-width: 64px; text-align: center; font: 650 15px var(--font-round); font-variant-numeric: tabular-nums; }
.switch { position: relative; flex: none; width: 51px; height: 31px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .16); transition: background .3s var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); transition: transform .35s var(--ease); }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; border: 0; border-radius: var(--r-sm);
  background: var(--blue-deep); color: #fff; font-size: 16px; font-weight: 650;
  transition: transform .18s var(--ease), filter .2s;
}
.btn:active { transform: scale(.975); filter: brightness(.9); }
.btn.secondary { background: rgba(255, 255, 255, .08); color: var(--text); }
.btn.danger { background: rgba(255, 126, 110, .13); color: var(--crit); }
#logDelete, #tripEnd { margin-top: 6px; }

.seg { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); padding: 3px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .07); }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg button { position: relative; z-index: 1; padding: 10px 0; border: 0; background: none; color: var(--dim); font-size: 13.5px; font-weight: 600; transition: color .25s; }
.seg button[aria-checked="true"] { color: var(--text); }
.seg-pill {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 5);
  border-radius: 11px; background: rgba(255, 255, 255, .13); box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
  transform: translateX(calc(var(--idx, 2) * 100%)); transition: transform .4s var(--ease);
}
.seg.two .seg-pill { width: calc((100% - 6px) / 2); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: 560px; margin: 0 auto; padding: 0 12px calc(var(--safe-b) + 8px); pointer-events: none; }
.tabbar-inner {
  position: relative; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px; border-radius: 26px; pointer-events: auto;
  background: rgba(18, 21, 32, .74);
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--stroke);
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, .8);
}
.tab {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 6px; border: 0; background: none; color: var(--faint);
  font-size: 10px; font-weight: 650; letter-spacing: .01em; transition: color .3s ease;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--ease); }
.tab[data-tab="trip"] svg { fill: currentColor; stroke: none; }
.tab[aria-selected="true"] { color: var(--text); }
.tab:active svg { transform: scale(.84); }
.tab-pill {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5);
  border-radius: 20px; background: rgba(255, 255, 255, .08);
  transform: translateX(calc(var(--idx, 0) * 100%)); transition: transform .5s var(--ease);
}

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(2, 3, 8, .6); opacity: 0; pointer-events: none; transition: opacity .42s ease; }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 560px; max-height: 92vh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 18px calc(var(--safe-b) + 22px);
  background: rgba(21, 24, 36, .95);
  -webkit-backdrop-filter: blur(28px) saturate(150%); backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--stroke-2); border-bottom: 0; border-radius: 28px 28px 0 0;
  box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, .8);
  transform: translateY(110%); visibility: hidden;
  transition: transform .5s var(--ease-sheet), visibility 0s linear .5s;
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform .5s var(--ease-sheet), visibility 0s; }
.sheet.dragging { transition: none; }
.grabber { width: 38px; height: 5px; margin: 2px auto 10px; border-radius: 3px; background: rgba(255, 255, 255, .22); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.text-btn { justify-self: start; padding: 6px 0; border: 0; background: none; color: var(--blue); font-size: 17px; }
.text-btn.strong { justify-self: end; font-weight: 650; }
.text-btn:active { opacity: .5; }
.dur-preview { display: flex; flex-direction: column; align-items: center; margin: 6px 0 18px; text-align: center; }
.dur-big { font: 700 46px/1.05 var(--font-round); letter-spacing: -.035em; font-variant-numeric: tabular-nums; transition: color .3s; }
.dur-big.short { color: var(--amber); }
.dur-note { margin-top: 2px; font-size: 14px; color: var(--dim); }
.sheet .group { margin-bottom: 18px; }
.welcome-mark { display: block; width: 68px; height: 68px; margin: 12px auto 10px; }
.welcome-title { margin: 0; text-align: center; font: 700 27px/1.15 var(--font); letter-spacing: -.025em; }
.welcome-body { max-width: 310px; margin: 6px auto 22px; text-align: center; font-size: 15px; color: var(--dim); }
.confirm-title { margin: 8px 0 6px; text-align: center; font-size: 19px; font-weight: 700; }
.confirm-body { max-width: 330px; margin: 0 auto 22px; text-align: center; font-size: 15px; color: var(--dim); }
.confirm-actions { display: grid; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 10px); z-index: 60;
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 22px;
  background: rgba(32, 35, 50, .95); border: 1px solid var(--stroke-2); color: var(--text);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  font-size: 14.5px; font-weight: 600; text-align: center;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .7);
  transform: translate(-50%, calc(-100% - var(--safe-t) - 20px));
  transition: transform .5s var(--ease-sheet);
}
.toast.on { transform: translate(-50%, 0); }

.bump { animation: bump .35s var(--ease); }
@keyframes bump { 40% { transform: scale(1.14); } }
.shake { animation: shake .4s ease; }
@keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

@media (max-width: 360px) {
  .title { font-size: 29px; }
  .stat .v { font-size: 19px; }
  .ring-num { font-size: 56px; }
  .tn-v { font-size: 22px; }
  .tab span { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; transition-delay: 0s !important;
  }
  .view { scroll-behavior: auto; }
  .now-pulse { display: none; }
}
