/* RadioCheck: the design system (brief section 3), the frame of every screen
 * (section 4: header, tab bar, safe areas, sheets) and Home.
 * Other screens have their own sheets, linked from index.html:
 *   study.css  (question screen, session summary)   more.css (Sections, Progress, exam result)
 *   family.css (onboarding, Family, Exams, Settings)
 * Lifted in part from design/mockups/mock.css (approved 2026-12-01).
 * No web fonts, no images, nothing from outside.
 */

/* ------------------------------------------------------------ tokens */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #F2F4F7; --surface: #FFFFFF; --surface-2: #E9EDF2; --line: #D5DAE1; --border: #7A8594;
  --text: #14181F; --text-2: #4A5565; --text-dim: #5B6676;
  --accent: #0B6E69; --on-accent: #FFFFFF; --accent-tint: #E0F2F0;
  --right: #17703A; --right-tint: #E3F4E8; --on-right: #FFFFFF;
  --wrong: #B3261E; --wrong-tint: #FBE9E7; --on-wrong: #FFFFFF;
  --shadow: 0 1px 2px rgba(20,24,31,.06), 0 4px 16px rgba(20,24,31,.06);
  --sheet-shadow: 0 -8px 32px rgba(0,0,0,.24);
  --knob: #FFFFFF;
  --seg-on: var(--surface); --seg-on-shadow: 0 1px 2px rgba(20,24,31,.08);

  /* type scale (px; the same on iPhone and iPad; nothing under 15 but the tab labels) */
  --t-display: 700 44px/48px var(--font);
  --t-title: 700 22px/28px var(--font);
  --t-question: 600 20px/26px var(--font);
  --t-body: 400 17px/22px var(--font);
  --t-small: 400 15px/20px var(--font);
  --t-tab: 600 13px/16px var(--font);

  /* motion: set to one frame by &fast=1, to 0 by reduced motion */
  --d-press: 80ms; --d-switch: 120ms; --d-sheet: 180ms; --d-sheet-out: 120ms; --d-badge: 150ms; --d-shake: 200ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1116; --surface: #1A1F27; --surface-2: #252B35; --line: #333B47; --border: #7E8A9A;
    --text: #F1F4F8; --text-2: #A9B4C2; --text-dim: #98A3B2;
    --accent: #4FD1C5; --on-accent: #06201E; --accent-tint: #12302E;
    --right: #5FD38A; --right-tint: #12301E; --on-right: #06200F;
    --wrong: #FF8A80; --wrong-tint: #3A1715; --on-wrong: #2A0906;
    --shadow: none; --knob: var(--on-accent);
    --seg-on: var(--accent-tint); --seg-on-shadow: none;
    color-scheme: dark;
  }
}
:root[data-fast="1"] { --d-press: 16ms; --d-switch: 16ms; --d-sheet: 16ms; --d-sheet-out: 16ms; --d-badge: 16ms; --d-shake: 16ms; }
@media (prefers-reduced-motion: reduce) {
  :root { --d-press: 0s; --d-switch: 0s; --d-sheet: 0s; --d-sheet-out: 0s; --d-badge: 0s; --d-shake: 0s; }
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
:root[data-reduced="1"] { --d-press: 0s; --d-switch: 0s; --d-sheet: 0s; --d-sheet-out: 0s; --d-badge: 0s; --d-shake: 0s; }
:root[data-reduced="1"] *, :root[data-reduced="1"] *::before, :root[data-reduced="1"] *::after { transition-duration: 0s !important; animation-duration: 0s !important; }

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font: var(--t-body); color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
button, a, input, select, textarea { font: inherit; color: inherit; }
button, a, [role="switch"], label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
a { text-decoration: none; }
input, textarea { font-size: 17px; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.t-display { font: var(--t-display); font-variant-numeric: tabular-nums; }
.t-title { font: var(--t-title); }
.t-body { font: var(--t-body); }
.t-small { font: var(--t-small); }
.t-2 { color: var(--text-2); }

/* ------------------------------------------------------------ the frame (#app > .rc-app) */
#app { position: fixed; inset: 0; }
.rc-app { position: absolute; inset: 0; display: flex; flex-direction: column; padding-top: var(--sat); background: var(--bg); }
.rc-app[data-chrome="bare"] { padding-bottom: var(--sab); }
.rc-screen {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.rc-screen--fixed { overflow: hidden; display: flex; flex-direction: column; }
.rc-col { max-width: 640px; margin: 0 auto; padding: 16px; }

/* Header .rc-head: 52 tall under the top safe area, --bg */
.rc-head { flex: none; height: 52px; padding: 0 16px; background: var(--bg); }
.rc-head-in { height: 100%; max-width: 608px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
[data-dev="side"] .rc-head--wide .rc-head-in { max-width: 1040px; }
.rc-head .rc-title { font: var(--t-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rc-status { display: flex; align-items: center; gap: 6px; font: var(--t-small); color: var(--text-2); white-space: nowrap; min-width: 0; }
.rc-status .rc-name { overflow: hidden; text-overflow: ellipsis; }
.rc-sync { flex: none; color: var(--text-2); }
/* pushed screens: a 44 x 44 back button at the left, the title centered, 17 / 600 */
.rc-head--pushed { padding: 0 8px; }
.rc-head--pushed .rc-head-in { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; max-width: 624px; }
.rc-head--pushed .rc-title { font: 600 17px/22px var(--font); text-align: center; }
.rc-head--pushed .rc-status { justify-content: flex-end; }
.rc-head-back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--accent); border-radius: 12px; }
.rc-head-back:active { background: var(--surface-2); }

/* Tab bar .rc-tabs: 56 + the bottom safe area; four tabs (a centered 640 group on the iPad) */
.rc-tabs {
  flex: none; height: calc(56px + var(--sab)); padding-bottom: var(--sab);
  background: var(--surface); border-top: 1px solid var(--line);
}
.rc-tabs-in { height: 56px; display: flex; max-width: 640px; margin: 0 auto; }
.rc-tab {
  flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-2); font: var(--t-tab); text-align: center;
}
.rc-tab svg { display: block; }
.rc-tab.is-on { color: var(--accent); }
.rc-tab.is-on::before {
  content: ""; position: absolute; top: -1px; left: 50%; width: 24px; height: 3px; margin-left: -12px;
  background: var(--accent); border-radius: 0 0 2px 2px;
}

/* ------------------------------------------------------------ components */
.rc-btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; padding: 0 16px;
  border-radius: 14px; background: var(--accent); color: var(--on-accent);
  font: 600 17px/22px var(--font); text-align: center;
  transition: transform var(--d-press), filter var(--d-press);
}
.rc-btn:active { transform: scale(.98); filter: brightness(.92); }
.rc-btn:disabled { opacity: .4; pointer-events: none; }
.rc-btn--study { height: 56px; }
.rc-btn--2 { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.rc-btn--tall { height: 64px; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 16px; text-align: left; }
.rc-btn--tall .rc-btn-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-btn--tall small { display: block; max-width: 100%; font: var(--t-small); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-btn--text { background: none; color: var(--accent); height: 44px; min-height: 44px; width: auto; min-width: 44px; padding: 0 8px; }
.rc-btn--text:active { transform: none; filter: none; background: var(--surface-2); }
.rc-btn--danger { color: var(--wrong); }

.rc-card { background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }

.rc-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; width: 100%;
  font: 600 17px/22px var(--font); text-align: left; color: var(--text);
}
.rc-row + .rc-row { border-top: 1px solid var(--line); }
.rc-row small { display: block; font: var(--t-small); color: var(--text-2); }
button.rc-row:active, a.rc-row:active { background: var(--surface-2); }
.rc-row-main { flex: 1; min-width: 0; padding: 8px 0; }
.rc-chev { flex: none; color: var(--text-2); }

.rc-tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 999px; flex: none;
  background: var(--surface-2); color: var(--text-2); font: 600 15px/20px var(--font); vertical-align: middle; white-space: nowrap;
}

/* Segmented control: each segment is the track's full height (44); the pill is drawn 2 px inside */
.rc-seg { display: flex; height: 44px; border-radius: 12px; background: var(--surface-2); }
.rc-seg button {
  position: relative; z-index: 0; flex: 1 1 auto; height: 44px; padding: 0 12px;
  font: 500 17px/22px var(--font); color: var(--text-2); white-space: nowrap; text-align: center;
}
.rc-seg button::before { content: ""; position: absolute; z-index: -1; inset: 2px; border-radius: 10px; transition: background var(--d-switch); }
.rc-seg button[aria-selected="true"] { color: var(--text); font-weight: 600; }
.rc-seg button[aria-selected="true"]::before { background: var(--seg-on); box-shadow: var(--seg-on-shadow); }

/* Switch: a button[role=switch][aria-checked], 51 x 31 (the row is the target) */
.rc-switch {
  position: relative; width: 51px; height: 31px; border-radius: 999px; flex: none;
  background: var(--surface-2); border: 1.5px solid var(--border); transition: background var(--d-switch), border-color var(--d-switch);
}
.rc-switch::after {
  content: ""; position: absolute; top: 0.5px; left: 0.5px; width: 27px; height: 27px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--d-switch);
}
.rc-switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.rc-switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--knob); }
/* Some but not all (a subelement with only some of its groups on): accent outline, the knob in the middle. */
.rc-switch[aria-checked="mixed"] { border-color: var(--accent); background: var(--accent-tint); }
.rc-switch[aria-checked="mixed"]::after { transform: translateX(10px); }

.rc-mk, .rc-bars { display: block; flex: none; }

/* A mini bar (the family card) and a player bar (Family): track, fill, pass tick */
.rc-mini { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--surface-2); }
.rc-mini > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
.rc-mini > b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.rc-mini--8 { height: 8px; border-radius: 4px; }
.rc-mini--8 > i { border-radius: 4px; }
.rc-mini--8 > b { top: -4px; bottom: -4px; }

/* ------------------------------------------------------------ sheets */
.rc-layer { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.rc-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity var(--d-sheet); }
.rc-sheet {
  position: relative; width: 100%; max-height: 80%; display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0;
  padding: 24px 16px calc(var(--sab) + 16px); box-shadow: var(--sheet-shadow);
  transform: translateY(24px); opacity: 0; transition: transform var(--d-sheet), opacity var(--d-sheet);
}
.rc-layer.is-open .rc-backdrop { opacity: 1; }
.rc-layer.is-open .rc-sheet { transform: none; opacity: 1; }
.rc-layer.is-closing { pointer-events: none; }
.rc-layer.is-closing .rc-backdrop, .rc-layer.is-closing .rc-sheet { transition-duration: var(--d-sheet-out); }
.rc-sheet-title { font: var(--t-title); margin-bottom: 8px; flex: none; }
.rc-sheet-body { font: var(--t-body); min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.rc-sheet-body p + p { margin-top: 8px; }
.rc-sheet-btns { flex: none; display: flex; flex-direction: column; gap: 8px; margin-top: 24px; }
.rc-sheet-btns .rc-btn--text { width: 100%; }
[data-dev="up"] .rc-layer, [data-dev="side"] .rc-layer { align-items: center; }
[data-dev="up"] .rc-sheet, [data-dev="side"] .rc-sheet { width: 480px; max-width: calc(100% - 32px); border-radius: 20px; padding: 24px; }

/* ------------------------------------------------------------ placeholders (stage 1 stubs) */
.rc-stub { display: flex; flex-direction: column; gap: 12px; }
.rc-stub-title { font: var(--t-title); margin-top: 8px; }
.rc-stub-text { color: var(--text-2); }

/* ------------------------------------------------------------ Home */
.rc-home { display: flex; flex-direction: column; }
.rc-gauge-card { padding: 16px 16px 14px; }
.rc-gauge-wrap { position: relative; }
.rc-gauge { display: block; margin: 0 auto; overflow: visible; }
.rc-gauge-tag { position: absolute; }
.rc-gauge-line { margin-top: 6px; text-align: center; font: var(--t-body); color: var(--text-2); }
.rc-gauge-line b { color: var(--text); font-weight: 600; }
.rc-next { margin-top: 12px; height: 20px; font: 400 17px/20px var(--font); color: var(--text-2); padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-study { margin-top: 8px; }
.rc-four { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.rc-hint { margin-top: 16px; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; }
.rc-hint p { flex: 1; font: var(--t-small); color: var(--text-2); padding: 6px 0; }
.rc-hint-close { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text-2); border-radius: 12px; }
.rc-hint-close:active { background: var(--surface-2); }
.rc-family-card { margin-top: 16px; padding: 4px 16px; }
.rc-fc-head { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.rc-fc-head h2 { font: 600 17px/22px var(--font); }
.rc-fc-all { display: flex; align-items: center; gap: 6px; height: 44px; margin-right: -8px; padding: 0 8px; color: var(--accent); font: 600 17px/22px var(--font); border-radius: 12px; }
.rc-fc-all .rc-chev { color: var(--accent); }
.rc-fc-all:active { background: var(--surface-2); }
.rc-fc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 38px 64px 82px; align-items: center; column-gap: 10px;
  height: 52px; border-top: 1px solid var(--line); font: var(--t-body);
}
.rc-fc-row .nm { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; white-space: nowrap; }
.rc-fc-row .nm-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rc-fc-row .rd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rc-fc-row .when { justify-self: end; text-align: right; font: var(--t-small); color: var(--text-2); white-space: nowrap; }
.rc-fc-alone { border-top: 1px solid var(--line); padding: 12px 0; font: var(--t-small); color: var(--text-2); }
.rc-exam-line {
  margin-top: 12px; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 16px;
  font: var(--t-body); text-align: left; color: var(--text);
}
.rc-exam-line:active { background: var(--surface-2); }
.rc-exam-line span { flex: 1; min-width: 0; }
.rc-exam-line b { font-weight: 600; }
.rc-home-end { height: 16px; flex: none; }

/* iPad on its side: two columns 24 apart, 1,040 at most, centered up and down;
   the right column keeps its own height and is centered on the left one */
.rc-home-side { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.rc-home-grid { width: 100%; max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; align-items: center; }
.rc-home-left .rc-family-card { margin-top: 12px; }
.rc-home-right { align-self: center; }
.rc-home-right .rc-next { margin-top: 0; }
.rc-home-right .rc-hint { margin-top: 12px; }
