:root {
  --paper: #fbf9f4;
  --surface: #ffffff;
  --surface-low: #f5f3ee;
  --surface-container: #f0eee9;
  --surface-high: #eae8e3;
  --ink: #1b1c19;
  --muted: #55433d;
  --line: #dbc1b9;
  --line-strong: #b99d94;
  --green: #99462a;
  --green-dark: #7a2f15;
  --amber: #ba1a1a;
  --amber-soft: #ffdad6;
  --mint: #ffdbd0;
  --charcoal: #30312e;
  --shadow: 0 18px 46px rgba(85, 67, 61, 0.11);
  --shadow-soft: 0 8px 24px rgba(85, 67, 61, 0.08);
  --radius: 18px;
  --mono: "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --headline: "Manrope", var(--sans);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(18px, 3vw, 44px);
  border-bottom: 1px solid rgba(219, 193, 185, 0.54);
  background: rgba(251, 249, 244, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-family: var(--headline);
  font-size: 13px;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1;
  font-family: var(--headline);
  font-weight: 900;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.topbar nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.topbar nav a,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 40px;
  border-radius: 999px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a:hover {
  color: var(--green);
  background: rgba(153, 70, 42, 0.08);
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-container);
}

.language-switch button {
  min-width: 38px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
}

.language-switch button.active {
  background: var(--green);
  color: #fff;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 760;
  white-space: nowrap;
}

.primary-button {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 30px rgba(153, 70, 42, 0.24);
}

.secondary-button {
  background: var(--ink);
  color: #fff;
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
  border-color: rgba(219, 193, 185, 0.76);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.option-button:active,
.unit-button:active,
.flashcard:active {
  transform: translateY(1px) scale(0.99);
}

main {
  padding: 0 clamp(18px, 3vw, 44px) 56px;
  max-width: 1440px;
  margin: 0 auto;
}

.workspace {
  min-height: calc(100dvh - 73px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.75fr);
  align-items: center;
  gap: clamp(28px, 6vw, 96px);
  margin-top: 28px;
  padding: clamp(34px, 6vw, 76px);
  border: 1px solid rgba(219, 193, 185, 0.42);
  border-radius: 28px;
  background:
    radial-gradient(circle at 100% 100%, rgba(255, 219, 208, 0.72), transparent 30%),
    var(--surface-low);
  overflow: hidden;
}

.workspace-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-family: var(--headline);
  font-size: clamp(42px, 6.4vw, 78px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0;
  max-width: 880px;
}

h2 {
  margin-bottom: 0;
  font-family: var(--headline);
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-family: var(--headline);
  font-size: 22px;
  font-weight: 850;
  line-height: 1.18;
}

.lead {
  max-width: 58ch;
  color: var(--muted);
  font-size: clamp(17px, 1.7vw, 20px);
  line-height: 1.58;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.live-panel,
.domain-view,
.unit-detail,
.quiz-card,
.flashcard,
.sources {
  border: 1px solid rgba(219, 193, 185, 0.52);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.live-panel {
  padding: 24px;
  border-radius: 50%;
  width: min(360px, 100%);
  aspect-ratio: 1;
  justify-self: center;
  display: grid;
  align-content: center;
  background:
    radial-gradient(circle at 50% 35%, #fff, transparent 46%),
    var(--surface);
}

.panel-head,
.section-head,
.quiz-controls,
.unit-card-head,
.question-meta,
.scenario-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel-head span,
.question-meta,
.caption,
.support-copy {
  color: var(--muted);
}

.panel-head strong {
  font-family: var(--mono);
  font-size: 38px;
  color: var(--green);
}

.meter {
  height: 10px;
  margin: 20px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-high);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #d97757);
  transition: width 420ms ease;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.metric-grid div {
  padding: 16px;
  background: var(--surface-low);
}

.metric-grid div + div {
  border-left: 1px solid var(--line);
}

.metric-grid b {
  display: block;
  font-family: var(--mono);
  font-size: 26px;
}

.metric-grid span,
.signal-list,
.caption {
  font-size: 13px;
}

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

.signal {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--mint);
  color: var(--green-dark);
}

.section {
  margin-top: 52px;
  padding: clamp(28px, 5vw, 54px) 0;
  border-top: 1px solid rgba(219, 193, 185, 0.52);
}

.intro-band {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1fr);
  align-items: end;
  gap: 40px;
}

.rule-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.rule-strip span {
  min-height: 88px;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--charcoal);
  font-family: var(--headline);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.rule-strip span + span {
  border-left: 1px solid var(--line);
}

.section-head {
  margin-bottom: 24px;
}

.search-box {
  min-width: min(380px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.search-box span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.domain-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 760;
}

.tab-button.active {
  border-color: var(--green);
  background: rgba(153, 70, 42, 0.1);
  color: var(--green);
}

.tab-button:hover {
  border-color: rgba(153, 70, 42, 0.45);
  color: var(--green);
}

.domain-tabs {
  scrollbar-width: thin;
}

.domain-view {
  border-radius: 24px;
}

.domain-copy .eyebrow {
  color: var(--green);
}

.domain-copy h3 {
  font-size: clamp(24px, 2.4vw, 34px);
}

.domain-copy {
  background: var(--surface);
}

.domain-image {
  border-left: 1px solid rgba(219, 193, 185, 0.48);
}

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

.domain-copy .knowledge-list .knowledge-item:first-child {
  grid-column: 1 / -1;
  background: var(--surface-low);
}

.knowledge-item,
.scenario-card,
.check-item,
.unit-button,
.option-button {
  border-color: rgba(219, 193, 185, 0.52);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.68) inset;
}

.knowledge-item strong,
.check-item h3 {
  color: var(--ink);
  font-family: var(--headline);
  font-weight: 850;
}

.unit-button.active,
.unit-button:hover {
  border-color: rgba(153, 70, 42, 0.45);
  background: rgba(255, 219, 208, 0.46);
  color: var(--green);
}

.unit-detail {
  border-radius: 24px;
}

.image-frame {
  border-color: rgba(219, 193, 185, 0.72);
  border-radius: 18px;
}

.caption {
  background: var(--surface-low);
}

.pill {
  border: 1px solid rgba(219, 193, 185, 0.64);
  background: var(--surface-container);
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 800;
}

.warning {
  border-left-color: var(--green);
  background: var(--mint);
  color: var(--green-dark);
}

.scenario-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scenario-card {
  border-radius: 22px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.scenario-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.scenario-card.active {
  outline: 0;
  border-color: rgba(153, 70, 42, 0.5);
  background: rgba(255, 219, 208, 0.42);
}

.flashcard {
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 219, 208, 0.42), transparent 42%),
    var(--surface);
}

.flashcard strong {
  color: var(--green);
  font-family: var(--sans);
  letter-spacing: 0.03em;
}

.flashcard span {
  font-family: var(--headline);
}

.quiz-card {
  border-radius: 26px;
}

.question-meta {
  color: var(--muted);
  font-weight: 800;
}

.question-text {
  font-family: var(--headline);
  font-weight: 850;
}

.option-button {
  border-radius: 16px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.option-button:hover {
  transform: translateY(-1px);
  border-color: rgba(153, 70, 42, 0.48);
  background: var(--surface-low);
}

.option-button.correct {
  border-color: var(--green);
  background: var(--mint);
}

.option-button.wrong {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.explanation {
  background: var(--surface-low);
  border: 1px solid rgba(219, 193, 185, 0.52);
}

.import-panel {
  border-color: rgba(219, 193, 185, 0.52);
  border-radius: 18px;
  background: var(--surface-low);
}

.file-import,
select {
  border-color: rgba(219, 193, 185, 0.76);
  background: var(--surface);
}

.checklist-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.check-item {
  border-radius: 22px;
}

.sources {
  border-radius: 24px;
  background: var(--surface-low);
}

@media (min-width: 1180px) {
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    gap: 28px;
    padding: 28px 20px;
    border-right: 1px solid rgba(219, 193, 185, 0.48);
    border-bottom: 0;
    background: rgba(251, 249, 244, 0.96);
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .topbar nav {
    width: 100%;
    display: grid;
    justify-content: stretch;
    align-content: start;
    gap: 8px;
  }

  .topbar nav a {
    justify-content: flex-start;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    font-weight: 800;
  }

  .topbar nav a:first-child {
    color: var(--green);
    background: rgba(153, 70, 42, 0.1);
  }

  .top-actions {
    width: 100%;
    display: grid;
    gap: 12px;
  }

  .language-switch,
  .top-actions .ghost-button {
    width: 100%;
  }

  main {
    max-width: none;
    margin-left: 272px;
    padding: 28px clamp(24px, 4vw, 56px) 64px;
  }

  .workspace {
    margin-top: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131312;
    --surface: #211f1e;
    --surface-low: #1d1b1a;
    --surface-container: #2b2928;
    --surface-high: #363433;
    --ink: #e6e2df;
    --muted: #dbc1b9;
    --line: #55433d;
    --line-strong: #a08d88;
    --green: #ffb59e;
    --green-dark: #ffdbd0;
    --amber: #ffb4ab;
    --amber-soft: #93000a;
    --mint: #541400;
    --charcoal: #f2f1ec;
    --shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.24);
  }

  .topbar,
  .workspace,
  .live-panel,
  .domain-view,
  .unit-detail,
  .quiz-card,
  .flashcard,
  .sources,
  .rule-strip,
  .knowledge-item,
  .scenario-card,
  .check-item,
  .unit-button,
  .option-button {
    border-color: rgba(85, 67, 61, 0.86);
  }

  .brand-mark,
  .primary-button {
    color: #541400;
  }

  .secondary-button {
    background: #e6e2df;
    color: #1b1c19;
  }

  .workspace {
    background:
      radial-gradient(circle at 100% 100%, rgba(84, 20, 0, 0.62), transparent 34%),
      var(--surface-low);
  }
}

@media (max-width: 1179px) {
  .topbar nav {
    overflow-x: auto;
  }
}

@media (max-width: 860px) {
  .live-panel {
    border-radius: 24px;
    width: 100%;
    aspect-ratio: auto;
  }

  .knowledge-list {
    grid-template-columns: 1fr;
  }

  .domain-image {
    border-left: 0;
    border-top: 1px solid rgba(219, 193, 185, 0.52);
  }
}

.tab-button.active {
  color: var(--green);
}

@media (max-width: 720px) {
  .workspace {
    padding: 28px 18px;
    border-radius: 22px;
  }

  .brand small {
    display: none;
  }

  h1 {
    font-size: 42px;
  }
}

/* Keep legacy selectors below this line from reintroducing the old green theme. */
.tab-button.active {
  color: #fff;
}

.domain-view {
  margin-top: 16px;
  overflow: hidden;
}

.domain-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1fr);
  gap: 0;
}

.domain-copy {
  padding: clamp(24px, 4vw, 42px);
}

.domain-copy p {
  color: var(--muted);
  line-height: 1.7;
}

.domain-image {
  min-height: 360px;
  background: var(--charcoal);
}

.domain-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.knowledge-list,
.trap-list,
.scenario-steps,
.checklist-grid {
  display: grid;
  gap: 12px;
}

.knowledge-list {
  margin-top: 22px;
}

.knowledge-item,
.scenario-card,
.check-item,
.unit-button,
.option-button {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.knowledge-item {
  padding: 14px;
}

.knowledge-item strong {
  display: block;
  margin-bottom: 5px;
}

.knowledge-item span {
  color: var(--muted);
  line-height: 1.55;
}

.unit-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.unit-rail {
  display: grid;
  align-content: start;
  gap: 10px;
}

.unit-button {
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.unit-button small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--mono);
}

.unit-button.active,
.unit-button:hover {
  border-color: var(--green);
  background: var(--mint);
}

.unit-detail {
  padding: clamp(20px, 4vw, 34px);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 22px;
}

.image-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111;
}

.image-frame img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.caption {
  padding: 9px 10px 11px;
  background: var(--surface);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 760;
}

.warning {
  margin-top: 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--amber);
  border-radius: 14px;
  background: var(--amber-soft);
  color: #5d3511;
}

.scenario-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.scenario-card {
  min-height: 236px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.scenario-card.active {
  outline: 3px solid rgba(31, 143, 95, 0.28);
  background: var(--mint);
}

.scenario-card p {
  color: var(--muted);
  line-height: 1.6;
}

.scenario-card ol {
  margin: 0;
  padding-left: 20px;
}

.scenario-card li {
  margin: 8px 0;
}

.flashcard {
  width: 100%;
  min-height: 240px;
  padding: clamp(24px, 5vw, 48px);
  color: var(--ink);
  text-align: left;
}

.flashcard strong {
  display: block;
  margin-bottom: 16px;
  color: var(--green-dark);
  font-family: var(--mono);
  font-size: 13px;
  text-transform: uppercase;
}

.flashcard span {
  display: block;
  max-width: 920px;
  font-size: clamp(24px, 4vw, 46px);
  font-weight: 820;
  line-height: 1.08;
}

.quiz-card {
  padding: clamp(22px, 4vw, 36px);
}

.import-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.import-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.file-import {
  position: relative;
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 760;
  white-space: nowrap;
  cursor: pointer;
}

.file-import input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.quiz-controls {
  justify-content: flex-end;
}

select {
  min-height: 40px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}

.question-text {
  margin: 10px 0 18px;
  font-size: clamp(20px, 2.6vw, 30px);
  font-weight: 760;
  line-height: 1.22;
}

.option-list {
  display: grid;
  gap: 10px;
}

.option-button {
  width: 100%;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  line-height: 1.55;
}

.option-button.correct {
  border-color: var(--green);
  background: var(--mint);
}

.option-button.wrong {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.explanation {
  display: none;
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  background: #f1f1ea;
  line-height: 1.7;
}

.explanation.show {
  display: block;
}

.checklist-grid {
  grid-template-columns: repeat(4, 1fr);
}

.check-item {
  min-height: 158px;
  padding: 18px;
}

.check-item p {
  color: var(--muted);
  line-height: 1.62;
}

.sources {
  padding: clamp(24px, 4vw, 42px);
}

.sources p {
  max-width: 86ch;
  color: var(--muted);
  line-height: 1.75;
}

.fade-in {
  animation: fadeUp 360ms ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1060px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .workspace,
  .intro-band,
  .domain-hero,
  .unit-layout {
    grid-template-columns: 1fr;
  }

  .domain-image {
    min-height: auto;
  }

  .scenario-board,
  .checklist-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  main {
    padding-inline: 14px;
  }

  .topbar {
    padding-inline: 14px;
  }

  .topbar .ghost-button {
    display: none;
  }

  h1 {
    font-size: 46px;
  }

  .workspace {
    padding-top: 38px;
  }

  .section-head,
  .panel-head,
  .unit-card-head,
  .quiz-controls,
  .import-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .rule-strip,
  .image-grid,
  .scenario-board,
  .checklist-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid div + div,
  .rule-strip span + span {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Reference-inspired final theme layer */
.topbar,
.workspace,
.live-panel,
.domain-view,
.unit-detail,
.quiz-card,
.flashcard,
.sources,
.rule-strip,
.import-panel,
.knowledge-item,
.scenario-card,
.check-item,
.unit-button,
.option-button,
.search-box,
.file-import,
select {
  border-color: rgba(219, 193, 185, 0.58);
}

.domain-view,
.unit-detail,
.quiz-card,
.flashcard,
.sources,
.rule-strip,
.import-panel,
.check-item,
.scenario-card {
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.topbar {
  background: rgba(251, 249, 244, 0.94);
}

.brand-mark,
.primary-button,
.language-switch button.active {
  background: var(--green);
  color: #fff;
}

.topbar nav a:hover,
.topbar nav a:focus-visible {
  color: var(--green);
  background: rgba(153, 70, 42, 0.08);
}

.tab-button.active {
  border-color: rgba(153, 70, 42, 0.5);
  background: rgba(153, 70, 42, 0.1);
  color: var(--green);
}

.knowledge-item,
.unit-button,
.option-button,
.check-item,
.scenario-card {
  background: var(--surface);
  border-radius: 16px;
}

.domain-copy .knowledge-list .knowledge-item:first-child,
.metric-grid div,
.caption,
.explanation,
.import-panel,
.sources {
  background: var(--surface-low);
}

.unit-button.active,
.unit-button:hover,
.option-button.correct,
.scenario-card.active {
  border-color: rgba(153, 70, 42, 0.52);
  background: rgba(255, 219, 208, 0.5);
  color: var(--green-dark);
}

.option-button.wrong {
  border-color: rgba(186, 26, 26, 0.54);
  background: var(--amber-soft);
  color: #690005;
}

.pill {
  border: 1px solid rgba(219, 193, 185, 0.7);
  background: var(--surface-container);
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 800;
}

.warning {
  border-left-color: var(--green);
  background: rgba(255, 219, 208, 0.62);
  color: var(--green-dark);
}

.question-text,
.flashcard span,
.check-item h3,
.knowledge-item strong,
.scenario-card h3,
.unit-button strong {
  font-family: var(--headline);
}

.question-meta,
.panel-head span,
.metric-grid span,
.support-copy,
.caption,
.sources p,
.import-panel p,
.scenario-card p,
.check-item p,
.knowledge-item span {
  color: var(--muted);
}

@media (min-width: 1180px) {
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    gap: 28px;
    padding: 28px 20px;
    border-right: 1px solid rgba(219, 193, 185, 0.5);
    border-bottom: 0;
  }

  .topbar nav {
    grid-column: auto;
    width: 100%;
    display: grid;
    justify-content: stretch;
    align-content: start;
    gap: 8px;
  }

  .topbar nav a {
    min-height: 46px;
    justify-content: flex-start;
    border-radius: 12px;
    font-weight: 800;
  }

  .topbar nav a:first-child {
    color: var(--green);
    background: rgba(153, 70, 42, 0.1);
  }

  .top-actions {
    width: 100%;
    display: grid;
    gap: 12px;
  }

  .language-switch,
  .top-actions .ghost-button {
    width: 100%;
  }

  main {
    max-width: none;
    margin-left: 272px;
    padding: 28px clamp(24px, 4vw, 56px) 64px;
  }

  .workspace {
    margin-top: 0;
  }
}

@media (max-width: 860px) {
  .knowledge-list,
  .domain-copy .knowledge-list {
    grid-template-columns: 1fr;
  }

  .live-panel {
    border-radius: 24px;
    width: 100%;
    aspect-ratio: auto;
  }
}

@media (prefers-color-scheme: dark) {
  .topbar {
    background: rgba(19, 19, 18, 0.95);
  }

  .brand-mark,
  .primary-button,
  .language-switch button.active {
    color: #541400;
  }

  .option-button.wrong {
    color: #ffdad6;
  }
}
