/* One phone column: a fixed top bar and bottom menu that never move, short sectioned pages,
   one row of actions above the menu, sheets for forms. Lexend only. */
:root {
  --bg: #F3F4F7; --surface: #FFFFFF; --sunk: #ECEEF2; --ink: #12141A; --muted: #5D6272; --faint: #8A8F9C; --line: #E0E3E9;
  --accent: #2B47E8; --accent-ink: #FFFFFF; --accent-soft: #E6EAFD;
  --wait: #A55F00; --wait-soft: #FBEFD9; --fail: #C2292E; --fail-soft: #FBE3E4; --review: #6A3FD0; --review-soft: #EEE7FC;
  --scrim: rgba(12, 14, 20, .38);
  --shadow: 0 1px 2px rgba(18, 20, 26, .05), 0 6px 20px rgba(18, 20, 26, .06);
  --font: "Lexend", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --top: 56px; --nav: 64px; --act: 68px;
  --ease: cubic-bezier(.2, .8, .2, 1); --sheet-ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0F13; --surface: #16191F; --sunk: #1E2229; --ink: #ECEEF2; --muted: #A0A5B2; --faint: #737887; --line: #2A2E37;
    --accent: #8496FF; --accent-ink: #0D0F13; --accent-soft: #1F2647;
    --wait: #F2AE4E; --wait-soft: #33260F; --fail: #FF7B7F; --fail-soft: #3A1A1C; --review: #B59CFF; --review-soft: #2A2142;
    --scrim: rgba(0, 0, 0, .55); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: 560px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg); }
.top .wrap { height: var(--top); display: flex; align-items: center; gap: 10px; }
.top h1 { flex: 1; min-width: 0; margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; transition: background .2s var(--ease); }
.icon-btn:hover { background: var(--sunk); }
.icon-btn svg { width: 22px; height: 22px; stroke-width: 2; }
.back { margin-left: -8px; }
.fresh { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.fresh.live .dot { background: var(--accent); }
.fresh.off .dot { background: var(--fail); }

/* Screens */
main { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px) + 24px); }
main.has-act { padding-bottom: calc(var(--nav) + var(--act) + env(safe-area-inset-bottom, 0px) + 24px); }
.screen { display: flex; flex-direction: column; gap: 22px; padding-top: 6px; }
.screen.enter { animation: enter .26s var(--ease) both; }
.screen.push { animation: push .26s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes push { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
section { display: flex; flex-direction: column; gap: 10px; }
.label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.label .count { letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.source { font-size: 12px; color: var(--faint); padding: 0 4px; }

/* An outer shell holding inner rows */
.shell { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--r-md); text-align: left; width: 100%; transition: background .18s var(--ease), transform .18s var(--ease); }
button.row:hover { background: var(--sunk); }
button.row:active { transform: scale(.99); }
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-weight: 500; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.row-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; font-size: 12px; color: var(--faint); min-width: 0; }
.row-meta { flex: none; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; text-align: right; }
.row-amount { flex: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 13.5px; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.needs_you, .pill.warn { background: var(--wait-soft); color: var(--wait); }
.pill.critical { background: var(--fail-soft); color: var(--fail); }
.pill.your_turn { background: var(--review-soft); color: var(--review); }
.pill.working { background: var(--accent-soft); color: var(--accent); }

/* Summary strip */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.stat { background: var(--sunk); border-radius: var(--r-md); padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 2px; text-align: left; transition: background .18s var(--ease); }
button.stat:hover { background: var(--line); }
.stat b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.needs_you b { color: var(--wait); }
.stat.your_turn b { color: var(--review); }
.stat.working b { color: var(--accent); }

/* Meters */
.meter { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.meter + .meter { box-shadow: 0 -1px 0 var(--line); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.meter-top b { font-weight: 500; }
.meter-top span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 8px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 8px; background: var(--accent); transition: width .6s var(--ease); }
.bar.warn i { background: var(--wait); }
.bar.critical i { background: var(--fail); }
.meter small { font-size: 12px; color: var(--faint); }

/* Cost cards */
.cost { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cost-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cost-head b { font-weight: 600; }
.cost-big { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cost-big small { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.lines { display: flex; flex-direction: column; gap: 2px; background: var(--sunk); border-radius: var(--r-md); padding: 6px 10px; }
.line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; }
.line span:first-child { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line span:last-child { font-variant-numeric: tabular-nums; }
.cost .err-note { font-size: 12.5px; color: var(--fail); overflow-wrap: anywhere; }

/* Session detail */
.head { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ask { background: var(--wait-soft); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.ask b { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--wait); }
.ask p, .said p { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.said { background: var(--sunk); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.said b { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* Filter chips */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease); }
.chip .n { font-variant-numeric: tabular-nums; color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: var(--bg); opacity: .7; }

/* Notes */
.note { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.note h3 { margin: 0; font-size: 15px; font-weight: 600; }
.note p { margin: 0; font-size: 13.5px; color: var(--muted); }
.skel { height: 64px; border-radius: var(--r-md); background: var(--sunk); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* One row of actions above the menu */
.act { position: fixed; left: 0; right: 0; bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px)); z-index: 15; background: var(--bg); border-top: 1px solid var(--line); }
.act .wrap { height: var(--act); display: flex; gap: 10px; align-items: center; }
.btn { flex: 1; height: 46px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; font-size: 15px; text-decoration: none; transition: transform .15s var(--ease), background .2s var(--ease), opacity .2s; }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; stroke-width: 2; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--surface); color: var(--fail); border: 1px solid var(--line); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Bottom menu */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav .wrap { height: var(--nav); display: grid; grid-template-columns: repeat(4, 1fr); }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 500; color: var(--faint); position: relative; transition: color .2s var(--ease); }
.nav button svg { width: 22px; height: 22px; transition: transform .25s var(--ease); }
.nav button[aria-current="page"] { color: var(--ink); }
.nav button[aria-current="page"] svg { transform: translateY(-1px); }
.badge { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px; background: var(--wait); color: var(--surface); font-size: 10.5px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }

/* Sheet */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; transition: opacity .3s var(--ease); }
.scrim.on { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; transform: translateY(100%); transition: transform .38s var(--sheet-ease); max-height: 92vh; overflow-y: auto; }
.sheet.on { transform: none; }
.sheet .wrap { background: var(--surface); border-radius: 22px 22px 0 0; padding-top: 10px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.grip { width: 36px; height: 4px; border-radius: 4px; background: var(--line); align-self: center; }
.sheet h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet .hint { font-size: 12.5px; color: var(--faint); margin: 0; }
.sheet .btns { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field input, .field select { height: 46px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 0 12px; font-size: 15px; width: 100%; min-width: 0; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sunk); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { height: 40px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); transition: background .2s var(--ease), color .2s var(--ease); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.token { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--sunk); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; user-select: all; }
pre.snippet { margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; background: var(--sunk); border-radius: 12px; padding: 12px; overflow-x: auto; }
.err { margin: 0; font-size: 13px; color: var(--fail); }
.link-btn { align-self: flex-start; font-size: 14px; color: var(--fail); font-weight: 500; padding: 6px 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + var(--act) + env(safe-area-inset-bottom, 0px) + 12px); z-index: 50; transform: translate(-50%, 12px); opacity: 0; background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 500; padding: 10px 16px; border-radius: 99px; transition: opacity .25s var(--ease), transform .25s var(--ease); pointer-events: none; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 10px; animation: enter .3s var(--ease) both; }
.login-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.login-card label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.login-card input { height: 48px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 0 12px; font-size: 16px; }
.login-card .btn { flex: none; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
