/* ===== AWS AIP-C01 学習ハブ - Mobile-first CSS ===== */

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-light: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --correct: #22c55e;
  --correct-bg: rgba(34,197,94,0.15);
  --wrong: #ef4444;
  --wrong-bg: rgba(239,68,68,0.15);
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,0.15);
  --purple: #a855f7;
  --border: #334155;
  --shadow: 0 10px 30px rgba(0,0,0,0.3);
  --bn-height: 64px;          /* Bottom nav height */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", sans-serif;
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
  /* Ensure content not hidden behind bottom nav */
  padding-bottom: calc(var(--bn-height) + var(--safe-bottom) + 16px);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== App Shell ===== */
.app { min-height: 100vh; }

/* ===== Top Bar (compact, both mobile & desktop) ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(15,23,42,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  max-width: 1100px; margin: 0 auto;
  padding: 10px 14px;
}
.brand { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-title { font-size: 14px; font-weight: 700; color: var(--primary); }
.brand-sub { font-size: 10px; color: var(--text-dim); }
.menu-btn {
  background: var(--panel-light); border: none; color: var(--text);
  font-size: 18px; width: 40px; height: 40px; border-radius: 8px;
  cursor: pointer; font-family: inherit;
}
.menu-btn:active { transform: scale(0.95); }

/* ===== Main Content ===== */
.main {
  max-width: 1100px; margin: 0 auto;
  padding: 16px 14px 24px;
}

/* ===== Bottom Navigation (always visible) ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bn-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
}
.bn-item {
  flex: 1; min-width: 0;
  background: transparent; border: none; color: var(--text-dim);
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  padding: 8px 4px;
  font-size: 11px;
  position: relative;
  transition: color 0.2s;
}
.bn-item:active { transform: scale(0.95); }
.bn-icon { font-size: 22px; line-height: 1; }
.bn-label { font-weight: 600; font-size: 11px; }
.bn-item.active { color: var(--primary); }
.bn-item.active::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%;
  height: 2px; background: var(--primary); border-radius: 0 0 2px 2px;
}
.bn-score {
  font-size: 9px; color: var(--text-dim);
  font-weight: 600;
}
.bn-item.active .bn-score { color: var(--primary); }

/* ===== Slide-out Menu Drawer ===== */
.menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.menu-overlay.open { opacity: 1; pointer-events: auto; }
.menu-drawer {
  position: fixed; top: 0; right: -100%; bottom: 0;
  width: min(320px, 85vw);
  background: var(--panel);
  z-index: 51;
  transition: right 0.3s ease;
  display: flex; flex-direction: column;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  padding-bottom: var(--safe-bottom);
}
.menu-drawer.open { right: 0; }
.menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.menu-title { font-weight: 700; color: var(--primary); font-size: 16px; }
.menu-close {
  background: var(--panel-light); border: none; color: var(--text);
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 16px; cursor: pointer; font-family: inherit;
}
.menu-list {
  list-style: none; padding: 8px 0; margin: 0;
  overflow-y: auto; flex: 1;
}
.menu-section {
  padding: 12px 18px 6px;
  font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}
.menu-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  color: var(--text); text-decoration: none;
  cursor: pointer; font-size: 15px;
}
.menu-link:hover { background: var(--panel-light); text-decoration: none; }
.menu-link.active { background: rgba(56,189,248,0.12); color: var(--primary); }
.menu-score {
  font-size: 11px; color: var(--text-dim); font-weight: 600;
  background: var(--panel-light); padding: 3px 8px; border-radius: 999px;
}
.menu-link.active .menu-score { background: rgba(56,189,248,0.25); color: var(--primary); }
.menu-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
}

/* ===== Progress + Stats ===== */
.quiz-only { display: none; }
body[data-tab-type="quiz"] .quiz-only { display: block; }
.progress-wrap {
  margin: 0 0 12px;
  background: var(--panel); border-radius: 999px; overflow: hidden;
  height: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--correct) 100%);
  transition: width 0.4s ease; width: 0%;
}
.stats {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 14px; flex-wrap: wrap; gap: 6px 10px;
}
.stats span b { color: var(--text); }
.stats .correct-stat b { color: var(--correct); }
.stats .wrong-stat b { color: var(--wrong); }

/* ===== Quiz Card ===== */
.card {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.qnum {
  display: inline-block;
  background: var(--primary); color: #0f172a;
  font-weight: 700; padding: 4px 12px;
  border-radius: 999px; font-size: 12px;
  margin-bottom: 10px;
}
.multi-badge {
  display: inline-block;
  background: var(--warn); color: #0f172a;
  font-weight: 700; padding: 4px 10px;
  border-radius: 999px; font-size: 11px;
  margin-left: 6px; margin-bottom: 10px;
}
.source-pill {
  display: inline-block;
  background: rgba(168,85,247,0.15); color: #c084fc;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  margin-left: 6px; margin-bottom: 8px;
}
.multi-hint {
  background: var(--warn-bg);
  border-left: 3px solid var(--warn);
  padding: 10px 12px; border-radius: 8px;
  margin-bottom: 14px; font-size: 13px; color: var(--warn);
}
.question-text {
  font-size: 15px; line-height: 1.8;
  margin-bottom: 16px; white-space: pre-wrap;
}

/* ===== Options ===== */
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 14px;
  background: var(--panel-light);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer; transition: all 0.15s;
  text-align: left; color: var(--text);
  font-size: 14px; line-height: 1.6;
  width: 100%; font-family: inherit;
  min-height: 44px; /* touch target */
}
.option:active:not(:disabled) { transform: scale(0.98); }
.option:disabled { cursor: default; }
.option.selected {
  border-color: var(--primary);
  background: rgba(56,189,248,0.15);
}
.option.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.option.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}
.option.missed {
  border-color: var(--correct);
  background: var(--correct-bg);
  opacity: 0.85;
  border-style: dashed;
}
.option-letter {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.option.correct .option-letter, .option.missed .option-letter {
  background: var(--correct); color: #fff;
}
.option.wrong .option-letter { background: var(--wrong); color: #fff; }
.option.selected .option-letter { background: var(--primary); color: #0f172a; }
.option-text { flex: 1; }
.icon { margin-left: auto; font-size: 16px; }

/* ===== Actions ===== */
.actions {
  display: flex; justify-content: space-between;
  gap: 10px; margin-top: 18px;
  flex-wrap: wrap;
}
.btn {
  background: var(--primary); color: #0f172a;
  border: none; padding: 12px 24px;
  border-radius: 10px; font-weight: 700;
  font-size: 14px; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  min-height: 44px;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--panel-light); color: var(--text); }
.btn.full { flex: 1; }

/* ===== Feedback ===== */
.feedback {
  margin-top: 20px; padding: 16px;
  border-radius: 12px; display: block;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback.correct-fb {
  background: var(--correct-bg);
  border-left: 4px solid var(--correct);
}
.feedback.wrong-fb {
  background: var(--wrong-bg);
  border-left: 4px solid var(--wrong);
}
.feedback-title {
  font-size: 15px; font-weight: 700;
  margin-bottom: 10px;
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.feedback.correct-fb .feedback-title { color: var(--correct); }
.feedback.wrong-fb .feedback-title { color: var(--wrong); }
.answer-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 6px; font-weight: 700;
  background: var(--correct); color: #fff;
  margin-left: 6px; font-size: 13px;
}

/* ===== Option explanations ===== */
.explain-section { margin-top: 14px; }
.explain-title {
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 8px; text-transform: uppercase;
  letter-spacing: 0.8px;
}
.opt-explain {
  display: flex; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--text-dim);
}
.opt-explain.correct {
  border-left-color: var(--correct);
  background: rgba(34,197,94,0.08);
}
.opt-explain.wrong-mark {
  border-left-color: var(--wrong);
  background: rgba(239,68,68,0.06);
}
.opt-explain .badge {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  background: var(--text-dim); color: #0f172a;
}
.opt-explain.correct .badge { background: var(--correct); color: #fff; }
.opt-explain.wrong-mark .badge { background: var(--wrong); color: #fff; }
.opt-explain .body { flex: 1; font-size: 13px; line-height: 1.7; }
.opt-explain .body .head { font-weight: 700; margin-bottom: 3px; opacity: 0.9; }
.opt-explain.correct .body .head::after {
  content: " ✓ 正解"; color: var(--correct);
  font-size: 11px; margin-left: 4px;
}
.opt-explain.wrong-mark .body .head::after {
  content: " ✗"; color: var(--wrong);
  font-size: 11px; margin-left: 4px;
}

/* ===== Meta blocks ===== */
.agent-note, .resolution-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px; line-height: 1.7;
}
.agent-note {
  background: rgba(56,189,248,0.08);
  border-left: 3px solid var(--primary);
  color: var(--text-dim);
}
.agent-note b { color: var(--primary); }
.resolution-note {
  background: rgba(168,85,247,0.08);
  border-left: 3px solid var(--purple);
  color: var(--text-dim);
}
.resolution-note b { color: #c084fc; }

/* ===== Deep dive ===== */
.deep-dive {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(56,189,248,0.06) 0%, rgba(34,197,94,0.06) 100%);
  border: 1px solid rgba(56,189,248,0.25);
  border-radius: 10px;
}
.dd-header {
  font-size: 14px; font-weight: 700;
  color: var(--primary); margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(56,189,248,0.15);
}
.dd-section { margin-bottom: 10px; }
.dd-section:last-child { margin-bottom: 0; }
.dd-label {
  font-size: 11px; color: var(--text-dim);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px;
}
.dd-text { font-size: 13px; line-height: 1.7; }
.dd-concepts {
  margin: 0; padding-left: 20px;
  font-size: 13px; line-height: 1.7;
}
.dd-concepts li { margin-bottom: 3px; }
.dd-concepts li::marker { color: var(--correct); }
.dd-traps {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(245,158,11,0.1);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  font-size: 12px; line-height: 1.7;
  color: var(--text-dim);
}
.dd-traps b { color: var(--warn); }

/* Black Belt resource links inside deep dive */
.dd-resources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(56,189,248,0.15);
}
.dd-res-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dd-res-list a {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(56,189,248,0.12);
  color: var(--primary);
  padding: 5px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(56,189,248,0.2);
}
.dd-res-list a:hover {
  background: rgba(56,189,248,0.2); text-decoration: none;
}

/* English original */
details.eng-orig {
  margin-top: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
}
details.eng-orig summary {
  cursor: pointer; color: var(--text-dim);
  user-select: none;
}
details.eng-orig .eng-content {
  margin-top: 8px; color: var(--text-dim);
  line-height: 1.6; white-space: pre-wrap;
}

/* ===== Results page ===== */
.results { text-align: center; padding: 32px 16px; }
.results h2 { color: var(--primary); font-size: 22px; margin: 0 0 8px; }
.score-big {
  font-size: 48px; font-weight: 800;
  color: var(--correct); margin: 16px 0;
}
.score-detail {
  font-size: 16px; color: var(--text-dim);
  margin-bottom: 20px;
}

/* ===== Quick nav ===== */
.nav-details {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.nav-details summary {
  cursor: pointer; color: var(--text-dim);
  font-size: 12px; user-select: none;
  display: flex; align-items: center; gap: 8px;
}
.nav-hint { font-size: 10px; opacity: 0.7; }
.quick-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.nav-pill {
  width: 100%; aspect-ratio: 1;
  border-radius: 6px;
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid transparent;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: all 0.15s;
  position: relative;
}
.nav-pill:active { transform: scale(0.92); }
.nav-pill.current { border-color: var(--primary); background: var(--primary); color: #0f172a; }
.nav-pill.correct { background: var(--correct); color: #fff; }
.nav-pill.wrong { background: var(--wrong); color: #fff; }
.nav-pill.multi::after {
  content: "▣";
  position: absolute; top: -3px; right: -2px;
  font-size: 9px; color: var(--warn);
}
.save-info {
  text-align: center; margin-top: 12px;
  font-size: 11px; color: var(--text-dim);
}
.save-info a {
  color: var(--primary); cursor: pointer;
  text-decoration: underline;
}

/* ===== Content panel (overview & study) ===== */
.content-panel {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.content-panel .section { margin: 24px 0; }
.content-panel .section:first-child { margin-top: 0; }
.content-panel .section-title {
  font-size: 16px; color: var(--primary);
  margin: 0 0 6px;
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}
.content-panel .section-desc {
  color: var(--text-dim); font-size: 12px;
  margin: 0 0 12px;
}

/* Hero stats */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 20px;
}
.stat-card {
  background: var(--panel-light); border-radius: 10px;
  padding: 14px 10px; text-align: center;
  border: 2px solid transparent;
}
.stat-card.highlight {
  border-color: var(--correct);
  background: rgba(34,197,94,0.1);
}
.stat-num {
  font-size: 26px; font-weight: 800;
  color: var(--primary); margin-bottom: 2px;
}
.stat-card.highlight .stat-num { color: var(--correct); }
.stat-label { font-size: 11px; color: var(--text-dim); }

/* Domain bars */
.domains-chart, .dom-compare {
  display: flex; flex-direction: column; gap: 10px;
}
.domain-row, .dom-cmp-row {
  background: var(--panel-light);
  padding: 10px 12px; border-radius: 8px;
}
.domain-info, .dom-cmp-info {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px; min-width: 0;
}
.domain-num, .dom-cmp-info .domain-num {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #0f172a;
  flex-shrink: 0; font-size: 13px;
}
.domain-text, .dom-cmp-info > div { flex: 1; min-width: 0; }
.domain-jp, .dom-cmp-name {
  font-weight: 700; font-size: 13px;
}
.domain-en, .dom-cmp-en {
  font-size: 10px; color: var(--text-dim);
}
.domain-weight { font-weight: 800; font-size: 18px; }
.domain-bar-bg, .dom-cmp-bar-bg {
  height: 8px; background: rgba(255,255,255,0.05);
  border-radius: 999px; overflow: hidden;
}
.domain-bar, .dom-cmp-bar {
  height: 100%; border-radius: 999px;
  transition: width 0.6s ease;
}
.dom-cmp-bar.dotted { opacity: 0.7; }
.dom-cmp-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.dom-cmp-bars {
  display: flex; flex-direction: column; gap: 4px;
}
.dom-cmp-bar-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px; align-items: center;
}
.dom-cmp-label { font-size: 10px; color: var(--text-dim); }
.dom-cmp-pct { font-size: 11px; font-weight: 700; text-align: right; }
.dom-cmp-diff {
  text-align: center; font-weight: 700;
  font-size: 13px;
  padding: 4px; border-radius: 6px;
}
.dom-cmp-diff.over { background: rgba(245,158,11,0.2); color: var(--warn); }
.dom-cmp-diff.under { background: rgba(56,189,248,0.2); color: var(--primary); }
.dom-cmp-diff.ok { background: rgba(255,255,255,0.05); color: var(--text-dim); }

.info-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.info-block { background: var(--panel-light); padding: 14px; border-radius: 8px; }
.info-block h3 { margin: 0 0 6px; font-size: 13px; color: var(--primary); }
.info-block ul { margin: 0; padding-left: 18px; font-size: 12px; }
.info-block p { font-size: 12px; margin: 4px 0; }

.topic-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.topic-pill {
  background: var(--panel-light); padding: 5px 10px;
  border-radius: 999px; font-size: 11px;
}

/* Services chart */
.services-chart { display: flex; flex-direction: column; gap: 5px; }
.svc-row {
  display: grid;
  grid-template-columns: minmax(120px, 35%) 1fr 32px;
  gap: 8px; align-items: center;
}
.svc-name {
  font-size: 12px; font-weight: 600;
  text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.svc-bar-bg {
  height: 18px; background: var(--panel-light);
  border-radius: 6px; overflow: hidden;
}
.svc-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--correct));
  border-radius: 6px;
}
.svc-count {
  font-size: 12px; font-weight: 700;
  color: var(--primary);
}

/* Categories grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cat-card {
  background: var(--panel-light);
  border-radius: 10px; padding: 12px;
  text-align: center;
  border-top: 3px solid var(--primary);
}
.cat-icon { font-size: 24px; margin-bottom: 2px; }
.cat-name { font-size: 11px; font-weight: 600; }
.cat-count { font-size: 16px; font-weight: 800; color: var(--primary); margin-top: 4px; }

/* Features / Patterns / Matrices */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.feature-card {
  background: var(--panel-light);
  border-radius: 10px; padding: 12px;
  border-left: 3px solid var(--correct);
}
.feature-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.feature-icon { font-size: 22px; }
.feature-name { font-weight: 700; font-size: 14px; color: var(--correct); }
.feature-desc { font-size: 12px; margin-bottom: 6px; }
.feature-use {
  font-size: 11px; color: var(--text-dim);
  padding-top: 6px; border-top: 1px solid var(--border);
}
.feature-use b { color: var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table {
  width: 100%; border-collapse: collapse;
  background: var(--panel-light); border-radius: 10px;
  overflow: hidden;
}
th, td {
  padding: 8px 10px; text-align: left;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
th {
  background: rgba(56,189,248,0.1); color: var(--primary);
  font-weight: 700; font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }

/* Eval cards */
.eval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.eval-card {
  background: var(--panel-light); padding: 12px;
  border-radius: 10px; border-top: 3px solid var(--purple);
}
.eval-card h4 { margin: 0 0 4px; color: var(--purple); font-size: 13px; }
.eval-card p { font-size: 12px; margin: 0 0 4px; }
.eval-card .when { font-size: 11px; color: var(--text-dim); }

/* Gotchas */
.gotchas-list { display: flex; flex-direction: column; gap: 8px; }
.gotcha-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: var(--panel-light);
  padding: 10px 12px; border-radius: 10px;
  border-left: 3px solid var(--warn);
}
.gotcha-phrase {
  font-weight: 700; color: var(--warn); font-size: 12px;
}
.gotcha-arrow { display: none; }
.gotcha-answer { font-size: 12px; }

/* Tips */
.tips-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.tip-card {
  background: var(--panel-light); padding: 14px;
  border-radius: 10px; display: flex; gap: 10px;
}
.tip-icon { font-size: 24px; flex-shrink: 0; }
.tip-content h4 { margin: 0 0 4px; font-size: 13px; color: var(--primary); }
.tip-content p { margin: 0; font-size: 12px; }
.tip-content b { color: var(--correct); }

/* Study intro & sticky nav */
.study-intro {
  background: rgba(56,189,248,0.08);
  border-left: 4px solid var(--primary);
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
}
.study-intro p { margin: 0 0 6px; }
.study-intro p:last-child { margin-bottom: 0; }
.study-nav {
  position: sticky; top: 56px; z-index: 10;
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  margin: -18px -18px 14px;
  padding-left: 18px; padding-right: 18px;
  overflow-x: auto; white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.study-nav a {
  display: inline-block; padding: 5px 10px;
  color: var(--text-dim); text-decoration: none;
  font-size: 11px; font-weight: 600;
  border-radius: 6px; margin-right: 3px;
}
.study-nav a:hover { color: var(--primary); background: rgba(56,189,248,0.1); }

/* Insight banner */
.insight-banner {
  background: rgba(56,189,248,0.08);
  border-left: 4px solid var(--primary);
  padding: 14px 16px; border-radius: 10px;
}
.insight-banner p { margin: 0 0 10px; font-size: 13px; line-height: 1.8; }
.insight-banner p:last-child { margin-bottom: 0; }
.insight-banner b { color: var(--primary); }

/* Archetypes */
.arch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.arch-card {
  background: var(--panel-light);
  padding: 10px 12px; border-radius: 8px;
  border-left: 3px solid var(--primary);
}
.arch-name { font-weight: 700; font-size: 12px; margin-bottom: 3px; }
.arch-count { font-size: 13px; color: var(--primary); font-weight: 800; margin-bottom: 4px; }
.arch-pct { color: var(--text-dim); font-size: 10px; font-weight: 400; }
.arch-bar-bg {
  height: 5px; background: rgba(255,255,255,0.05);
  border-radius: 999px; overflow: hidden;
}
.arch-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--correct));
}

/* Service pairs */
.pairs-list { display: flex; flex-direction: column; gap: 5px; }
.pair-row {
  background: var(--panel-light);
  padding: 8px 12px; border-radius: 8px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px; align-items: center;
}
.pair-rank { color: var(--primary); font-weight: 800; font-size: 13px; }
.pair-svc { font-size: 12px; }
.pair-plus { color: var(--warn); margin: 0 6px; font-weight: 700; }
.pair-count {
  font-size: 11px; font-weight: 700;
  color: var(--correct); text-align: right;
}

/* Domain deep */
.domain-deep {
  background: var(--panel-light);
  border-radius: 10px; padding: 0;
  margin-bottom: 8px;
}
.domain-deep > summary {
  list-style: none; cursor: pointer;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; user-select: none;
}
.domain-deep > summary::-webkit-details-marker { display: none; }
.domain-deep > summary::before {
  content: "▶"; color: var(--text-dim);
  font-size: 9px; transition: transform 0.2s;
}
.domain-deep[open] > summary::before { transform: rotate(90deg); }
.domain-deep-num {
  width: 32px; height: 32px;
  border-radius: 6px; color: #0f172a;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.domain-deep-name { font-weight: 700; flex: 1; font-size: 13px; }
.domain-deep-weight {
  font-size: 11px; color: var(--text-dim);
  width: 100%;
}
.domain-deep-content { padding: 0 14px 14px; }
.task-block {
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  margin-bottom: 5px; padding: 0;
}
.task-block > summary {
  list-style: none; cursor: pointer;
  padding: 8px 12px;
  display: flex; gap: 8px; align-items: center;
  user-select: none; font-size: 12px;
}
.task-block > summary::-webkit-details-marker { display: none; }
.task-id {
  color: #0f172a; padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
}
.task-skills {
  margin: 0 12px 10px; padding-left: 18px;
  font-size: 12px; line-height: 1.7;
}
.task-skills li { margin-bottom: 3px; }

/* Pattern cards */
.pattern-card {
  background: var(--panel-light);
  border-radius: 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--correct);
}
.pattern-card > summary {
  list-style: none; cursor: pointer;
  padding: 10px 14px;
  user-select: none; font-size: 13px;
}
.pattern-card > summary::-webkit-details-marker { display: none; }
.pattern-card > summary::before {
  content: "▶"; color: var(--text-dim);
  font-size: 9px; margin-right: 6px;
  transition: transform 0.2s;
}
.pattern-card[open] > summary::before { transform: rotate(90deg); }
.pat-id {
  color: var(--correct); font-weight: 800;
  font-size: 11px;
  background: rgba(34,197,94,0.15);
  padding: 2px 6px; border-radius: 4px;
  margin-right: 6px;
}
.pat-body { padding: 0 14px 14px; }
.pat-section { margin-top: 10px; }
.pat-label {
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px;
  font-weight: 700;
}
.pat-text { font-size: 12px; line-height: 1.7; }
.gotcha-section .pat-text {
  background: rgba(245,158,11,0.1);
  border-left: 3px solid var(--warn);
  padding: 6px 10px; border-radius: 6px;
}
.svc-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.svc-tag {
  background: rgba(56,189,248,0.15); color: var(--primary);
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
}
.pat-refs a {
  display: inline-block;
  color: var(--primary); text-decoration: none;
  margin-right: 6px; margin-bottom: 4px;
  font-size: 11px; font-family: monospace;
  padding: 2px 6px; border-radius: 4px;
  background: rgba(56,189,248,0.1);
  border: 1px solid rgba(56,189,248,0.2);
}
.pat-refs a:hover {
  background: rgba(56,189,248,0.2);
  text-decoration: none; cursor: pointer;
}

/* Matrix cards */
.matrix-card {
  background: var(--panel-light);
  border-radius: 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--purple);
}
.matrix-card > summary {
  list-style: none; cursor: pointer;
  padding: 10px 14px;
  user-select: none; font-weight: 700;
  font-size: 13px; color: var(--purple);
}
.matrix-card > summary::-webkit-details-marker { display: none; }
.matrix-card > summary::before {
  content: "▶"; color: var(--text-dim);
  font-size: 9px; margin-right: 6px;
  transition: transform 0.2s;
}
.matrix-card[open] > summary::before { transform: rotate(90deg); }
.matrix-card .table-wrap { margin: 0 10px 12px; }

/* New features grid */
.new-feat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.new-feat-card {
  background: var(--panel-light);
  border-radius: 10px; padding: 12px;
  border-top: 3px solid var(--warn);
}
.new-feat-head {
  display: flex; justify-content: space-between;
  gap: 6px; align-items: flex-start; margin-bottom: 4px;
}
.new-feat-name { font-weight: 700; font-size: 13px; color: var(--warn); }
.new-feat-date {
  background: rgba(245,158,11,0.2); color: var(--warn);
  padding: 2px 6px; border-radius: 4px;
  font-size: 9px; white-space: nowrap;
  flex-shrink: 0; font-weight: 700;
}
.new-feat-what { font-size: 12px; margin-bottom: 6px; }
.new-feat-pattern {
  font-size: 11px; color: var(--text-dim);
  padding-top: 6px; border-top: 1px solid var(--border);
}
.new-feat-pattern b { color: var(--primary); }

/* Traps */
.traps-grid { display: flex; flex-direction: column; gap: 5px; }
.trap-card {
  background: var(--panel-light);
  border-radius: 10px;
  border-left: 3px solid var(--wrong);
}
.trap-card > summary {
  list-style: none; cursor: pointer;
  padding: 10px 14px;
  user-select: none; font-size: 13px;
}
.trap-card > summary::-webkit-details-marker { display: none; }
.trap-card > summary::before {
  content: "▶"; color: var(--text-dim);
  font-size: 9px; margin-right: 6px;
  transition: transform 0.2s;
}
.trap-card[open] > summary::before { transform: rotate(90deg); }
.trap-num {
  color: var(--wrong); font-weight: 800;
  font-size: 11px;
  background: rgba(239,68,68,0.15);
  padding: 2px 6px; border-radius: 4px;
  margin-right: 6px;
}
.trap-body { padding: 0 14px 12px; font-size: 12px; line-height: 1.7; }
.trap-examples {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; font-family: monospace;
}

/* ===== Desktop adaptations (>= 768px) ===== */
@media (min-width: 768px) {
  body { font-size: 16px; }
  .topbar-inner { padding: 12px 20px; }
  .brand-title { font-size: 16px; }
  .brand-sub { font-size: 11px; }
  .main { padding: 24px 24px 32px; }
  .card, .content-panel { padding: 24px; border-radius: 16px; }
  .question-text { font-size: 16px; }
  .option { font-size: 15px; padding: 14px 16px; }
  .option-letter { width: 32px; height: 32px; font-size: 14px; }

  .hero-stats { grid-template-columns: repeat(4, 1fr); }
  .stat-num { font-size: 32px; }
  .stat-label { font-size: 12px; }

  .info-grid { grid-template-columns: 1fr 1fr; }

  .dom-cmp-row {
    grid-template-columns: 260px 1fr 80px;
    align-items: center;
  }

  .gotcha-card {
    grid-template-columns: 220px 30px 1fr;
    align-items: center;
  }
  .gotcha-arrow {
    display: block; color: var(--warn);
    font-size: 18px; text-align: center;
  }

  .tips-grid { grid-template-columns: repeat(2, 1fr); }

  table th, table td {
    padding: 10px 14px; font-size: 13px;
  }

  /* Larger study nav on desktop */
  .study-nav a {
    padding: 6px 12px; font-size: 12px;
  }
}

@media (min-width: 1024px) {
  .quick-nav {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  }
  .nav-pill { font-size: 12px; }
  .features-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* Larger touch targets on coarse pointer */
@media (pointer: coarse) {
  .option { min-height: 56px; padding: 16px 16px; }
  .btn { padding: 14px 28px; }
  .nav-pill { min-height: 36px; }
}
