:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-2: #243044;
  --text: #e7eef8;
  --muted: #9aadc2;
  --accent: #3d9cf0;
  --accent-2: #2ecc71;
  --danger: #e74c3c;
  --border: #314258;
  --correct-bg: rgba(46, 204, 113, 0.15);
  --wrong-bg: rgba(231, 76, 60, 0.12);
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute only works through the UA stylesheet's
 * `[hidden] { display: none }`, and ANY author rule that sets `display`
 * outranks it (author styles beat UA styles). `.badge { display: inline-flex }`
 * therefore made `el.hidden = true` a no-op, leaving the previous question's
 * status/figure badges painted on the next card — e.g. a green "Mastered" chip
 * on a never-seen question. Keep this ahead of component rules.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1b3a5a 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #1a3d32 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  padding-top: max(1.5rem, env(safe-area-inset-top));
}

.top {
  margin-bottom: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 20, 25, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin-left: -0.25rem;
  margin-right: -0.25rem;
  padding: 0.25rem 0.25rem 0.35rem;
}

.chrome-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
}

.chrome-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chrome-toggle:active {
  filter: brightness(1.12);
}

.top.is-open .chrome-toggle {
  border-color: rgba(61, 156, 240, 0.55);
  background: rgba(61, 156, 240, 0.18);
  color: #b7dbff;
}

.chrome-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0.25rem 0.15rem;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chrome-heading {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.chrome-compact-meta {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chrome-user {
  flex-shrink: 0;
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapsed by default — open only with .top.is-open */
.chrome-panel {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.45rem;
  padding: 0.75rem 0.35rem 0.65rem;
  border-top: 1px solid var(--border);
}

.top.is-open .chrome-panel {
  display: flex;
}

.chrome-stats {
  margin: 0;
  font-size: 0.85rem;
}

.chrome-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(26, 35, 50, 0.85);
}

.chrome-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
}

.chrome-field select,
.chrome-field input {
  width: 100%;
  min-height: 42px;
  font-size: 16px; /* avoid iOS zoom */
}

.chrome-jump {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
}

.chrome-jump .chrome-field {
  flex: 1;
  min-width: 8rem;
}

.chrome-jump .btn {
  min-height: 42px;
}

.chrome-position {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

h2 { margin-top: 0; }

.muted { color: var(--muted); margin: 0; font-size: 0.95rem; }

.tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--panel);
  padding: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.tab.active {
  background: var(--panel-2);
  color: var(--text);
}

.exports { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.view { display: none; }
.view.active { display: block; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.jump-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.jump-form input {
  width: 7rem;
}

.study-panel {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(36, 48, 68, 0.55);
  overflow: hidden;
}

.study-panel-toggle {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
}

.study-panel-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.study-panel-body {
  padding: 0 0.9rem 0.9rem;
  border-top: 1px solid var(--border);
}

.study-panel-body .explanation {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  color: #d5e2f0;
  line-height: 1.55;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  background: transparent;
  border: 0;
  padding: 0;
  max-width: 100%;
}

.study-panel-body .explanation a.ref-link {
  color: #7ec8ff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.study-panel-body .explanation a.ref-link:hover {
  color: #b7e0ff;
}

.ai-teach {
  margin: 1rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(141, 224, 176, 0.35);
  background: linear-gradient(
    165deg,
    rgba(45, 120, 80, 0.18),
    rgba(20, 40, 32, 0.55)
  );
}
.ai-teach-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8de0b0;
}
.ai-teach-refresh {
  min-height: 28px !important;
  padding: 0.15rem 0.45rem !important;
  font-size: 0.9rem !important;
  color: #8de0b0;
}
.ai-teach-body {
  margin: 0;
  color: #e4f5ea;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-teach-body.is-loading {
  color: #94a3b8;
  font-style: italic;
}
.ai-teach-body.is-error {
  color: #f0d48a;
  font-size: 0.88rem;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0.25rem;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 156, 240, 0.45);
  background: rgba(61, 156, 240, 0.12);
  color: #b7dbff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.source-chip:hover {
  filter: brightness(1.12);
  text-decoration: underline;
}

.chevron {
  color: var(--muted);
  font-size: 0.9em;
}

.figures {
  order: 0;
}

.practice-card #practice-question {
  margin-bottom: 0.5rem;
}

/* Keep figure highly visible before answering */
.figures img.zoomable {
  cursor: zoom-in;
}

.figures figure:focus-within,
.figures figure:hover {
  box-shadow: 0 0 0 1px var(--accent);
}

.figures figcaption .linkish {
  border: 0;
  background: none;
  color: #1a5fb4;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

body.lightbox-open {
  overflow: hidden;
}

.fig-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(4px);
}

.fig-lightbox[hidden] {
  display: none !important;
}

.fig-lightbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.fig-lightbox-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.fig-lightbox-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.fig-zoom-label {
  min-width: 3.5rem;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.fig-lightbox-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.fig-lightbox-stage.dragging {
  cursor: grabbing;
}

.fig-lightbox-transform {
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.fig-lightbox-stage img {
  max-width: min(96vw, 1400px);
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
  /* transform is on the wrapper — do not set transform here */
  pointer-events: none;
  display: block;
}

.fig-lightbox-hint {
  margin: 0;
  padding: 0.5rem 1rem 0.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.toolbar label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.kbd-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: auto;
}

kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.8rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  background: rgba(61, 156, 240, 0.18);
  border: 1px solid rgba(61, 156, 240, 0.45);
  color: #b7dbff;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.muted-badge {
  background: rgba(154, 173, 194, 0.12);
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
}

.badge.fig-badge {
  background: rgba(46, 204, 113, 0.12);
  border-color: rgba(46, 204, 113, 0.4);
  color: #8de0b0;
}

.figures {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
  /* Side-by-side when a question references 2+ figures */
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .figures:has(figure:nth-child(2)) {
    grid-template-columns: 1fr 1fr;
  }
  .figures:has(figure:nth-child(3)) {
    grid-template-columns: 1fr 1fr;
  }
}

.figures figure {
  margin: 0;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.figures img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  background: #fff;
  transform-origin: center center;
}
.figures:has(figure:nth-child(2)) img {
  max-height: 380px;
}

.figures figcaption {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel-2);
}

.qnum-cell {
  white-space: nowrap;
  font-weight: 600;
  color: #b7dbff;
  font-variant-numeric: tabular-nums;
}

.choices {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.55rem;
}

.choices li button {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.choices li button:hover:not(:disabled) {
  border-color: var(--accent);
}

.choices li button.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choices li button.correct {
  background: var(--correct-bg);
  border-color: var(--accent-2);
}

.choices li button.wrong {
  background: var(--wrong-bg);
  border-color: var(--danger);
}

.choices li button:disabled {
  cursor: default;
  opacity: 0.95;
}

.choice-letter {
  display: inline-block;
  min-width: 1.4rem;
  color: var(--muted);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(180deg, #4aa6f5, #2d7fd0);
  border-color: #2d7fd0;
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.danger {
  background: rgba(231, 76, 60, 0.15);
  border-color: var(--danger);
  color: #ffb4ac;
}

.badge.status-badge {
  background: rgba(120, 140, 160, 0.2);
  border: 1px solid rgba(120, 140, 160, 0.35);
}
.badge.status-badge.mastered {
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.45);
  color: #8de0b0;
}
.badge.status-badge.flagged {
  background: rgba(240, 180, 61, 0.18);
  border-color: rgba(240, 180, 61, 0.5);
  color: #f0d48a;
}
.badge.status-badge.learning {
  background: rgba(61, 156, 240, 0.15);
  border-color: rgba(61, 156, 240, 0.4);
  color: #b7dbff;
}
#btn-flag.flagged-on {
  border-color: rgba(240, 180, 61, 0.55);
  background: rgba(240, 180, 61, 0.18);
  color: #f0d48a;
}
.chrome-study-progress {
  margin: 0;
  font-size: 0.8rem;
  grid-column: 1 / -1;
}
.mastery-card h3 { margin-top: 0; }

.answer-result {
  margin: 0.75rem 0 0.35rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  line-height: 1.35;
}
.answer-result-main {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}
.answer-result-stats {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  font-weight: 500;
}
.answer-result.result-correct {
  background: var(--correct-bg);
  border: 1px solid rgba(46, 204, 113, 0.55);
  color: #8de0b0;
}
.answer-result.result-wrong {
  background: var(--wrong-bg);
  border: 1px solid rgba(231, 76, 60, 0.5);
  color: #ffb4ac;
}
.answer-result.result-revealed {
  background: rgba(61, 156, 240, 0.12);
  border: 1px solid rgba(61, 156, 240, 0.4);
  color: #b7dbff;
}
.answer-result.result-correct .answer-result-stats,
.answer-result.result-wrong .answer-result-stats,
.answer-result.result-revealed .answer-result-stats {
  color: inherit;
  opacity: 0.9;
}

.reveal-panel {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--correct-bg);
  border: 1px solid rgba(46, 204, 113, 0.35);
}

.reveal-panel p { margin: 0.25rem 0; }
.explanation { color: var(--muted); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

input[type="search"] { min-width: 220px; flex: 1; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
  position: sticky;
  top: 0;
}

td.q { max-width: 280px; }
td.choices-cell { color: var(--muted); max-width: 320px; font-size: 0.85rem; }

.edit-form {
  display: grid;
  gap: 0.85rem;
}

.edit-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem;
  max-width: 520px;
  width: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.error { color: #ffb4ac; margin: 0; }
.ok { color: #8de0b0; margin: 0; }
.empty { color: var(--muted); }

/* Login */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.login-wrap { width: min(420px, 100%); }
.login-card { padding: 1.5rem; }
.login-brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.login-brand img { border-radius: 12px; }
.login-submit {
  width: 100%;
  justify-content: center;
  min-height: 48px;
  margin-top: 0.25rem;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(61, 156, 240, 0.15);
  border: 1px solid rgba(61, 156, 240, 0.4);
  color: #b7dbff;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Admin users */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 0.85rem;
  align-items: start;
}
.admin-users-card { min-width: 0; }
.admin-handbook-card { grid-column: 1 / -1; }
.admin-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.admin-handbook-card code {
  font-size: 0.85em;
  color: #f0d48a;
}
.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.checkbox-row input { width: auto; }
.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.role-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.role-badge.admin {
  background: rgba(240, 180, 61, 0.18);
  border: 1px solid rgba(240, 180, 61, 0.45);
  color: #f0d48a;
}
.role-badge.user {
  background: rgba(120, 140, 160, 0.15);
  border: 1px solid rgba(120, 140, 160, 0.35);
  color: var(--muted);
}
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}

/* Analytics / game */
.analytics-toolbar {
  align-items: center;
}
.day-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
}
.day-picker-label {
  margin-right: 0.15rem;
  font-size: 0.85rem;
}
.day-chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  min-height: 36px;
  min-width: 2.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.day-chip.active {
  background: rgba(61, 156, 240, 0.2);
  border-color: rgba(61, 156, 240, 0.55);
  color: #b7dbff;
}
.section-progress-table th,
.section-progress-table td {
  white-space: nowrap;
  vertical-align: middle;
}
.section-progress-table .section-name {
  white-space: normal;
  font-weight: 650;
  min-width: 8rem;
}
.section-progress-table .stat-right { color: #8de0b0; font-weight: 700; }
.section-progress-table .stat-wrong { color: #f0a0a0; font-weight: 700; }
.section-meter-cell {
  min-width: 7.5rem;
}
.section-meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.section-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3d9cf0, #8de0b0);
  min-width: 0;
}
.section-meter-label {
  font-size: 0.75rem;
}
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.analytics-wide { grid-column: 1 / -1; }

/* Study competition leaderboard */
.competition-card {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(240, 212, 138, 0.35);
  background: linear-gradient(
    145deg,
    rgba(61, 156, 240, 0.08),
    rgba(240, 212, 138, 0.06)
  );
}
.competition-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.competition-header h3 { margin: 0 0 0.25rem; }
.competition-header .muted { margin: 0; font-size: 0.9rem; }
.competition-you-box {
  text-align: right;
  flex-shrink: 0;
  min-width: 4.5rem;
}
.competition-you-box .stat-big {
  color: #f0d48a;
  font-size: 1.65rem;
}
.competition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.competition-table th,
.competition-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.competition-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.competition-table tr.is-you {
  background: rgba(61, 156, 240, 0.12);
}
.competition-table tr.is-you td { font-weight: 600; }
.comp-rank {
  width: 2.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.comp-name { min-width: 6rem; }
.comp-you-tag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(61, 156, 240, 0.25);
  color: #9fd0ff;
  vertical-align: middle;
}
.comp-mastery { min-width: 7rem; }
.comp-meter-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.comp-meter {
  height: 6px;
  min-width: 4rem;
}
.comp-week {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .competition-table th:nth-child(5),
  .competition-table td:nth-child(5),
  .competition-table th:nth-child(6),
  .competition-table td:nth-child(6) {
    display: none;
  }
  .comp-week { white-space: normal; }
}

.stat-card h3 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.stat-big {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.game-card { padding: 1rem 1.1rem; }
.game-rank-row {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1rem;
}
.game-emoji { font-size: 2.2rem; line-height: 1; }
.game-rank { margin: 0 0 0.2rem; font-size: 1.25rem; }
.game-score-box {
  margin-left: auto;
  text-align: right;
  flex-shrink: 0;
}
.game-score-box .stat-big {
  color: #f0d48a;
  font-size: 1.85rem;
}
.game-meters { margin-bottom: 0.85rem; }
.meter-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}
.meter-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid var(--border);
}
.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3d9cf0, #2ecc71);
  transition: width 0.35s ease;
}
.game-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  font-size: 0.95rem;
}
.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 72px;
  padding: 0.5rem 0 0.15rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.daily-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}
.daily-bar {
  width: 100%;
  max-width: 36px;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: rgba(61, 156, 240, 0.55);
  transition: height 0.25s ease;
}
.daily-bar.has-wrong {
  background: linear-gradient(180deg, #3d9cf0 55%, #e74c3c 100%);
}
.daily-bar-label {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}
.all-time-line {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
}
.hint-list {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.5;
}
.hint-list li { margin-bottom: 0.4rem; }

.study-links-bar {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(240, 180, 61, 0.4);
  background: rgba(240, 180, 61, 0.08);
}
.study-panel-body .study-links-bar {
  margin-top: 0.15rem;
}
.study-links-label {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f0d48a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.study-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.study-link-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  text-decoration: none;
  border: 1px solid rgba(240, 180, 61, 0.45);
  background: rgba(26, 35, 50, 0.9);
  color: var(--text);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  max-width: 100%;
}
.study-link-btn:hover {
  border-color: #f0d48a;
  background: rgba(61, 156, 240, 0.12);
}
.study-link-btn strong {
  font-size: 0.9rem;
  color: #f0d48a;
}
.study-link-btn span {
  font-size: 0.78rem;
  color: var(--muted);
}
.study-link-btn.study-link-faa {
  border-color: rgba(61, 156, 240, 0.5);
  background: rgba(61, 156, 240, 0.1);
}
.study-link-btn.study-link-faa strong {
  color: #b7dbff;
}
.study-link-btn.study-link-rod {
  border-color: rgba(240, 180, 61, 0.45);
}

.memory-aids-bar {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(46, 204, 113, 0.35);
  background: rgba(46, 204, 113, 0.08);
}
.memory-aids-label {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8de0b0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.memory-aids-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
  line-height: 1.45;
  font-size: 0.92rem;
}
.memory-aids-list li {
  margin-bottom: 0.45rem;
}
.memory-aids-list strong {
  color: #8de0b0;
}

/* Workpad: notes + E6B */
.workpad {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.workpad-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.workpad-notes textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  font-size: 16px;
  line-height: 1.4;
}
.e6b-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(20, 28, 40, 0.95);
  padding: 0.65rem;
}
.e6b-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

/* ── CX-3 digital flight computer (clean) ───────────────── */
.cx3 {
  max-width: 400px;
  margin: 0 auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.cx3-top {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.cx3-brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0 0.1rem;
}
.cx3-brand strong {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #f1f5f9;
}
.cx3-brand span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.cx3-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  background: #0f172a;
  padding: 0.28rem;
  border-radius: 10px;
  border: 1px solid #1e293b;
}
.cx3-tab {
  min-height: 40px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
}
.cx3-tab:hover { color: #e2e8f0; background: rgba(255,255,255,0.04); }
.cx3-tab.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.cx3-body {
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 0.65rem;
}
.cx3-func-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
}
.cx3-chip {
  min-height: 34px;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #cbd5e1;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.cx3-chip:hover { border-color: #475569; color: #f1f5f9; }
.cx3-chip.active {
  background: rgba(37, 99, 235, 0.25);
  border-color: #3b82f6;
  color: #93c5fd;
}
.cx3-work-head { margin-bottom: 0.5rem; }
.cx3-func-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
  color: #e2e8f0;
}
.cx3-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
@media (max-width: 380px) {
  .cx3-form { grid-template-columns: 1fr; }
}
.cx3-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}
.cx3-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.cx3-field-label em {
  font-style: normal;
  color: #64748b;
  font-weight: 600;
}
.cx3-input {
  min-height: 44px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  padding: 0.4rem 0.6rem;
  box-sizing: border-box;
}
.cx3-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
.cx3-input:disabled {
  opacity: 0.55;
}
.cx3-answers {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(15, 23, 42, 0.6));
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.cx3-ans {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.cx3-ans-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
}
.cx3-ans-value {
  font-size: 1rem;
  font-weight: 800;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cx3-ans.primary .cx3-ans-label {
  color: #93c5fd;
  font-size: 0.85rem;
}
.cx3-ans.primary .cx3-ans-value {
  font-size: 1.35rem;
  color: #fff;
  letter-spacing: 0.01em;
}

/* Calculator */
.cx3-calc {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.cx3-calc-screen {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  min-height: 4.5rem;
}
.cx3-calc-expr {
  min-height: 1.15rem;
  text-align: right;
  font-size: 0.85rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cx3-calc-display {
  text-align: right;
  font-size: 2.1rem;
  font-weight: 750;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  word-break: break-all;
  line-height: 1.2;
  margin-top: 0.15rem;
}
.cx3-hist {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.4rem 0.45rem;
  margin-bottom: 0.15rem;
}
.cx3-hist.empty {
  padding: 0.45rem 0.55rem;
}
.cx3-hist-empty {
  margin: 0;
  font-size: 0.75rem;
  color: #64748b;
  text-align: center;
}
.cx3-hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.1rem 0.25rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}
.cx3-hist-clear {
  border: none;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  min-height: 28px;
}
.cx3-hist-clear:hover { color: #f87171; background: rgba(248, 113, 113, 0.1); }
.cx3-hist-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 7.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cx3-hist-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #1e293b;
  color: #cbd5e1;
  font: inherit;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  padding: 0.4rem 0.5rem;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
}
.cx3-hist-item:hover,
.cx3-hist-item:active {
  border-color: #3b82f6;
  background: #243447;
}
.cx3-hist-line {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #94a3b8;
}
.cx3-hist-result {
  font-weight: 800;
  color: #e2e8f0;
  flex-shrink: 0;
}
.cx3-calc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}
.cx3-btn {
  min-height: 52px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f1f5f9;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
.cx3-btn:hover { background: #273549; }
.cx3-btn:active { transform: scale(0.97); background: #334155; }
.cx3-btn.op {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #93c5fd;
}
.cx3-btn.fn {
  background: #2a2438;
  border-color: #4c3f63;
  color: #d8b4fe;
  font-size: 1rem;
}
.cx3-btn.eq {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #fff;
}
.cx3-btn.eq:hover { background: #2563eb; }
.cx3-btn.wide {
  flex: 1;
  font-size: 1rem;
}

/* Timer */
.cx3-timer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
}
.cx3-clock {
  text-align: center;
  font-size: 2.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
  letter-spacing: 0.04em;
  padding: 0.75rem 0 0.15rem;
  line-height: 1;
}
.cx3-clock.running { color: #4ade80; }
.cx3-clock-status {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #64748b;
}
.cx3-timer-actions {
  display: flex;
  gap: 0.4rem;
}
.cx3-timer-set {
  max-width: 140px;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .cx3 { max-width: 100%; }
  .cx3-btn { min-height: 54px; }
  .cx3-tab { min-height: 44px; }
  .cx3-input { min-height: 48px; font-size: 16px; }
}


.answer-timing {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.answer-timing.timing-fast { color: #8de0b0; }
.answer-timing.timing-slow { color: #f0d48a; }
.timing-subhead {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 800px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .game-rank-row { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .kbd-hint { display: none; }
  .app {
    padding-top: max(0.65rem, env(safe-area-inset-top));
    padding-bottom: max(5.5rem, calc(env(safe-area-inset-bottom) + 4.5rem));
  }
  .chrome-toggle-label { display: none; }
  .chrome-heading { font-size: 1.02rem; }
  .chrome-tools {
    grid-template-columns: 1fr;
  }
  .tabs {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
  }
  .tab {
    flex: 1 1 auto;
    text-align: center;
    padding: 0.65rem 0.5rem;
    min-height: 44px;
  }
  .exports {
    width: 100%;
  }
  .exports .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }
  /* Keep answer controls reachable without scrolling past chrome */
  #view-practice.active .practice-card .actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 0.75rem -0.85rem -0.85rem;
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, rgba(26, 35, 50, 0.96) 18%);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
  }
  #view-practice.active .practice-card .actions .btn {
    flex: 1 1 40%;
    min-height: 44px;
    justify-content: center;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar label,
  .jump-form {
    width: 100%;
  }
  .toolbar select,
  .jump-form input {
    width: 100%;
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .jump-form {
    flex-wrap: wrap;
  }
  .jump-form .btn {
    min-height: 44px;
  }
  .choices li button {
    padding: 0.9rem 1rem;
    min-height: 48px;
    font-size: 1rem;
  }
  .actions {
    gap: 0.5rem;
  }
  .actions .btn {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 0.6rem;
  }
  .figures img {
    max-height: 45vh;
  }
  .table-wrap {
    font-size: 0.85rem;
  }
  td.q { max-width: 160px; }
  .fig-lightbox-controls .btn {
    min-height: 44px;
  }
  .fig-lightbox-stage img {
    max-height: 70vh;
  }
}


/* ---------------------------------------------------------------
 * FAA practice test
 * --------------------------------------------------------------- */

.exam-facts {
  list-style: none;
  margin: 1rem 0 0.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
}
.exam-facts li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.5rem;
  text-align: center;
}
.exam-facts strong { display: block; font-size: 1.5rem; line-height: 1.2; }
.exam-facts span { display: block; color: var(--muted); font-size: 0.8rem; }
.exam-note { margin-top: 0.75rem; }

/* Sticky bar so the clock stays visible while you scroll a long question */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.exam-counter { font-weight: 600; }
.exam-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
  border-radius: 8px;
  background: var(--panel-2);
}
.exam-timer.warn { color: #f5b041; }
.exam-timer.danger { color: var(--danger); animation: exam-pulse 1s ease-in-out infinite; }
@keyframes exam-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .exam-timer.danger { animation: none; }
}
.exam-answered { margin-left: auto; font-size: 0.85rem; }

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
  gap: 0.35rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.exam-cell {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}
.exam-cell.answered { background: rgba(46, 204, 113, 0.18); color: var(--text); }
.exam-cell.marked { border-color: #f5b041; box-shadow: inset 0 0 0 1px #f5b041; }
.exam-cell.current { outline: 2px solid var(--accent); outline-offset: 1px; }

.choice.chosen {
  border-color: var(--accent);
  background: rgba(61, 156, 240, 0.16);
}

.exam-score-card { text-align: center; }
.exam-verdict {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0;
}
.exam-score-card.passed .exam-verdict { color: var(--accent-2); }
.exam-score-card.failed .exam-verdict { color: var(--danger); }
.exam-score { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }
.exam-score-card .actions { justify-content: center; }

.badge.pass { background: rgba(46, 204, 113, 0.2); color: var(--accent-2); }
.badge.fail { background: rgba(231, 76, 60, 0.18); color: var(--danger); }

.exam-cat { margin-bottom: 0.85rem; }
.exam-cat-head { display: flex; justify-content: space-between; gap: 0.5rem; }
.exam-cat-name { font-weight: 600; }
.exam-cat-score.ok { color: var(--accent-2); }
.exam-cat-score.weak { color: var(--danger); }
.exam-cat-bar {
  height: 8px;
  margin-top: 0.3rem;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.exam-cat-bar span { display: block; height: 100%; border-radius: 999px; }
.exam-cat-bar span.ok { background: var(--accent-2); }
.exam-cat-bar span.weak { background: var(--danger); }
.exam-missed { display: block; font-size: 0.8rem; margin-top: 0.25rem; }

.exam-review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.45rem;
}
.exam-review-item.correct { background: var(--correct-bg); }
.exam-review-item.wrong { background: var(--wrong-bg); }
.exam-review-item summary {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  cursor: pointer;
}
.exam-review-mark { font-weight: 700; }
.exam-review-num { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.exam-review-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exam-review-item[open] .exam-review-text { white-space: normal; }
.exam-review-body { margin-top: 0.6rem; }

.exam-history th, .exam-history td { text-align: left; }


/* ---------------------------------------------------------------
 * Train tab launcher (docs/train-modes-spec.md §5)
 * --------------------------------------------------------------- */
.train-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.train-card {
  text-align: left; cursor: pointer; font: inherit; color: var(--text);
  display: flex; flex-direction: column; gap: 0.35rem;
  border: 1px solid var(--border); background: var(--panel);
  transition: border-color 120ms ease, transform 120ms ease;
}
.train-card:hover, .train-card:focus-visible { border-color: var(--accent); transform: translateY(-1px); outline: none; }
.train-card-kicker { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.train-card-title { font-size: 1.25rem; font-weight: 700; }
.train-card-blurb { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.train-stage-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.train-stage-title { font-weight: 700; font-size: 1.05rem; }

/* ---------- Home: test picker ---------- */
.home-head { margin-bottom: 1rem; }
.home-head h2 { margin: 0 0 0.25rem; }
.home-head p { margin: 0; }
.home-card { padding: 1.1rem 1.15rem; gap: 0.45rem; }
.home-card.is-current { border-color: var(--accent); }
.home-card-meter { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; }
.home-card-meter .meter-track { flex: 1; display: block; }
.home-card-meter .meter-fill { display: block; }
.home-card-meter strong { min-width: 2.75rem; text-align: right; font-variant-numeric: tabular-nums; }
.home-card-status { font-size: 0.85rem; }

/* Oral tests: choices stay hidden until the pilot has answered aloud */
.choices[hidden] { display: none; }
.recall-gate {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
  margin: 0.75rem 0; padding: 0.85rem 1rem;
  border: 1px dashed var(--border); border-radius: 10px;
}
.recall-gate[hidden] { display: none; }
.recall-gate p { margin: 0; flex: 1; min-width: 12rem; }
