/* Signal Lab web. Tokens mirror design/DESIGN-SYSTEM.md and UI/Theme.swift: no grey text, glass on
   controls only (never on content), lamp colors as accents, dark by default. */

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --text: #FFFFFF;
  --accent: #6EE05A;
  --accent-text: #6EE05A;
  --on-accent: #0A0A0A;
  --correct: #6EE05A;
  --incorrect: #FF6B5C;
  --warn: #FFE14A;
  --card: #1C1C1E;
  --card-edge: #38383A;
  --mast: #8E8E93;
  --head-outline: #3A3A3C;
  --sign-mast: #8E8E93;
  --drawing-tint: transparent;
  --glass: rgba(120, 120, 128, 0.20);
  --glass-hover: rgba(120, 120, 128, 0.30);
  --glass-edge: rgba(255, 255, 255, 0.14);
  --glass-shine: rgba(255, 255, 255, 0.10);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --tint-right: rgba(110, 224, 90, 0.30);
  --tint-wrong: rgba(255, 107, 92, 0.30);
  --divider: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --text: #1C1C1E;
  --accent-text: #1F7A16;
  --correct: #1F7A16;
  --incorrect: #C4210F;
  --warn: #8A6500;
  --card: #F2F2F7;
  --card-edge: #D1D1D6;
  --mast: #1C1C1E;
  --head-outline: #0A0A0A;
  --sign-mast: #404040;
  --drawing-tint: rgba(0, 0, 0, 0.05);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-hover: rgba(245, 245, 247, 0.85);
  --glass-edge: rgba(0, 0, 0, 0.08);
  --glass-shine: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 6px 22px rgba(0, 0, 0, 0.10);
  --tint-right: rgba(110, 224, 90, 0.38);
  --tint-wrong: rgba(240, 65, 47, 0.30);
  --divider: rgba(0, 0, 0, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* ---- Liquid Glass (controls only) ---- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--glass-shadow);
}
.glass.interactive { cursor: pointer; transition: transform 0.12s ease-out, background 0.12s ease-out; }
.glass.interactive:hover { background: var(--glass-hover); }
.glass.interactive:active { transform: scale(0.98); }
.glass.tint-right { background: var(--tint-right); }
.glass.tint-wrong { background: var(--tint-wrong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Frame ---- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; min-height: 64px;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.top h1 { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.top h1.large { font-size: 34px; font-weight: 700; text-align: left; }
.top .slot { width: 44px; display: flex; }
.round-btn { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; border: 0; }
main { padding: 0 24px 140px; }
.column { max-width: 680px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.xl { gap: 24px; }

.tabbar[hidden] { display: none; }
.tabbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  display: flex; gap: 2px; padding: 4px; border-radius: 32px;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 8px 16px; border-radius: 28px; border: 0; background: none;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-selected="true"] { background: var(--glass-hover); color: var(--accent-text); }

/* ---- Text ---- */
.headline { font-weight: 600; }
.sub { font-size: 15px; }
.caption { font-size: 12px; }
.accent { color: var(--accent-text); }
.rule { color: var(--accent-text); font-weight: 600; font-size: 15px; }
.title-xl { font-size: 34px; font-weight: 700; line-height: 1.15; }
.section-title { font-weight: 600; margin: 8px 0 4px; }
.indication { display: flex; flex-direction: column; gap: 12px; font-size: 20px; user-select: text; }
.indication ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.indication li { display: flex; gap: 8px; }
.indication .num { font-variant-numeric: tabular-nums; }
.indication .between { padding-left: 24px; }
.detail-section h3 { color: var(--accent-text); font-size: 17px; font-weight: 600; margin-bottom: 8px; }

/* ---- Rows and lists ---- */
.list { background: var(--card); border-radius: 18px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 76px; cursor: pointer; }
.row + .row { border-top: 1px solid var(--divider); }
.row:hover { background: var(--divider); }
.row.entry { min-height: 64px; }
.row .thumb { width: 44px; height: 64px; display: grid; place-items: center; flex: none; }
.row .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.row .chev { opacity: 0.9; }
.glass-row { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 18px; border: 0; width: 100%; text-align: left; }
.glass-row .icon { width: 28px; text-align: center; color: var(--accent-text); font-size: 20px; }
/* The app's own icon in the Get the App row: wider than the 28px symbol slot, the slot grows to fit. */
.glass-row .icon:has(.app-icon) { width: auto; display: flex; }
.glass-row .app-icon { width: 48px; height: 48px; display: block; }
.glass-row .grow { flex: 1; display: flex; flex-direction: column; }
.glass-row .action { color: var(--accent-text); font-weight: 600; font-size: 15px; }

.search {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 22px; margin-bottom: 8px;
}
.search input { flex: 1; border: 0; background: none; outline: none; font: inherit; color: var(--text); }
.search input::placeholder { color: var(--text); opacity: 0.75; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-radius: 18px; }
.chip { padding: 6px 14px; border-radius: 18px; border: 0; font-weight: 600; font-size: 15px; }
.empty { text-align: center; padding: 48px 16px; }

/* ---- Drawings ---- */
.drawing { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.flash-note { display: none; font-size: 12px; font-weight: 600; color: var(--warn); }
.flash { animation: flash 2s steps(1, end) infinite; }
@keyframes flash { 0% { opacity: 1; } 50% { opacity: 0; } }
/* Row thumbnails are too small for the label; under Reduce Motion the detail page says Flashing. */
.thumb .flash-note { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
  .flash-note { display: block; }
}
.figures { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; padding: 8px 0; }
.figures figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.figures figcaption { font-weight: 600; font-size: 16px; }

/* ---- Study ---- */
.card-count { text-align: center; font-weight: 600; }
.flashcard { perspective: 1400px; width: 100%; max-width: 640px; height: min(520px, 62vh); margin: 0 auto; cursor: pointer; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform 0.45s ease; transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 26px; padding: 24px;
  display: flex; flex-direction: column; overflow: auto;
}
.face.front { align-items: center; justify-content: center; }
.face.back { transform: rotateY(180deg); gap: 16px; }
.face.back .indication { font-size: 17px; }
@media (prefers-reduced-motion: reduce) {
  .flashcard .inner { transition: none; transform: none !important; }
  .face { transition: opacity 0.2s; }
  .face.back { transform: none; opacity: 0; }
  .flashcard.flipped .face.front { opacity: 0; }
  .flashcard.flipped .face.back { opacity: 1; }
}
.mark-buttons { display: flex; gap: 16px; justify-content: center; }
.mark-buttons.hidden { visibility: hidden; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 150px; padding: 14px 22px; border-radius: 26px; border: 0; font-weight: 600; cursor: pointer; }
.btn.prominent { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), var(--glass-shadow); }
.btn.prominent:hover { filter: brightness(1.05); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.missed { color: var(--incorrect); }
.summary { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 40px; text-align: center; }
.cab-line { display: flex; align-items: center; gap: 12px; }
/* As wide as a one-lamp head, so every name in a cab choice list starts at the same x. */
.cab-slot { width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; }

/* ---- Choose Signals ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border-radius: 26px; border: 0; background-image: linear-gradient(var(--drawing-tint), var(--drawing-tint)); }
.tile .on { color: var(--correct); font-weight: 600; font-size: 15px; }
.tile .off { font-weight: 600; font-size: 15px; }
.tile.is-off svg { filter: saturate(0); opacity: 0.6; }

/* ---- Test ---- */
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; gap: 2px; background: var(--card); flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 9px; font-size: 15px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.toggle-chip { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; border: 0; text-align: left; font-weight: 600; font-size: 15px; }
.toggle-chip .icon { width: 24px; color: var(--accent-text); text-align: center; }
.toggle-chip .grow { flex: 1; }
.switch { display: flex; align-items: center; justify-content: space-between; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer; flex: none;
  width: 52px; height: 32px; border-radius: 16px; background: var(--card-edge); position: relative; transition: background 0.2s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 14px;
  background: #FFFFFF; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: transform 0.2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.prompt { font-size: 22px; font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 52px; border-radius: 12px; border: 0; width: 100%; text-align: left; font-size: 18px; font-weight: 600; }
.choice .num { width: 26px; height: 26px; border-radius: 13px; display: grid; place-items: center; background: var(--card-edge); font-size: 15px; font-weight: 700; flex: none; }
.choice .grow { flex: 1; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice.tall { position: relative; min-height: 200px; justify-content: center; background-image: linear-gradient(var(--drawing-tint), var(--drawing-tint)); }
.choice.tall .num { position: absolute; top: 12px; left: 12px; }
.choice.tall .mark { position: absolute; top: 12px; right: 12px; }
.mark.right { color: var(--correct); }
.mark.wrong { color: var(--incorrect); }
.score { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.timer { font-weight: 600; font-variant-numeric: tabular-nums; padding: 8px 14px; border-radius: 20px; white-space: nowrap; }
.timer.low { color: var(--incorrect); }
.center { text-align: center; }
.row-static { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--divider); }

@media (max-width: 520px) {
  main { padding: 0 16px 130px; }
  .tab { min-width: 76px; padding: 8px 10px; }
  .btn { min-width: 0; flex: 1; }
}

/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
