:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --paper-strong: #fffefb;
  --ink: #1f2933;
  --muted: #607080;
  --line: #d8d0c2;
  --line-strong: #b5ab98;
  --accent: #2e5e89;
  --accent-soft: #ecf3fa;
  --known: #2f7d4f;
  --known-soft: #edf7f0;
  --fuzzy: #b07a15;
  --fuzzy-soft: #fbf5e7;
  --unknown: #b44b45;
  --unknown-soft: #fbeeed;
  --untested: #6e7781;
  --untested-soft: #f1f3f5;
  --shadow: 0 18px 48px rgba(52, 61, 72, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #f8f3ea 0%, #f0ece5 100%);
  color: var(--ink);
}

button {
  font: inherit;
}

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

body.home-mode .shell {
  grid-template-columns: 1fr;
}

body.home-mode .sidebar {
  display: none;
}

body.home-mode .app {
  padding: 28px 24px 40px;
}

.sidebar {
  padding: 28px 24px 32px;
  border-right: 1px solid rgba(181, 171, 152, 0.45);
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
}

.brand h1 {
  margin: 0;
  font-size: 1.82rem;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.intro {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.sidebar-nav {
  margin-top: 28px;
  display: grid;
  gap: 10px;
}

.nav-link,
.ghost-button,
.primary-button,
.status-button {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.nav-link:hover,
.nav-link:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.status-button:hover,
.status-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
}

.nav-link {
  text-align: left;
}

.nav-link.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.nav-link.is-disabled {
  color: #8a908f;
  background: rgba(242, 239, 232, 0.8);
  cursor: not-allowed;
}

.sidebar-card {
  margin-top: 28px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--paper-strong);
}

.sidebar-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.sidebar-card ul,
.plain-list,
.compact-list {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.75;
}

.compact-list {
  line-height: 1.55;
}

.app {
  padding: 30px;
}

.screen-page {
  width: min(100%, 1320px);
  margin: 0 auto;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 252, 246, 0.97) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero,
.unit-hero {
  padding: 28px;
}

.hero-title,
.page-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
}

.hero-subtitle,
.page-subtitle,
.panel-summary,
.toolbar-note,
.section-hint {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.86rem;
}

.section {
  margin-top: 22px;
}

.two-up,
.chapter-grid,
.selector-grid {
  display: grid;
  gap: 16px;
}

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

.chapter-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.selector-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.media-grid {
  align-items: stretch;
}

.textbook-grid {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.info-card,
.chapter-card,
.selector-card,
.toolbar,
.graph-shell,
.panel {
  padding: 20px;
}

.selector-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 18px 48px rgba(46, 94, 137, 0.12);
}

.upcoming-curriculum-card {
  max-width: 760px;
}

.media-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.textbook-card.is-upcoming {
  opacity: 0.94;
}

.media-thumb {
  position: relative;
  min-height: 168px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(135deg, #6b8fb0 0%, #365d86 58%, #1f3f62 100%);
  color: #f7fbff;
}

.subject-thumb {
  background: linear-gradient(135deg, #759ab9 0%, #446d97 55%, #22486e 100%);
}

.subject-thumb.is-selected-thumb {
  background: linear-gradient(135deg, #8fb3d1 0%, #4d80af 52%, #254f79 100%);
}

.grade-thumb {
  background: linear-gradient(135deg, #9a8fba 0%, #6e6395 55%, #473d69 100%);
}

.media-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(18, 28, 42, 0.42);
  backdrop-filter: blur(6px);
  font-size: 0.78rem;
}

.media-thumb-main {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.media-thumb-sub {
  margin-top: 8px;
  font-size: 0.88rem;
  color: rgba(247, 251, 255, 0.9);
}

.media-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 18px 16px;
  gap: 0;
}

.media-card h3 {
  margin: 0;
  font-size: 1.16rem;
}

.media-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.media-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.media-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(236, 243, 250, 0.9);
  color: var(--accent);
  font-size: 0.8rem;
}

.media-action {
  margin-top: auto;
  width: 100%;
}

.media-progress {
  margin-top: 18px;
  margin-bottom: 16px;
}

.subject-card.is-selected {
  border-color: #4d80af;
  box-shadow: 0 22px 52px rgba(77, 128, 175, 0.16);
}

.home-hero {
  padding: 30px;
}

.selector-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.5);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 1.12rem;
}

.chapter-topline {
  color: var(--accent);
  font-size: 0.86rem;
}

.chapter-card h3 {
  margin: 8px 0 0;
  font-size: 1.18rem;
}

.chapter-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.chapter-card.is-upcoming {
  opacity: 0.8;
}

.chapter-actions {
  margin-top: 14px;
}

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

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.progress-block {
  margin-top: 16px;
}

.progress-meta,
.mini-stats,
.toolbar,
.toolbar-group,
.status-actions,
.action-group-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-meta {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: #ebe6dc;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6798c2, #2e5e89);
}

.status-chip {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.status-chip.known,
.status-button.known {
  background: var(--known-soft);
  color: var(--known);
  border-color: rgba(47, 125, 79, 0.25);
}

.status-chip.fuzzy,
.status-button.fuzzy {
  background: var(--fuzzy-soft);
  color: var(--fuzzy);
  border-color: rgba(176, 122, 21, 0.25);
}

.status-chip.unknown,
.status-button.unknown {
  background: var(--unknown-soft);
  color: var(--unknown);
  border-color: rgba(180, 75, 69, 0.25);
}

.status-chip.untested {
  background: var(--untested-soft);
  color: var(--untested);
  border-color: rgba(110, 119, 129, 0.2);
}

.toolbar {
  margin-top: 18px;
  justify-content: space-between;
  align-items: center;
}

.toolbar-note {
  flex: 1 1 100%;
}

.is-active-filter,
.status-button.is-active {
  box-shadow: inset 0 0 0 1px currentColor;
  font-weight: 700;
}

.workspace {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(310px, 1fr);
  gap: 18px;
  align-items: start;
}

.graph-shell {
  overflow: hidden;
}

.graph-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.graph-edge {
  stroke: #cabca5;
  stroke-width: 3;
  fill: none;
  marker-end: url(#graph-arrow);
}

.graph-arrow {
  fill: #cabca5;
}

.graph-node {
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}

.graph-node rect {
  fill: #fffdf8;
  stroke: #c7bda8;
  stroke-width: 2;
}

.graph-node.level-1 rect {
  filter: drop-shadow(0 10px 18px rgba(112, 93, 61, 0.08));
}

.graph-node.level-2 rect {
  rx: 14;
  ry: 14;
}

.graph-node.status-known rect {
  fill: var(--known-soft);
  stroke: rgba(47, 125, 79, 0.7);
}

.graph-node.status-fuzzy rect {
  fill: var(--fuzzy-soft);
  stroke: rgba(176, 122, 21, 0.7);
}

.graph-node.status-unknown rect {
  fill: var(--unknown-soft);
  stroke: rgba(180, 75, 69, 0.72);
}

.graph-node.status-untested rect {
  fill: #fffdf8;
  stroke: #bfb4a1;
}

.graph-node.is-selected rect {
  stroke: var(--accent);
  stroke-width: 3;
}

.graph-node.is-dimmed {
  opacity: 0.28;
}

.graph-node:hover,
.graph-node:focus-visible {
  opacity: 1;
}

.graph-label {
  fill: var(--ink);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}

.self-check-panel {
  position: sticky;
  top: 24px;
}

.panel-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
}

.self-check-panel h3 {
  margin: 14px 0 0;
  font-size: 1.4rem;
}

.self-check-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.panel-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.panel-section-title,
.field-title {
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.reveal-button {
  margin-top: 14px;
  width: 100%;
}

.answer-panel {
  background: rgba(236, 243, 250, 0.32);
  border-radius: var(--radius-md);
  padding: 18px;
}

.answer-block + .answer-block {
  margin-top: 14px;
}

.answer-block p {
  margin-top: 8px;
}

.warning-block {
  background: rgba(251, 238, 237, 0.8);
  border: 1px solid rgba(180, 75, 69, 0.12);
  border-radius: 12px;
  padding: 12px;
}

.current-state {
  font-size: 0.95rem;
}

.status-actions {
  margin-top: 12px;
}

.status-button {
  flex: 1 1 0;
  min-width: 84px;
}

.empty-panel {
  min-height: 480px;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

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

  .self-check-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(181, 171, 152, 0.45);
  }

  .app {
    padding: 22px 16px 34px;
  }

  body.home-mode .app {
    padding: 18px 14px 28px;
  }
}

@media (max-width: 820px) {
  .two-up {
    grid-template-columns: 1fr;
  }

  .hero,
  .unit-hero,
  .toolbar,
  .graph-shell,
  .panel {
    padding: 18px;
  }

  .hero-title,
  .page-title {
    font-size: 1.72rem;
  }
}
