:root {
  --ink: #1d2528;
  --muted: #607073;
  --paper: #f7f6f0;
  --surface: #ffffff;
  --line: #dde3de;
  --teal: #2f6f78;
  --red: #b94739;
  --ochre: #8a6f23;
  --green: #52795b;
  --plum: #8e2f56;
  --shadow: 0 16px 42px rgba(27, 45, 48, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: linear-gradient(180deg, #fbfaf5 0%, var(--paper) 58%, #edf4f1 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 68px;
  padding: 10px clamp(14px, 4vw, 44px);
  background: rgba(251, 250, 245, 0.9);
  border-bottom: 1px solid rgba(97, 112, 115, 0.18);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  padding: 4px;
  border: 1px solid rgba(97, 112, 115, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  scrollbar-width: none;
}

.nav a {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  background: var(--ink);
  color: #fff;
}

.top-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}

.search-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 30;
  display: none;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-results.open {
  display: grid;
  gap: 6px;
}

.search-results button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.search-results button:hover {
  background: rgba(47, 111, 120, 0.1);
}

.search-results strong,
.search-results span {
  display: block;
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 134px);
  margin: 0 auto;
}

.page {
  display: none;
  padding: 44px 0 60px;
}

.page.active {
  display: block;
}

.landing-hero {
  position: relative;
  min-height: calc(100vh - 120px);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 40px 0 78px;
  text-align: center;
}

.landing-hero h1 {
  max-width: 900px;
  font-size: clamp(48px, 9vw, 104px);
}

.landing-hero .subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 800;
}

.landing-hero .quick-actions {
  justify-content: center;
}

.scroll-cue {
  position: absolute;
  bottom: 20px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 22px;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(27, 45, 48, 0.08);
}

.scroll-cue:hover {
  background: var(--ink);
  color: #fff;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(22px, 5vw, 60px);
  align-items: start;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.14;
}

h1 {
  max-width: 700px;
  font-size: clamp(38px, 7vw, 72px);
  letter-spacing: 0;
}

h2 {
  font-size: clamp(28px, 4vw, 42px);
}

.lead {
  max-width: 680px;
  margin: 18px 0 0;
  color: #425053;
  font-size: clamp(17px, 2vw, 21px);
}

.quick-actions,
.trainer-actions,
.practice-buttons,
.switch-row,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions {
  margin-top: 26px;
}

.home-panel,
.control-panel,
.list-panel,
.flashcard,
.case-list,
.case-reader,
.abstract-trainer,
.writing-notes,
.example-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.home-panel {
  padding: 16px;
  box-shadow: var(--shadow);
}

.exam-info,
.priority-system {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

#home .exam-info {
  scroll-margin-top: 90px;
  margin-top: 0;
}

.subsection-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 14px;
}

.compact-toolbar {
  margin-bottom: 0;
}

.theme-reference {
  margin-top: 30px;
  padding-top: 4px;
}

.compact-head {
  margin-bottom: 14px;
}

.exam-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.exam-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.exam-grid h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.exam-grid ul {
  margin: 0;
  padding-left: 20px;
}

.exam-notice {
  margin: 14px 0 0;
}

.exam-note {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(47, 111, 120, 0.08);
  color: #425053;
  font-size: 14px;
}

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

.priority-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.priority-row h3 {
  font-size: 18px;
}

.priority-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.stat {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat strong {
  display: block;
  font-size: 28px;
}

.stat span,
.muted,
.unit-progress-card span {
  color: var(--muted);
}

.unit-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.unit-tile {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.unit-tile strong,
.unit-tile span,
.unit-tile small {
  display: block;
}

.unit-tile span {
  margin-top: 6px;
  color: var(--teal);
  font-weight: 800;
}

.unit-tile small {
  margin-top: 8px;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.tool-layout {
  display: grid;
  grid-template-columns: 260px minmax(280px, 0.95fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.tool-layout > *,
.case-shell > *,
.home-layout > * {
  min-width: 0;
}

.control-panel {
  padding: 16px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.segmented.compact {
  margin-top: 12px;
}

.segmented.compact button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.field-label {
  display: block;
  margin: 18px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.text-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfd8d2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.switch-row {
  margin-top: 16px;
}

.icon-button {
  width: 48px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 24px;
  font-weight: 900;
}

.solid-button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

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

.solid-button.warn {
  border-color: var(--ochre);
  background: var(--ochre);
}

.solid-button.danger {
  border-color: var(--red);
  background: var(--red);
}

.practice-buttons {
  margin-top: 12px;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-stats span {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(97, 112, 115, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 13px;
}

.module-tip {
  margin: -8px 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: rgba(47, 111, 120, 0.08);
  color: #425053;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid rgba(47, 111, 120, 0.2);
  border-radius: 999px;
  background: rgba(47, 111, 120, 0.08);
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.flashcard {
  min-height: 390px;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.card-inner {
  width: 100%;
}

.card-side {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.flashcard .front {
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card-hint {
  margin: 16px 0 0;
  color: var(--muted);
}

.list-panel {
  max-height: 500px;
  overflow: auto;
  padding: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.mini-row:hover,
.mini-row.active {
  background: rgba(47, 111, 120, 0.1);
}

.mini-row span {
  overflow-wrap: anywhere;
}

.mini-row small {
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 420px) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.term-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.term-card,
.translation-item,
.progress-card,
.unit-progress-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.term-card {
  min-height: 178px;
}

.term-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.term-card p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.theme-reader {
  display: grid;
  gap: 14px;
}

.theme-head,
.theme-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.theme-head p,
.theme-section p {
  overflow-wrap: anywhere;
}

.objective-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.objective-list span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  color: #405155;
  font-size: 13px;
}

.theme-pair {
  margin-top: 12px;
}

.theme-pair.single {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
}

.root-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.root-pill {
  margin-bottom: 10px;
  background: rgba(82, 121, 91, 0.14);
  color: #385842;
}

.status-pill {
  background: rgba(47, 111, 120, 0.11);
  color: var(--teal);
}

.translation-stack {
  display: grid;
  gap: 12px;
}

.translation-item .en {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.translation-item .source-badge {
  margin-bottom: 10px;
}

.answer-panel {
  margin-top: 12px;
  border: 1px dashed #cfd8d2;
  border-radius: 8px;
  background: #f8faf7;
}

.answer-panel p {
  margin: 0;
  padding: 14px 14px 8px;
  color: #48605b;
}

.answer-panel.covered {
  display: grid;
  min-height: 64px;
  place-items: center;
}

.answer-panel.covered button {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.answer-panel.revealed .cover-answer {
  min-height: 34px;
  margin: 0 14px 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

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

.item-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.item-actions button[data-status="mastered"] {
  border-color: rgba(82, 121, 91, 0.38);
  color: var(--green);
}

.item-actions button[data-status="weak"] {
  border-color: rgba(185, 71, 57, 0.38);
  color: var(--red);
}

.notice {
  margin: -6px 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: rgba(47, 111, 120, 0.08);
  color: #425053;
}

.case-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
}

.case-list {
  max-height: 620px;
  overflow: auto;
  padding: 8px;
}

.case-tab {
  width: 100%;
  min-height: 74px;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.case-tab.active {
  border-color: #bfd4d7;
  background: rgba(47, 111, 120, 0.12);
}

.case-tab strong,
.case-tab small {
  display: block;
}

.case-tab small,
.source {
  color: var(--muted);
}

.case-reader {
  min-height: 520px;
  padding: 22px;
}

.case-reader h3 {
  margin-bottom: 8px;
  font-size: 26px;
}

.case-part {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.parallel-text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.parallel-text.single {
  grid-template-columns: 1fr;
}

.parallel-text div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.parallel-text p {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.writing-notes {
  padding: 18px;
}

.note-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.note-block:first-child {
  padding-top: 0;
}

.note-block:last-child {
  border-bottom: 0;
}

.note-block h3 {
  margin-bottom: 8px;
  font-size: 19px;
}

.note-block p {
  margin: 7px 0;
  color: #405155;
  overflow-wrap: anywhere;
}

.example-area {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
}

.abstract-trainer {
  padding: 16px;
}

.order-list {
  display: grid;
  gap: 8px;
}

.order-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.order-item span {
  overflow-wrap: anywhere;
}

.order-item .badge {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(47, 111, 120, 0.13);
  color: var(--teal);
  font-weight: 900;
}

.move-buttons {
  display: flex;
  gap: 4px;
}

.move-buttons button {
  width: 38px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.result-line {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--teal);
  font-weight: 900;
}

.progress-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.progress-card,
.unit-progress-card {
  box-shadow: 0 10px 28px rgba(27, 45, 48, 0.06);
}

.progress-card strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.progress-card span,
.unit-progress-card strong,
.unit-progress-card span {
  display: block;
}

.progress-card meter,
.unit-progress-card meter {
  width: 100%;
  height: 10px;
  margin-top: 12px;
}

.unit-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(16px, 4vw, 48px);
  color: var(--muted);
  border-top: 1px solid rgba(97, 112, 115, 0.2);
}

@media (max-width: 980px) {
  .home-layout,
  .tool-layout,
  .case-shell,
  .example-area {
    grid-template-columns: 1fr;
  }

  .term-board,
  .unit-progress,
  .exam-grid,
  .parallel-text {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .progress-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 8px;
    min-height: 0;
    padding: 6px 10px;
  }

  .brand {
    min-width: 0;
    gap: 7px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .brand strong {
    font-size: 14px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .brand small {
    display: none;
  }

  .top-search {
    width: auto;
    max-width: none;
    min-width: 0;
  }

  .search-input {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 13px;
  }

  .nav {
    grid-column: 1 / -1;
    width: 100%;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 2px;
  }

  .nav a {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 13px;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .page {
    padding: 34px 0 46px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-stats,
  .unit-strip,
  .term-board,
  .unit-progress,
  .exam-grid,
  .parallel-text {
    grid-template-columns: 1fr;
  }

  .order-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .move-buttons {
    grid-column: 2;
  }

  .footer {
    flex-direction: column;
  }
}
