:root {
  --sky: #e8f4ff;
  --sky-deep: #cfe7fb;
  --line: #b9d4ea;
  --ink: #16304a;
  --ink-soft: #4a6b88;
  --accent: #2069b0;
  --card: rgba(255,255,255,.80);
  --glass-brd: rgba(255,255,255,.66);
  --glass-sh: 0 12px 32px rgba(22,58,96,.16), inset 0 1px 0 rgba(255,255,255,.55);
  --s1: #5b93c8;   /* 小学 */
  --s2: #3a7ab8;   /* 初中 */
  --s3: #235e96;   /* 高中 */
  --fml: #7a5fb3;  /* 公式 */
  --exm: #b0712a;  /* 例题 */
  --pre: #26805a;  /* 进阶 */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "幼圆", "YouYuan", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
  color: var(--ink);
  position: relative;
  background: linear-gradient(160deg, #dcecfb 0%, #f2f8fe 48%, #cfe3f8 100%);
  display: flex;
  flex-direction: column;
}
.chrome {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--glass-brd);
}
footer.chrome { border-bottom: 0; border-top: 1px solid var(--glass-brd); color: var(--ink-soft); font-size: 11px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .5px; }
.tag { font-size: 11px; color: var(--ink-soft); background: var(--sky); border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #d3d3d3; }
.dot.ok { background: #2fa36b; }
.controls { display: flex; align-items: center; gap: 10px; font-size: 12px; }
input, select { font-family: inherit; font-size: 12px; padding: 3px 8px; border: 1px solid rgba(255,255,255,.7); border-radius: 6px; background: rgba(255,255,255,.66); color: var(--ink); outline: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
input:focus { border-color: var(--accent); }
#q { width: 240px; }
.state { color: var(--ink-soft); }

main { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 10px; }
.panel {
  width: 320px; flex: none; display: flex; flex-direction: column;
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--glass-brd); border-radius: 12px;
  overflow: hidden; box-shadow: var(--glass-sh);
}
.panel-title {
  padding: 7px 12px; border-bottom: 1px solid var(--glass-brd); font-weight: 600; font-size: 13px;
  background: rgba(255,255,255,.42);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.filters { padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--ink-soft); word-break: break-all; }
/* 两级标签：体系（课内/奥数/速算） × 学段（小学/初中/高中）。
   单行平铺在 320px 侧栏里必然溢出，所以按维度分行，各自可换行兜底。 */
.stages { display: flex; flex-direction: column; gap: 3px; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.tab-row { display: flex; align-items: center; gap: 3px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tab-row::-webkit-scrollbar { display: none; }
.tab-lab { font-size: 10px; color: var(--ink-soft); flex: 0 0 22px; letter-spacing: 0; }
.stage-tab { cursor: pointer; font-size: 11.5px; padding: 1px 7px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink-soft); user-select: none;
  white-space: nowrap; flex: 0 0 auto; line-height: 1.6; }
.stage-tab:hover { border-color: var(--accent); color: var(--accent); }
.stage-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.stage-tab .n { opacity: .72; margin-left: 3px; font-size: 11px; }
.stage-tab.track-on:not(.on) { border-color: #b9d6ef; background: #f3f9ff; }
.stage-tab.dim { opacity: .42; }
.tree { list-style: none; margin: 0; padding: 4px 6px 10px; overflow: auto; flex: 1; }
.tree .module { margin: 2px 0; }
.tree .m-row { display: flex; align-items: center; gap: 5px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--ink); }
.tree .stage-h { display: flex; align-items: baseline; gap: 6px; margin: 8px 0 3px; padding: 2px 6px;
  font-size: 11.5px; font-weight: 500; color: var(--accent); border-bottom: 1px dashed var(--line); }
.tree .stage-h .n { font-size: 10px; color: var(--ink-soft); font-weight: 400; }
.tree .stage-h .tk { margin-left: auto; }
.tree .tk { font-size: 9.5px; line-height: 1.5; padding: 0 5px; border-radius: 7px;
  border: 1px solid #c4d8e8; color: #557a9c; background: rgba(234,243,251,.8); flex: none; }
.tree .tk.oly { border-color: #ddd0b8; color: #8f7448; background: rgba(250,245,235,.8); }
.tree .tk.spd { border-color: #bfd8cb; color: #4a7d64; background: rgba(240,249,244,.8); }
.tree .m-row:hover { background: var(--sky); }
/* 体系色条：模块行左侧 3px 竖条，一眼分辨课内/奥数/速算 */
.tree .module { margin: 2px 0; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; }
.tree .module.tk-oly { border-left-color: #c8a86a; }
.tree .module.tk-spd { border-left-color: #6fae8c; }
.tree .caret { font-size: 10px; color: var(--ink-soft); width: 10px; display: inline-block; }
.tree .m-count { margin-left: auto; font-size: 10px; color: var(--ink-soft); font-weight: 400; }
.tree ul { list-style: none; margin: 0; padding: 0 0 4px 18px; }
.tree ul.hide { display: none; }
.tree li.kp { padding: 3px 7px; border-radius: 6px; cursor: pointer; line-height: 1.5; color: #2a4763; }
.tree li.kp:hover { background: var(--sky); }
.tree li.kp.active { background: var(--sky-deep); font-weight: 500; }
.tree li.kp .kd { font-size: 10px; color: var(--ink-soft); margin-left: 4px; }

.right { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--glass-brd); border-radius: 12px;
  overflow: hidden; box-shadow: var(--glass-sh);
}
.card-title {
  padding: 7px 14px; border-bottom: 1px solid var(--glass-brd); font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between; gap: 10px;
  background: rgba(255,255,255,.42);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card-title span { font-weight: 400; color: var(--ink-soft); font-size: 11px; }

.detail { flex: 1; overflow: auto; padding: 14px 18px 20px; }
.detail h2 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: .3px; }
.crumb { font-size: 11px; color: var(--ink-soft); margin-bottom: 10px; }
.crumb a { color: var(--accent); text-decoration: none; cursor: pointer; }
.crumb a:hover { text-decoration: underline; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; align-items: center; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(232,244,255,.7); color: var(--ink-soft); }
.chip.kp-id { border: 0; background: none; padding: 0; font-size: 10.5px; color: var(--ink-soft); opacity: .75; letter-spacing: .3px; }
.sec { margin: 12px 0 0; }
.sec > .sec-h, #detail > .sec-h { font-size: 12px; font-weight: 500; color: var(--accent); border-left: 3px solid var(--accent); padding-left: 7px; margin: 18px 0 7px; display: flex; justify-content: space-between; gap: 8px; }
#detail > .sec-h:first-of-type { margin-top: 6px; }
.sec > .sec-h em, #detail > .sec-h em { font-style: normal; color: var(--ink-soft); font-weight: 400; font-size: 11px; }
.row { border: 1px solid rgba(255,255,255,.55); border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; background: rgba(255,255,255,.42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 6px; }
.rows .row { margin-bottom: 0; }
.row .t { font-weight: 500; margin-bottom: 2px; }
.row .t small { font-weight: 400; color: var(--ink-soft); margin-left: 6px; font-size: 10px; }
.row .e { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; color: #1b4a6f; background: #f2f8ff; border-radius: 5px; padding: 3px 7px; margin: 4px 0; word-break: break-word; }
.row .c { font-size: 11.5px; color: var(--ink-soft); line-height: 1.6; }
.row ol { margin: 3px 0 0; padding-left: 18px; }
.row ol li { font-size: 12px; line-height: 1.65; margin-bottom: 2px; }
.row .ans { font-size: 12px; margin-top: 4px; color: #1b5c3a; }
.row .pit { font-size: 11.5px; margin-top: 3px; color: #9a4b1f; }
.row .hint { font-size: 11.5px; margin-top: 3px; color: #7a5fb3; }
.tag-src { font-size: 10px; border-radius: 8px; padding: 0 6px; border: 1px solid var(--line); color: var(--ink-soft); margin-left: 5px; }
.tag-src.cloud { border-color: #d8c7f0; color: var(--fml); }
/* 变式 / 延伸 分级标记 */
.lv-tag { font-size: 10px; border-radius: 8px; padding: 0 6px; margin-left: 6px;
  border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.lv-tag.var { border-color: #cfc0e4; color: #6f5aa0; background: rgba(246,242,252,.75); }
.lv-tag.ext { border-color: #e0d0b4; color: #97662e; background: rgba(253,248,239,.75); }
.link-list { display: flex; flex-wrap: wrap; gap: 6px; }
.link-pill { cursor: pointer; font-size: 11.5px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.link-pill:hover { background: var(--sky); }
.link-pill.pre { border-color: #bfe3d0; background: #f2fbf6; }
.empty { color: var(--ink-soft); padding: 22px 0; }

/* ---------- 空态总览面板 ---------- */
.ov { padding: 4px 2px; }
.ov-lead { font-size: 13px; color: var(--ink); margin: 0 0 12px; line-height: 1.7; }
.ov-lead b { color: var(--accent); font-weight: 600; }
.ov-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ov-stat {
  background: rgba(255,255,255,.55); border: 1px solid var(--glass-brd); border-radius: 10px;
  padding: 10px 8px; text-align: center;
}
.ov-stat b { display: block; font-size: 22px; font-weight: 600; color: var(--accent); line-height: 1.2; }
.ov-stat span { font-size: 11px; color: var(--ink-soft); }
.ov-sub { font-size: 11px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 6px; letter-spacing: .5px; }
.ov-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 6px; }
.ov-bar i { display: block; height: 100%; }
.ov-bar-lab { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); margin-bottom: 10px; }
.ov-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.ov-leg {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 3px 10px;
  background: rgba(255,255,255,.5); cursor: pointer;
}
.ov-leg:hover { border-color: var(--accent); color: var(--accent); }
.ov-leg i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ov-tip { font-size: 11.5px; color: var(--ink-soft); margin: 14px 0 0; line-height: 1.7; }
body.is-embed .chrome, body.is-embed footer.chrome { display: none; }
/* embed 保留手稿底图（此前被 #fff 盖掉，Agent 控制台 iframe 里看不到背景） */
body.is-embed main { padding: 8px; }
body.is-embed .panel { width: 290px; }
a { color: var(--accent); }
.muted { color: var(--ink-soft); }

/* ---------- 知识点配图（SVG 现场绘制） ---------- */
.fig-host {
  background: linear-gradient(180deg, #fbfdff 0%, #f4faff 100%);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px 6px; margin: 2px 0 10px;
}
.fig-svg { display: block; width: 100%; height: auto; max-width: 460px; margin: 0 auto; }
.example-row .fig-host { max-width: 520px; margin: 9px 0 11px; }
.fig-wrap .fig-cap {
  font-size: 11.5px; color: var(--ink-soft); line-height: 1.7;
  border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 5px;
}
body.is-embed .fig-svg { max-width: 100%; max-height: 220px; }

/* ---------- 学习详情与基础练习 ---------- */
button { font-family: inherit; }
.learning-hero {
  margin: 4px 0 12px; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(232,244,255,.94), rgba(255,255,255,.72));
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.learning-label { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: .08em; }
.learning-hero > p { margin: 6px 0 10px; font-size: 13px; line-height: 1.85; }
.learning-hero .review-note { margin: 8px 0 0; color: var(--ink-soft); font-size: 11.5px; }
.learning-progress { font-size: 11.5px; color: var(--ink-soft); }
.learning-section { margin-top: 16px; }
.mastery-list { display: grid; gap: 6px; }
.mastery-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.5);
  line-height: 1.65; cursor: pointer;
}
.mastery-item input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.example-row { padding: 12px 13px; margin-bottom: 8px; }
.example-row .t { line-height: 1.7; }
.example-meta { margin: 4px 0 9px; font-size: 10.5px; color: var(--ink-soft); }
.practice-actions, .wrong-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn {
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 11px;
  background: #fff; color: var(--ink); cursor: pointer; font-size: 12px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.subtle { background: rgba(255,255,255,.62); color: var(--ink-soft); }
.answer-form { display: flex; gap: 7px; margin-top: 8px; }
.answer-input {
  flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: rgba(255,255,255,.86); color: var(--ink); font-size: 13px;
}
.answer-input:focus { border-color: var(--accent); outline: 2px solid rgba(32,105,176,.14); }
.answer-feedback { min-height: 18px; margin-top: 6px; font-size: 12px; line-height: 1.6; }
.answer-feedback.ok { color: #1d6a43; }
.answer-feedback.warn { color: #9a4b1f; }
.hint-box { margin-top: 8px; padding: 7px 10px; border-left: 3px solid var(--fml); background: rgba(246,242,252,.72); border-radius: 0 7px 7px 0; }
.hint-box p { margin: 3px 0; color: #6b568f; font-size: 12px; line-height: 1.65; }
.analysis-box { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.5); overflow: hidden; }
.analysis-box summary { cursor: pointer; padding: 7px 10px; color: var(--accent); font-size: 12px; user-select: none; }
.analysis-body { padding: 4px 12px 10px; border-top: 1px dashed var(--line); }
.self-check { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.wrong-card { margin-top: 7px; padding: 10px 12px; border: 1px solid #e4c9b4; border-radius: 9px; background: rgba(255,249,244,.78); }
.wrong-stem { font-weight: 500; line-height: 1.65; }
.wrong-detail { margin-top: 5px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.65; }
.tree-toggle, .panel-scrim { display: none; }

@media (max-width: 1100px) {
  .panel { width: 280px; }
  .rows { grid-template-columns: 1fr; }
  .ov-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  main { padding-top: 52px; }
  .tree-toggle {
    display: inline-flex; position: fixed; left: 12px; top: 60px; z-index: 45;
    align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 8px;
    padding: 6px 11px; background: rgba(255,255,255,.9); color: var(--accent);
    box-shadow: 0 6px 18px rgba(22,58,96,.12); cursor: pointer;
  }
  .panel-scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(16,42,66,.28); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  body.panel-open .panel-scrim { opacity: 1; pointer-events: auto; }
  .panel {
    position: fixed; z-index: 50; top: 58px; left: 10px; bottom: 10px;
    width: min(340px, calc(100vw - 54px)); transform: translateX(-120%);
    transition: transform .2s ease; box-shadow: 0 18px 50px rgba(16,42,66,.24);
  }
  body.panel-open .panel { transform: translateX(0); }
  .right { width: 100%; }
  .brand .tag, .state { display: none; }
  .controls #q { width: min(52vw, 240px); }
  .detail { padding: 12px 13px 18px; }
  body.is-embed .panel { width: min(340px, calc(100vw - 54px)); }
}

@media (max-width: 600px) {
  .chrome { padding: 8px 10px; }
  .brand { gap: 6px; }
  .brand h1 { font-size: 14px; }
  main { padding: 48px 6px 6px; gap: 6px; }
  .tree-toggle { top: 55px; left: 8px; }
  .panel { top: 53px; left: 6px; bottom: 6px; }
  .card-title { padding: 7px 10px; }
  .detail { padding: 11px 10px 16px; }
  .detail h2 { font-size: 19px; }
  .learning-hero { padding: 12px; }
  .learning-hero > p { font-size: 12.5px; }
  .answer-form { flex-direction: column; }
  .answer-form .btn { width: 100%; }
  .example-row { padding: 10px; }
  .mastery-item { padding: 7px 8px; }
  footer.chrome { display: none; }
}
