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

:root {
  --bg: #111318;
  --surface: #1a1d24;
  --surface-hover: #22252e;
  --border: #2a2d38;
  --red: #EB0A1E;
  --red-hover: #ff1f33;
  --red-dim: rgba(235, 10, 30, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --error: #ef4444;
  --error-dim: rgba(239, 68, 68, 0.15);
  --text: #e8ecf1;
  --text-dim: #8891a0;
  --text-muted: #5a6270;
  --radius: 8px;
  --sidebar-width: 280px;
  --topbar-height: 56px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ── Top Bar ── */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 100;
}

.top-bar-title {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 1rem;
}

.top-bar-title strong {
  color: var(--red);
  letter-spacing: 0.05em;
}

.top-bar-subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.top-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-indicator {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.user-name {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Login */
.login-box {
  max-width: 380px;
  margin: 18vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-brand {
  color: var(--red);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.login-box h1 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.login-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-box input {
  margin-bottom: 0.75rem;
}

.error-msg {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ── Menu Toggle (mobile) ── */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Layout ── */
.layout {
  display: flex;
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: 100%;
}

.sidebar-header {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}

.chapter-list {
  list-style: none;
  padding: 0.5rem 0;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-dim);
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.3;
}

.chapter-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chapter-item.active {
  background: var(--red-dim);
  color: var(--text);
  border-left-color: var(--red);
}

.chapter-item .ch-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-weight: 600;
}

.chapter-item.completed .ch-icon {
  background: var(--green);
  color: #fff;
}

.chapter-item.active .ch-icon {
  background: var(--red);
  color: #fff;
}

.chapter-item .ch-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

/* ── Main Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  height: 100%;
}

.content-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ── Welcome ── */
.welcome {
  text-align: center;
  padding: 8vh 1rem 2rem;
}

.welcome h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.welcome p {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.welcome-sub {
  font-size: 0.9rem !important;
  margin-bottom: 2rem !important;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-primary:hover { background: var(--red-hover); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--red);
  color: var(--red);
}

.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ── Chapter Content ── */
.chapter-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.chapter-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--red);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.chapter-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
}

.chapter-body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

.chapter-body p {
  margin-bottom: 1rem;
}

.chapter-body h2, .chapter-body h3 {
  color: var(--text);
  margin: 1.75rem 0 0.75rem;
  font-weight: 600;
}

.chapter-body h2 { font-size: 1.2rem; }
.chapter-body h3 { font-size: 1.05rem; color: var(--red); }

.chapter-body ul, .chapter-body ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

.chapter-body li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}

.chapter-body strong {
  color: #fff;
}

.chapter-body blockquote {
  border-left: 3px solid var(--red);
  background: rgba(235, 10, 30, 0.06);
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 0.92rem;
}

/* G.E.T.T.E.L. value items */
.chapter-body .value-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.chapter-body .value-item strong {
  color: var(--red);
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.chapter-body .value-item p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Objection cards (Ch 9-10) */
.chapter-body .objection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.chapter-body .objection-q {
  font-weight: 500;
  margin-bottom: 0.6rem;
  line-height: 1.5;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.chapter-body .objection-num {
  background: var(--red);
  color: #fff;
  width: 24px;
  height: 24px;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 2px;
}

.chapter-body .objection-card blockquote {
  margin: 0.5rem 0 0 0;
}

.chapter-body .alt-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

/* Spec tables (Ch 5 vehicle specs, Ch 11 phone grid, Ch 17 recon) */
.chapter-body .spec-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
}

.chapter-body .spec-row {
  display: flex;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.4;
}

.chapter-body .spec-row:last-child { border-bottom: none; }

.chapter-body .spec-row:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

.chapter-body .spec-key {
  min-width: 140px;
  max-width: 200px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  padding-right: 1rem;
}

.chapter-body .spec-val {
  color: var(--text-dim);
  flex: 1;
}

/* Closing script text (white, prominent) */
.chapter-body .closing-script {
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.7;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0.75rem 0 1.5rem;
}

/* Sub-headings h4 for conditional labels */
.chapter-body h4 {
  font-size: 0.95rem;
  color: var(--red);
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

/* Ordered lists */
.chapter-body ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

.chapter-body ol li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}

/* ── Chapter Navigation ── */
.chapter-nav {
  display: flex;
  gap: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.chapter-nav .btn { flex: 1; }

/* ── Quiz Section ── */
.quiz-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.quiz-prompt {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quiz-prompt h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.quiz-prompt p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* ── Question Cards ── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.question-number {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.options { display: flex; flex-direction: column; gap: 0.4rem; }

.option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.92rem;
  line-height: 1.4;
}

.option:hover { border-color: var(--red); }
.option.selected { border-color: var(--red); background: var(--red-dim); }
.option.correct { border-color: var(--green); background: var(--green-dim); }
.option.incorrect { border-color: var(--error); background: var(--error-dim); }

.option-letter {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.option.selected .option-letter { background: var(--red); color: #fff; }
.option.correct .option-letter { background: var(--green); color: #fff; }
.option.incorrect .option-letter { background: var(--error); color: #fff; }

.explanation {
  margin-top: 0.6rem;
  padding: 0.65rem;
  background: rgba(235, 10, 30, 0.06);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
  display: none;
}

.explanation.show { display: block; }

/* ── Quiz Results ── */
.results-box {
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.score-big {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0.4rem 0;
}

.score-big.pass { color: var(--green); }
.score-big.fail { color: var(--error); }

.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 0.75rem 0 0.4rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
    z-index: 49;
  }

  .content-inner {
    padding: 1.5rem 1rem 3rem;
  }

  .welcome h1 { font-size: 1.5rem; }

  .chapter-title { font-size: 1.3rem; }

  .top-bar-subtitle { display: none; }
}
