:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #20232a;
  --muted: #5f6775;
  --border: #d9dde7;
  --accent: #1f6feb;
  --correct-bg: #e9f8ee;
  --correct-border: #2f8f46;
  --wrong-bg: #fff0f0;
  --wrong-border: #c73a3a;
  --anchor-bg: #eff5ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell { min-height: 100vh; }
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.topbar h1 { margin: 0; font-size: 1.2rem; }

.voice-panel {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.voice-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.voice-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.voice-actions select,
.voice-actions button {
  min-height: 38px;
}

.interaction-mode-control {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7faff;
  white-space: nowrap;
}

.interaction-mode-control span {
  display: inline;
  margin: 0;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
}

.interaction-mode-control select {
  min-height: 30px;
}

body.voice-quiz-enabled .interaction-mode-control {
  border-color: var(--accent);
  background: var(--anchor-bg);
}

body.voice-quiz-enabled .manual-voice-control {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
  align-content: start;
}
.domain-nav { display: contents; }
.sidebar button {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.55rem 0.65rem;
  border-radius: 0.5rem;
  cursor: pointer;
}
.sidebar button.active,
.sidebar button:hover,
button.primary {
  border-color: var(--accent);
  color: var(--accent);
}

.content {
  padding: 1rem;
  max-width: 1200px;
  min-width: 0;
  width: 100%;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.domain-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.domain-header h2,
.domain-header h3 { margin: 0.2rem 0; }
.module-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
}
.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.anchor-box {
  border: 1px solid #bcd2ff;
  background: var(--anchor-bg);
  border-radius: 10px;
  padding: 0.8rem;
}
.small { color: var(--muted); font-size: 0.9rem; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}
.module-summary,
.lesson-card,
.objective-group,
.guided-lab {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.module-summary { padding: 1rem; }
.module-number {
  display: inline-grid;
  place-items: center;
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.lesson-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.readiness-box,
.objective-box,
.lab-scenario,
.validation-box,
.challenge-box {
  border: 1px solid #bcd2ff;
  background: var(--anchor-bg);
  border-radius: 10px;
  padding: 0.9rem;
  margin: 1rem 0;
}
.module-lead { font-size: 1.08rem; line-height: 1.65; }
.lesson-stack { display: grid; gap: 1.2rem; margin: 1.25rem 0; }
.lesson-card { padding: 1.15rem; box-shadow: 0 5px 18px rgb(20 45 85 / 5%); }
.lesson-card > p { line-height: 1.6; }
.lesson-summary {
  padding: 0.85rem;
  border-left: 4px solid var(--accent);
  background: var(--anchor-bg);
}
.mastery-content {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #bcd2ff;
  border-radius: 12px;
  background: linear-gradient(145deg, #f8fbff, #fff);
}
.mastery-content > h4 { margin-top: 0; font-size: 1.08rem; }
.mastery-section + .mastery-section {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}
.mastery-section h4 { margin: 0 0 0.45rem; color: #183d77; }
.mastery-section p { margin: 0.45rem 0; line-height: 1.68; }
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.concept-card {
  padding: 0.8rem;
  border-left: 3px solid var(--accent);
  background: #f8faff;
}
.concept-card p { margin: 0.35rem 0 0; line-height: 1.45; }
.exam-traps {
  border-left: 4px solid #c06b00;
  background: #fff8e8;
  padding: 0.65rem 0.9rem;
  margin: 1rem 0;
}
.checkpoint,
.troubleshooting,
.guided-lab details {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.75rem;
  margin-top: 0.9rem;
}
summary { cursor: pointer; }
.checkpoint-answer { padding: 0.7rem; background: var(--correct-bg); border-radius: 7px; }
.lesson-check {
  margin-top: 1.2rem;
  padding: 1rem;
  border: 2px solid #789ee9;
  border-radius: 12px;
  background: #f7faff;
}
.lesson-check-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.lesson-check-heading h4 { margin: 0.2rem 0; font-size: 1.08rem; }
.lesson-check-heading label { min-width: 230px; font-weight: 650; }
.lesson-check-heading select { display: block; width: 100%; margin-top: 0.25rem; }
.topic-check-buttons { display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0.8rem 0; }
.topic-check-button { text-align: left; }
.topic-check-button.completed {
  border-color: var(--correct-border);
  background: var(--correct-bg);
}
.topic-check-button.completed::before { content: "✓ "; font-weight: 800; }
.lesson-check-player {
  min-height: 3.25rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.lesson-check-question h5 { margin: 0.8rem 0; font-size: 1.03rem; line-height: 1.5; }
.lesson-check-choices { display: grid; gap: 0.55rem; }
.lesson-check-feedback[hidden] { display: none; }
.code-example { margin: 0.8rem 0; }
.code-label {
  background: #263043;
  color: #dce7ff;
  padding: 0.45rem 0.7rem;
  border-radius: 8px 8px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}
.code-example pre {
  margin: 0;
  padding: 0.9rem;
  overflow-x: auto;
  background: #101827;
  color: #f4f7ff;
  border-radius: 0 0 8px 8px;
  line-height: 1.5;
}
.module-footer,
.lab-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.button-link {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}
.objective-group-list { display: grid; gap: 0.8rem; margin-top: 1rem; }
.objective-group { display: flex; align-items: flex-start; gap: 0.9rem; padding: 1rem; }
.objective-group h3 { margin: 0 0 0.35rem; }
.objective-group p { margin: 0; color: var(--muted); }

.guided-lab { padding: 1.15rem; margin: 1.2rem 0; }
.lab-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.lab-heading h3 { margin: 0.25rem 0; }
.lab-scenario p { margin-bottom: 0; }
.lab-steps { padding-left: 2rem; }
.lab-steps > li { padding: 0.75rem 0 1.15rem 0.35rem; border-bottom: 1px solid var(--border); }
.lab-steps > li:last-child { border-bottom: 0; }
.step-title { font-size: 1.02rem; }
.expected-result {
  border-left: 3px solid var(--correct-border);
  background: var(--correct-bg);
  padding: 0.65rem;
  margin-top: 0.75rem;
}
.challenge-box { border-color: #e0bf73; background: #fff8e8; }
.troubleshooting > div { padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.troubleshooting > div:last-child { border-bottom: 0; }
.troubleshooting p { margin: 0.3rem 0; }
.timer-badge { border-color: #c06b00; color: #8c4d00; font-weight: 700; }

.module-checkpoint {
  margin-top: 1.4rem;
  padding: 1.1rem;
  border: 2px solid #789ee9;
  border-radius: 12px;
  background: linear-gradient(145deg, #f4f8ff, #fff);
}
.checkpoint-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.checkpoint-heading h3 { margin: 0.25rem 0; }
.checkpoint-status { background: #fff; white-space: nowrap; }
.checkpoint-player { margin-top: 1rem; }
.checkpoint-player > .card { box-shadow: 0 8px 24px rgb(31 111 235 / 9%); }
.narration-question h3 { line-height: 1.45; }

label, select, button, input { font: inherit; }
button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
input[type="url"] {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.25rem;
}

.quiz-header { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.quiz-progress {
  width: 100%;
  height: 12px;
  background: #eef1f5;
  border-radius: 999px;
  overflow: hidden;
}
.quiz-progress > span { display: block; height: 100%; background: var(--accent); }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}
.filters label { min-width: 0; }
.filters select { display: block; width: 100%; min-width: 0; margin-top: 0.25rem; }
.practice-filter-context,
.difficulty-note {
  margin: 0.85rem 0;
  padding: 0.75rem;
  border-radius: 9px;
  background: var(--anchor-bg);
  border: 1px solid #bcd2ff;
}
.choice {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  display: block;
  cursor: pointer;
}
.choice.correct { background: var(--correct-bg); border-color: var(--correct-border); }
.choice.incorrect { background: var(--wrong-bg); border-color: var(--wrong-border); }
.choice:focus-within { outline: 2px solid var(--accent); }
.choice-marker {
  display: inline-block;
  min-width: 3.1rem;
  margin: 0 0.25rem;
  color: var(--accent);
  font-weight: 700;
}

.feedback { margin-top: 0.8rem; padding: 0.7rem; border-radius: 8px; }
.feedback.good { background: var(--correct-bg); border: 1px solid var(--correct-border); }
.feedback.bad { background: var(--wrong-bg); border: 1px solid var(--wrong-border); }

.post-answer-choice {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border: 1px solid #b88900;
  border-radius: 10px;
  background: #fff9df;
}

.post-answer-choice p {
  margin: 0.45rem 0;
}

.voice-answer-panel {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px solid #bcd2ff;
  border-radius: 10px;
  background: var(--anchor-bg);
}
.voice-answer-panel.listening {
  border-color: #c73a3a;
  box-shadow: 0 0 0 3px rgb(199 58 58 / 10%);
}
.voice-transcript {
  display: block;
  min-height: 1.2rem;
  font-weight: 600;
}

.stats-pills { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.actions-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.bridge-panel {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  margin: 0.9rem 0;
  display: grid;
  gap: 0.6rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, #fff 30%);
  padding-top: 0.6rem;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.8rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .voice-panel {
    padding: 0.75rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .voice-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .voice-actions select,
  .voice-actions button,
  .interaction-mode-control {
    width: 100%;
  }

  .sidebar button,
  .actions-row button,
  .sticky-actions button {
    min-height: 44px;
  }

  .content {
    padding: 0.75rem;
  }

  .module-footer,
  .lab-two-column { grid-template-columns: 1fr; }

  .lab-heading,
  .domain-header,
  .checkpoint-heading,
  .lesson-check-heading { flex-direction: column; }

  .lesson-check-heading label { min-width: 0; width: 100%; }

  .module-meta { justify-content: flex-start; }
}

.verbatim-guide {
  white-space: pre-wrap;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: #fbfcfe;
  max-height: 70vh;
  overflow: auto;
}

.markdown-guide {
  line-height: 1.55;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: #fbfcfe;
  overflow: auto;
}

.markdown-guide h1,
.markdown-guide h2,
.markdown-guide h3,
.markdown-guide h4,
.markdown-guide h5,
.markdown-guide h6 {
  margin: 1rem 0 0.6rem;
}

.markdown-guide h1:first-child,
.markdown-guide h2:first-child,
.markdown-guide h3:first-child {
  margin-top: 0;
}

.markdown-guide p,
.markdown-guide ul,
.markdown-guide ol,
.markdown-guide pre {
  margin: 0.65rem 0;
}

.markdown-guide code {
  background: #eef2f8;
  border: 1px solid #dfe6f2;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

.markdown-guide pre {
  background: #f3f6fb;
  border: 1px solid #dfe6f2;
  border-radius: 8px;
  padding: 0.7rem;
}

.markdown-guide pre code {
  background: transparent;
  border: none;
  padding: 0;
}
