/* ============================================================
   LECTIRA — Academic Editorial PWA Design System
   Themes: Light (Warm Ivory) | Sepia (Paper) | Dark (Midnight)
   ============================================================ */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-alt: #F1EDE4;
  --border: #E3DDD0;
  --text: #1B2432;
  --text-muted: #556172;
  --primary: #1B365D;
  --primary-hover: #132846;
  --primary-soft: rgba(27, 54, 93, 0.09);
  --accent: #B88323;
  --accent-soft: rgba(184, 131, 35, 0.13);
  --good: #157347;
  --good-bg: rgba(21, 115, 71, 0.09);
  --bad: #B42318;
  --bad-bg: rgba(180, 35, 24, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --base-size: 16px;
  --topbar-h: 64px;
  --sidebar-w: 274px;
}

[data-theme="sepia"] {
  --bg: #F2E8D5;
  --surface: #FAF3E6;
  --surface-alt: #EADCC4;
  --border: #DCCBB0;
  --text: #2F2418;
  --text-muted: #6C5841;
  --primary: #5B3E1D;
  --primary-hover: #442D14;
  --primary-soft: rgba(91, 62, 29, 0.11);
  --accent: #9E6816;
  --accent-soft: rgba(158, 104, 22, 0.15);
  --good: #1E6B42;
  --good-bg: rgba(30, 107, 66, 0.1);
  --bad: #A62B22;
  --bad-bg: rgba(166, 43, 34, 0.09);
}

[data-theme="dark"] {
  --bg: #0D1522;
  --surface: #152033;
  --surface-alt: #1C2A42;
  --border: #273754;
  --text: #E9EFF8;
  --text-muted: #98A9C4;
  --primary: #7DB2F5;
  --primary-hover: #9BC4F8;
  --primary-soft: rgba(125, 178, 245, 0.14);
  --accent: #E7B95D;
  --accent-soft: rgba(231, 185, 93, 0.14);
  --good: #4AD395;
  --good-bg: rgba(74, 211, 149, 0.12);
  --bad: #F87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-font="sm"] { --base-size: 14.5px; }
[data-font="md"] { --base-size: 16px; }
[data-font="lg"] { --base-size: 18px; }

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--base-size);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------------- Top Header ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-center {
  flex: 1;
  max-width: 460px;
  margin: 0 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand-mark { display: inline-flex; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.brand-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.search-wrap {
  position: relative;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
#global-search {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.88rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#global-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.level-switcher {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}
.level-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.level-btn.active {
  background: var(--primary);
  color: #fff;
}
[data-theme="dark"] .level-btn.active { color: #0D1522; }

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.auth-btn:hover { background: var(--surface-alt); border-color: var(--primary); }

.auth-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.76rem;
  overflow: hidden;
}
.auth-avatar img { width: 100%; height: 100%; object-fit: cover; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-alt); }

/* Top-Right Corner Version & Academic Attribution Pill */
.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.12s, background 0.15s;
}
.version-pill:hover { transform: translateY(-1px); }
.version-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------------- Shell Layout ---------------- */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 14px;
  gap: 14px;
}

.sidebar-level-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.level-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.badge-level {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 8px;
  border-radius: 999px;
}
.sync-pill {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}
.sync-pill.synced { color: var(--good); border-color: var(--good); background: var(--good-bg); }
.level-card-desc {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.progress-mini-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  margin-bottom: 5px;
}
.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s ease;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-ico { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.install-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.84rem;
}
[data-theme="dark"] .install-btn { color: #0D1522; }

.sidebar-credit-btn {
  text-align: left;
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-credit-btn strong { font-size: 0.8rem; color: var(--primary); }
.sidebar-credit-btn span { font-size: 0.72rem; color: var(--text-muted); }

/* ---------------- Main Content ---------------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 64px;
  max-width: 1060px;
  margin: 0 auto;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}
h1, h2, h3 {
  font-family: var(--font-serif);
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.25;
}
.page-title { font-size: 2rem; margin-bottom: 8px; }
.page-lead {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 72ch;
}

/* ---------------- Hero & Cards ---------------- */
.hero-card {
  background: linear-gradient(135deg, var(--primary) 0%, #2B4F81 100%);
  color: #FFFFFF;
  border-radius: 18px;
  padding: 28px 30px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
[data-theme="sepia"] .hero-card {
  background: linear-gradient(135deg, #5B3E1D 0%, #7C5629 100%);
}
[data-theme="dark"] .hero-card {
  background: linear-gradient(135deg, #1B365D 0%, #244675 100%);
}
.hero-card h1 { color: #FFFFFF; font-size: 1.95rem; margin-bottom: 10px; }
.hero-card p { color: rgba(255, 255, 255, 0.88); margin: 0 0 18px; max-width: 66ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
[data-theme="dark"] .btn-primary { color: #0D1522; }
.btn-gold { background: #E3B14E; color: #1A1A1A; }
.btn-gold:hover { background: #EDC065; }
.btn-ghost-light { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.28); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, 0.22); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-alt); border-color: var(--primary); }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s; cursor: pointer; }
.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat-box small { display: block; font-size: 0.76rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-box strong { font-size: 1.3rem; color: var(--primary); font-weight: 800; }

/* ---------------- Lesson List Cards ---------------- */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lesson-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.lesson-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.lesson-num {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.lesson-num.done { background: var(--good-bg); color: var(--good); }
.lesson-meta { flex: 1; min-width: 0; }
.lesson-meta h3 { font-size: 1.15rem; margin-bottom: 4px; }
.lesson-meta p { margin: 0 0 10px; font-size: 0.9rem; color: var(--text-muted); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-done { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------------- Deep Lesson Reader ---------------- */
.reader-shell { max-width: 820px; }
.reader-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.reader-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.reader-section h2 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}
.callout-title { font-weight: 800; font-size: 0.88rem; margin-bottom: 5px; display: block; }
.callout-ai { border-left-color: var(--primary); background: var(--primary-soft); }

.step-list { display: flex; flex-direction: column; gap: 14px; }
.step-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
[data-theme="dark"] .step-badge { color: #0D1522; }
.step-body h4 { margin: 0 0 5px; font-size: 0.98rem; font-weight: 700; }
.step-body p { margin: 0; font-size: 0.92rem; white-space: pre-line; color: var(--text); }

/* Adaptive Depth Tabs (S1 / S2 / S3) */
.depth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.depth-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.depth-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
[data-theme="dark"] .depth-tab.active { color: #0D1522; }
.depth-panel {
  padding: 15px 17px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.94rem;
}

/* Good vs Bad Comparison */
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-box {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.compare-bad { background: var(--bad-bg); border-color: rgba(180, 35, 24, 0.25); }
.compare-good { background: var(--good-bg); border-color: rgba(21, 115, 71, 0.25); }
.compare-label { font-weight: 800; font-size: 0.84rem; margin-bottom: 8px; display: block; }
.compare-bad .compare-label { color: var(--bad); }
.compare-good .compare-label { color: var(--good); }
.compare-box p { margin: 0; font-size: 0.9rem; }

/* Interactive Quiz & Checklists */
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  margin-bottom: 8px;
  cursor: pointer;
}
.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  margin-top: 2px;
  flex-shrink: 0;
}
.check-item.checked span { text-decoration: line-through; opacity: 0.72; }

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.quiz-option:hover { border-color: var(--primary); }
.quiz-option.correct { background: var(--good-bg); border-color: var(--good); color: var(--good); font-weight: 700; }
.quiz-option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.quiz-feedback {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  font-size: 0.9rem;
}

.notes-area {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.92rem;
  resize: vertical;
}
.notes-area:focus { outline: none; border-color: var(--primary); }

/* ---------------- Prompt Builder & Toolkit ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 5px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.9rem;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }

.prompt-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 360px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  padding-bottom: 10px;
}
.tab-pill {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--text-muted);
}
.tab-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
[data-theme="dark"] .tab-pill.active { color: #0D1522; }

.decision-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.94rem;
  transition: border-color 0.15s, transform 0.12s;
}
.decision-opt:hover { border-color: var(--primary); transform: translateX(3px); }

.calc-result {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
}
.calc-number { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.1; }

/* ---------------- Glossary & FAQ ---------------- */
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
}
.faq-item summary {
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 1.2rem; color: var(--primary); font-weight: 800; }
.faq-item[open] summary::after { content: '−'; }
.faq-answer {
  padding: 0 18px 16px;
  font-size: 0.93rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ---------------- Modal & Toast ---------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 32, 0.58);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 600px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.25rem; color: var(--primary); }
.modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  font-size: 0.92rem;
}

.academic-credit-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.academic-credit-box h3 { font-size: 1.05rem; margin-bottom: 6px; color: var(--primary); }
.academic-credit-box p { margin: 0 0 8px; font-size: 0.88rem; }
.academic-credit-box p:last-child { margin-bottom: 0; }

.changelog-list { padding-left: 18px; margin: 8px 0 14px; }
.changelog-list li { margin-bottom: 6px; font-size: 0.88rem; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background: #142238;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

/* ---------------- Responsive & Mobile ---------------- */
.mobile-only { display: none; }
.mobile-bottom-nav { display: none; }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 32, 0.5);
  z-index: 45;
}

@media (max-width: 960px) {
  .mobile-only { display: inline-flex; }
  .brand-text small { display: none; }
  .topbar-center { display: none; }
  .auth-label { display: none; }
  .auth-btn { padding: 4px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 18px 16px 88px; }
  .grid-3, .grid-2, .compare-grid, .form-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 1.05rem;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 8px;
  }
  .mb-item small { font-size: 0.68rem; font-weight: 700; }
  .mb-item.active { color: var(--primary); background: var(--primary-soft); }
  .toast { bottom: 76px; right: 16px; left: 16px; text-align: center; }
}

/* ---------------- Stage 2: Walkthroughs & Literature Matrix ---------------- */
.annotation-list {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 0.86rem;
}
.annotation-list li { margin-bottom: 6px; }

.draft-quote {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-serif);
  font-size: 0.94rem;
  line-height: 1.6;
  margin-bottom: 10px;
}

.matrix-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 14px;
}
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 740px;
}
.matrix-table th, .matrix-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.matrix-table th {
  background: var(--surface-alt);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.matrix-table tr:last-child td { border-bottom: none; }
.btn-danger-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--bad);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}
.btn-danger-ghost:hover { background: var(--bad-bg); border-color: var(--bad); }

@media (max-width: 520px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-left, .topbar-right { gap: 5px; }
  .brand-text strong { font-size: 1.05rem; }
  .level-btn { padding: 4px 7px; font-size: 0.72rem; }
  .icon-btn { width: 32px; height: 32px; }
  .version-pill { padding: 5px 8px; font-size: 0.7rem; gap: 4px; }
  .version-pill .version-dot { display: none; }
}

/* ---------------- Stage 3: Defense Simulator, Planner & Templates ---------------- */
.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.timer-pill.urgent { background: var(--bad-bg); color: var(--bad); }

.rating-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rating-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
}
.rating-btn.active-low { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.rating-btn.active-mid { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rating-btn.active-high { background: var(--good-bg); border-color: var(--good); color: var(--good); }

.countdown-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  margin-bottom: 18px;
}
.countdown-days {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.template-card-btn {
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.template-card-btn:hover { border-color: var(--primary); background: var(--surface-alt); }
.template-card-btn.active { border-color: var(--primary); background: var(--primary-soft); }
