:root {
  /* Shape / motion / type — theme-independent */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --app-max: 1180px;
  --gutter: clamp(1rem, 2.5vw, 2rem);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", var(--font-sans);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 140ms;
  --t: 220ms;
  --t-slow: 420ms;
}

/* ---- DARK (default) ---- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b16;
  --bg-mesh-1: rgba(124, 107, 255, 0.18);
  --bg-mesh-2: rgba(34, 211, 238, 0.12);
  --bg-mesh-3: rgba(236, 107, 168, 0.12);
  --panel: #13152b;
  --panel-2: #1b1e3a;
  --surface-3: #232752;
  --border: #2a2f55;
  --border-soft: #20243f;
  --text: #eef0ff;
  --muted: #9aa0c8;
  --faint: #6b7099;
  --accent: #8b7bff;
  --accent-2: #a855f7;
  --accent-cyan: #22d3ee;
  --user: #6d5efc;
  --assistant: #1b1e3a;
  --error: #f87171;
  --danger: #f87171;
  --success: #34d399;
  --gold: #fbbf24;
  --grad: linear-gradient(135deg, #7c6bff 0%, #b06bff 52%, #ff6ba8 100%);
  --grad-accent: linear-gradient(135deg, #22d3ee, #7c6bff);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 50px rgba(124, 107, 255, 0.28);
}

/* ---- LIGHT ---- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6fc;
  --bg-mesh-1: rgba(124, 107, 255, 0.16);
  --bg-mesh-2: rgba(34, 211, 238, 0.14);
  --bg-mesh-3: rgba(236, 107, 168, 0.12);
  --panel: #ffffff;
  --panel-2: #f3f4fb;
  --surface-3: #eceefb;
  --border: #e4e7f2;
  --border-soft: #eef0f8;
  --text: #161830;
  --muted: #6b7090;
  --faint: #9aa0bd;
  --accent: #6d5efc;
  --accent-2: #a855f7;
  --accent-cyan: #06b6d4;
  --user: #6d5efc;
  --assistant: #f3f4fb;
  --error: #ef4444;
  --danger: #ef4444;
  --success: #10b981;
  --gold: #f59e0b;
  --grad: linear-gradient(135deg, #6d5efc 0%, #a855f7 52%, #ec4899 100%);
  --grad-accent: linear-gradient(135deg, #06b6d4, #6d5efc);
  --shadow: 0 1px 3px rgba(16, 18, 40, 0.06), 0 10px 28px rgba(16, 18, 40, 0.08);
  --shadow-lg: 0 18px 48px rgba(109, 94, 252, 0.2);
}

/* Responsive device tiers: laptop (default) -> 27" -> 49" ultrawide.
   We scale the content frame AND the root font with the viewport so the UI
   adapts to the detected screen instead of sitting in one fixed column.
   The cap keeps line length readable (no 5000px-wide text on an ultrawide). */
@media (min-width: 1600px) {
  :root { --app-max: 1440px; }
  html { font-size: 17px; }
}
@media (min-width: 2300px) {
  :root { --app-max: 1800px; }
  html { font-size: 18px; }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

/* The app shell owns the viewport height; inner panels scroll, the page never does. */
body {
  overflow: hidden;
}

/* Ambient gamified mesh behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 40% at 12% 8%, var(--bg-mesh-1), transparent 60%),
    radial-gradient(45% 45% at 92% 18%, var(--bg-mesh-2), transparent 60%),
    radial-gradient(40% 50% at 78% 96%, var(--bg-mesh-3), transparent 60%);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

[hidden] {
  display: none !important;
}

/* ---------- Access gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: radial-gradient(1200px 600px at 50% -10%, #1d4ed833, transparent), var(--bg);
  padding: 1rem;
}

.gate-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: 0 20px 60px #0008;
}

.gate-card h1 {
  margin: 0;
  font-size: 1.5rem;
}

.gate-logo {
  font-size: 2.5rem;
  line-height: 1;
}

.gate-tagline {
  color: var(--text) !important;
  font-weight: 600;
  font-size: 1rem !important;
}

.gate-features {
  list-style: none;
  margin: 0.4rem 0 0.6rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
}

.gate-features li {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
}

.gate-note {
  font-size: 0.8rem !important;
  margin-top: 0.5rem !important;
}

.gate-card p {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.gate-card label {
  font-size: 0.8rem;
  color: var(--muted);
}

.gate-card input {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
}

.gate-card button,
.composer button {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.gate-card button:hover,
.composer button:hover {
  background: var(--accent-2);
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
}

/* ---------- Chat app ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0.9rem var(--gutter);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.link:hover {
  color: var(--text);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bubble {
  max-width: 100%;
  padding: 0;
  border-radius: var(--radius);
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 1rem;
}

.bubble.user {
  align-self: flex-end;
  max-width: min(80%, 680px);
  padding: 0.7rem 1rem;
  white-space: pre-wrap;
  background: var(--user);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  color: var(--text);
}

/* Rendered Markdown inside an assistant reply (document-style, like MS Copilot). */
.bubble.assistant > :first-child {
  margin-top: 0;
}
.bubble.assistant > :last-child {
  margin-bottom: 0;
}
.bubble.assistant p {
  margin: 0 0 0.75rem;
}
.bubble.assistant ul,
.bubble.assistant ol {
  margin: 0 0 0.75rem;
  padding-left: 1.4rem;
}
.bubble.assistant li {
  margin: 0.25rem 0;
}
.bubble.assistant li > ul,
.bubble.assistant li > ol {
  margin: 0.25rem 0 0.35rem;
}
.bubble.assistant h1,
.bubble.assistant h2,
.bubble.assistant h3,
.bubble.assistant h4 {
  margin: 1rem 0 0.5rem;
  line-height: 1.3;
  font-weight: 700;
}
.bubble.assistant h1 {
  font-size: 1.3rem;
}
.bubble.assistant h2 {
  font-size: 1.15rem;
}
.bubble.assistant h3,
.bubble.assistant h4 {
  font-size: 1.02rem;
}
.bubble.assistant strong {
  color: #fff;
  font-weight: 600;
}
.bubble.assistant a {
  color: var(--accent-2);
}
.bubble.assistant code {
  background: #0b1220;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.88em;
}
.bubble.assistant pre {
  background: #0b1220;
  border: 1px solid var(--border-soft);
  padding: 0.85rem 1rem;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0 0 0.75rem;
}
.bubble.assistant pre code {
  background: none;
  padding: 0;
  font-size: 0.9em;
}

.bubble.typing {
  color: var(--muted);
  font-style: italic;
  white-space: pre-wrap;
}

.bubble.assistant.streaming {
  white-space: pre-wrap;
}

.chat-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--gold) 10%, var(--panel-2));
  color: var(--text);
}

.chat-retry {
  flex: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.chat-retry:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.welcome {
  color: var(--muted);
  text-align: center;
  margin: auto 0;
  padding: 2rem 1rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.2rem 0.6rem;
}

.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent-2);
}

.composer {
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem 1.2rem 1.2rem;
  border-top: 1px solid var(--border-soft);
}

.composer textarea {
  flex: 1;
  resize: none;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  max-height: 160px;
}

.composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Mode tabs + views ---------- */
.modes {
  display: flex;
  gap: 0.25rem;
}

.mode {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}

.mode.active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.mode:hover {
  color: var(--text);
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Quiz ---------- */
.quiz-panel {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-width: none;
  width: 100%;
  margin: 0 auto;
}

.quiz-panel.center {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.quiz-panel h2 {
  margin: 0;
}

.quiz-panel label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.quiz-panel select {
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
}

/* Setup is a form: render it as a tidy, centered column instead of a left-hugging
   strip when the panel fills a wide screen (play/result still use the full frame).
   Widened from 460px so it isn't a cramped strip on large screens; kept below the
   play column's width because form controls read best at a moderate width. */
#quiz-setup {
  align-items: center;
}
#quiz-setup > * {
  width: 100%;
  max-width: min(100%, 820px);
}

/* Balance the result screen too: centered heading + actions (review stays wide). */
#quiz-result .quiz-result-head,
#quiz-result .quiz-actions {
  justify-content: center;
}

.muted {
  color: var(--muted);
  margin: 0;
}

#quiz-start,
#quiz-retry,
#quiz-review-btn,
#drill-btn,
.quiz-next,
.quiz-submit,
#examreview-finalize {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

.quiz-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quiz-actions-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.quiz-skip {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

.quiz-skip:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

#quiz-start:hover,
#quiz-retry:hover,
#quiz-review-btn:hover,
#drill-btn:hover,
.quiz-next:hover,
.quiz-submit:hover {
  background: var(--accent-2);
}

#drill-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.progress-drill {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.progress-drill .muted {
  margin: 0;
}

#quiz-new,
.secondary {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

#quiz-new:hover,
.secondary:hover {
  border-color: var(--accent-2);
  background: #2f3e57;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Question navigator: an at-a-glance map of the set you can jump around. */
.quiz-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.qnav-dot {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.qnav-dot:not(:disabled):hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.qnav-dot.current {
  border-color: var(--accent-2);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.qnav-dot.skipped {
  border-color: #f59e0b;
  color: #fbbf24;
}

.qnav-dot.right {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  cursor: default;
}

.qnav-dot.wrong {
  border-color: var(--error);
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
  cursor: default;
}

/* Results summary: a clickable table of every question (number, domain, verdict). */
.quiz-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.6rem 0 1rem;
}

.quiz-summary-title {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.quiz-summary-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-summary-row:hover {
  background: #2f3e57;
}

.quiz-summary-row.right {
  border-left-color: #22c55e;
}

.quiz-summary-row.wrong {
  border-left-color: var(--error);
}

.qs-num {
  flex: 0 0 1.6rem;
  font-weight: 700;
  color: var(--muted);
}

.qs-dom {
  flex: 0 0 auto;
  min-width: 2rem;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-2);
}

.qs-stem {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.qs-badge {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.qs-badge.right {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.qs-badge.wrong {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

/* Neutral "answered" dot for exam mode (correctness hidden until finalize). */
.qnav-dot.answered {
  border-color: var(--accent-2);
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
  cursor: default;
}

/* Quiz mode selector (Training vs Exam simulation). */
.quiz-mode {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
}

.mode-opt:has(input:checked) {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.mode-opt input {
  margin-top: 0.2rem;
}

.mode-opt-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mode-opt-body .muted {
  font-size: 0.82rem;
}

/* Exam Review screen (exam simulation). */
.examreview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.8rem;
}

.examreview-chip {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.examreview-chip.right {
  border-color: #22c55e;
  color: #86efac;
}

.examreview-chip.wrong {
  border-color: var(--error);
  color: #fca5a5;
}

.examreview-chip.skipped {
  border-color: #f59e0b;
  color: #fbbf24;
}

.examreview-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.examreview-row {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  background: var(--panel-2);
  padding: 0.6rem 0.75rem;
}

.examreview-row.right {
  border-left-color: #22c55e;
}

.examreview-row.wrong {
  border-left-color: var(--error);
}

.examreview-row.answered {
  border-left-color: var(--accent-2);
}

.examreview-row.skipped {
  border-left-color: #f59e0b;
}

.examreview-row-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.er-num {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--muted);
}

.er-dom {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-2);
}

.er-stem {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.er-badge {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
}

.er-badge.right {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.er-badge.wrong {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

.er-badge.skipped {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.examreview-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.examreview-row-actions button {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.examreview-row-actions button.secondary {
  background: transparent;
  color: var(--muted);
}

.examreview-row-actions button:hover {
  border-color: var(--accent-2);
}

.examreview-detail {
  margin-top: 0.6rem;
}

.quiz-stem {
  font-size: 1.05rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quiz-option {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  flex-wrap: wrap;
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
}

.opt-rationale {
  flex-basis: 100%;
  margin-left: 2.3rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- Yes/No ---------- */
.yesno-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.yesno-row.correct {
  border-color: #22c55e;
}
.yesno-row.incorrect {
  border-color: #ef4444;
}

.yesno-text {
  flex: 1 1 60%;
  font-size: 0.95rem;
  line-height: 1.45;
}

.yesno-toggle {
  display: flex;
  gap: 0.3rem;
}

.yesno-btn {
  min-width: 3.2rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border-soft);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.yesno-btn.selected {
  border-color: var(--accent-2);
  background: var(--accent);
  color: #fff;
}

.yesno-btn.correct {
  border-color: #22c55e;
  background: #14361f;
  color: #22c55e;
}
.yesno-btn.incorrect {
  border-color: #ef4444;
  background: #3a1717;
  color: #f87171;
}
.yesno-btn:disabled {
  cursor: default;
}

.yesno-row .opt-rationale {
  flex-basis: 100%;
  margin-left: 0;
}

/* ---------- Sequence ---------- */
.seq-hint {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.seq-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.seq-chip {
  padding: 0.5rem 0.8rem;
  border: 1px dashed #475569;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.seq-chip:hover {
  border-color: var(--accent-2);
  border-style: solid;
}

.seq-answer-label {
  font-size: 0.8rem;
  margin: 0.3rem 0;
}

.seq-answer {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 2.5rem;
}

.seq-placed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: grab;
}

.seq-placed.dragging {
  opacity: 0.5;
}

.seq-placed.correct {
  border-color: #22c55e;
  background: #14361f55;
}
.seq-placed.missed {
  border-color: #f59e0b;
  background: #3a2a1755;
}
.seq-placed.incorrect {
  border-color: #ef4444;
  background: #3a171755;
}

.seq-num {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
}

.seq-placed-text {
  flex: 1;
  font-size: 0.92rem;
}

.seq-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.seq-remove:hover {
  color: #f87171;
}

.seq-placed .opt-rationale {
  flex-basis: 100%;
  margin-left: 2.2rem;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent-2);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option .opt-label {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--border);
  font-weight: 700;
  font-size: 0.8rem;
}

.quiz-option.selected {
  border-color: var(--accent-2);
}

.quiz-option.correct {
  border-color: #22c55e;
  background: #14361f;
}

.quiz-option.correct .opt-label {
  background: #22c55e;
}

.quiz-option.incorrect {
  border-color: #ef4444;
  background: #3a1717;
}

.quiz-option.incorrect .opt-label {
  background: #ef4444;
}

.quiz-feedback {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: var(--panel-2);
  line-height: 1.5;
}

.quiz-feedback .verdict {
  font-weight: 700;
}

.quiz-feedback .verdict.right {
  color: #22c55e;
}

.quiz-feedback .verdict.wrong {
  color: #ef4444;
}

.quiz-feedback .explanation {
  margin-top: 0.4rem;
  white-space: pre-wrap;
}

.quiz-next,
.quiz-submit {
  align-self: flex-start;
}

.quiz-final {
  font-size: 1.6rem;
  font-weight: 700;
}

.save-warn {
  margin-top: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: #3a2a17;
  border: 1px solid #b4791f;
  color: #f0c674;
  font-size: 0.85rem;
  text-align: center;
}

.quiz-actions {
  display: flex;
  gap: 0.6rem;
}

/* ---------- Matching ---------- */
.match-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 0.5rem;
}

.match-row.correct {
  border-color: #22c55e;
}
.match-row.incorrect {
  border-color: #ef4444;
}

.match-text {
  flex: 1 1 55%;
  font-size: 0.95rem;
  line-height: 1.45;
}

.match-select {
  flex: 0 0 auto;
  min-width: 11rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.match-select:disabled {
  cursor: default;
  opacity: 0.85;
}

.match-answer {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--muted);
}

.match-row .opt-rationale {
  flex-basis: 100%;
  margin-left: 0;
}

/* ---------- Dropdown / build-list ---------- */
.dropdown-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  line-height: 2.1;
}

.dropdown-textseg {
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.dropdown-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  background: var(--border-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.dropdown-select.correct {
  border-color: #22c55e;
  color: #22c55e;
}
.dropdown-select.incorrect {
  border-color: #ef4444;
  color: #f87171;
}
.dropdown-select:disabled {
  cursor: default;
}

.dropdown-detail {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---------- Progress ---------- */
.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.progress-summary {
  margin: 0.5rem 0 1rem;
}

.progress-overall {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  background: var(--panel-2);
  border-left: 5px solid var(--accent);
}

.progress-overall.good {
  border-left-color: #22c55e;
}
.progress-overall.ok {
  border-left-color: #eab308;
}
.progress-overall.weak {
  border-left-color: #ef4444;
}

.progress-overall .big {
  font-size: 2rem;
  font-weight: 700;
}

.progress-hint {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.progress-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.pr-name {
  font-size: 0.9rem;
  line-height: 1.35;
}

.pr-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.pr-bar span {
  display: block;
  height: 100%;
}

.pr-bar span.good {
  background: #22c55e;
}
.pr-bar span.ok {
  background: #eab308;
}
.pr-bar span.weak {
  background: #ef4444;
}

.pr-stat {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .brand {
    font-size: 0.98rem;
  }
  .mode {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
  }
  .bubble {
    max-width: 100%;
  }
  .progress-row {
    grid-template-columns: 1fr auto;
  }
  .pr-bar {
    display: none;
  }
}

/* ---------- Quiz review ---------- */
.quiz-result-head {
  text-align: center;
}

.quiz-result-head h2 {
  margin: 0 0 0.4rem;
}

.quiz-review {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.review-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-num {
  font-size: 0.8rem;
  color: var(--muted);
}

.review-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.review-badge.right {
  background: #14361f;
  color: #22c55e;
}

.review-badge.wrong {
  background: #3a1717;
  color: #f87171;
}

.review-stem {
  font-size: 0.98rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.review-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.review-option.correct {
  border-color: #22c55e;
  background: #14361f55;
}

.review-option.missed {
  border-color: #f59e0b;
  background: #3a2a1755;
}

.review-subhead,
.seq-subhead {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0.85rem 0 0.4rem;
  color: var(--muted);
}

.review-subhead:first-child,
.seq-subhead:first-child {
  margin-top: 0.2rem;
}

.review-none {
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.review-option.incorrect {
  border-color: #ef4444;
  background: #3a171755;
}

.review-option-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.review-option .opt-label {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--border);
  font-weight: 700;
  font-size: 0.78rem;
}

.review-option.correct .opt-label {
  background: #22c55e;
}

.review-option.incorrect .opt-label {
  background: #ef4444;
}

.review-option .opt-text {
  flex: 1;
}

.review-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.review-tag.correct {
  background: #22c55e;
  color: #06240f;
}

.review-tag.wrong {
  background: #ef4444;
  color: #2a0a0a;
}

.review-option .opt-rationale {
  margin-left: 2.1rem;
  margin-top: 0;
}

.review-explanation {
  font-size: 0.88rem;
  color: var(--text);
  background: var(--border-soft);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ---------- Learn tab: domain explorer + key concepts ---------- */
/* The Learn view has TWO children (cert picker + domains list), unlike the
   single-panel quiz/progress views. Make the whole view the one scroll container
   and stop the picker panel from stretching (flex:1) or nesting its own scroll. */
#learn-view {
  overflow-y: auto;
  padding: var(--gutter);
}

#learn-view .quiz-panel {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0;
}

.learn-domains {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1.2rem;
}

.learn-head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
}

.learn-head p {
  margin: 0 0 0.3rem;
}

.learn-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.learn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  padding: 0.9rem 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.learn-card-head:hover {
  background: var(--panel-2);
}

.learn-card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.7rem;
}

.learn-card-name {
  font-weight: 700;
  font-size: 1rem;
}

.learn-badges {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.learn-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.learn-badge.weight {
  color: #bfdbfe;
  border-color: var(--accent-2);
}

.learn-chevron {
  color: var(--muted);
  flex: 0 0 auto;
}

.learn-objectives {
  list-style: none;
  margin: 0;
  padding: 0 1rem 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.2rem;
}

.learn-objectives li {
  position: relative;
  padding-left: 1.3rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.learn-objectives li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #22c55e;
  font-weight: 700;
}

@media (max-width: 720px) {
  .learn-objectives { grid-template-columns: 1fr; }
}

.learn-card-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.learn-desc {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  margin: 0.9rem 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

.learn-subhead {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}

.concept-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.5rem;
}

.concept-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.concept-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.concept-priority {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
}

.concept-priority.critical {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

.concept-priority.high {
  background: rgba(139, 92, 246, 0.22);
  color: #c4b5fd;
}

.concept-priority.medium {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
}

.concept-desc {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.learn-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.learn-link {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--accent-2);
  color: #bfdbfe;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.learn-link:hover {
  background: rgba(59, 130, 246, 0.15);
}

/* ---------- Learn: sub-tabs + flashcards ---------- */
.learn-subnav {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.learn-subtab {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.learn-subtab.active {
  border-color: var(--accent-2);
  color: var(--text);
  background: rgba(59, 130, 246, 0.15);
}

.learn-flashcards {
  margin-top: 1.2rem;
}

.fc-stats {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.fc-stat {
  flex: 1 1 0;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 0.6rem 0.4rem;
}

.fc-stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-2);
}

.fc-stat-value.known { color: #86efac; }
.fc-stat-value.xp { color: #fbbf24; }

.fc-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fc-services {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.fc-service {
  padding: 0.8rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.fc-service:hover {
  border-color: var(--accent-2);
  background: #2f3e57;
}

.fc-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.fc-back-link {
  align-self: flex-start;
}

.fc-player-title {
  color: var(--muted);
  font-size: 0.85rem;
}

.fc-card {
  width: 100%;
  max-width: 640px;
  min-height: 280px;
  perspective: 1200px;
  cursor: pointer;
}

.fc-card-inner {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.fc-card.flipped .fc-card-inner {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 1.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.fc-face.fc-back {
  transform: rotateY(180deg);
}

.fc-face-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.fc-face-text {
  font-size: 1.15rem;
  line-height: 1.55;
  font-weight: 600;
}

.fc-back .fc-face-text {
  font-size: 1.02rem;
  font-weight: 400;
}

.fc-flip-hint {
  font-size: 0.8rem;
  color: var(--accent-2);
}

.fc-actions {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  max-width: 640px;
}

.fc-actions button {
  flex: 1 1 0;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.fc-actions button.secondary {
  background: transparent;
  color: var(--muted);
}

.fc-actions button:hover { border-color: var(--accent-2); }

.fc-next-row {
  margin-top: 0.2rem;
}

/* ---------- Searchable cert picker (type to filter, star to pin) ---------- */
.cert-picker {
  position: relative;
}

.cert-search {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.cert-search:focus {
  outline: none;
  border-color: var(--accent-2);
}

.cert-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  margin-top: 0.3rem;
  max-height: 340px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.cert-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

.cert-row:hover {
  background: var(--panel-2);
}

.cert-row.selected {
  background: rgba(59, 130, 246, 0.12);
}

.cert-star {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.15rem;
}

.cert-star.on {
  color: #fbbf24;
}

.cert-star:hover {
  color: #fbbf24;
}

.cert-row-text {
  flex: 1 1 auto;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-row-cat {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.cert-divider {
  height: 1px;
  background: var(--border);
  margin: 0.2rem 0;
}

.cert-empty {
  padding: 0.7rem;
  font-size: 0.9rem;
}

/* ---------- Profile hub ---------- */
.profile-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.profile-header-panel {
  flex: 0 0 auto;
  padding: var(--gutter);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.profile-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.profile-id h2 {
  margin: 0;
  font-size: 1.25rem;
}

.profile-stats {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.profile-stat {
  flex: 1 1 0;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 0.55rem 0.4rem;
}

.profile-stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-2);
}

.profile-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.profile-section {
  flex: 0 0 auto;
  padding: var(--gutter);
}

.profile-section-title {
  margin: 0;
  font-size: 1.05rem;
}

.profile-section-sub {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.85rem;
}

.profile-held-picker {
  margin-bottom: 0.8rem;
}

.profile-certs {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.profile-empty {
  font-size: 0.88rem;
}

.profile-cert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

.profile-cert-label {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-cert-actions {
  display: inline-flex;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.profile-cert-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-cert-btn:hover {
  border-color: var(--accent-2);
}

.profile-cert-btn.danger {
  color: var(--muted);
}

.profile-cert-btn.danger:hover {
  border-color: var(--error);
  color: #fca5a5;
}

.cert-row-held {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 700;
  color: #86efac;
}

/* ---------- Profile avatar + chooser ---------- */
.profile-avatar {
  border: 1px solid var(--border);
  cursor: pointer;
  background-size: cover;
  background-position: center;
  padding: 0;
  font-family: inherit;
  color: var(--text);
  position: relative;
  transition: border-color 0.15s;
}

.profile-avatar:hover {
  border-color: var(--accent-2);
}

.profile-avatar.has-img {
  font-size: 0;
}

.profile-avatar::after {
  content: "✎";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--panel);
}

.profile-header {
  position: relative;
}

.avatar-chooser {
  position: absolute;
  top: 3.6rem;
  left: 0;
  z-index: 40;
  width: min(320px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.avatar-chooser-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.avatar-upload-btn {
  padding: 0.6rem 0.8rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.avatar-upload-btn:hover {
  background: var(--accent-2);
}

.avatar-emojis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
}

.avatar-emoji {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.avatar-emoji:hover {
  border-color: var(--accent-2);
  background: #2f3e57;
}

.avatar-chooser-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.avatar-chooser-actions .muted {
  font-size: 0.8rem;
}

/* ---------- Profile: suggested-next (cert path) ---------- */
.profile-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.suggest-cert {
  align-items: flex-start;
}

.suggest-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
}

.suggest-reason {
  font-size: 0.82rem;
  line-height: 1.4;
  white-space: normal;
}

@media (max-width: 640px) {
  .suggest-cert {
    flex-direction: column;
  }
  .suggest-cert .profile-cert-actions {
    align-self: flex-end;
  }
}

/* ============================================================
   V2 DESIGN LANGUAGE — gamified polish (overrides above)
   Tokens drive everything; these refine the prominent components.
   ============================================================ */

/* Brand mark with gradient logo glyph */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.06rem;
  letter-spacing: -0.02em;
}
.brand::before {
  content: "C";
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  box-shadow: var(--shadow-lg);
}

/* Glassy topbar */
.topbar {
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 5;
}

/* Pill nav with gradient active state */
.mode {
  font-weight: 600;
  transition: all var(--t-fast) var(--ease);
}
.mode.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.mode:hover:not(.active) {
  background: var(--panel-2);
}

/* Primary buttons → gradient + lift */
#signin-btn,
.gate-card button,
.composer button,
#quiz-start,
#quiz-retry,
#quiz-review-btn,
#drill-btn,
.quiz-next,
.quiz-submit,
#fc-know,
#examreview-finalize,
#examreview-new,
#avatar-upload {
  background: var(--grad);
  border: none;
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
#signin-btn:hover,
.gate-card button:hover,
.composer button:hover:not(:disabled),
#quiz-start:hover,
#quiz-retry:hover,
#quiz-review-btn:hover,
#drill-btn:hover:not(:disabled),
.quiz-next:hover,
.quiz-submit:hover:not(:disabled),
#fc-know:hover,
#examreview-finalize:hover,
#avatar-upload:hover {
  background: var(--grad);
  transform: translateY(-2px);
  filter: brightness(1.06);
}

/* Secondary / ghost buttons */
.secondary,
.quiz-skip {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  transition: all var(--t-fast) var(--ease);
}
.secondary:hover,
.quiz-skip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Chips */
.chip {
  font-weight: 600;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Inputs / selects / textarea focus ring */
.composer textarea:focus,
.quiz-panel select:focus,
.gate-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Mode option cards (quiz setup) */
.mode-opt {
  transition: all var(--t-fast) var(--ease);
}
.mode-opt:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Gate landing polish */
.gate-card {
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}
.gate-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--grad);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-lg);
  margin: 0 auto 0.4rem;
}
.gate-card h1 {
  font-family: var(--font-display);
  font-weight: 800;
}

/* Theme toggle icon button */
.theme-toggle {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border);
}

/* Accessible focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   V2 SHELL — sidebar + main + Dashboard (gamified home)
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.4rem 1rem;
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  min-height: 0;
}
.sidebar .brand {
  padding: 0.2rem 0.5rem 1.2rem;
  font-size: 1.15rem;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  background: none;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  position: relative;
}
.nav-item .nav-ic {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}
.nav-item:hover {
  background: var(--panel-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--panel-2);
  color: var(--text);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--grad);
}
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.side-foot .link {
  text-align: left;
  padding: 0.4rem 0.5rem;
}
.side-xp {
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
}
.side-xp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}
.side-xp-top b {
  font-family: var(--font-display);
}
.xpbar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
  margin: 0.45rem 0 0.35rem;
}
.xpbar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--grad);
  box-shadow: 0 0 10px var(--accent);
  transition: width var(--t-slow) var(--ease);
}
.side-xp small {
  font-size: 0.72rem;
}

/* ---- Main column ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.topbar-slim {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem var(--gutter);
  border-bottom: 1px solid var(--border-soft);
  min-height: 56px;
}
.topbar-spacer {
  flex: 1;
}
.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Dashboard ---- */
.dashboard {
  display: block;
  overflow-y: auto;
  padding: var(--gutter);
}
.dash-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.8rem;
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.dash-hero::after {
  content: "";
  position: absolute;
  right: -50px;
  top: -70px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
}
.dash-hero-text {
  flex: 1;
  position: relative;
}
.dash-hero h2 {
  font-size: 1.6rem;
  margin: 0;
}
.dash-hero p {
  margin: 0.4rem 0 0;
  opacity: 0.92;
  max-width: 52ch;
}
.dash-cta {
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  border-radius: 11px;
  border: none;
  background: #fff;
  color: #5b3df0;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: transform var(--t-fast) var(--ease);
}
.dash-cta:hover {
  transform: translateY(-2px);
}
.dash-readiness {
  position: relative;
}
.ring {
  --p: 0;
  --sz: 116px;
  width: var(--sz);
  height: var(--sz);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  flex: none;
  background: conic-gradient(rgba(255, 255, 255, 0.92) calc(var(--p) * 1%), rgba(255, 255, 255, 0.26) 0);
}
.ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #6d4bf0;
}
.ring > div {
  position: relative;
  text-align: center;
  color: #fff;
}
.ring b {
  font-family: var(--font-display);
  font-size: 1.5rem;
}
.ring small {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.2rem;
}
.dash-stat {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.dash-stat:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.dash-stat-ico {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
}
.dash-stat-num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.dash-stat-lbl {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 2px;
}
.bg-violet { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.bg-cyan { background: color-mix(in srgb, var(--accent-cyan) 18%, transparent); color: var(--accent-cyan); }
.bg-green { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.bg-gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }

.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.dash-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.dash-card-head {
  margin-bottom: 0.8rem;
}
.dash-card-head h3 {
  font-size: 1rem;
  margin: 0;
}
.dash-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  margin-bottom: 0.5rem;
}
.dash-row:last-child {
  margin-bottom: 0;
}
.dash-row-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 0;
}
.dash-row-text {
  min-width: 0;
}
.dash-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  font-family: var(--font-display);
  flex: none;
}
.dash-row-nm {
  font-weight: 700;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-row-sub {
  font-size: 0.78rem;
}
.dash-row-btn {
  flex: none;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.dash-row-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.dash-empty {
  padding: 0.6rem 0.2rem;
  font-size: 0.88rem;
}
#dash-weak-card {
  margin-top: 1rem;
}

/* ---- Responsive: collapse sidebar to a top bar ---- */
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    max-width: none;
  }
  /* Sidebar becomes an off-canvas drawer, opened by the ☰ button in the topbar. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    max-width: 82vw;
    z-index: 1200;
    flex-direction: column;
    border-right: 1px solid var(--border-soft);
    border-bottom: none;
    padding: 1.2rem 1rem;
    gap: 0.4rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--t) var(--ease);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  /* Keep the drawer usable even if a desktop "collapsed" preference is stored. */
  .app.sidebar-collapsed .sidebar { display: flex; }
  .sidebar .brand { display: flex; }
  .side-nav { flex-direction: column; gap: 3px; }
  .nav-item { padding: 0.7rem 0.8rem; font-size: 1rem; }
  .nav-item span:not(.nav-ic) { display: inline; }
  .side-foot { flex-direction: column; align-items: stretch; gap: 0.8rem; }
  .side-xp { display: block; }
  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1150;
    background: color-mix(in srgb, #000 50%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-fast) var(--ease);
  }
  .app.sidebar-open .nav-scrim { opacity: 1; }
  .drawer-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 1rem;
    right: 0.9rem;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--panel-2);
    border: 1px solid var(--border-soft);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    z-index: 1;
  }
  .topbar-slim { padding: 0.6rem 0.8rem; gap: 0.5rem; min-height: 56px; }
  .topbar-search { min-width: 0; }
  .topbar-right { flex: none; }
  .dash-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-cols {
    grid-template-columns: 1fr;
  }
  .dash-hero {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================
   V2 ADMIN — platform overview panels
   ============================================================ */
.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.admin-head h2 {
  margin: 0;
  font-size: 1.5rem;
}
.admin-head p {
  margin: 0.2rem 0 0;
}
.pill-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}
.pill-live .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 1.8s infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.admin-spark {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 72px;
  margin-top: 0.4rem;
}
.admin-spark i {
  flex: 1;
  min-height: 6px;
  border-radius: 4px 4px 0 0;
  background: var(--grad);
  opacity: 0.85;
  transition: height var(--t-slow) var(--ease);
}

.admin-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.3rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 56px;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
}
.bar-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.bar-track > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--grad-accent);
}
.bar-val {
  text-align: right;
  font-weight: 700;
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
}
.kv:last-child {
  border-bottom: none;
}

.gauge {
  --p: 0;
  width: 150px;
  height: 150px;
  margin: 0.3rem auto 0.8rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--surface-3) 0);
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--panel);
}
.gauge > div {
  position: relative;
  text-align: center;
}
.gauge b {
  font-family: var(--font-display);
  font-size: 1.5rem;
}
.gauge small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.nav-admin .nav-ic {
  color: var(--gold);
}

/* ============================================================
   V2 SHELL FIXES — full-bleed + rich topbar (match prototype)
   ============================================================ */
/* Full-bleed: no centered max-width gutters. */
.app {
  max-width: none;
  margin: 0;
}

/* Brand: gradient mark + wordmark with COACH subtitle */
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.4rem 1.3rem;
}
.brand::before {
  content: none;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: var(--shadow-lg);
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.16rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.brand-text small {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* Sidebar section labels */
.nav-label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0.9rem 0.8rem 0.35rem;
}
.nav-label:first-child {
  padding-top: 0.2rem;
}

/* Rich topbar */
.topbar-slim {
  gap: 1rem;
  min-height: 64px;
}
.topbar-search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.topbar-search .ts-ico {
  font-size: 0.9rem;
  opacity: 0.8;
}
.topbar-search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.chat-conversation {
  width: clamp(9rem, 16vw, 15rem);
  min-width: 0;
  padding: 0.42rem 1.8rem 0.42rem 0.65rem;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  text-overflow: ellipsis;
}
.streak {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  font-weight: 700;
  font-size: 0.84rem;
  white-space: nowrap;
}
.streak .fire {
  filter: drop-shadow(0 0 6px var(--gold));
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border);
}
.avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--grad-accent);
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
  transition: transform var(--t-fast) var(--ease);
}
.avatar-sm:hover {
  transform: translateY(-1px);
}

/* Toast (used by notifications + future feedback) */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  transition: all var(--t) var(--ease-spring);
  pointer-events: none;
}
.app-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 820px) {
  .nav-label {
    display: none;
  }
}
@media (max-width: 640px) {
  .topbar-search {
    max-width: none;
  }
  .streak {
    display: none;
  }
}

/* ============================================================
   V2 QUIZ PLAY — match the prototype (cards, key badges, bar)
   ============================================================ */
/* Center the play column like the prototype (setup stays as-is). Widened from 720px so the
   quiz uses more of a large/high-DPI screen; still capped for readability (very long text
   lines are hard to scan). */
#quiz-play { align-items: stretch; }
#quiz-play > * { width: 100%; max-width: min(100%, 1200px); margin-left: auto; margin-right: auto; }

/* Gradient progress bar under the position/score line. */
.quiz-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 0.4rem; }
.quiz-bar > i { display: block; height: 100%; width: 0%; border-radius: 99px; background: var(--grad); box-shadow: 0 0 10px var(--accent); transition: width var(--t-slow) var(--ease); }

/* Question card */
.quiz-stem {
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.4;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}

/* Option cards with square key badges + hover lift */
.quiz-option {
  align-items: center;
  padding: 0.95rem 1.05rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.quiz-option:hover:not(:disabled) { transform: translateX(3px); border-color: var(--accent); }
.quiz-option .opt-label {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface-3); font-weight: 800; font-size: 0.85rem;
}
.quiz-option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.quiz-option.selected .opt-label { background: var(--grad); color: #fff; }
.quiz-option.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.quiz-option.correct .opt-label { background: var(--success); color: #fff; }
.quiz-option.incorrect { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.quiz-option.incorrect .opt-label { background: var(--danger); color: #fff; }

/* Confetti (quiz pass) */
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; border-radius: 2px; z-index: 999; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* ============================================================
   V2 PHASE 3 — delight: score ring, result card, transitions
   ============================================================ */
#quiz-result { align-items: center; text-align: center; }
/* Widened from 560px so the results + review cards use the screen like the play area,
   instead of a cramped centered strip. */
#quiz-result > * { width: 100%; max-width: min(100%, 1200px); }
.quiz-result-head { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }

.score-ring {
  --p: 0; width: 150px; height: 150px; border-radius: 50%;
  display: grid; place-items: center; position: relative; margin: 0.4rem auto 0.2rem;
  background: conic-gradient(var(--success) calc(var(--p) * 1%), var(--surface-3) 0);
}
.score-ring.warn { background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--surface-3) 0); }
.score-ring.low { background: conic-gradient(var(--danger) calc(var(--p) * 1%), var(--surface-3) 0); }
.score-ring::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--panel); }
.score-ring > div { position: relative; text-align: center; }
.score-ring b { font-family: var(--font-display); font-size: 2rem; display: block; }
.score-ring small { color: var(--muted); font-size: 0.78rem; }

/* Gentle enter animation for each view (coherent with the prototype). */
.view:not([hidden]) { animation: view-in 0.32s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view:not([hidden]) { animation: none; } }

/* ============================================================
   Feedback: collapsible sidebar + quiz quit + confirm modal
   ============================================================ */

/* Collapsible left sidebar (toggle lives in the topbar). */
.app.sidebar-collapsed { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.app.sidebar-collapsed .sidebar { display: none; }
.sidebar-toggle { flex: none; }
.nav-scrim { display: none; }
.drawer-close { display: none; }
.lang-select {
  height: 40px;
  padding: 0 0.55rem;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

/* Quit control on the quiz play screen. */
.quiz-play-top { display: flex; justify-content: flex-end; margin-bottom: 0.4rem; }
.quiz-quit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--danger);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.quiz-quit-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Confirmation modal (used by "Quit quiz", reusable). */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, #000 55%, transparent);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.modal-backdrop.show { opacity: 1; }
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--t) var(--ease-spring);
}
.modal-backdrop.show .modal-card { transform: none; }
.modal-card h3 { font-family: var(--font-display); font-size: 1.25rem; margin: 0 0 0.5rem; }
.modal-card p { color: var(--muted); margin: 0 0 1.3rem; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.modal-actions button {
  padding: 0.55rem 1.1rem;
  border-radius: 11px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
}
.modal-cancel { background: var(--panel-2); border-color: var(--border-soft); color: var(--text); }
.modal-cancel:hover { border-color: var(--border); }
.modal-confirm { background: var(--danger); color: #fff; }
.modal-confirm:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-card { transition: none; }
}

/* ============================================================
   Topics browser (Choose a Topic → instant exam-style quiz)
   ============================================================ */
#topics-view { padding: var(--gutter); overflow-y: auto; }
.topics-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.topics-head h2 { font-family: var(--font-display); font-size: 1.8rem; margin: 0 0 0.2rem; }
.topics-head-text p { margin: 0; }
.topics-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  flex: 1;
  min-width: 240px;
  max-width: 380px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.topics-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.topics-search input { flex: 1; background: none; border: none; color: var(--text); font-size: 0.95rem; outline: none; }
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}
.topic-group-label {
  grid-column: 1 / -1;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint); padding: 0.7rem 0.2rem 0.05rem;
}
.topic-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  padding: 1.3rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.topic-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topic-ic {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-3); font-size: 1.3rem;
}
.topic-cert { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em; color: var(--accent); text-transform: uppercase; }
.topic-title { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.topic-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.topic-pill {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border-soft);
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.topic-prep-badge { font-size: 0.68rem; font-weight: 700; color: var(--success); }

/* Deep-learn CTA on the low-score result. */
#quiz-deeplearn { background: var(--grad); color: #fff; border: none; }
#quiz-deeplearn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
@media (max-width: 640px) {
  .topics-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ============================================================
   Certification Poster card + inline PDF viewer
   ============================================================ */
.poster-card { display: flex; align-items: center; gap: 1.2rem; }
.poster-icon {
  width: 64px; height: 64px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 2rem; background: var(--surface-3); flex: none;
}
.poster-body { flex: 1; min-width: 0; }
.poster-title-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.poster-title-row h3 { margin: 0; }
.poster-new {
  font-size: 0.68rem; font-weight: 700; color: #fff;
  background: var(--grad); padding: 0.15rem 0.55rem; border-radius: 999px;
}
.poster-desc { margin: 0.3rem 0 0.8rem; }
.poster-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.poster-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin: 0;
  padding: 0.5rem 1rem; border-radius: 11px;
  background: var(--grad); color: #fff; border: none;
  font-weight: 700; font-size: 0.9rem; cursor: pointer; text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.poster-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.poster-btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border-soft); }
.poster-lang {
  padding: 0.45rem 0.7rem; border-radius: 10px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-soft);
  font-size: 0.88rem; cursor: pointer;
}
.poster-source { font-size: 0.8rem; margin-left: auto; }

/* Inline viewer modal (reuses .modal-backdrop show/hide). */
.poster-backdrop { padding: 2vh 2vw; }
.poster-modal {
  width: 100%; max-width: 1000px; height: 92vh;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(12px) scale(0.99); transition: transform var(--t) var(--ease-spring);
}
.modal-backdrop.show .poster-modal { transform: none; }
.poster-modal-bar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-soft);
}
.poster-modal-title { font-weight: 700; font-family: var(--font-display); }
.poster-modal-bar .poster-btn { margin-left: auto; }
.poster-modal-close {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--panel-2); border: 1px solid var(--border-soft); color: var(--text);
  font-size: 1rem; cursor: pointer;
}
.poster-modal-close:hover { border-color: var(--border); }
.poster-frame { flex: 1; width: 100%; border: none; background: #fff; }
@media (max-width: 640px) {
  .poster-card { flex-direction: column; text-align: center; align-items: stretch; }
  .poster-icon { margin: 0 auto; }
  .poster-source { margin: 0 auto; }
}

/* Skeleton loader utility for async lists. */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
