/* ============================================================ 主题变量 */
:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #eeebe3;
  --text: #1d1d1b;
  --muted: #6f6e68;
  --border: #e0ddd3;
  --accent: #534ab7;
  --accent-soft: #eeedfe;
  --on-accent: #ffffff;
  --ok: #3b6d11; --ok-soft: #eaf3de;
  --warn: #854f0b; --warn-soft: #faeeda;
  --bad: #a32d2d; --bad-soft: #fcebeb;
  --code-bg: #1f1f1d;
  --code-text: #e8e6df;
  --cream: #f3efe6;
  --ink: #1d1d1b;
  --c-base: #888780;
  --c-assume: #1d9e75;
  --c-param: #534ab7;
  --c-nonparam: #d85a30;
  --c-posthoc: #ba7517;
  --c-categorical: #d4537e;
  --c-relation: #378add;
  --c-plan: #c9c7bf;
  /* 侧栏在两种主题下都是深色 */
  --side-bg: #121211;
  --side-2: #1d1d1b;
  --side-text: #ecebe6;
  --side-muted: #8b8a84;
  --side-border: #2a2a27;
  --radius: 10px;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0d; --surface: #181817; --surface-2: #232321; --text: #ecebe6; --muted: #9c9a93; --border: #2c2c29;
    --accent: #8f87ee; --accent-soft: #24213f; --on-accent: #12102a;
    --ok: #97c459; --ok-soft: #1f2d12; --warn: #efa027; --warn-soft: #33250e; --bad: #f09595; --bad-soft: #381818;
    --code-bg: #0a0a09; --c-plan: #55544f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0d; --surface: #181817; --surface-2: #232321; --text: #ecebe6; --muted: #9c9a93; --border: #2c2c29;
  --accent: #8f87ee; --accent-soft: #24213f; --on-accent: #12102a;
  --ok: #97c459; --ok-soft: #1f2d12; --warn: #efa027; --warn-soft: #33250e; --bad: #f09595; --bad-soft: #381818;
  --code-bg: #0a0a09; --c-plan: #55544f; color-scheme: dark;
}

/* ============================================================ 基础 */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }
svg { stroke-linecap: round; stroke-linejoin: round; }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 14px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.small-btn { font-size: 13px; padding: 4px 10px; }
.btn-xl {
  display: inline-flex; align-items: center; gap: 14px; padding: 13px 26px; border-radius: 999px; font: inherit;
  font-size: 15px; font-weight: 600; cursor: pointer; border: 1.5px solid var(--ink); text-decoration: none;
}
.btn-xl.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-xl.primary:hover { filter: brightness(1.08); }
.btn-xl.ghost { background: transparent; color: var(--ink); }
.btn-xl.ghost:hover { background: rgba(0, 0, 0, .05); }

/* ============================================================ 框架 */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: grid; }
.scrim { display: none; }

/* 侧栏 */
.sidebar {
  background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px 14px; overflow-y: auto; border-right: 1px solid var(--side-border);
}
.logo { display: flex; align-items: center; gap: 12px; padding: 0 4px 14px; border-bottom: 1px solid var(--side-border); }
.logo .mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--cream); color: var(--ink); display: grid;
  place-items: center; font-weight: 900; font-size: 22px; position: relative; flex: none;
}
.logo .mark::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 3px; background: #534ab7; }
.logo b { display: block; font-size: 16px; }
.logo small { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--side-muted); }
.search { position: relative; margin: 10px 0 6px; }
.search svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; fill: none; stroke: var(--side-muted); stroke-width: 2; }
.search input {
  width: 100%; background: var(--side-2); border: 1px solid var(--side-border); color: var(--side-text); border-radius: 10px;
  padding: 8px 60px 8px 34px; font: inherit; font-size: 13px; outline: 0;
}
.search input:focus { border-color: #534ab7; }
.search kbd {
  position: absolute; right: 8px; top: 7px; font-family: var(--mono); font-size: 10px; color: var(--side-muted);
  border: 1px solid var(--side-border); border-radius: 5px; padding: 1px 5px;
}
.search-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: 42px; background: var(--side-2); border: 1px solid var(--side-border);
  border-radius: 10px; padding: 6px; max-height: 320px; overflow: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.search-results a { display: block; padding: 7px 9px; border-radius: 7px; color: var(--side-text); text-decoration: none; font-size: 13px; cursor: pointer; }
.search-results a:hover { background: #2b2b28; }
.search-results .ep { font-family: var(--mono); font-size: 10px; color: var(--side-muted); margin-right: 8px; }
.search-results .empty { padding: 8px; color: var(--side-muted); font-size: 13px; }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a, .side-tools a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text);
  text-decoration: none; font-size: 14px; cursor: pointer;
}
.side-nav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; opacity: .8; }
.side-nav a:hover, .side-tools a:hover { background: var(--side-2); }
.side-nav a.active { background: var(--side-2); box-shadow: inset 2px 0 0 #8f87ee; }
.side-nav .tag { margin-left: auto; font-family: var(--mono); font-size: 10px; color: #8f87ee; }
.side-group { margin-top: 10px; }
.side-label { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--side-muted); padding: 6px 10px; }
.side-label span { margin-left: 6px; opacity: .6; }
.side-lessons { list-style: none; margin: 0; padding: 0; }
.side-lessons li { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; line-height: 1.4; }
.side-lessons li:hover { background: var(--side-2); }
.side-lessons li.active { background: var(--side-2); color: #fff; }
.side-lessons .ep { font-family: var(--mono); font-size: 11px; color: var(--side-muted); padding-top: 1px; }
.side-lessons li.part { cursor: default; font-size: 11.5px; color: var(--side-muted); padding: 10px 10px 4px; }
.side-lessons li.part:hover { background: none; }
.side-lessons li.active .ep { color: #8f87ee; }
.side-tools a { font-size: 13.5px; padding-left: 12px; }
.side-tools a::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--side-muted); }
.side-cta {
  margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 12px; text-decoration: none;
  background: var(--cream); color: var(--ink); position: relative; overflow: hidden;
}
.side-cta::before { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: #cecbf6; opacity: .7; }
.side-cta b { position: relative; font-size: 15px; }
.side-cta span { position: relative; font-size: 12px; color: #5f5e5a; line-height: 1.5; }
.side-cta em { position: relative; font-style: normal; margin-top: 8px; align-self: flex-start; background: #534ab7; color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 999px; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 22px; border-bottom: 1px solid var(--border); background: var(--bg); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-grid; place-items: center; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
#menu { display: none; }
.crumb { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--muted); }
.crumb b { font-family: var(--sans); letter-spacing: 0; color: var(--text); font-size: 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.pill.loading { background: var(--warn-soft); color: var(--warn); }
.pill.ready { background: var(--ok-soft); color: var(--ok); }
.pill.error { background: var(--bad-soft); color: var(--bad); }

/* ============================================================ 首页 */
.view.home.active { display: block; overflow-y: auto; padding: 24px 28px 40px; }
.home > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; align-items: center; gap: 20px; background: var(--cream); color: var(--ink);
  border-radius: 22px; padding: 46px 48px; min-height: 400px; position: relative; overflow: hidden;
}
.hero .kicker { color: #6f6e68; }
.hero h1 { font-size: clamp(42px, 6vw, 76px); line-height: 1.02; margin: 14px 0 18px; font-weight: 900; letter-spacing: -.02em; }
.hero-sub { font-size: 18px; font-weight: 700; margin: 0 0 18px; }
.hero-sub i { font-style: normal; color: #534ab7; margin: 0 6px; }
.hero-sub mark { background: var(--ink); color: var(--cream); padding: 1px 8px; border-radius: 4px; }
.hero-stats { font-size: 14px; color: #5f5e5a; margin-bottom: 26px; }
.hero-stats b { color: #534ab7; font-size: 16px; }
.hero-stats span { margin: 0 8px; opacity: .5; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-art { display: flex; justify-content: center; }
.art { width: 100%; max-width: 440px; }
.art text { font-family: var(--mono); font-size: 13px; fill: #f3efe6; }
.art text.dark { fill: #1d1d1b; }
@media (prefers-reduced-motion: no-preference) {
  .art .bar { transform-box: fill-box; transform-origin: bottom; animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; }
  .art .chip-a { animation: float 4s ease-in-out infinite; }
  .art .chip-b { animation: float 4s ease-in-out 1.5s infinite; }
  .marquee-track { animation: marquee 40s linear infinite; }
}
@keyframes grow { from { transform: scaleY(0); } }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes marquee { to { transform: translateX(-50%); } }

.marquee { max-width: none !important; margin: 26px -28px 10px !important; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow: hidden; }
.marquee-track { display: flex; width: max-content; padding: 12px 0; font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .12em; }
.marquee-track span { padding: 0 16px; }
.marquee-track i { font-style: normal; color: var(--accent); }

.sec { margin-top: 46px; }
.sec-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 16px; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 18px; }
.sec-no, .sec-meta { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.sec-meta { text-align: right; }
.sec-head h2 { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: -.01em; }
.sec-head h2 em { font-style: normal; color: var(--accent); }

.feature-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.feature-main {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px; min-height: 260px; transition: border-color .15s;
}
.feature-main:hover, .fitem:hover, .lrow:hover, .topic:hover { border-color: var(--accent); }
.feature-main h3 { font-size: 26px; line-height: 1.25; margin: 8px 0 0; font-weight: 800; }
.feature-main p { color: var(--muted); margin: 0; }
.feature-main .read { margin-top: auto; align-self: flex-start; background: var(--accent); color: var(--on-accent); padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.tagrow { display: flex; gap: 10px; align-items: center; }
.badge-dark { background: var(--text); color: var(--bg); font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.feature-list { display: flex; flex-direction: column; gap: 10px; }
.fitem {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text); flex: 1;
}
.fitem .no { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--accent); }
.fitem h4 { margin: 2px 0; font-size: 16px; }
.fitem p { margin: 0; font-size: 13px; color: var(--muted); }
.go { font-size: 18px; color: var(--muted); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { font: inherit; font-size: 13px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.lesson-rows { display: flex; flex-direction: column; }
.part-head { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 4px; padding: 0 16px; font-size: 17px; font-weight: 800; }
.part-head:first-child { margin-top: 4px; }
.part-head .muted { margin-left: auto; font-weight: 400; }
.lrow {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 18px; align-items: center; padding: 18px 16px; cursor: pointer;
  border: 1px solid transparent; border-bottom-color: var(--border); border-radius: 12px; text-decoration: none; color: var(--text);
}
.lrow .ep { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--muted); }
.lmeta { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); display: inline-block; }
.lrow h3 { margin: 3px 0; font-size: 18px; }
.lrow p { margin: 0; font-size: 13.5px; color: var(--muted); }
.lside { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.free { background: var(--ok-soft); color: var(--ok); padding: 1px 9px; border-radius: 999px; font-size: 12px; }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.topic {
  display: flex; flex-direction: column; gap: 2px; padding: 18px; min-height: 150px; cursor: pointer; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; position: relative; overflow: hidden;
}
.topic::after { content: ""; position: absolute; right: -24px; bottom: -24px; width: 84px; height: 84px; border-radius: 50%; background: var(--c); opacity: .18; }
.topic h3 { margin: 18px 0 0; font-size: 20px; }
.topic .en { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--c); }
.topic .count { margin-top: auto; font-size: 12.5px; color: var(--muted); }

.join { margin-top: 50px; text-align: center; padding: 50px 24px; border-radius: 22px; background: var(--cream); color: var(--ink); }
.join .kicker { color: #6f6e68; }
.join h2 { font-size: clamp(30px, 4vw, 46px); font-weight: 900; margin: 8px 0 10px; }
.join p { max-width: 560px; margin: 0 auto 24px; color: #5f5e5a; }
.join .hero-cta { justify-content: center; }
.foot { margin-top: 30px; text-align: center; font-size: 12px; color: var(--muted); }

/* ============================================================ 学习中心 */
#view-learn { grid-template-columns: minmax(0, 1fr) 420px; }
.lesson-main { overflow: auto; padding: 20px 30px 40px; }
.lesson-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.lesson-head h1 { font-size: 28px; font-weight: 900; margin: 2px 0 0; }
.lesson-nav { display: flex; gap: 8px; }
.chapters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.chapters::before { content: "本讲目录"; width: 100%; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.chapters:empty { display: none; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; color: var(--text); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .t { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-right: 4px; }
.lecture { max-width: 860px; }
.lecture h1 { display: none; }
.lecture h2 { font-size: 21px; margin: 36px 0 10px; padding-top: 6px; }
.lecture h2.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.lecture table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.lecture th, .lecture td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.lecture th { background: var(--surface-2); }
.lecture { font-size: 15.5px; line-height: 1.85; }
.lecture blockquote {
  margin: 16px 0; padding: 12px 18px; border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0;
  background: var(--accent-soft); color: var(--text);
}
.lecture blockquote p { margin: 4px 0; }
.lecture blockquote strong:first-child { color: var(--accent); }
.lecture pre { position: relative; background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: var(--radius); overflow: auto; font-size: 13px; line-height: 1.55; }
.lecture pre code { background: none; padding: 0; color: inherit; }
.lecture pre .try { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 10px; background: #534ab7; color: #fff; border: 0; border-radius: 6px; cursor: pointer; }

.terminal { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.term-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
#code {
  flex: 0 0 42%; resize: vertical; border: 0; outline: 0; padding: 12px 14px; font-family: var(--mono); font-size: 13px;
  background: var(--code-bg); color: var(--code-text); line-height: 1.55; tab-size: 4;
}
.term-actions { display: flex; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.output { flex: 1; overflow: auto; padding: 10px 14px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.output .err { color: var(--bad); }
.output .sys { color: var(--muted); }
.output img { max-width: 100%; background: #fff; border-radius: 6px; margin: 6px 0; display: block; }
.output .run-sep { border-top: 1px dashed var(--border); margin: 8px 0; }

/* 讲义：思维导图 */
.mindmap-wrap { overflow-x: auto; margin: 14px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.mindmap { display: block; }
.mindmap .mm-link { fill: none; stroke: var(--border); stroke-width: 1.6; }
.mindmap .mm-node rect { fill: var(--bg); stroke: var(--border); stroke-width: 1.2; }
.mindmap .mm-node text { font-size: 14px; fill: var(--text); }
.mindmap .mm-node.root rect { fill: var(--accent); stroke: var(--accent); }
.mindmap .mm-node.root text { fill: var(--on-accent); font-weight: 600; }
.mindmap .mm-node.leaf rect { fill: var(--surface-2); }
.mindmap .mm-node.linked { cursor: pointer; }
.mindmap .mm-node.linked rect { stroke-width: 2; }
.mindmap .mm-node.linked:hover rect { fill: var(--accent-soft); }

/* 讲义：互动组件 */
.widget { margin: 16px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.w-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.w-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.w-controls select { font: inherit; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 5px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.w-plots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.w-plots > div { height: 290px; }
.w-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; margin: 6px 0; }
.w-explain h4 { margin: 12px 0 4px; }
.w-explain p, .w-quiz p { margin: 6px 0; }
.w-quiz { margin-top: 10px; }

/* ============================================================ 分析助手 */
#view-analyze { grid-template-columns: minmax(0, 1fr) 280px; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow: auto; padding: 22px 30px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 880px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); padding: 9px 14px; border-radius: 14px 14px 4px 14px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); padding: 12px 16px; border-radius: 4px 14px 14px 14px; width: 100%; }
.msg.bot p { margin: 4px 0 8px; }
.msg.bot h4 { margin: 10px 0 6px; font-size: 14px; }
.msg.bot ul { margin: 4px 0 8px; padding-left: 20px; }
.msg .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.msg table { border-collapse: collapse; font-size: 13px; margin: 6px 0; width: 100%; }
.msg th, .msg td { border-bottom: 1px solid var(--border); padding: 5px 8px; text-align: right; white-space: nowrap; }
.msg th:first-child, .msg td:first-child { text-align: left; }
.msg th { color: var(--muted); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.msg .plot { width: 100%; height: 340px; }
.plots { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 8px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.callout { padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.info { background: var(--accent-soft); color: var(--accent); }
.decision { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.decision .step { padding: 3px 10px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.decision .step.final { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.decision .arrow { color: var(--muted); }
.kn { cursor: pointer; border-bottom: 1px dashed var(--accent); color: var(--accent); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.form-row select, .form-row input { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.form-row input { width: 90px; }
.form-row select:disabled { opacity: .7; }
.typing { color: var(--muted); font-size: 14px; }
.composer { display: flex; gap: 8px; padding: 12px 30px 18px; border-top: 1px solid var(--border); background: var(--bg); }
.composer input { flex: 1; font: inherit; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); outline: 0; }
.composer input:focus { border-color: var(--accent); }
.composer .btn { border-radius: 999px; padding: 6px 20px; }
.flow { border-left: 1px solid var(--border); padding: 4px 18px 20px; overflow: auto; background: var(--surface); }
.side-title { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); margin: 16px 0 8px; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { padding: 6px 0 6px 26px; position: relative; color: var(--muted); font-size: 14px; }
.steps li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.current { color: var(--accent); font-weight: 600; }
.steps li.current::before { border-color: var(--accent); background: var(--accent-soft); }
.related { display: flex; flex-direction: column; gap: 6px; }
.related .rel { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; cursor: pointer; background: var(--bg); }
.related .rel:hover { border-color: var(--accent); }
.related .rel b { display: block; font-size: 14px; }
.member { font-size: 13.5px; }
.member .member-status { margin-bottom: 6px; line-height: 1.6; }
.member details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin: 4px 0; }
.member .form-row { margin: 6px 0; }
.member .redeem-code { width: 100%; }
.redeem-code { font-family: var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.setting { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 10px; }
.setting select { font: inherit; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ============================================================ 知识图谱 */
#view-graph { grid-template-columns: minmax(0, 1fr) 320px; }
.graph-wrap { position: relative; min-height: 0; }
#graph { width: 100%; height: 100%; display: block; }
#graph .link { stroke: var(--border); stroke-width: 1.4; }
#graph .link.alt { stroke-dasharray: 4 4; }
#graph .link.hl { stroke: var(--accent); stroke-width: 2.6; }
#graph .col-title { font-family: var(--mono); font-size: 12px; fill: var(--muted); letter-spacing: .08em; }
#graph .node circle { stroke: var(--bg); stroke-width: 2; cursor: pointer; }
#graph .node text { font-size: 13px; fill: var(--text); pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
#graph .node.dim { opacity: .3; }
#graph .node.hl circle { stroke: var(--accent); stroke-width: 3.5; }
#graph .node.sel circle { stroke: var(--text); stroke-width: 3; }
.legend { position: absolute; left: 16px; bottom: 14px; display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); background: var(--surface); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: -1px; }
.node-card { border-left: 1px solid var(--border); padding: 20px; overflow: auto; background: var(--surface); }
.node-card h3 { margin: 0 0 4px; font-size: 20px; }
.node-card .cat { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.node-card .links { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.node-card .rels { margin-top: 18px; font-size: 13px; }
.node-card .rels div { margin: 4px 0; }

/* ============================================================ 窄屏 */
@media (max-width: 1200px) {
  #view-learn { grid-template-columns: minmax(0, 1fr); overflow: auto; }
  #view-learn .lesson-main { overflow: visible; }
  .terminal { border-left: 0; border-top: 1px solid var(--border); min-height: 460px; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .45); }
  #menu { display: inline-grid; }
  .hero { grid-template-columns: 1fr; padding: 32px 26px; }
  .hero-art { order: -1; }
  .art { max-width: 320px; }
  .feature-grid { grid-template-columns: 1fr; }
  #view-analyze { grid-template-columns: 1fr; }
  .flow { display: none; }
  #view-graph { grid-template-columns: 1fr; grid-template-rows: 62vh auto; overflow: auto; }
  .node-card { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .view.home.active { padding: 16px 16px 30px; }
  .marquee { margin: 20px -16px 6px !important; }
  .sec-head { grid-template-columns: 1fr; gap: 4px; }
  .sec-meta { text-align: left; }
  .sec-head h2 { font-size: 28px; }
  .lrow { grid-template-columns: 1fr; gap: 6px; padding: 14px 6px; }
  .lside { white-space: normal; }
  .lesson-main, .messages { padding: 14px 16px; }
  .composer { padding: 10px 16px; }
  .topbar { padding: 10px 16px; }
  .crumb #crumb-brand { display: none; }
  .w-plots { grid-template-columns: 1fr; }
  .hero h1 { font-size: 44px; }
}
