:root {
  --bg: #f3eee6;
  --bg-strong: #e8ded1;
  --surface: #fffdf9;
  --surface-strong: #f8f2ea;
  --ink: #1f1b18;
  --muted: #6d655c;
  --border: rgba(31, 27, 24, 0.1);
  --accent: #b61f24;
  --accent-soft: rgba(182, 31, 36, 0.08);
  --accent-strong: #8f181d;
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --success: #0b6b57;
  --success-soft: rgba(11, 107, 87, 0.11);
  --shadow: 0 18px 44px rgba(39, 31, 24, 0.08);
  --radius: 8px;
  --radius-lg: 16px;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --sans: "Inter", "Segoe UI", sans-serif;
  --display: "Inter Tight", "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 30%),
    linear-gradient(90deg, rgba(31, 27, 24, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(31, 27, 24, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 28px 28px, 28px 28px, auto;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  padding: 12px 0 24px;
  overflow-y: auto;
}

.rail-block,
.hero-band,
.control-band,
.history-band,
.summary-band {
  background: rgba(255, 250, 241, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.rail-block {
  padding: 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.brand-block {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 16px 18px;
  background:
    linear-gradient(180deg, rgba(182, 31, 36, 0.08), rgba(182, 31, 36, 0.02)),
    rgba(255, 253, 249, 0.96);
}

.company-mark {
  display: grid;
  gap: 2px;
}

.company-logo {
  font-family: var(--display);
  font-size: clamp(30px, 3vw, 38px);
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.company-submark {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.hero-copy h2,
.question-stream-header h2,
.history-head h2,
.rail-title-row h2 {
  margin: 0;
  line-height: 1.02;
  font-family: var(--display);
}

.hero-copy p,
.stream-meta,
.micro-copy {
  color: var(--muted);
}

.snapshot-row,
.section-filter,
.history-item,
.summary-row,
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.snapshot-row + .snapshot-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(33, 26, 20, 0.08);
}

.snapshot-row span,
.stat-label,
.dock-label {
  color: var(--muted);
  font-size: 12px;
}

.snapshot-row strong,
.hero-stat strong,
.dock-button,
.dock-button-primary {
  font-weight: 700;
}

.rail-title-row,
.history-head,
.question-stream-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.rail-title-row h2,
.history-head h2,
.question-stream-header h2 {
  font-size: 18px;
}

.section-filter-list,
.history-compact,
.history-list,
.question-stream {
  display: grid;
  gap: 12px;
}

.section-filter {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(33, 26, 20, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.4);
  text-align: left;
}

.section-filter strong {
  display: block;
  font-size: 13px;
}

.section-filter span {
  font-size: 11px;
  color: var(--muted);
}

.section-filter.is-active {
  border-color: rgba(182, 31, 36, 0.22);
  background: var(--accent-soft);
}

.workspace {
  padding-bottom: 120px;
}

.hero-band,
.control-band,
.history-band {
  border-radius: 20px;
  padding: 22px 24px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 18px;
}

.hero-copy h2 {
  max-width: 13ch;
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.04;
}

.hero-copy p {
  max-width: 58ch;
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.5;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hero-stat {
  min-height: 102px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(33, 26, 20, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-stat strong {
  font-size: clamp(20px, 2.5vw, 26px);
}

.control-band {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.control-row-search {
  align-items: stretch;
}

.segment-control {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(33, 26, 20, 0.06);
}

.segment-control.compact {
  overflow-x: auto;
}

.segment-button,
.action-button,
.dock-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  padding: 11px 16px;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.segment-button.is-active {
  background: var(--ink);
  color: #fffaf1;
}

.segment-button:disabled,
.action-button:disabled,
.dock-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-button {
  border-color: rgba(33, 26, 20, 0.1);
}

.action-button-primary,
.dock-button-primary {
  background: var(--accent);
  border-color: transparent;
  color: #f8fffd;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(33, 26, 20, 0.1);
  background: rgba(255, 255, 255, 0.62);
}

.inline-field span {
  font-size: 13px;
  color: var(--muted);
}

.inline-field select,
.search-field input {
  border: 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
  outline: none;
}

.search-field {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(33, 26, 20, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

.search-field input {
  width: 100%;
  padding: 14px 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-band {
  margin-top: 18px;
  padding: 0;
  border-radius: 20px;
  overflow: hidden;
}

.summary-band[hidden] {
  display: none;
}

.summary-top {
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr);
  gap: 20px;
  border-bottom: 1px solid rgba(33, 26, 20, 0.08);
}

.summary-score {
  padding: 18px;
  border-radius: 0 0 0 18px;
}

.summary-score h3,
.summary-section h3 {
  margin: 0;
}

.summary-score p,
.summary-section p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.summary-score.tier-great {
  background: var(--success-soft);
}

.summary-score.tier-good {
  background: var(--accent-soft);
}

.summary-score.tier-ok {
  background: var(--warning-soft);
}

.summary-score.tier-bad {
  background: var(--danger-soft);
}

.score-big {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

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

.summary-metric {
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(33, 26, 20, 0.08);
}

.summary-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.summary-body {
  padding: 18px 24px 24px;
  display: grid;
  gap: 12px;
}

.topic-row {
  padding: 14px 0;
  border-bottom: 1px solid rgba(33, 26, 20, 0.08);
}

.topic-row:last-child {
  border-bottom: 0;
}

.topic-main {
  flex: 1;
  min-width: 0;
}

.topic-main strong {
  display: block;
  font-size: 15px;
}

.topic-main span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.topic-bar {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(33, 26, 20, 0.08);
  overflow: hidden;
}

.topic-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.topic-action {
  white-space: nowrap;
}

.question-stream-header {
  margin-top: 28px;
}

.question-stream {
  margin-top: 16px;
}

.question-card {
  border: 1px solid rgba(33, 26, 20, 0.12);
  border-radius: 18px;
  background: rgba(255, 250, 241, 0.88);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.question-card.is-hidden {
  display: none;
}

.question-card.is-open .question-body {
  display: block;
}

.question-card.is-correct {
  border-color: rgba(11, 107, 87, 0.32);
}

.question-card.is-incorrect {
  border-color: rgba(180, 35, 24, 0.25);
}

.question-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 20px;
}

.question-head[data-question-toggle] {
  cursor: pointer;
  transition: background 0.18s ease;
}

.question-head[data-question-toggle]:hover {
  background: rgba(182, 31, 36, 0.035);
}

.question-head-main {
  min-width: 0;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pill,
.section-chip,
.status-chip,
.bookmark-toggle {
  border-radius: 999px;
  border: 1px solid rgba(31, 27, 24, 0.1);
  background: rgba(255, 255, 255, 0.72);
  padding: 6px 10px;
  font-size: 12px;
}

.pill {
  font-family: var(--mono);
}

.section-chip {
  color: var(--accent-strong);
}

.status-chip.is-correct {
  color: var(--success);
  border-color: rgba(11, 107, 87, 0.18);
  background: var(--success-soft);
}

.status-chip.is-incorrect {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.18);
  background: var(--danger-soft);
}

.status-chip.is-unanswered {
  color: var(--warning);
  border-color: rgba(180, 83, 9, 0.18);
  background: var(--warning-soft);
}

.question-title {
  margin: 0;
  font-family: var(--display);
  font-size: 21px;
  line-height: 1.32;
}

.question-actions {
  display: flex;
  align-items: start;
}

.bookmark-toggle {
  min-width: 132px;
  text-align: center;
}

.bookmark-toggle.is-active {
  background: var(--warning-soft);
  border-color: rgba(180, 83, 9, 0.24);
  color: var(--warning);
}

.question-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid rgba(31, 27, 24, 0.08);
  background: rgba(255, 255, 255, 0.34);
}

.question-image {
  width: 100%;
  margin-top: 18px;
  border-radius: 12px;
  border: 1px solid rgba(33, 26, 20, 0.1);
  background: rgba(255, 255, 255, 0.55);
}

.options-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.option {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(33, 26, 20, 0.1);
  background: rgba(255, 255, 255, 0.55);
}

.option input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.option.is-selected {
  border-color: rgba(182, 31, 36, 0.22);
  background: var(--accent-soft);
}

.option.is-correct {
  border-color: rgba(11, 107, 87, 0.26);
  background: var(--success-soft);
}

.option.is-incorrect {
  border-color: rgba(180, 35, 24, 0.22);
  background: var(--danger-soft);
}

.option.is-reveal {
  border-style: dashed;
}

.question-footnote,
.review-block {
  margin-top: 16px;
}

.question-footnote {
  color: var(--warning);
  font-size: 13px;
}

.review-block {
  padding: 16px;
  border-radius: 14px;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.68);
}

.review-block.is-warn {
  border-left-color: var(--warning);
}

.review-block.is-exam {
  border-left-color: var(--ink);
}

.review-block .ans-label {
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.review-block .ans-value {
  font-size: 18px;
  font-weight: 700;
}

.review-block .ans-explain,
.review-block .ans-extra {
  margin-top: 10px;
  line-height: 1.7;
  color: var(--ink);
}

.review-block .ans-ref {
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent-strong);
}

.review-block .ref-tbl {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}

.review-block .ref-tbl th,
.review-block .ref-tbl td {
  border: 1px solid rgba(33, 26, 20, 0.12);
  padding: 4px 6px;
}

.review-block .ref-tbl th {
  text-align: left;
  background: rgba(182, 31, 36, 0.08);
}

.review-block .ref-tbl .hl {
  background: rgba(182, 31, 36, 0.12);
  font-weight: 700;
}

.history-list,
.history-compact {
  margin-top: 16px;
}

.history-item {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(33, 26, 20, 0.1);
  background: rgba(255, 255, 255, 0.48);
}

.history-item strong {
  display: block;
  font-size: 14px;
}

.history-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(33, 26, 20, 0.12);
  background: rgba(255, 250, 241, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.mobile-dock > div {
  min-width: 0;
}

.mobile-dock strong {
  display: block;
}

.dock-button {
  white-space: nowrap;
}

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

  .rail {
    position: static;
    max-height: none;
    padding: 0;
  }

  .hero-band {
    grid-template-columns: 1fr;
  }

  .brand-block {
    justify-items: center;
    text-align: center;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 14px;
    gap: 18px;
  }

  .hero-copy h2 {
    max-width: none;
    font-size: 36px;
  }

  .hero-stats,
  .summary-top,
  .summary-metrics {
    grid-template-columns: 1fr;
  }

  .question-head {
    grid-template-columns: 1fr;
  }

  .question-actions {
    justify-content: flex-start;
  }

  .bookmark-toggle {
    min-width: 0;
  }

  .mobile-dock {
    display: flex;
  }
}
