:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #5c685f;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --panel-strong: #f1efe4;
  --line: #d9d4c5;
  --accent: #0f7f75;
  --accent-dark: #075c57;
  --accent-soft: #d9f0eb;
  --gold: #d5981f;
  --rose: #b94b5d;
  --good: #24764a;
  --bad: #b43d35;
  --shadow: 0 18px 50px rgba(39, 49, 42, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 127, 117, 0.12), transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(213, 152, 31, 0.16), transparent 26%),
    repeating-linear-gradient(90deg, rgba(23, 33, 27, 0.035) 0 1px, transparent 1px 80px),
    var(--paper);
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 28px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.88);
  backdrop-filter: blur(18px);
}

.brand-block h1,
.topbar h2 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  line-height: 0.95;
  letter-spacing: 0;
}

.brand-block h1 {
  max-width: 240px;
  font-size: clamp(2rem, 8vw, 3.6rem);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.select-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
}

.file-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

.nav-button.active {
  border-color: rgba(15, 127, 117, 0.35);
  background: var(--accent-soft);
}

.nav-button strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.94rem;
}

.nav-button span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.main-stage {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 52px) 56px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1160px;
  margin: 0 auto 22px;
  padding: 16px 0;
  background: linear-gradient(180deg, var(--paper) 72%, rgba(251, 250, 245, 0));
}

.topbar h2 {
  font-size: clamp(2rem, 5vw, 4.8rem);
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-badge,
.progress-badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.72);
}

.reader {
  max-width: 1160px;
  margin: 0 auto;
}

.hero-card,
.quiz-card,
.markdown-body {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.86);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.6fr);
  gap: 24px;
  margin-bottom: 18px;
  padding: clamp(20px, 4vw, 36px);
  overflow: hidden;
}

.hero-card p {
  max-width: 70ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.hero-meter {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(150deg, rgba(15, 127, 117, 0.14), transparent),
    var(--panel-strong);
}

.hero-meter strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(3.5rem, 10vw, 6.8rem);
  line-height: 1;
}

.hero-meter span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.markdown-body {
  padding: clamp(20px, 4vw, 42px);
  font-size: 1rem;
  line-height: 1.72;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: "Newsreader", Georgia, serif;
  line-height: 1.08;
}

.markdown-body h1 {
  margin-top: 0;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.markdown-body h2 {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.markdown-body h3 {
  margin-top: 1.6rem;
  font-size: 1.45rem;
}

.markdown-body a {
  color: var(--accent-dark);
  font-weight: 800;
}

.markdown-body code {
  padding: 0.18em 0.38em;
  border-radius: 5px;
  background: var(--panel-strong);
}

.markdown-body pre {
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: #18201c;
  color: #f7f1df;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.markdown-body th,
.markdown-body td {
  padding: 11px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.markdown-body th {
  background: var(--panel-strong);
}

.quiz-shell {
  display: grid;
  gap: 18px;
}

.quiz-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background:
    linear-gradient(120deg, rgba(15, 127, 117, 0.15), transparent 52%),
    rgba(255, 255, 255, 0.88);
}

.quiz-intro h3 {
  margin: 0 0 10px;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.quiz-intro p {
  max-width: 78ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.quiz-intro-copy {
  max-width: 78ch;
  color: var(--muted);
  line-height: 1.6;
}

.quiz-intro-copy p {
  margin: 0 0 10px;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent-dark);
  color: #fff;
  background: var(--accent-dark);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

.question-list {
  display: grid;
  gap: 14px;
}

.quiz-card {
  padding: clamp(18px, 3vw, 28px);
}

.question-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.question-number {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  background: var(--ink);
}

.question-text {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.4;
}

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

.option-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-align: left;
  background: #fff;
  cursor: pointer;
}

.option-button:hover,
.option-button:focus-visible {
  border-color: rgba(15, 127, 117, 0.55);
  outline: none;
}

.option-letter {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--accent-dark);
  font-weight: 900;
  background: var(--accent-soft);
}

.option-button.selected {
  border-color: var(--accent);
  background: rgba(15, 127, 117, 0.08);
}

.option-button.correct {
  border-color: rgba(36, 118, 74, 0.55);
  background: rgba(36, 118, 74, 0.12);
}

.option-button.wrong {
  border-color: rgba(180, 61, 53, 0.45);
  background: rgba(180, 61, 53, 0.1);
}

.feedback {
  display: none;
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  background: var(--panel-strong);
}

.feedback.visible {
  display: block;
}

.feedback.good {
  border-left: 5px solid var(--good);
}

.feedback.bad {
  border-left: 5px solid var(--bad);
}

.quiz-result {
  display: none;
  padding: 18px;
  border: 1px solid rgba(15, 127, 117, 0.35);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.quiz-result.visible {
  display: block;
}

.quiz-result strong {
  display: block;
  margin-bottom: 6px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 2rem;
}

.source-block {
  margin-top: 18px;
}

.source-block summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 900;
}

.source-block pre {
  white-space: pre-wrap;
}

.load-error {
  padding: 22px;
  border: 1px solid rgba(180, 61, 53, 0.5);
  border-radius: var(--radius);
  background: rgba(180, 61, 53, 0.08);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-block h1 {
    max-width: none;
  }

  .file-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-card,
  .quiz-intro {
    grid-template-columns: 1fr;
  }

  .hero-card {
    display: block;
  }

  .hero-meter {
    margin-top: 18px;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .main-stage {
    padding: 18px;
  }

  .topbar,
  .quiz-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .quiz-actions {
    justify-content: flex-start;
  }

  .file-nav,
  .option-grid {
    grid-template-columns: 1fr;
  }
}