/* ==================================================================
   Physio Log — styles. Written phone-first: the base rules are the
   phone layout, and the wider screens are the exception below.
================================================================== */

:root {
  --bg: #F1F4F1;
  --surface: #FFFFFF;
  --surface-2: #E9EEE9;
  --ink: #17211D;
  --ink-muted: #5C6D66;
  --line: #D6DDD7;
  --line-soft: #E4EAE4;
  --accent: #17624F;
  --accent-soft: #DCEDE5;
  --accent-ink: #FFFFFF;
  --danger: #A8321F;
  --cal-empty: #E1E7E1;
  --cal-logged: #C6D6CC;
  --shadow: 0 1px 2px rgba(23, 40, 33, .06), 0 8px 24px -16px rgba(23, 40, 33, .3);
  --radius: 14px;
  --radius-sm: 10px;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
  --sidebar-w: 240px;
  --tap: 46px;
}

[data-theme="dark"] {
  --bg: #0E1412;
  --surface: #171F1C;
  --surface-2: #202A26;
  --ink: #E9EFEA;
  --ink-muted: #9AAAA3;
  --line: #2B3733;
  --line-soft: #232E2A;
  --accent: #55C6A0;
  --accent-soft: #1B3A31;
  --accent-ink: #072019;
  --danger: #E4796A;
  --cal-empty: #222C28;
  --cal-logged: #2E4840;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.015em; margin: 0; color: var(--ink); }
h1 { font-size: 1.45rem; line-height: 1.15; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .5rem; }
p:last-child { margin-bottom: 0; }

a, .link {
  color: var(--accent); background: none; border: 0; padding: 0; font: inherit;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
[data-theme="dark"] a, [data-theme="dark"] .link { color: var(--accent); }

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; }
.skip-link:focus { left: 0; }

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

/* ---------------- splash ---------------- */

.splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
  background: var(--bg); color: var(--accent);
  transition: opacity .35s ease, visibility .35s ease;
}
.splash.gone { opacity: 0; visibility: hidden; }
.splash-mark { width: 92px; color: var(--accent); }
.splash-mark svg { width: 100%; height: auto; }
.splash-name { font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.splash-bar { width: 120px; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.splash-bar i { display: block; width: 40%; height: 100%; border-radius: 999px; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ---------------- chrome ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .4rem .5rem;
  padding-top: calc(.4rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-title { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
body.signed-out .topbar, body.signed-out .sidebar, body.signed-out .scrim { display: none; }

.burger, .burger::before, .burger::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; background: linear-gradient(135deg, currentColor 0 50%, transparent 50% 100%); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: min(82vw, 300px);
  display: flex; flex-direction: column; gap: .8rem;
  padding: 1rem .7rem 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.drawer-open .sidebar { transform: translateX(0); }

.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.1rem; padding: 0 .3rem .3rem; }
.brand-mark { width: 32px; height: 20px; color: var(--accent); flex: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block; width: 100%; text-align: left;
  padding: .7rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-muted);
  font: inherit; font-weight: 500; cursor: pointer; min-height: var(--tap);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
[data-theme="dark"] .nav-item.is-active { color: var(--ink); }
.nav-physio { margin-top: .3rem; border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding-top: .8rem; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding: 0 .3rem; }
.whoami { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .88rem; }
.who-name { font-weight: 600; }
.side-note { font-size: .74rem; color: var(--ink-muted); line-height: 1.45; }

.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8, 20, 16, .45); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.drawer-open .scrim { opacity: 1; pointer-events: auto; }

.main { min-height: 100%; padding: .8rem .7rem calc(2.5rem + env(safe-area-inset-bottom)); }
.view { max-width: 940px; margin: 0 auto; display: flex; flex-direction: column; gap: .75rem; }

@media (min-width: 900px) {
  .topbar { display: none; }
  .sidebar { width: var(--sidebar-w); transform: none; box-shadow: none; }
  .main { margin-left: var(--sidebar-w); padding: 1.5rem 1.5rem 4rem; }
  .scrim { display: none; }
  h1 { font-size: 1.7rem; }
  body { font-size: 15px; }
}

/* ---------------- sign in ---------------- */

.auth { min-height: 82vh; display: grid; place-items: center; padding: 1rem .2rem; }
.auth-card {
  width: min(420px, 100%);
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 1.3rem 1.1rem; display: flex; flex-direction: column; gap: .6rem;
}
.auth-brand { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.auth-brand .brand-mark { color: var(--accent); }
.auth-tag { color: var(--ink-muted); font-size: .9rem; }
.auth-seg { margin: .2rem 0 .3rem; }
.auth-pane { display: flex; flex-direction: column; gap: .1rem; }
.auth-note { font-size: .74rem; color: var(--ink-muted); border-top: 1px solid var(--line-soft); padding-top: .6rem; margin-top: .3rem; }

/* ---------------- blocks ---------------- */

.page-head { display: flex; flex-direction: column; gap: .2rem; }
.page-sub { color: var(--ink-muted); font-size: .88rem; }

.card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: .85rem .8rem; display: flex; flex-direction: column; gap: .65rem;
}
.card-title { font-size: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.sub-title { font-size: .8rem; font-weight: 600; color: var(--ink-muted); }
.hint { font-size: .8rem; color: var(--ink-muted); }
.empty { color: var(--ink-muted); font-size: .88rem; }
.empty.small { font-size: .76rem; }
.meta { font-size: .8rem; color: var(--ink-muted); }
.unit { color: var(--ink-muted); font-size: .78rem; }
.count-pill { font-size: .78rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: .15rem .6rem; }
[data-theme="dark"] .count-pill { color: var(--ink); }

.physio-note {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: .7rem .8rem; color: var(--ink);
}
.physio-note strong { display: block; font-size: .78rem; color: var(--accent); margin-bottom: .1rem; }
[data-theme="dark"] .physio-note strong { color: var(--ink); }

@media (min-width: 900px) { .card { padding: 1rem 1.05rem; } }

/* ---------------- controls ---------------- */

.btn, .btn-quiet {
  font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2;
  border-radius: var(--radius-sm); padding: .6rem .9rem; border: 1px solid transparent;
  min-height: var(--tap);
}
.btn { background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.06); }
.btn.big { width: 100%; font-size: 1rem; padding: .75rem 1rem; }
.btn-quiet { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--accent); }
.btn-quiet.danger, .btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--surface); }
.btn:disabled, .btn-quiet:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-row .btn, .btn-row .btn-quiet { flex: 1 1 auto; }

.icon-btn {
  border: 0; background: transparent; color: var(--ink);
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

.input, .select, .textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .6rem; max-width: 100%; min-height: var(--tap);
}
.textarea { width: 100%; resize: vertical; min-height: 80px; }
.input.grow { flex: 1 1 160px; min-width: 0; }
.input.tiny, .select.tiny { width: 72px; padding: .35rem .4rem; min-height: 40px; }
.select.tiny { width: 92px; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--ink-muted); margin-bottom: .5rem; }
.field .input, .field .select, .field .textarea { color: var(--ink); }
.field.inline { flex-direction: row; align-items: center; gap: .4rem; margin-bottom: 0; }
.two, .three { display: grid; gap: .5rem; }
.three { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 620px) { .two { grid-template-columns: 1fr 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar .input { flex: 1 1 160px; min-width: 0; }
.add-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.add-row .input[type="date"], .add-row .input[type="time"] { flex: 0 1 auto; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; max-width: 100%; }
.seg.full { display: flex; }
.seg.full .seg-btn { flex: 1; }
.seg-btn {
  border: 0; background: transparent; color: var(--ink-muted); font: inherit; font-weight: 500;
  padding: .45rem .7rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font: inherit; font-size: .86rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: .4rem .75rem; min-height: 38px;
}
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
[data-theme="dark"] .chip.is-on { color: var(--ink); }

.toggle-btn {
  font: inherit; cursor: pointer; border-radius: var(--radius-sm); min-height: var(--tap);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .5rem .8rem;
}
.toggle-btn.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
[data-theme="dark"] .toggle-btn.is-on { color: var(--ink); }
.switch-row { display: flex; flex-direction: column; gap: .4rem; }
@media (min-width: 620px) { .switch-row { flex-direction: row; flex-wrap: wrap; } }

/* ---------------- pain ---------------- */

.daynav { display: flex; align-items: center; gap: .4rem; }
.daynav-mid { flex: 1; display: flex; flex-direction: column; }

.pain-grid { display: grid; gap: .8rem; }
@media (min-width: 760px) { .pain-grid { grid-template-columns: repeat(3, 1fr); } }

.pain-head { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; font-size: .85rem; color: var(--ink-muted); }
.pain-out { font-weight: 600; font-size: .85rem; text-align: right; }
.range { width: 100%; margin: .5rem 0 .2rem; accent-color: var(--track, var(--accent)); height: 28px; }
.range.is-unset { filter: grayscale(1); opacity: .6; }
.range-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-muted); }

/* ---------------- the daily tick list ---------------- */

.do-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.do-row {
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--surface); padding: .5rem .55rem;
}
.do-row.is-done { background: var(--accent-soft); border-color: var(--accent); }
.do-tick {
  flex: none; width: 48px; height: 48px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface);
  color: transparent; font-size: 1.4rem; font-weight: 700; line-height: 1;
}
.do-row.is-done .do-tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.do-main {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0;
  font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: .1rem;
}
.do-name { font-weight: 600; line-height: 1.25; }
.do-row.is-done .do-name { text-decoration: line-through; text-decoration-thickness: 1px; }
.do-target, .do-sets { font-size: .78rem; color: var(--ink-muted); }
.do-side { display: flex; align-items: center; gap: .3rem; flex: none; }
.step-btn {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1.1rem; font-weight: 600; line-height: 1;
}
.step-btn.wide { width: auto; padding: 0 .6rem; font-size: .82rem; }
.step-btn:hover { border-color: var(--accent); }

/* ---------------- physio plan rows ---------------- */

.plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.plan-row {
  border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface);
  padding: .55rem .6rem; display: flex; flex-direction: column; gap: .4rem;
}
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.plan-name { font-weight: 600; }
.plan-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.plan-fields label { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--ink-muted); }

.daypick { display: flex; flex-wrap: wrap; gap: .3rem; }
.daypick.wide-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; }
.day-btn {
  position: relative; font: inherit; font-size: .85rem; cursor: pointer; min-height: 44px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); padding: .4rem .3rem;
}
.day-btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.day-btn:disabled { opacity: .4; }
.day-btn .dot { position: absolute; top: 5px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.day-btn.is-on .dot { background: var(--accent-ink); }

/* ---------------- exercise library ---------------- */

.ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
@media (min-width: 620px) { .ex-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; } }
.ex-card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: .5rem; cursor: pointer; display: flex; flex-direction: column; gap: .2rem;
}
.ex-card:hover { border-color: var(--accent); }
.ex-card-fig { background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.ex-card-fig img { width: 100%; height: 110px; object-fit: cover; display: block; }
.ex-card h3 { font-size: .9rem; line-height: 1.2; }
.fig-blank { height: 90px; display: grid; place-items: center; font-size: .75rem; color: var(--ink-muted); }

/* ---------------- figures & body map ---------------- */

.figure { width: 100%; height: auto; display: block; }
.fig-floor { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.fig-limb { fill: none; stroke: var(--ink-muted); stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.fig-spine { fill: none; stroke: var(--accent); stroke-width: 8.5; stroke-linecap: round; stroke-linejoin: round; }
.fig-prop { fill: none; stroke: var(--line); stroke-width: 4; stroke-linecap: round; }
.fig-head { fill: var(--accent); }

.bodymap-wrap { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.bodymap-col { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.bodymap { width: 130px; height: auto; max-width: 40vw; }
.bm-frame path { fill: none; stroke: var(--line); stroke-width: 9; stroke-linecap: round; }
.bm-zone { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; cursor: pointer; }
.bm-zone:hover { fill: var(--accent-soft); stroke: var(--accent); }
.bm-zone.is-selected { fill: var(--accent); stroke: var(--accent); }
.bm-heat { stroke: var(--line); cursor: default; }

/* ---------------- week ---------------- */

.week-nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .7rem .8rem; display: flex; flex-direction: column; }
.stat-num { font-family: var(--display); font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .76rem; color: var(--ink-muted); }
.stat-delta { font-size: .74rem; font-weight: 600; margin-top: .15rem; }
.stat-delta.good { color: #1F7A54; }
[data-theme="dark"] .stat-delta.good { color: #63C89C; }
.stat-delta.bad { color: var(--danger); }

.week-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
@media (min-width: 620px) { .week-grid { grid-template-columns: repeat(7, 1fr); } }
.week-day {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: .5rem .3rem; cursor: pointer; font: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
}
.week-day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wd-name { font-size: .74rem; color: var(--ink-muted); }
.wd-num { font-family: var(--display); font-weight: 700; font-size: 1rem; }
.wd-pain { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .85rem; margin: .15rem 0; }
.wd-meta { font-size: .68rem; color: var(--ink-muted); text-align: center; }
.wd-flare { font-size: .64rem; color: var(--danger); font-weight: 600; }

.prog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (min-width: 820px) { .prog-grid { grid-template-columns: repeat(7, 1fr); } }
.prog-day h3 { font-size: .78rem; color: var(--ink-muted); margin-bottom: .2rem; }
.prog-day ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.prog-day li { font-size: .78rem; }

/* ---------------- lists ---------------- */

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.list-row {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface);
}
.list-row.is-done .list-text { text-decoration: line-through; color: var(--ink-muted); }
.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .92rem; }
.check {
  flex: none; width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--accent);
  font-size: .9rem; display: grid; place-items: center;
}
.check[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------- charts ---------------- */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: var(--line-soft); stroke-width: 1; }
.ch-axis { fill: var(--ink-muted); font-size: 10px; font-family: var(--sans); }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.ch-avg { fill: none; stroke: var(--ink-muted); stroke-width: 6; opacity: .18; stroke-linejoin: round; stroke-linecap: round; }
.ch-bar { fill: var(--accent); opacity: .3; }
.chart-cal { max-height: 160px; }

.bars { display: flex; flex-direction: column; gap: .35rem; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: .5rem; align-items: center; font-size: .82rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-value { color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-note { font-size: .7rem; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.legend-item { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; color: var(--ink-muted); }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; }

/* ---------------- modal ---------------- */

.modal { display: none; }
.modal.open {
  display: grid; place-items: end center;
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 20, 16, .5);
}
.modal-card {
  background: var(--surface); color: var(--ink);
  border-radius: var(--radius) var(--radius) 0 0; border: 1px solid var(--line-soft);
  width: 100%; max-height: 92vh; overflow: auto; position: relative; box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 620px) {
  .modal.open { place-items: center; padding: 1rem; }
  .modal-card { border-radius: var(--radius); width: min(560px, 100%); max-height: 88vh; }
  .modal.wide .modal-card { width: min(780px, 100%); }
}
.modal-body { padding: 1.1rem .9rem 1.2rem; display: flex; flex-direction: column; gap: .6rem; }
.modal-close { position: sticky; float: right; top: .4rem; right: .4rem; z-index: 2; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.modal-actions .btn, .modal-actions .btn-quiet { flex: 1 1 auto; }
body.modal-open { overflow: hidden; }

.detail { display: grid; gap: .8rem; }
@media (min-width: 620px) { .detail { grid-template-columns: 1fr 1fr; align-items: start; } }
.detail-fig { background: var(--surface-2); border-radius: var(--radius); padding: .4rem; }
.detail-fig img { width: 100%; border-radius: var(--radius-sm); display: block; }
.detail-text { display: flex; flex-direction: column; gap: .35rem; }
.cues { margin: .2rem 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.caution {
  font-size: .85rem; color: var(--ink); background: var(--accent-soft);
  border-left: 3px solid var(--accent); padding: .5rem .6rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.pick-list { display: flex; flex-direction: column; gap: .3rem; max-height: 46vh; overflow: auto; }
.pick-row {
  display: flex; align-items: center; gap: .55rem; text-align: left; cursor: pointer;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); padding: .35rem .45rem; font: inherit;
}
.pick-row.is-on { background: var(--accent-soft); border-color: var(--accent); }
.pick-fig { flex: none; width: 58px; height: 38px; overflow: hidden; display: grid; place-items: center; }
.pick-fig img { width: 100%; height: 100%; object-fit: cover; }
.pick-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: block; }
.pick-text { display: flex; flex-direction: column; min-width: 0; }
.pick-text strong { font-size: .92rem; }
.pick-text span { font-size: .76rem; color: var(--ink-muted); }

.timer { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; }
.timer-ring {
  width: 150px; height: 150px; border-radius: 50%; border: 7px solid var(--accent-soft);
  display: grid; place-items: center; font-family: var(--display); font-size: 2.6rem; font-weight: 700; color: var(--accent);
}
[data-theme="dark"] .timer-ring { color: var(--ink); }
.timer-phase { color: var(--ink-muted); font-size: .88rem; }

.file-label { display: inline-flex; align-items: center; justify-content: center; }

/* ---------------- report ---------------- */

.report { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1rem .85rem; display: flex; flex-direction: column; gap: .8rem; }
.rep-head h2 { font-size: 1.2rem; }
.rep-head p { color: var(--ink-muted); font-size: .85rem; }
.rep-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 620px) { .rep-stats { grid-template-columns: repeat(4, 1fr); } }
.rep-stats strong { font-family: var(--display); font-size: 1.4rem; }
.rep-stats span { font-size: .74rem; color: var(--ink-muted); }
.rep-stats div { display: flex; flex-direction: column; }
.rep-cols { display: grid; gap: .7rem; }
@media (min-width: 620px) { .rep-cols { grid-template-columns: repeat(2, 1fr); } }
.rep-cols h3 { font-size: .8rem; color: var(--ink-muted); margin-bottom: .1rem; }
.rep-cols p { font-size: .86rem; }
.rep-questions ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .86rem; }
.rep-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.rep-table th, .rep-table td { text-align: left; padding: .3rem .35rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rep-table th { color: var(--ink-muted); font-weight: 600; }
.rep-foot { font-size: .72rem; color: var(--ink-muted); }

/* ---------------- toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 160%);
  background: var(--ink); color: var(--bg);
  padding: .6rem 1rem; border-radius: 999px; font-size: .88rem; font-weight: 500;
  z-index: 80; transition: transform .2s ease; max-width: 92vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.warn { background: var(--danger); color: #fff; }

/* ---------------- print ---------------- */

@media print {
  .no-print, .sidebar, .topbar, .scrim, .toast, .modal, .splash { display: none !important; }
  body { background: #fff; color: #000; }
  .main { margin: 0; padding: 0; }
  .report { border: 0; padding: 0; }
  .rep-table { font-size: 10pt; }
}

/* ==================================================================
   Sign-in tiles, field labels and collapsible sections
================================================================== */

.fl { font-size: .82rem; color: var(--ink-muted); }
.field > .fl { margin-bottom: .1rem; }

.check-row {
  display: flex; align-items: center; gap: .5rem;
  font-size: .88rem; color: var(--ink); padding: .35rem 0; cursor: pointer;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.quick-tiles { display: flex; flex-direction: column; gap: .5rem; margin: .3rem 0; }
.quick-tile {
  display: flex; align-items: center; gap: .3rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: .3rem .35rem .3rem .45rem;
}
.quick-tile:hover { border-color: var(--accent); }
.quick-go {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem;
  background: none; border: 0; padding: .4rem .2rem; font: inherit; color: var(--ink);
  cursor: pointer; text-align: left; min-height: var(--tap);
}
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
}
.quick-text { display: flex; flex-direction: column; min-width: 0; }
.quick-text strong { font-size: .98rem; }
.quick-text span { font-size: .78rem; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.collapse { padding: 0; }
.collapse > summary {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .85rem .8rem; cursor: pointer; list-style: none; min-height: var(--tap);
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::after {
  content: "›"; font-size: 1.3rem; color: var(--ink-muted); line-height: 1;
  transform: rotate(90deg); transition: transform .18s ease; flex: none;
}
.collapse[open] > summary::after { transform: rotate(270deg); }
.collapse > summary .hint { text-align: right; }
.collapse-body { padding: 0 .8rem .85rem; display: flex; flex-direction: column; gap: .6rem; }
@media (min-width: 900px) {
  .collapse > summary { padding: 1rem 1.05rem; }
  .collapse-body { padding: 0 1.05rem 1rem; }
}

.input.is-bad { border-color: var(--danger); }

/* ==================================================================
   Fixes: hidden panes and the signed-out layout
================================================================== */

/* .auth-pane sets display:flex, which was beating the hidden attribute
   and showing the sign-in and create-account panes at the same time. */
[hidden] { display: none !important; }

/* Signed out there is no sidebar, so the main area must not keep its
   240px left gutter — that is what pushed the card off centre. */
body.signed-out .main { margin-left: 0; padding: 1rem .7rem; }
body.signed-out .view { max-width: none; }
.auth { min-height: 88vh; }

/* ---------------- sync status ---------------- */

.sync-pill {
  display: inline-block; font-size: .78rem; font-weight: 600;
  border-radius: 999px; padding: .2rem .7rem;
  background: var(--surface-2); color: var(--ink-muted);
}
.sync-pill.s-synced { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .sync-pill.s-synced { color: var(--ink); }
.sync-pill.s-error, .sync-pill.s-offline { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.forgot { align-self: flex-start; font-size: .84rem; margin-top: .4rem; }
code { font-size: .85em; background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px; }

/* live feedback under a typed date */
.field-note { font-size: .78rem; color: var(--ink-muted); min-height: 1.1em; margin-top: .15rem; }
.field-note.is-bad { color: var(--danger); }

/* the title doubles as a home button */
.topbar-title {
  background: none; border: 0; padding: .3rem .4rem; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--ink);
  border-radius: var(--radius-sm);
}
.topbar-title:active { background: var(--surface-2); }
.brand {
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
  font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--ink);
  border-radius: var(--radius-sm);
}
.brand:hover { color: var(--accent); }

/* destructive confirmations and the backup box */
.btn.danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.backup-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .74rem; }
.sync-error { font-size: .8rem; color: var(--danger); }
