/* Lumina 全站样式。颜色都在 :root 里，改主题只改这里。 */
:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #5d6475;
  --line: #e4e0d6;
  --accent: #3b4cca;
  --accent-soft: #e9ebfb;
  --i-color: #1f9d6b;   /* 基向量 i 的颜色 */
  --j-color: #e0603a;   /* 基向量 j 的颜色 */
  --good: #1f9d6b;
  --bad: #c2410c;
  --grid: #d9d4c7;
  --grid-t: #9aa3d8;
  --radius: 14px;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --surface: #1c1f27;
    --ink: #e8e6e1;
    --muted: #a3a8b5;
    --line: #2d313c;
    --accent: #8d9bff;
    --accent-soft: #252a45;
    --i-color: #3ccf91;
    --j-color: #ff8a5c;
    --grid: #2b2f3a;
    --grid-t: #4c5592;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.35; font-weight: 700; }
h1 { font-size: clamp(30px, 5vw, 48px); margin: 0 0 16px; }
h2 { font-size: clamp(24px, 3.4vw, 32px); margin: 0 0 12px; }
h3 { font-size: 20px; margin: 24px 0 8px; }
p { margin: 0 0 14px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 720px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: 18px; font-size: 15px; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--ink); }

/* 按钮 */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 9px 18px; border-radius: 999px; font-size: 15px; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 首页 */
.hero { padding: 72px 0 48px; }
.hero .lead { font-size: 19px; color: var(--muted); max-width: 640px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.section { padding: 48px 0; border-top: 1px solid var(--line); }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 20px; counter-reset: flow; }
.flow li {
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; counter-increment: flow;
}
.flow li::before { content: counter(flow); display: block; font-family: var(--serif); font-size: 26px; color: var(--accent); }
.flow li b { display: block; margin-bottom: 4px; }
.flow li span { color: var(--muted); font-size: 15px; }
.flow { padding: 0; }

.acts { display: grid; gap: 14px; margin-top: 20px; }
.act { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.act h3 { margin: 0 0 8px; font-size: 18px; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; }
.lv {
  font-size: 14px; padding: 6px 12px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted);
}
.lv.open { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); text-decoration: none; font-weight: 600; }
.principles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.principles div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.principles b { display: block; margin-bottom: 4px; }
footer { padding: 40px 0 60px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }

/* 关卡页 */
.level-head { padding: 40px 0 8px; }
.level-head .kicker { color: var(--muted); font-size: 15px; }
.stepnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 0; padding: 0; }
.stepnav li { list-style: none; }
.stepnav a {
  display: block; font-size: 14px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; background: var(--surface);
}
.stepnav a.done { border-color: var(--good); color: var(--good); }
.step { padding: 36px 0; border-top: 1px solid var(--line); }
.step .tag { font-size: 14px; color: var(--accent); font-weight: 600; letter-spacing: .05em; }

.lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 22px; align-items: start; margin: 18px 0; }
@media (max-width: 760px) { .lab { grid-template-columns: 1fr; } }
.plane-box { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.plane-box svg { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }
.side { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card.task { border-left: 4px solid var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.feedback { min-height: 1.5em; font-size: 15px; margin-top: 8px; }
.feedback.good { color: var(--good); font-weight: 600; }
.feedback.bad { color: var(--bad); }

/* 矩阵显示与输入 */
.matrix { display: inline-flex; align-items: stretch; gap: 6px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 18px; vertical-align: middle; }
.matrix .br { width: 7px; border: 2px solid var(--ink); }
.matrix .br.l { border-right: none; border-radius: 4px 0 0 4px; }
.matrix .br.r { border-left: none; border-radius: 0 4px 4px 0; }
.matrix .cols { display: flex; gap: 12px; padding: 4px 0; }
.matrix .col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 2.6em; }
.matrix .col.i { color: var(--i-color); }
.matrix .col.j { color: var(--j-color); }
.matrix input {
  width: 3.4em; font: inherit; text-align: center; padding: 2px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: inherit;
}
.vec-in { width: 4em; font: inherit; text-align: center; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }

textarea.think {
  width: 100%; min-height: 80px; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); resize: vertical;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.reveal { display: none; }
.reveal.shown { display: block; animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.def {
  background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; margin: 14px 0;
  border-left: 4px solid var(--accent);
}
.def b:first-child { font-family: var(--serif); }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices button {
  font: inherit; font-size: 15px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.choices button.sel { border-color: var(--accent); background: var(--accent-soft); }
.cases { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.next-level { background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius); padding: 18px 20px; margin-top: 18px; }

/* AI 导师面板 */
.tutor-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tutor-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 100px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 12px 40px rgba(0,0,0,.22); display: none; flex-direction: column; overflow: hidden;
}
.tutor-panel.open { display: flex; }
@media (max-width: 520px) { .tutor-panel { right: 16px; bottom: 16px; } .tutor-fab { right: 16px; bottom: 16px; } }
.tutor-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.tutor-head b { font-family: var(--serif); }
.tutor-head button { margin-left: auto; border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.tutor-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.msg { padding: 9px 12px; border-radius: 12px; max-width: 90%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.msg.note { align-self: center; color: var(--muted); font-size: 13px; text-align: center; }
.tutor-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.tutor-input textarea { flex: 1; min-height: 44px; max-height: 120px; font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); resize: none; }

/* 长公式在手机上横向滚动，不撑破页面 */
.def, .card { overflow-x: auto; }
p { overflow-wrap: anywhere; }
.katex-display { overflow-x: auto; overflow-y: hidden; }
