/* Header, brand lockup and status-pill rules live in
   ../shared/chrome.css — do not redefine them here. */
/* Design tokens ---------------------------------------------------------
   Shared Thermalsock Labs house style — same tokens as every sibling app.
------------------------------------------------------------------------- */

:root {
  --chassis: #0B0D12;
  --panel: #0F1118;
  --panel-raised: #161A22;
  --hairline: rgba(138, 160, 184, 0.16);
  --hairline-strong: rgba(138, 160, 184, 0.30);
  --text: #E7F4FF;
  --text-dim: #8AA0B8;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --serif-display: 'Space Grotesk', -apple-system, system-ui, sans-serif;

  --accent: #00C8FF;
  --accent-dim: rgba(0, 200, 255, 0.32);
  --accent-fg: #04222C;
  --danger: #FF5A6E;
  --good: #3f7a4f;

  --amber: #FFB454;
  --violet: #A98CFF;
  --teal: #3FD9C4;
  --pink: #FF7BB0;
  --blue: #6FA8FF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--chassis);
  color: var(--text);
  font-family: var(--sans);
}

/* --- Permission gate ------------------------------------------------------ */

.gate {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(0, 200, 255, 0.08), transparent 60%), var(--chassis);
}
.gate[hidden], .app[hidden] { display: none; }

.gate-panel {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(138, 160, 184, 0.18);
  margin: 24px 0;
}
.gate-panel h1 { font-family: var(--serif-display); font-size: 24px; font-weight: 600; margin: 0 0 2px; letter-spacing: 0.005em; }
.gate-sub { font-family: var(--mono); font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 20px; }
.gate-copy { font-size: 14px; line-height: 1.55; color: var(--text-dim); margin: 0 0 24px; }


select, button { font-family: var(--sans); }
select {
  width: 100%;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.btn-primary {
  width: 100%;
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { filter: brightness(1.08); }

.gate-error { color: var(--danger); font-size: 13px; margin-top: 14px; line-height: 1.4; }

/* --- Topbar --------------------------------------------------------------- */


.page-nav { display: flex; gap: 4px; background: rgba(138, 160, 184, 0.04); border: 1px solid var(--hairline); border-radius: 3px; padding: 3px; flex-wrap: wrap; }
.page-nav-link { font-family: var(--sans); font-size: 11px; letter-spacing: 0.04em; text-decoration: none; color: var(--text-dim); padding: 6px 12px; border-radius: 3px; }
.page-nav-link:hover { color: var(--text); }
.page-nav-link.active { color: var(--accent-fg); background: var(--accent); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 3px;
  border: 1px solid var(--hairline-strong);
  background: rgba(138, 160, 184, 0.04);
  color: var(--text-dim);
}
.pill.live { color: var(--text-dim); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.status-dot.live { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* --- Stage layout ----------------------------------------------------------- */

.stage { flex: 1; display: flex; gap: 18px; padding: 18px 22px 12px 22px; min-height: 0; }
.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding-right: 2px; }
.card h2 { font-family: var(--serif-display); font-size: 17px; font-weight: 600; margin: 0 0 8px; }
/* .card h3 is covered by the shared .card > h3 rule in chrome.css. */

.panel { width: 300px; flex-shrink: 0; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-self: flex-start; gap: 14px; }
.panel-group select { margin-bottom: 6px; }
.mode-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin: 0; }

.stats-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; }
.stats-list dt { font-size: 12px; color: var(--text-dim); }
.stats-list dd { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--accent); text-align: right; }

.xp-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.xp-bar { height: 7px; background: var(--panel-raised); border: 1px solid var(--hairline-strong); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.xp-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--amber)); transition: width 0.3s ease; }
.vision-toggle-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; }
.vision-toggle-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* --- Tuning screen ----------------------------------------------------------- */

.tune-card { text-align: center; }
.tune-copy { font-size: 13.5px; color: var(--text-dim); line-height: 1.6; max-width: 480px; margin: 0 auto 20px; }
.tune-readout { padding: 24px; }
.tune-note { font-family: var(--serif-display); font-size: 48px; font-weight: 600; color: var(--accent); min-height: 60px; }
.tune-hint { font-family: var(--mono); font-size: 12px; color: var(--text-dim); letter-spacing: 0.04em; margin-top: 8px; }
.tune-progress {
  width: 180px;
  height: 5px;
  margin: 12px auto 0;
  background: var(--panel-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: 3px;
  overflow: hidden;
}
.tune-progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.08s linear; }

/* --- Page / glyph display ----------------------------------------------------- */

.page-card { display: flex; flex-direction: column; gap: 14px; }
.page-wrap { position: relative; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 18px rgba(138, 160, 184, 0.22); }
#pageCanvas { width: 100%; height: 340px; display: block; }
.page-label {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(138, 160, 184, 0.55);
  pointer-events: none;
}

.feedback-banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.feedback-banner.success { background: rgba(63, 122, 79, 0.14); color: var(--good); }
.feedback-banner.fail { background: rgba(255, 90, 110, 0.12); color: var(--danger); }

.game-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.io-btn {
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.io-btn:hover { border-color: var(--accent); }
.tonic-readout { margin-left: auto; font-size: 12.5px; color: var(--text-dim); font-family: var(--mono); }
.tonic-readout strong { color: var(--accent); }

/* --- Mode tabs ------------------------------------------------------------- */

.mode-tab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  margin-bottom: 4px;
}
.mode-tab {
  background: var(--panel-raised);
  color: var(--text-dim);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
}
.mode-tab:hover { border-color: var(--accent); color: var(--text); }
.mode-tab.active { background: var(--accent); color: var(--accent-fg); border-color: transparent; }

/* --- Stage / lesson navigation --------------------------------------------- */

.stage-list { display: flex; flex-direction: column; gap: 18px; }
.stage-group h3 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 4px;
}
.stage-group .stage-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin: 0 0 10px; }
.lesson-list { display: flex; flex-direction: column; gap: 6px; }
.lesson-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.lesson-card:hover { border-color: var(--accent); }
.lesson-card .lc-name { font-size: 13px; font-weight: 600; }
.lesson-card .lc-sub { font-size: 11.5px; color: var(--text-dim); }
.lesson-card .lc-check { margin-left: auto; font-size: 14px; color: var(--good); }

/* --- Lesson content -------------------------------------------------------- */

.lesson-header h2 { margin-bottom: 2px; }
.lesson-subtitle { font-size: 13px; color: var(--text-dim); margin: 0 0 18px; }
.lesson-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--hairline); }
.lesson-section:last-child { border-bottom: none; margin-bottom: 0; }
.lesson-section h4 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.lesson-text { font-size: 13.5px; line-height: 1.65; color: var(--text); margin: 0 0 12px; }
.example-list { display: flex; flex-direction: column; gap: 8px; }
.example-row { display: flex; align-items: center; gap: 10px; }
.example-label { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.lesson-play-btn {
  flex-shrink: 0;
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
}
.lesson-play-btn:hover { background: var(--accent); color: var(--accent-fg); }

/* --- Try exercise ---------------------------------------------------------- */

.try-status { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-bottom: 10px; letter-spacing: 0.05em; }
.try-prompt { font-size: 13px; color: var(--text); margin: 10px 0; }
.try-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.try-choice-btn {
  background: var(--panel-raised);
  color: var(--text);
  border: 1.5px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: border-color 0.15s, background 0.15s;
  min-width: 80px;
  text-align: center;
}
.try-choice-btn:hover { border-color: var(--accent); }
.try-choice-btn.correct { background: rgba(63, 122, 79, 0.18); border-color: var(--good); color: var(--good); }
.try-choice-btn.wrong { background: rgba(255, 90, 110, 0.12); border-color: var(--danger); color: var(--danger); }
.try-feedback { font-size: 13px; line-height: 1.5; min-height: 20px; padding: 8px 0; }
.try-feedback.fb-correct { color: var(--good); }
.try-feedback.fb-wrong { color: var(--danger); }
.try-btn-row { display: flex; gap: 10px; margin-top: 10px; }

.game-round-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.game-round-header h2 { margin: 0; font-size: 16px; }
.game-note-display {
  font-family: var(--serif-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  padding: 18px 0 12px;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.game-note-display.pressed-correct { color: var(--good); }
.game-note-display.pressed-wrong { color: var(--danger); }
.game-note-display.pressed-miss { color: var(--text-dim); opacity: 0.6; }
.game-summary {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  text-align: center;
}
.game-summary .gs-score { font-family: var(--serif-display); font-size: 28px; font-weight: 600; color: var(--accent); }
.game-summary .gs-detail { font-size: 13px; color: var(--text-dim); margin: 6px 0 14px; }
.game-summary .gs-xp { font-family: var(--mono); font-size: 12px; color: var(--amber); }

/* --- Progress summary ------------------------------------------------------ */

.progress-summary { display: flex; flex-direction: column; gap: 10px; }
.progress-stage { font-size: 12px; }
.progress-stage .ps-name { font-weight: 600; color: var(--text); display: block; margin-bottom: 3px; }
.progress-stage .ps-bar { height: 5px; background: var(--panel-raised); border: 1px solid var(--hairline-strong); border-radius: 3px; overflow: hidden; }
.progress-stage .ps-bar-fill { height: 100%; background: var(--good); transition: width 0.3s; }
.progress-stage .ps-count { font-family: var(--mono); font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* --- Support widget & legal bar -------------------------------------------- */

#supportWidget { position: fixed; left: 14px; bottom: 34px; z-index: 10; }
#supportWidget img { display: block; }
#legalBar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 5px 12px; font-size: 10.5px; color: var(--text-dim);
  background: rgba(11, 13, 18, 0.9);
  border-top: 1px solid var(--hairline);
  font-family: var(--mono);
}
#legalBar a { color: var(--text-dim); text-decoration: none; }
#legalBar a:hover { color: var(--accent); }

@media (max-width: 900px) {
  html, body { overflow-y: auto; height: auto; }
  .stage { flex-direction: column; }
  .panel { width: 100%; }
}

/* --- Progress totals, actions, playback speed ---------------------------- */
.progress-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.pt-label {
  font-family: var(--mono, var(--mono), monospace);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pt-value {
  font-family: var(--serif-display, Space Grotesk, Georgia, serif);
  font-size: 15px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.progress-actions { display: flex; gap: 8px; margin-top: 12px; }
.mini-btn {
  flex: 1;
  font-family: var(--mono, var(--mono), monospace);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
