/* AskSathi caretaker app — v4.5 (D-192…D-200). Phone-first (390 px is the
   design width), Apple-HIG lens: glass ONLY on the control layer (top bar,
   tab bar, sheets, menus, desktop sidebar); content stays solid. Every value
   resolves through the --ct-* tokens in /ui/tokens.css (XIV.1). WCAG 2.2 AA:
   ≥ 44 px targets (48 used), visible focus, reduced motion + transparency. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--ct-top-clear); scroll-padding-bottom: var(--ct-tabbar-clear); }
body.ct {
  margin: 0; min-height: 100vh; background: var(--ct-paper); color: var(--ct-ink);
  font: var(--ct-fs-body)/1.45 var(--ct-font); -webkit-font-smoothing: antialiased;
}
/* Reset the shared panel element rules (tokens.css: button/input/h2/label/main) for the
   caretaker app. Specificity (0,0,3): beats a bare element rule, loses to every .ct-* class,
   so each component's own size, padding and colour wins (tab labels, switches, buttons). */
html body :is(button, input, select, textarea) { font: inherit; color: inherit; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; }
html body :is(h1, h2, h3) { color: inherit; font-size: inherit; margin: 0; }
html body label { display: inline; margin: 0; font-weight: inherit; }
.ct a { color: var(--ct-sage-deep); }
.ct :focus-visible { outline: 3px solid var(--ct-focus); outline-offset: 2px; border-radius: 8px; }
.ct [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- environment strip (F-100 / A-34, FND-012) ---------- */
.ct-env {
  position: fixed; inset: 0 0 auto; z-index: 90; height: 26px; display: flex; align-items: center; justify-content: center;
  padding: 0 var(--ct-gutter); font-size: var(--ct-fs-xs); font-weight: 800; color: var(--ct-ink);
  background: repeating-linear-gradient(135deg, var(--ct-hazard-a) 0 14px, var(--ct-surface) 14px 28px);
}
body.ct.has-env { padding-top: var(--ct-space-6); }
body.ct.has-env .ct-top, body.ct.has-env .ct-side { top: 26px; }

/* Today: the nudge/setup band, moved under an open alert (placeTodayExtras) */
#today-extras-slot > #today-extras { margin-top: var(--ct-space-4); }

/* ---------- decorative wash behind the top of Today / first run ---------- */
.ct-wash {
  position: absolute; left: 0; right: 0; top: 0; height: 320px; pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 90% at 10% 0%, var(--ct-wash-sage) 0%, transparent 72%),
    radial-gradient(90% 70% at 100% 0%, var(--ct-wash-clay) 0%, transparent 70%);
}

/* ---------- glass top bar (phone) ---------- */
.ct-top {
  position: sticky; top: 0; z-index: 40; padding: var(--ct-space-3) var(--ct-gutter) var(--ct-space-3);
  background: var(--ct-glass); -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur);
  border-bottom: 1px solid var(--ct-sep);
}
.ct-top .row { display: flex; align-items: center; gap: var(--ct-space-3); min-height: 44px; }
.ct-brand { font: 600 var(--ct-fs-xl) var(--ct-font-brand); flex: 1; color: var(--ct-ink); text-decoration: none; min-height: 44px; display: flex; align-items: center; }
.ct-me {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--ct-clay); color: var(--ct-on-accent); font-weight: 800; font-size: var(--ct-fs-md);
  box-shadow: 0 0 0 2px var(--ct-surface);
}
.ct-chips { display: flex; gap: var(--ct-space-2); overflow-x: auto; scrollbar-width: none; padding: 2px 2px 2px; margin-top: var(--ct-space-2); }
.ct-chips::-webkit-scrollbar { display: none; }
.ct-chip {
  flex: none; min-height: 44px; display: inline-flex; align-items: center; gap: var(--ct-space-2); padding: 0 var(--ct-space-4) 0 var(--ct-space-1);
  border-radius: var(--ct-r-pill); border: 1px solid var(--ct-sep); background: var(--ct-glass-strong);
  font-weight: 700; font-size: var(--ct-fs-small); cursor: pointer; position: relative; color: var(--ct-ink);
}
.ct-chip[aria-pressed="true"] { background: var(--ct-sage-deep); color: var(--ct-on-accent); border-color: transparent; }
.ct-av {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ct-sage); color: var(--ct-on-accent); font: 600 var(--ct-fs-md) var(--ct-font-brand);
}
.ct-chip[aria-pressed="true"] .ct-av { background: var(--ct-surface); color: var(--ct-sage-deep); }
.ct-dot { position: absolute; top: 3px; left: 30px; width: 12px; height: 12px; border-radius: 50%; background: var(--ct-alert); box-shadow: 0 0 0 2px var(--ct-surface); }
.ct-chip.add { padding: 0 var(--ct-space-4); background: transparent; border: 1.5px dashed var(--ct-ink-3); color: var(--ct-sage-deep); }

/* ---------- layout ---------- */
.ct-app { position: relative; min-height: 100vh; }
.ct-main { position: relative; z-index: 1; padding: var(--ct-space-5) var(--ct-gutter) var(--ct-tabbar-clear); max-width: 760px; margin: 0 auto; }
.ct-view > * + * { margin-top: 0; }
.ct-eyebrow { font-size: var(--ct-fs-label); font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ct-ink-3); margin: var(--ct-space-2) 0 0; }
.ct-title { color: var(--ct-ink); font: 800 var(--ct-fs-title)/1.12 var(--ct-font); letter-spacing: -0.01em; margin: 2px 0 var(--ct-space-3); text-wrap: balance; }
.ct-sub { color: var(--ct-ink-2); margin: -4px 0 var(--ct-space-4); max-width: 62ch; }
.ct-sec { font-size: var(--ct-fs-label); font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ct-ink-3); margin: var(--ct-space-6) var(--ct-space-4) var(--ct-space-2); }
.ct-note { font-size: var(--ct-fs-small); color: var(--ct-ink-3); margin: var(--ct-space-2) var(--ct-space-4) 0; }
.ct-h2 { color: var(--ct-ink); font: 700 var(--ct-fs-h2)/1.25 var(--ct-font); margin: 0 0 var(--ct-space-2); }

/* pushed-screen nav bar (Settings, All alerts, Local Sathi) */
.ct-navbar { display: flex; align-items: center; min-height: 44px; margin: -6px 0 var(--ct-space-2); }
.ct-back { min-height: 44px; min-width: 64px; display: inline-flex; align-items: center; gap: var(--ct-space-1); padding: 0 var(--ct-space-2) 0 0; border: 0; background: none; color: var(--ct-sage-deep); font-weight: 700; cursor: pointer; }
.ct-navtitle { display: none; }
/* Phone: a pushed screen swaps the chip bar for a glass nav bar "‹ Back · Title" (S05/S15/S19, HIG). */
@media (max-width: 1023px) {
  body.ct.is-pushed .ct-top { display: none; }
  body.ct.is-pushed .ct-navbar {
    position: sticky; top: 0; z-index: 40; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    min-height: 52px; margin: calc(-1 * var(--ct-space-5)) calc(-1 * var(--ct-gutter)) var(--ct-space-4); padding: 0 var(--ct-gutter);
    background: var(--ct-glass); -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur); border-bottom: 1px solid var(--ct-sep);
  }
  body.ct.has-env.is-pushed .ct-navbar { top: 26px; }
  body.ct.is-pushed .ct-back { justify-self: start; }
  body.ct.is-pushed .ct-navtitle { display: block; font-weight: 700; color: var(--ct-ink); }
}

/* ---------- content: cards and grouped lists (solid, never glass) ---------- */
.ct-card { background: var(--ct-surface); border-radius: var(--ct-r-card); padding: var(--ct-space-5); box-shadow: var(--ct-shadow-card); }
.ct-group { background: var(--ct-surface); border-radius: var(--ct-r-card); overflow: hidden; box-shadow: var(--ct-shadow-card); }
.ct-cell {
  position: relative; display: flex; align-items: center; gap: var(--ct-space-3); min-height: var(--ct-row); padding: var(--ct-space-3) var(--ct-space-4);
  width: 100%; border: 0; background: transparent; text-align: left; color: var(--ct-ink);
}
.ct-cell + .ct-cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--ct-sep); }
button.ct-cell, a.ct-cell { cursor: pointer; text-decoration: none; }
.ct a.ct-cell:not(.danger):not(.action) { color: var(--ct-ink); } /* a row is a row, not a text link (S17) */
button.ct-cell:hover, a.ct-cell:hover { background: var(--ct-sage-wash); }
.ct-cell .main { flex: 1; min-width: 0; }
.ct-cell .main b { display: block; font-weight: 700; }
/* a row's title wraps between words, never mid-word (tokens.css sets body overflow-wrap:anywhere) */
.ct-cell .main > b { overflow-wrap: break-word; }
/* Family rows (S10): the name column never shrinks below its longest word; the status pill wraps instead */
:is(#fam-loved, #fam-circle) .ct-cell .main { min-width: min-content; }
:is(#fam-loved, #fam-circle) .ct-cell > .ct-pill { overflow-wrap: normal; }
/* very narrow phones (< 360 px): the status pill drops to its own line under the name */
@media (max-width: 359px) {
  :is(#fam-loved, #fam-circle) .ct-cell { flex-wrap: wrap; }
  :is(#fam-loved, #fam-circle) .ct-cell .main { flex: 1 1 0; }
  :is(#fam-loved, #fam-circle) .ct-cell > .ct-pill { order: 3; margin-left: calc(var(--ct-avatar) + var(--ct-space-3)); }
}
/* a link that ends a caption still gets a full 44 px target (PRD §12.3: no target under 44 px) */
.ct-tap-link { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; font-weight: 700; }
.ct-cell .main > span { display: block; font-size: var(--ct-fs-small); color: var(--ct-ink-3); overflow-wrap: anywhere; }
.ct-cell .val { color: var(--ct-ink-3); font-size: var(--ct-fs-md); text-align: right; }
.ct-cell .chev { color: var(--ct-ink-3); font-size: var(--ct-fs-h2); line-height: 1; }
.ct-cell.action { color: var(--ct-sage-deep); font-weight: 800; }
.ct-cell.danger { color: var(--ct-alert-ink); font-weight: 700; }
.ct-cell.indent { padding-left: var(--ct-space-8); }
.ct-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: var(--ct-fs-lg); background: var(--ct-sage-tint); }
.ct-ic.alert { background: var(--ct-alert-bg); } .ct-ic.scam { background: var(--ct-scam-bg); }
.ct-ic.ok { background: var(--ct-ok-bg); } .ct-ic.sun { background: var(--ct-sun-bg); } .ct-ic.sky { background: var(--ct-sky-bg); }
.ct-time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 78px; }
.ct-person { width: var(--ct-avatar); height: var(--ct-avatar); border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--ct-clay); color: var(--ct-on-accent); font-weight: 800; }
.ct-person.senior { background: var(--ct-sage-deep); font: 600 var(--ct-fs-body) var(--ct-font-brand); }
.ct-person.other { background: var(--ct-ink-3); }

.ct-pill { display: inline-flex; align-items: center; gap: var(--ct-space-2); border-radius: var(--ct-r-pill); padding: var(--ct-space-1) var(--ct-space-3); font-size: var(--ct-fs-label); font-weight: 800; white-space: nowrap; }
.ct-pill.ok { background: var(--ct-ok-bg); color: var(--ct-ok); }
.ct-pill.alert { background: var(--ct-alert-bg); color: var(--ct-alert-ink); }
.ct-pill.scam { background: var(--ct-scam-bg); color: var(--ct-scam); }
.ct-pill.muted { background: var(--ct-surface-2); color: var(--ct-ink-2); }

/* ---------- buttons ---------- */
.ct-btn {
  min-height: var(--ct-tap); border-radius: var(--ct-r-ctl); border: 0; padding: 0 var(--ct-space-5); width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ct-space-2); font-weight: 800; font-size: var(--ct-fs-body);
  cursor: pointer; text-decoration: none; background: var(--ct-surface-2); color: var(--ct-ink);
}
.ct-btn.primary { background: var(--ct-sage-deep); color: var(--ct-on-accent); }
.ct-btn.danger { background: var(--ct-danger-bg); color: var(--ct-alert-ink); }
.ct-btn.text { background: transparent; color: var(--ct-sage-deep); }
.ct-btn.inline { width: auto; }
.ct-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.ct-stack { display: flex; flex-direction: column; gap: var(--ct-space-3); margin-top: var(--ct-space-4); }
.ct-row { display: flex; gap: var(--ct-space-3); align-items: center; }
.ct-row > .ct-input { flex: 1; min-width: 0; }
/* time beside a select (S07 "When"): the time keeps its own width; the select takes the rest */
.ct-row > .ct-input[type="time"] { flex: none; width: auto; }
.ct-row > .ct-select { flex: 1; min-width: 0; width: auto; }

/* ---------- inputs ---------- */
.ct-input, .ct-select, .ct-textarea {
  width: 100%; min-height: 52px; border-radius: var(--ct-r-ctl); border: 1px solid var(--ct-sep);
  background: var(--ct-surface); padding: 0 var(--ct-space-4); font-size: var(--ct-fs-body); color: var(--ct-ink);
}
.ct-textarea { padding: var(--ct-space-4) var(--ct-space-4); min-height: 96px; resize: vertical; }
.ct-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ct-ink-3) 50%), linear-gradient(135deg, var(--ct-ink-3) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: var(--ct-space-7); }
.ct-label { display: block; font-size: var(--ct-fs-label); font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ct-ink-2); margin: var(--ct-space-4) var(--ct-space-1) var(--ct-space-2); }
.ct-check { display: flex; align-items: center; gap: var(--ct-space-3); min-height: var(--ct-row); font-weight: 700; }
.ct-check input { width: 26px; height: 26px; accent-color: var(--ct-sage-deep); flex: none; }

/* segmented control */
.ct-seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--ct-surface-2); margin: var(--ct-space-1) 0 var(--ct-space-2); overflow-x: auto; }
.ct-seg button { flex: 1 0 auto; min-height: 44px; padding: 0 var(--ct-space-3); border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: var(--ct-fs-small); color: var(--ct-ink-2); cursor: pointer; }
.ct-seg button[aria-pressed="true"], .ct-seg button[aria-selected="true"] { background: var(--ct-surface); color: var(--ct-ink); box-shadow: var(--ct-shadow-card); }

/* switch (role="switch"): a 52×32 iOS-size track inside a 52×44 hit area (our ≥ 44 px rule) */
.ct-switch { width: 52px; height: 44px; flex: none; border: 0; background: transparent; position: relative; cursor: pointer; }
.ct-switch::before { content: ""; position: absolute; left: 0; top: 6px; width: 52px; height: 32px; border-radius: var(--ct-r-pill); background: var(--ct-switch-off); }
.ct-switch::after { content: ""; position: absolute; top: 8px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: var(--ct-surface); box-shadow: var(--ct-shadow-knob); transition: left 0.15s ease; }
.ct-switch[aria-checked="true"]::before { background: var(--ct-sage); }
.ct-switch[aria-checked="true"]::after { left: 22px; }
.ct-switch[disabled] { opacity: 0.45; cursor: not-allowed; }
.ct-switch-wrap { min-width: 52px; min-height: 44px; display: grid; place-items: center; }
.ct-lock { font-size: var(--ct-fs-small); color: var(--ct-ink-3); font-weight: 700; }

/* ---------- Today ---------- */
.ct-alert { background: var(--ct-surface); border-radius: var(--ct-r-card); overflow: hidden; box-shadow: var(--ct-shadow-alert); }
.ct-alert .band { display: flex; align-items: center; gap: var(--ct-space-2); padding: var(--ct-space-3) var(--ct-space-5); background: var(--ct-alert); color: var(--ct-on-accent); font-weight: 800; font-size: var(--ct-fs-small); }
.ct-alert .body { padding: var(--ct-space-4) var(--ct-space-5) var(--ct-space-5); }
.ct-alert h3 { font: 800 var(--ct-fs-alert)/1.25 var(--ct-font); margin: 0 0 var(--ct-space-2); }
.ct-alert .more { display: flex; justify-content: space-between; align-items: center; gap: var(--ct-space-3); width: 100%; min-height: 48px; margin-top: var(--ct-space-3); border: 0; border-top: 1px solid var(--ct-sep); background: none; padding: var(--ct-space-3) 0 0; text-align: left; cursor: pointer; font-size: var(--ct-fs-small); }
.ct-calm { display: flex; align-items: center; gap: var(--ct-space-4); padding: var(--ct-space-5); border-radius: var(--ct-r-card); background: var(--ct-ok-bg); }
.ct-calm .big { font-size: var(--ct-fs-calm); }
.ct-banner { display: flex; gap: var(--ct-space-3); align-items: flex-start; padding: var(--ct-space-4); border-radius: var(--ct-r-card); background: var(--ct-surface); box-shadow: var(--ct-shadow-card); }
.ct-banner .d { width: 11px; height: 11px; margin-top: var(--ct-space-2); border-radius: 50%; flex: none; background: var(--ct-scam); }
.ct-banner .d.alert { background: var(--ct-alert); }
.ct-banner .d.calm { background: var(--ct-sage); }
.ct-banner b { display: block; }
.ct-bars { display: flex; align-items: flex-end; gap: var(--ct-space-3); height: 120px; padding: var(--ct-space-2) var(--ct-space-4) 0; }
.ct-bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--ct-space-2); height: 100%; justify-content: flex-end; }
.ct-bars .bar { width: 100%; max-width: 30px; border-radius: 8px 8px 4px 4px; background: var(--ct-sage); }
.ct-bars .bar.peak { background: var(--ct-sage-deep); }
.ct-bars .day { font-size: var(--ct-fs-xs); color: var(--ct-ink-3); font-variant-numeric: tabular-nums; }
.ct-reasons { padding: 0 var(--ct-space-4) var(--ct-space-4); }
.ct-reasons li { font-size: var(--ct-fs-small); color: var(--ct-ink-2); margin: var(--ct-space-1) 0; }

/* ---------- Notes / My list cards ---------- */
.ct-cards { display: flex; flex-direction: column; gap: var(--ct-space-3); margin-top: var(--ct-space-3); }
.ct-paper { background: var(--ct-note-bg); border-radius: 18px; padding: var(--ct-space-3) var(--ct-space-2) var(--ct-space-4) var(--ct-space-4); box-shadow: var(--ct-shadow-card); }
.ct-paper.list { background: var(--ct-list-bg); }
.ct-paper.rem { background: var(--ct-sky-bg); }
.ct-paper.shared { background: var(--ct-sage-tint); }
.ct-paper .head { display: flex; align-items: center; gap: var(--ct-space-2); min-height: 44px; }
.ct-paper .who { flex: 1; font-size: var(--ct-fs-label); font-weight: 800; color: var(--ct-ink-2); }
.ct-paper p { margin: 2px var(--ct-space-2) 0 0; overflow-wrap: anywhere; }
.ct-paper ul { list-style: none; margin: var(--ct-space-2) var(--ct-space-2) 0 0; padding: 0; }
.ct-paper li { display: flex; align-items: center; gap: var(--ct-space-2); min-height: 48px; border-top: 1px solid var(--ct-sep); }
.ct-paper li.done .txt { text-decoration: line-through; color: var(--ct-ink-3); }
.ct-paper li .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ct-tick { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 2px solid var(--ct-sage); background: var(--ct-surface); font-weight: 800; color: var(--ct-sage-deep); cursor: pointer; }
.ct-more-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px; background: transparent; font-size: var(--ct-fs-xl); font-weight: 900; color: var(--ct-ink-2); cursor: pointer; letter-spacing: 1px; }
.ct-more-btn:hover { background: var(--ct-sage-wash); }
.ct-pinbar { display: flex; gap: var(--ct-space-3); margin-top: var(--ct-space-4); }
.ct-drop { flex: 1; min-height: 56px; border-radius: var(--ct-r-ctl); border: 2px dashed var(--ct-ink-3); display: grid; place-items: center; font-weight: 800; color: var(--ct-ink-2); }
.ct-drop.on { background: var(--ct-sage-wash); border-color: var(--ct-sage-deep); }
.ct-story { white-space: pre-wrap; }
.ct-linkbox { background: var(--ct-surface); border: 1px solid var(--ct-sep); border-radius: var(--ct-r-ctl); padding: var(--ct-space-4) var(--ct-space-4); font: 500 var(--ct-fs-small) var(--ct-font-mono); color: var(--ct-ink-2); overflow-wrap: anywhere; user-select: all; }

/* ---------- floating glass tab bar ---------- */
.ct-tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 45; height: 70px;
  max-width: 560px; margin: 0 auto; display: flex; padding: var(--ct-space-2); border-radius: 35px;
  background: var(--ct-glass-strong); -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur);
  border: 1px solid var(--ct-glass-edge); box-shadow: var(--ct-shadow-float);
}
.ct-tab {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 44px; border: 0; border-radius: 28px; background: transparent; cursor: pointer;
  font-size: var(--ct-fs-tab); font-weight: 800; color: var(--ct-ink-2);
}
.ct-tab .i { font-size: var(--ct-fs-h2); line-height: 1; }
.ct-tab[aria-current="page"] { background: var(--ct-sage-wash); color: var(--ct-sage-deep); }
.ct-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 var(--ct-space-1); border-radius: var(--ct-r-pill); display: grid; place-items: center; background: var(--ct-alert); color: var(--ct-on-accent); font-size: var(--ct-fs-badge); font-weight: 900; box-shadow: 0 0 0 2px var(--ct-surface); }

/* ---------- sheets, menus, scrim (glass) ---------- */
.ct-scrim { position: fixed; inset: 0; z-index: 60; background: var(--ct-scrim); }
.ct-scrim.light { background: var(--ct-scrim-light); }
.ct-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: calc(100vh - 56px); overflow-y: auto;
  max-width: 640px; margin: 0 auto; padding: var(--ct-space-2) var(--ct-gutter) calc(var(--ct-space-6) + env(safe-area-inset-bottom, 0px));
  border-radius: var(--ct-r-sheet) var(--ct-r-sheet) 0 0; background: var(--ct-glass-strong);
  -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur); box-shadow: var(--ct-shadow-sheet);
  animation: ct-up 0.25s ease-out;
}
.ct-sheet.tall { top: 56px; }
@keyframes ct-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.ct-grab { width: 40px; height: 5px; border-radius: 9px; background: var(--ct-sep); margin: var(--ct-space-1) auto var(--ct-space-2); }
.ct-sh-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; margin-bottom: var(--ct-space-2); }
.ct-sh-head .t { font-weight: 800; text-align: center; }
.ct-sh-head .l, .ct-sh-head .r { min-height: 44px; border: 0; background: none; font-weight: 700; color: var(--ct-sage-deep); cursor: pointer; padding: 0; }
.ct-sh-head .l { text-align: left; } .ct-sh-head .r { text-align: right; }
.ct-sh-head .r[disabled] { color: var(--ct-ink-3); cursor: default; }
.ct-steps { display: flex; gap: var(--ct-space-2); margin: 2px 0 var(--ct-space-3); }
.ct-steps i { flex: 1; height: 5px; border-radius: 9px; background: var(--ct-sep); }
.ct-steps i.on { background: var(--ct-sage-deep); }
.ct-menu {
  position: fixed; z-index: 70; top: 64px; right: 12px; width: min(320px, calc(100vw - 24px)); overflow: hidden;
  border-radius: 22px; background: var(--ct-glass-strong); -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur);
  border: 1px solid var(--ct-glass-edge); box-shadow: var(--ct-shadow-float);
}
.ct-status { min-height: 1.2em; font-size: var(--ct-fs-small); color: var(--ct-ink-2); margin: var(--ct-space-2) var(--ct-space-1) 0; }

/* ---------- gates and first run ---------- */
.ct-gate { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: var(--ct-space-9) var(--ct-gutter) var(--ct-space-8); }

/* ---------- tour (D-180 one-screen picture) ---------- */
.ct-tour img { width: 100%; border-radius: 16px; border: 1px solid var(--ct-sep); display: block; }
.ct-legend { display: flex; flex-wrap: wrap; gap: var(--ct-space-2) var(--ct-space-4); margin: var(--ct-space-3) var(--ct-space-1) 0; font-size: var(--ct-fs-small); color: var(--ct-ink-2); }

/* ---------- desktop sidebar (≥ 1024 px; D-197 desktop derives from phone) ---------- */
.ct-side { display: none; }
@media (min-width: 1024px) {
  .ct-top { display: none; }
  .ct-tabbar { display: none; }
  .ct-side {
    display: flex; flex-direction: column; gap: var(--ct-space-1); position: fixed; top: 0; bottom: 0; left: 0; width: var(--ct-side-w); z-index: 40;
    padding: var(--ct-space-5) var(--ct-space-4); overflow-y: auto; background: var(--ct-glass-strong);
    -webkit-backdrop-filter: var(--ct-blur); backdrop-filter: var(--ct-blur); border-right: 1px solid var(--ct-sep);
  }
  .ct-side .ct-brand { padding: var(--ct-space-2) var(--ct-space-4) var(--ct-space-3); flex: none; font-size: var(--ct-fs-h2); }
  .ct-side .grp { font-size: var(--ct-fs-xs); font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ct-ink-3); padding: var(--ct-space-4) var(--ct-space-4) var(--ct-space-1); }
  .ct-lo, .ct-nav { min-height: 48px; display: flex; align-items: center; gap: var(--ct-space-3); padding: 0 var(--ct-space-3); border: 0; border-radius: 14px; background: transparent; font-weight: 700; color: var(--ct-ink-2); cursor: pointer; text-align: left; position: relative; width: 100%; }
  .ct-lo { color: var(--ct-ink); }
  .ct-lo[aria-pressed="true"] { background: var(--ct-sage-deep); color: var(--ct-on-accent); }
  .ct-lo[aria-pressed="true"] .ct-av { background: var(--ct-surface); color: var(--ct-sage-deep); }
  .ct-lo .ct-dot { position: static; margin-left: auto; box-shadow: none; }
  .ct-lo.add { border: 1.5px dashed var(--ct-ink-3); color: var(--ct-sage-deep); margin-top: var(--ct-space-1); }
  .ct-nav[aria-current="page"] { background: var(--ct-sage-wash); color: var(--ct-sage-deep); }
  .ct-nav .ct-badge { position: static; margin-left: auto; }
  .ct-side-me { position: fixed; top: 20px; right: 28px; z-index: 45; }
  body.ct.has-env .ct-side-me { top: 46px; }
  .ct-main { margin-left: var(--ct-side-w); max-width: none; padding: var(--ct-space-7) var(--ct-space-8) var(--ct-space-8); }
  .ct-cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 0 var(--ct-space-6); align-items: start; }
  .ct-sheet { left: var(--ct-side-w); bottom: auto; top: 50%; transform: translateY(-50%); border-radius: var(--ct-r-sheet); max-height: calc(100vh - 80px); animation: none; }
  .ct-sheet.tall { top: 50%; }
  .ct-menu { top: 72px; right: 28px; }
}
@media (min-width: 1024px) { .ct-only-phone { display: none !important; } }
@media (max-width: 1023px) { .ct-only-desk { display: none !important; } .ct-side-me { display: none; } }

/* ---------- reduced motion / transparency; no backdrop-filter ---------- */
@media (prefers-reduced-motion: reduce) {
  .ct *, .ct *::before, .ct *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .ct-top, .ct-tabbar, .ct-sheet, .ct-menu, .ct-side, body.ct.is-pushed .ct-navbar { background: var(--ct-surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .ct-top, .ct-tabbar, .ct-sheet, .ct-menu, .ct-side, body.ct.is-pushed .ct-navbar { background: var(--ct-surface); }
}

/* ---------- spacing utilities (token scale only; replaces inline styles) ---------- */
.ct-m0 { margin: 0; }
.ct-mt-1 { margin-top: var(--ct-space-1); } .ct-mt-2 { margin-top: var(--ct-space-2); }
.ct-mt-3 { margin-top: var(--ct-space-3); } .ct-mt-4 { margin-top: var(--ct-space-4); }
.ct-mb-1 { margin-bottom: var(--ct-space-1); } .ct-mb-2 { margin-bottom: var(--ct-space-2); } .ct-mb-3 { margin-bottom: var(--ct-space-3); }
.ct-my-2 { margin-top: var(--ct-space-2); margin-bottom: var(--ct-space-2); }
.ct-my-3 { margin-top: var(--ct-space-3); margin-bottom: var(--ct-space-3); }
.ct-mx-1 { margin-left: var(--ct-space-1); margin-right: var(--ct-space-1); }
.ct-mx-4 { margin-left: var(--ct-space-4); margin-right: var(--ct-space-4); }
.ct-ml-1 { margin-left: var(--ct-space-1); }
.ct-pr-2 { padding-right: var(--ct-space-2); }
.ct-pad-x { padding-left: var(--ct-space-4); padding-right: var(--ct-space-4); }
.ct-wrap { flex-wrap: wrap; }
.ct-grow { flex: 1; }
.ct-field-grow { flex: 1 1 220px; }
/* v4.6.0 (D-205): the level row — the words beside the icon, the three choices on their own
   full-width line below (a .main with flex-basis 0 would otherwise shrink to one letter wide). */
#eng-level-row > .main { flex: 1 1 calc(100% - 64px); }
#eng-level-row > .ct-seg { flex: 1 1 100%; }
/* v4.6.0 (D-207): a checkbox row in a sheet (the lesson plan) — tokens.css makes every
   phone input width:100%, which would squeeze the row's words to one letter wide. The
   whole label row stays the tap target. */
#sheet-body .ct-cell > input[type="checkbox"] { width: 22px; height: 22px; flex: none; margin: 0; }
.ct-auto { width: auto; }
.ct-h-ctl { min-height: 44px; }
.ct-tall { min-height: 64px; }
.ct-sheet-title { font-size: var(--ct-fs-sheet-title); margin: var(--ct-space-3) 0 var(--ct-space-1); }
