:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-strong: #eef3f2;
  --ink: #101418;
  --muted: #65717c;
  --line: #dce3e2;
  --accent: #0f766e;
  --accent-2: #2457a7;
  --gold: #b7791f;
  --danger: #be3144;
  --warn: #a76f14;
  --shadow: 0 18px 50px rgba(16, 20, 24, 0.08);
  --shadow-soft: 0 10px 26px rgba(16, 20, 24, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(232, 238, 248, 0.75), rgba(245, 246, 244, 0) 360px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  padding-bottom: 0;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.94);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

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

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.sync-panel p,
.metric p,
.course-card p,
.rule-card p,
.note-block p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line);
}

.sync-panel {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3f2, #f8faf9);
  border: 1px solid var(--line);
}

.sync-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.main {
  padding: 26px 30px 40px;
  min-width: 0;
}

.topbar,
.section-head,
.panel-head,
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar {
  margin-bottom: 24px;
}

.command-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.command-chip {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 8px 12px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.command-chip span {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  margin-right: 8px;
  border-radius: 6px;
  background: #e8eef8;
  color: var(--accent-2);
  font-size: 12px;
}

.command-chip.active,
.command-chip:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #f8fffd;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h2,
h3,
h4 {
  margin: 0;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 22px;
}

h4 {
  font-size: 16px;
}

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

.search-box {
  height: 42px;
  min-width: 310px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.icon-button,
.text-button,
.primary-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  min-width: 70px;
}

.text-button {
  padding: 0 14px;
}

.primary-button {
  padding: 0 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.card-grid,
.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.focus-band {
  min-height: 140px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  padding: 24px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(36, 87, 167, 0.08)),
    #ffffff;
  box-shadow: var(--shadow);
}

.focus-band h3 {
  font-size: 26px;
}

.focus-band p:not(.eyebrow) {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.metric,
.course-card,
.rule-card,
.answer-block,
.note-block,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric {
  padding: 18px;
  min-height: 140px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.28;
}

.metric-label,
.course-id,
.rule-id,
.status-pill {
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent-2);
  background: #e8eef8;
}

.path-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.path-rail article {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
}

.path-rail span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.path-rail strong {
  display: block;
}

.path-rail p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 18px;
}

.chart-preview {
  width: 100%;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-list {
  padding-left: 20px;
  line-height: 1.8;
}

.course-card,
.rule-card,
.answer-block,
.note-block {
  padding: 18px;
}

.course-card code {
  display: block;
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  background: #f0f3f5;
  color: #43505b;
  white-space: normal;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.tag-row span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 430px;
  gap: 14px;
  margin-top: 18px;
  align-items: start;
}

.chart-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.chart-tab {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.chart-tab span {
  margin-right: 8px;
  color: var(--accent);
}

.chart-tab.active,
.chart-tab:hover {
  color: var(--ink);
  border-color: rgba(15, 118, 110, 0.4);
  background: #f3fbf9;
}

.chart-viewer {
  display: grid;
  gap: 14px;
}

.chart-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.featured-chart {
  box-shadow: var(--shadow);
  position: sticky;
  top: 16px;
}

.validation-card {
  box-shadow: var(--shadow-soft);
}

.chart-card img {
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  background: #f8faf9;
  display: block;
  margin-top: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.notes-pane,
.stack {
  display: grid;
  gap: 14px;
}

.notes-pane {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.note-block ul,
.answer-block ul {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.75;
}

.focus-note {
  border-left: 4px solid var(--gold);
}

.study-panel {
  padding: 16px;
}

.study-section {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.study-section h5 {
  margin: 0 0 8px;
  font-size: 14px;
}

.study-section p {
  margin: 0 0 8px;
}

.study-section ol,
.study-section ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.user-answer {
  background: #f7f4ed;
}

.teacher-answer {
  background: #eff7f4;
}

.trade-plan {
  background: #eef3fb;
}

.verification-answer {
  background: #f4f8ff;
  border-color: #ccd9ee;
}

.note-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.rule-card {
  border-top: 4px solid var(--accent);
}

.rule-id {
  color: var(--accent);
}

.resume-box {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101418;
  color: #eff5f4;
  overflow: auto;
}

.resume-box pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.8;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.reader-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  margin-top: 18px;
  align-items: start;
}

.library-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  margin-top: 18px;
  align-items: start;
  height: calc(100vh - 184px);
  min-height: 560px;
  overflow: hidden;
}

.doc-list {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.folder-tree {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfefd;
  box-shadow: var(--shadow-soft);
}

.tree-root {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--line);
}

.folder-section {
  margin-top: 10px;
}

.folder-button,
.file-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.folder-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px;
  background: #f2f6f5;
}

.folder-button small {
  min-width: 28px;
  text-align: center;
  color: var(--muted);
}

.folder-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 18px;
  border: 1px solid #c5d1ce;
  border-top: 5px solid #d9a441;
  border-radius: 3px;
  color: transparent;
  background: #ffe8a3;
}

.file-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding-left: 18px;
}

.file-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 7px 8px;
}

.file-button:hover,
.file-button.active {
  background: #eef8f6;
  border-color: rgba(15, 118, 110, 0.28);
}

.file-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 22px;
  border-radius: 4px;
  background: #e8eef8;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
}

.library-reader {
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.doc-list button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  padding: 10px;
}

.doc-list button:hover,
.doc-list button.active {
  background: #eef8f6;
  border-color: rgba(15, 118, 110, 0.28);
}

.doc-list span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.doc-list strong {
  display: block;
  line-height: 1.45;
}

.doc-reader {
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.doc-reader h4 {
  font-size: 22px;
  margin: 12px 0 18px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.doc-meta span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.doc-meta code {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.doc-reader pre,
.markdown-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.78;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

.markdown-body {
  line-height: 1.78;
  font-size: 16px;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 24px 0 10px;
  line-height: 1.35;
}

.markdown-body h2 {
  font-size: 24px;
}

.markdown-body h3 {
  font-size: 20px;
}

.markdown-body p {
  margin: 0 0 14px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.markdown-body li {
  margin: 5px 0;
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef3f2;
  color: var(--accent-2);
  font-size: 0.92em;
}

.markdown-body blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: #eef8f6;
  color: #263238;
}

.doc-figure {
  margin: 18px 0 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.doc-figure img {
  display: block;
  width: 100%;
  max-height: 560px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.doc-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-state {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.bottom-tabs {
  display: none;
}

.top-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.top-button.visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 980px) {
  body {
    padding-bottom: 72px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .top-actions,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    min-width: 0;
  }

  .metric-grid,
  .card-grid,
  .rule-grid,
  .workbench,
  .chart-layout,
  .path-rail,
  .command-strip,
  .reader-layout,
  .library-layout {
    grid-template-columns: 1fr;
  }

  .featured-chart {
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 10px;
  }

  .notes-pane {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .chart-card img {
    max-height: min(44vh, 420px);
  }

  .focus-band {
    align-items: stretch;
    flex-direction: column;
  }

  .doc-list {
    position: static;
    max-height: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    overflow-x: auto;
  }

  .folder-tree {
    position: static;
    max-height: none;
    height: 34vh;
  }

  .library-layout {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .library-reader {
    height: 58vh;
    min-height: 420px;
  }

  .bottom-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
  }

  .bottom-tab {
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
  }

  .bottom-tab.active {
    color: var(--ink);
    background: #eef8f6;
    border-color: rgba(15, 118, 110, 0.2);
  }

  .top-button {
    bottom: 86px;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 16px;
  }

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

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 19px;
  }

  .chart-card img {
    max-height: 36vh;
  }
}
