/* =========================================================================
 * MathStudio — 样式表
 * 纸张质感 + 靛蓝强调色，专注数学阅读与轻量交互
 * ========================================================================= */
:root {
  --bg: #f4f0e6;
  --bg-2: #efe9dc;
  --paper: #fffdf8;
  --paper-2: #faf6ec;
  --ink: #1d2733;
  --ink-soft: #364152;
  --muted: #6b7280;
  --muted-2: #94a3b8;
  --line: rgba(29, 39, 51, 0.11);
  --line-strong: rgba(29, 39, 51, 0.2);
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --rose: #be123c;
  --shadow-sm: 0 1px 2px rgba(29, 39, 51, 0.04);
  --shadow: 0 12px 32px rgba(29, 39, 51, 0.07), 0 2px 6px rgba(29, 39, 51, 0.04);
  --shadow-lg: 0 28px 70px rgba(29, 39, 51, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --font-ui: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Cambria", "Songti SC", "SimSun", serif;
  --font-math: "Cambria Math", "STIX Two Math", "Cambria", "Times New Roman", "SimSun", serif;
  --font-mono: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 8% -8%, rgba(99, 102, 241, 0.10), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(13, 148, 136, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, #f6f2e9 45%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(29, 39, 51, 0.05) 0.7px, transparent 0.7px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 60%);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: rgba(79, 70, 229, 0.2); }

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1460px;
  margin: 0 auto;
  padding: 18px 30px 46px;
}

/* ------------------------------ 顶栏 ------------------------------ */
.topbar {
  position: sticky;
  top: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: rgba(255, 253, 248, 0.84);
  border: 1px solid rgba(29, 39, 51, 0.09);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, #312e81, #4f46e5 55%, #0f766e);
  color: #fff;
  font-family: var(--font-display);
  font-size: 25px;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; white-space: nowrap; }

.main-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav-btn {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: 0.18s ease;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--ink); background: rgba(29, 39, 51, 0.05); }
.nav-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #1e293b, #334155);
  box-shadow: 0 6px 16px rgba(30, 41, 59, 0.22);
}
.top-meta { flex-shrink: 0; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 5px 10px; border-radius: 999px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16); }

/* ------------------------------ 模块与卡片 ------------------------------ */
.main { margin-top: 26px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--paper);
  border: 1px solid rgba(29, 39, 51, 0.09);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 700;
}
.card h2 { margin: 2px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.head-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); max-width: 420px; text-align: right; }

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13.5px;
  transition: 0.18s ease;
  white-space: nowrap;
}
.btn.primary {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(79, 70, 229, 0.34); }
.btn.ghost {
  background: var(--paper-2);
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn.ghost:hover { background: #f3eee2; border-color: var(--line-strong); }
.btn.small { padding: 6px 12px; font-size: 12px; border-radius: 9px; }
.btn.wide { width: 100%; margin-top: 16px; padding: 12px; }

/* ------------------------------ 高数顶部 ------------------------------ */
.calc-topline { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: rgba(239, 233, 220, 0.82);
  border: 1px solid rgba(29, 39, 51, 0.07);
  border-radius: 13px;
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 7px 15px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: 0.18s ease;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(29, 39, 51, 0.08); }
.segmented.mini { padding: 3px; border-radius: 10px; }
.segmented.mini .seg-btn { padding: 4px 10px; font-size: 11.5px; border-radius: 7px; }
.example-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.example-chip {
  border: 1px dashed rgba(79, 70, 229, 0.3);
  background: rgba(255, 253, 248, 0.7);
  color: #4338ca;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  transition: 0.18s ease;
}
.example-chip:hover { background: #eef2ff; border-style: solid; transform: translateY(-1px); }

/* ------------------------------ 公式输入 ------------------------------ */
.formula-card { padding: 22px 24px 18px; }
.math-input-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.input-prefix {
  font-family: var(--font-math);
  font-size: 26px;
  color: var(--muted);
  min-width: 34px;
  text-align: right;
  flex-shrink: 0;
}
.input-shell {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 13px;
  background: #fff;
  transition: 0.18s ease;
  box-shadow: inset 0 1px 2px rgba(29, 39, 51, 0.03);
}
.input-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }
.math-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 15.5px;
  letter-spacing: 0.01em;
}
.math-input::placeholder { color: #a4adba; font-family: var(--font-ui); font-size: 13.5px; }

.math-preview {
  margin-top: 12px;
  min-height: 86px;
  display: flex;
  align-items: center;
  padding: 14px 22px;
  border-radius: 15px;
  border: 1px solid rgba(29, 39, 51, 0.06);
  background:
    linear-gradient(rgba(250, 246, 236, 0.72), rgba(250, 246, 236, 0.72)),
    radial-gradient(rgba(79, 70, 229, 0.12) 0.8px, transparent 0.8px);
  background-size: auto, 18px 18px;
  overflow-x: auto;
  font-size: clamp(21px, 2.4vw, 30px);
}
.math-preview .math { font-size: 1.15em; }
.preview-placeholder { font-size: 13.5px; color: var(--muted-2); font-family: var(--font-ui); }
.preview-raw { font-family: var(--font-mono); font-size: 15px; color: var(--muted); white-space: pre-wrap; }

.palette { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.palette-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.palette-label {
  width: 60px; flex-shrink: 0;
  font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted-2);
  text-transform: uppercase; font-weight: 700;
}
.palette-btns { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.sym-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  font-family: var(--font-math);
  font-size: 15px;
  color: var(--ink-soft);
  transition: 0.15s ease;
}
.sym-btn:hover { background: #eef2ff; border-color: rgba(79, 70, 229, 0.35); color: #4338ca; transform: translateY(-1px); }
.sym-btn:active { transform: translateY(0); }

.calc-error, .la-error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  font-size: 13px;
}

/* ------------------------------ 绘图区 ------------------------------ */
.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(330px, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.plot-card { padding: 18px 18px 14px; }
.plot-head { padding: 2px 4px 0; }
.plot-stage {
  position: relative;
  height: 438px;
  margin-top: 12px;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid rgba(29, 39, 51, 0.07);
  background: #fff;
}
.plot-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.plot-stage canvas#calc-canvas-3d { cursor: grab; }
.plot-stage canvas#calc-canvas-3d:active { cursor: grabbing; }
.plot-stage canvas#calc-canvas-complex3d { cursor: grab; }
.plot-stage canvas#calc-canvas-complex3d:active { cursor: grabbing; }
.plot-badge {
  position: absolute;
  top: 12px; left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(238, 242, 255, 0.92);
  color: #4338ca;
  border: 1px solid rgba(79, 70, 229, 0.18);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.plot-badge.badge-def { background: rgba(236, 253, 245, 0.94); color: #047857; border-color: #a7f3d0; }
.plot-badge.badge-indef { background: rgba(238, 242, 255, 0.94); color: #4338ca; }
.plot-badge.badge-func { background: rgba(248, 250, 252, 0.94); color: #475569; border-color: #e2e8f0; }
.plot-badge.badge-3d { background: rgba(245, 243, 255, 0.94); color: #6d28d9; border-color: #ddd6fe; }
.plot-badge.badge-deriv { background: rgba(240, 253, 244, 0.94); color: #047857; border-color: #bbf7d0; }
.plot-badge.badge-complex { background: rgba(255, 247, 237, 0.94); color: #c2410c; border-color: #fed7aa; }

.range-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 4px 0; font-size: 12px; color: var(--muted); }
.mini-field { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mini-field input, .mini-field select {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 8px;
  padding: 5px 8px;
  width: 72px;
  font-size: 12px;
  outline: 0;
}
.mini-field input:focus, .mini-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.mini-field select { width: auto; }
.tilde { color: var(--muted-2); }
.check-field { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check-field input { accent-color: var(--accent); }
.range-hint { margin-left: auto; color: var(--muted-2); font-size: 11.5px; }

/* ------------------------------ 解析面板 ------------------------------ */
.insight-card { padding: 20px 20px 22px; }
.insight-body { margin-top: 14px; }
.insight-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 12px; padding: 42px 16px;
  color: var(--muted);
  font-size: 13px;
}
.insight-empty p { margin: 0; max-width: 260px; }
.empty-icon {
  width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef2ff, #f0fdfa);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 25px;
}
.insight-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  background: #f1f5f9; color: #475569;
}
.tag-green { background: #ecfdf5; color: #047857; }
.tag-blue { background: #eef2ff; color: #4338ca; }
.tag-purple { background: #f5f3ff; color: #6d28d9; }
.tag-warn { background: #fff7ed; color: #b45309; }
.tag-soft { background: #f8fafc; color: #64748b; font-weight: 600; }

.insight-block { margin-bottom: 14px; }
.block-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; margin-bottom: 6px; }
.insight-formula {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid rgba(29, 39, 51, 0.05);
  font-size: 18px;
  overflow-x: auto;
}
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.metric {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fbf8f1;
  border: 1px solid rgba(29, 39, 51, 0.06);
  display: flex; flex-direction: column; gap: 3px;
}
.metric span { font-size: 11px; color: var(--muted); }
.metric strong { font-family: var(--font-display); font-size: 23px; font-weight: 700; line-height: 1.2; }
.metric-accent { background: linear-gradient(135deg, #eef2ff, #f5f3ff); border-color: rgba(79, 70, 229, 0.14); }
.metric-accent strong { color: #3730a3; }
.small-formula { font-size: 14px !important; line-height: 1.9; }
.complex-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.complex-item {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: 10px;
  background: #fbf8f1; border: 1px solid var(--line);
}
.complex-name { font-family: var(--font-math); font-size: 13px; color: var(--muted); min-width: 26px; }
.complex-value { font-family: var(--font-math); font-size: 17px; color: var(--ink); }
.complex-meta { margin-left: auto; font-size: 11px; color: var(--muted-2); }
.insight-note { margin: 8px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.insight-warning {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 12px; line-height: 1.6;
}
.verify-row {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  font-size: 12px; line-height: 1.55;
}
.verify-row.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.verify-row.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.verify-dot {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 11px; font-weight: 700; background: currentColor;
}
.verify-dot { color: #16a34a; }
.verify-dot span { color: #fff; }
.verify-row.ok .verify-dot { color: #16a34a; }
.verify-row.warn .verify-dot { color: #ea580c; }
.insight-tip {
  display: flex; gap: 11px; margin-top: 14px; padding: 13px 14px;
  border-radius: 12px; background: #f8fafc; border: 1px dashed #cbd5e1;
  font-size: 12px; color: var(--muted);
}
.insight-tip b { display: block; color: var(--ink-soft); font-size: 12.5px; margin-bottom: 2px; }
.insight-tip p { margin: 0; line-height: 1.6; }
.tip-icon {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: #eef2ff; color: #4338ca; font-family: var(--font-math); font-size: 16px;
}
.muted { color: var(--muted); }
.small { font-size: 11.5px; }

/* ------------------------------ 公式大纲 ------------------------------ */
.formula-outline { margin-top: 18px; padding: 24px; }
.outline-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.outline-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.outline-search {
  position: relative;
  display: flex; align-items: center;
  min-width: 280px;
}
.outline-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); font-size: 16px;
}
.outline-search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 10px;
  padding: 9px 12px 9px 34px;
  font-size: 13px;
  outline: 0;
  transition: 0.18s ease;
}
.outline-search input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.09); }
.outline-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 8px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: 0.16s ease;
}
.chip span { font-size: 10px; color: var(--muted-2); background: rgba(29, 39, 51, 0.05); padding: 1px 5px; border-radius: 999px; }
.chip:hover { border-color: rgba(79, 70, 229, 0.35); color: #4338ca; }
.chip.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.chip.active span { background: rgba(255, 255, 255, 0.16); color: #e2e8f0; }

.outline-categories { margin-top: 8px; }
.formula-cat { margin-top: 22px; }
.cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cat-head h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.cat-count { font-size: 11px; color: var(--muted-2); }
.formula-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.formula-item {
  padding: 13px 15px 12px;
  border-radius: 13px;
  background: #fbf8f1;
  border: 1px solid rgba(29, 39, 51, 0.07);
  transition: 0.18s ease;
  min-width: 0;
}
.formula-item.insertable { cursor: pointer; }
.formula-item.insertable:hover {
  border-color: rgba(79, 70, 229, 0.35);
  background: #f8f7ff;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.08);
}
.formula-item.insertable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.formula-name { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; margin-bottom: 5px; }
.formula-math { font-size: 17px; line-height: 1.6; overflow-x: auto; padding: 2px 0; }
.formula-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
.outline-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.tex-fallback { font-family: var(--font-mono); color: var(--rose); font-size: 13px; }

/* ------------------------------ 线代 ------------------------------ */
.module-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 28px 30px;
  border-radius: 24px;
  background:
    radial-gradient(700px 300px at 85% 10%, rgba(45, 212, 191, 0.22), transparent 70%),
    linear-gradient(135deg, #191735 0%, #26225a 52%, #0f4c46 100%);
  color: #f8fafc;
  box-shadow: 0 22px 55px rgba(30, 27, 75, 0.25);
}
.module-hero.compact { padding: 22px 26px; }
.module-hero .eyebrow { color: #a5b4fc; }
.module-hero h2 { margin: 4px 0 6px; font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -0.01em; }
.module-hero p { margin: 0; max-width: 720px; font-size: 13px; color: rgba(241, 245, 249, 0.75); }
.hero-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.hero-chips span {
  font-size: 11px; color: #dbeafe;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.la-toolbar { margin-top: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.la-dim-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; flex: 1; }
.dim-group { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dim-label { font-weight: 700; color: var(--ink-soft); }
.dim-sub { color: var(--muted-2); font-size: 11px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.step-btn { border: 0; background: transparent; width: 25px; height: 27px; color: var(--muted); font-size: 15px; line-height: 1; }
.step-btn:hover { background: #eef2ff; color: #4338ca; }
.step-value { min-width: 24px; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.dim-hint { font-size: 11px; color: var(--muted-2); margin-left: auto; }

.la-grid { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr); gap: 18px; margin-top: 18px; align-items: start; }
.la-editor-card, .la-result-card { padding: 20px 22px; }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.la-editors { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 18px; }
.matrix-editor { min-width: 0; }
.editor-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.matrix-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.matrix-dims { font-size: 11px; color: var(--muted-2); }
.matrix-note { font-size: 10.5px; color: var(--muted-2); }
.matrix-input-wrap { display: flex; align-items: stretch; gap: 2px; overflow-x: auto; padding: 2px 0; }
.editor-bracket {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 0.9;
  color: var(--muted);
  align-self: stretch;
  display: flex;
  align-items: center;
  transform: scaleY(1.2);
  transform-origin: center;
}
.matrix-input-table { border-collapse: separate; border-spacing: 4px; }
.matrix-cell {
  width: 52px; height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: 0;
  transition: 0.15s ease;
}
.matrix-cell:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.matrix-cell.invalid { border-color: #fda4af; background: #fff1f2; }
.editor-hint { margin-top: 14px; font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.inline-demo {
  border: 0; background: #eef2ff; color: #4338ca;
  border-radius: 6px; padding: 1px 6px;
  font-size: 11.5px; font-weight: 600;
}
.inline-demo:hover { background: #e0e7ff; }
.la-result-body { margin-top: 14px; }
.result-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dim-note { font-size: 11.5px; color: var(--muted); }
.matrix-flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0; overflow-x: auto; padding-bottom: 4px; }
.flow-op { font-family: var(--font-math); font-size: 22px; color: var(--muted); padding: 0 2px; }
.formula-inline {
  font-family: var(--font-math);
  font-size: 16px;
  padding: 10px 12px;
  background: var(--paper-2);
  border-radius: 10px;
  margin: 8px 0;
}
.result-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 12px; }
.result-kicker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.result-big { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.result-big sup { font-size: 0.48em; vertical-align: super; letter-spacing: 0; }
.result-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.65; }
.result-matrix { overflow-x: auto; max-width: 100%; }
.verify-matrix { margin: 12px 0; padding: 12px 14px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; overflow-x: auto; }
.verify-label { font-size: 11px; color: #166534; font-weight: 700; margin-bottom: 6px; }
.rank-card {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 12px 20px; border-radius: 14px;
  background: linear-gradient(135deg, #eef2ff, #f0fdfa);
  border: 1px solid rgba(79, 70, 229, 0.14);
}
.rank-card span { font-size: 10.5px; color: var(--muted); }
.rank-card strong { font-family: var(--font-display); font-size: 27px; color: #3730a3; line-height: 1.1; }

.vector-strip { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0; }
.vector-item { padding: 8px 10px; border-radius: 10px; background: #fbf8f1; border: 1px solid var(--line); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.mini-card { padding: 13px 14px; border-radius: 12px; background: #fbf8f1; border: 1px solid var(--line); }
.mini-card h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--ink-soft); }
.mini-card p { margin: 4px 0; font-size: 12px; }
.basis-list { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.basis-item { padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.general-solution { font-family: var(--font-math); font-size: 14px; }
.relation-box { padding: 12px 14px; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; margin-top: 12px; }
.relation-formula { font-family: var(--font-math); font-size: 17px; }

/* LaTeX 矩阵（线代输出） */
.la-matrix { display: inline-flex; align-items: stretch; gap: 2px; vertical-align: middle; max-width: 100%; }
.la-bracket {
  width: 9px;
  font-size: 0;
  color: transparent;
  border: 1.7px solid var(--ink-soft);
  border-right: 0;
  border-radius: 5px 0 0 5px;
  flex-shrink: 0;
}
.la-bracket-r { border: 1.7px solid var(--ink-soft); border-left: 0; border-radius: 0 5px 5px 0; }
.la-matrix-table { border-collapse: collapse; }
.la-matrix-table td { padding: 2px 7px; text-align: center; font-family: var(--font-math); font-size: 14.5px; vertical-align: middle; }
.la-cell { display: inline-block; min-width: 16px; }
.la-aug-sep { border-left: 1px dashed #cbd5e1; }
.frac-cell { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; font-size: 0.92em; }
.frac-cell-n { border-bottom: 1px solid currentColor; padding: 0 2px; }
.frac-cell-d { padding: 0 2px; }
.la-vector { display: inline-flex; align-items: center; gap: 4px; }
.la-matrix-name { font-family: var(--font-math); font-size: 15px; }
.la-matrix-labeled { display: inline-flex; align-items: center; gap: 6px; }

/* 推导步骤 */
.derivation { margin-top: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fdfbf5; overflow: hidden; }
.derivation summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  background: #f8f4ea;
  border-bottom: 1px solid transparent;
}
.derivation summary::-webkit-details-marker { display: none; }
.derivation[open] summary { border-bottom-color: var(--line); }
.derivation summary::before { content: "▸"; margin-right: 7px; color: var(--muted); transition: 0.18s ease; }
.derivation[open] summary::before { transform: rotate(90deg); }
.steps-count { font-size: 10.5px; color: var(--muted-2); font-weight: 600; background: rgba(29, 39, 51, 0.05); padding: 2px 7px; border-radius: 999px; }
.steps-body { padding: 6px 14px 12px; }
.step { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed rgba(29, 39, 51, 0.08); }
.step:last-child { border-bottom: 0; }
.step-num {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: #eef2ff; color: #4338ca;
  font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; margin-top: 2px;
}
.step-main { min-width: 0; overflow-x: auto; }
.step-text { margin: 0 0 6px; font-size: 11.8px; color: var(--ink-soft); line-height: 1.6; }
.entry-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.entry-list li { display: flex; gap: 10px; align-items: baseline; font-size: 12px; flex-wrap: wrap; }
.entry-label { flex-shrink: 0; font-family: var(--font-math); color: #4338ca; min-width: 30px; }
.entry-work { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); word-break: break-word; }

/* ------------------------------ 数学排版（自定义） ------------------------------ */
.math {
  font-family: var(--font-math);
  font-size: 1.05em;
  line-height: 1.55;
  white-space: nowrap;
  color: var(--ink);
}
.math-display { display: inline-block; font-size: clamp(22px, 2.3vw, 31px); line-height: 1.6; }
.m-var { font-style: italic; }
.m-num, .m-sym, .m-text, .m-func { font-style: normal; }
.m-upright { font-style: normal; }
.m-text { white-space: pre; font-family: var(--font-ui); font-size: 0.86em; }
.m-bold { font-weight: 700; }
.m-italic { font-style: italic; }
.m-func { margin-right: 0.04em; }
.m-func-app { white-space: nowrap; }
.m-bin { margin: 0 0.16em; }
.m-plus, .m-minus { font-style: normal; }
.m-times { font-style: normal; }
.m-rel { margin: 0 0.28em; font-style: normal; }
.m-setop { margin: 0 0.22em; }
.m-thin { display: inline-block; width: 0.14em; }
.m-punct { margin-right: 0.12em; }
.m-prefix-op { margin-right: 0.14em; }
.m-paren { font-family: var(--font-math); }
.m-unknown { color: #b91c1c; font-family: var(--font-mono); font-size: 0.9em; }

.m-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 0.12em;
  line-height: 1.15;
}
.m-frac-n { border-bottom: 1.4px solid currentColor; padding: 0 0.22em 0.04em; }
.m-frac-d { padding: 0.04em 0.22em 0; }
.m-div-frac .m-frac-n, .m-div-frac .m-frac-d { padding-left: 0.16em; padding-right: 0.16em; }

.m-pow { white-space: nowrap; }
.m-sup { font-size: 0.64em; line-height: 0; vertical-align: super; margin-left: 0.02em; }
.m-sub { font-size: 0.64em; line-height: 0; vertical-align: sub; margin-left: 0.02em; }
.m-prime { letter-spacing: 0.02em; }

.m-sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0 0.04em; }
.m-sqrt-sign { font-size: 1.14em; line-height: 1; transform: scaleY(1.06); transform-origin: center; }
.m-sqrt-body { border-top: 1.2px solid currentColor; padding: 0.08em 0.14em 0 0.08em; margin-left: -0.04em; }
.m-sqrt-index { font-size: 0.55em; align-self: flex-start; margin-right: -0.28em; margin-top: 0.05em; z-index: 1; }

.m-abs { display: inline-flex; align-items: stretch; margin: 0 0.04em; }
.m-abs-bar { font-size: 1.02em; line-height: 1.4; padding: 0 0.05em; }

.m-int { display: inline-flex; align-items: center; vertical-align: middle; margin: 0 0.08em 0 0.05em; white-space: nowrap; }
.m-int-sign { font-size: 2.05em; line-height: 0.8; font-family: var(--font-math); transform: translateY(-0.02em); }
.m-int-limits { display: inline-flex; flex-direction: column; font-size: 0.56em; line-height: 1.15; margin-left: 0.05em; margin-top: -0.2em; }
.m-int-up { order: 1; padding-left: 0.1em; }
.m-int-low { order: 3; padding-left: 0.1em; }
.m-int-body { margin-left: 0.16em; }
.m-int-dx { margin-left: 0.22em; font-style: normal; }
.m-int-dx .m-upright { font-style: normal; padding-right: 0.05em; }

.m-bigop { display: inline-flex; align-items: center; vertical-align: middle; margin: 0 0.1em; }
.m-bigop-stack { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; }
.m-bigop-up, .m-bigop-low { font-size: 0.55em; }
.m-bigop-sign { font-size: 1.75em; line-height: 0.95; }
.m-bigop-body { margin-left: 0.14em; }

.m-lim { display: inline-flex; align-items: center; vertical-align: middle; margin: 0 0.1em; }
.m-lim-stack { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; }
.m-lim-word { font-family: var(--font-ui); font-size: 0.95em; font-weight: 500; }
.m-lim-sub { font-size: 0.56em; }
.m-lim-body { margin-left: 0.16em; }

.m-matrix-wrap { display: inline-flex; align-items: stretch; gap: 2px; vertical-align: middle; margin: 0 0.1em; max-width: 100%; overflow-x: auto; }
.m-matrix { border-collapse: collapse; }
.m-mcell { padding: 0.12em 0.5em; text-align: center; font-size: 0.95em; line-height: 1.35; }
.m-matrix-br { display: block; width: 8px; flex-shrink: 0; font-size: 0; color: inherit; border: 1.6px solid currentColor; border-right: 0; border-radius: 5px 0 0 5px; }
.m-matrix-br.m-br-right { border: 1.6px solid currentColor; border-left: 0; border-radius: 0 5px 5px 0; }
.m-matrix-br.m-br-bar { width: 2px; border: 0; background: currentColor; border-radius: 1px; }
.m-matrix-br.m-br-brace {
  width: auto; font-size: 2.2em; color: inherit; border: 0; line-height: 0.8;
  font-family: var(--font-math); transform: scaleY(1.05); transform-origin: center;
}
.m-aligned-table .m-mcell { padding: 0.08em 0.35em; }
.m-cell-right { text-align: right; padding-right: 0.55em !important; }
.m-cell-left { text-align: left; padding-left: 0.35em !important; }
.m-cases { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.m-case-brace { font-size: 2.5em; line-height: 0.8; font-family: var(--font-math); transform: scaleY(1.15); transform-origin: center; }
.m-cases .m-mcell { text-align: left; }
.m-cases .m-mcell:nth-child(2) { padding-left: 0.55em; }

.m-delim-wrap { display: inline-flex; align-items: stretch; vertical-align: middle; }
.m-delim-char { font-size: 1.3em; line-height: 1.1; display: flex; align-items: center; padding: 0 0.02em; }
.m-delim-body { padding: 0 0.04em; }

.m-binom { display: inline-flex; align-items: center; vertical-align: middle; }
.m-binom-paren { font-size: 2em; line-height: 0.85; }
.m-binom-stack { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.78em; line-height: 1.15; }
.m-binom-top { border-bottom: 1px solid currentColor; padding: 0 0.24em; }

.m-deco { position: relative; display: inline-block; }
.m-vec-arrow { position: absolute; top: -0.62em; left: 0; right: 0; text-align: center; font-size: 0.7em; line-height: 1; }
.m-overline { padding: 0 0.06em; text-decoration-line: overline; text-decoration-thickness: 1.3px; text-underline-offset: 0.12em; }
.m-hat-mark, .m-tilde-mark { position: absolute; top: -0.58em; left: 0; right: 0; text-align: center; font-size: 0.75em; line-height: 1; }
.m-sub-wrap { white-space: nowrap; }
.m-prime-wrap { white-space: nowrap; }
.m-fact-wrap { white-space: nowrap; }
.m-group { display: inline; }

/* ------------------------------ 页脚 / 提示 ------------------------------ */
.footer {
  margin-top: 34px;
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted-2);
  padding: 0 4px;
}
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: #0f172a; color: #f8fafc;
  padding: 9px 18px; border-radius: 999px;
  font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: 0.25s ease; z-index: 200;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1180px) {
  .calc-grid { grid-template-columns: 1fr; }
  .insight-card { order: 2; }
  .la-grid { grid-template-columns: 1fr; }
  .formula-grid { grid-template-columns: 1fr; }
  .top-meta { display: none; }
}
@media (max-width: 900px) {
  .app-shell { padding: 10px 14px 34px; }
  .topbar { top: 8px; padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .brand-sub { display: none; }
  .brand-mark { width: 36px; height: 36px; font-size: 21px; }
  .brand-title { font-size: 17px; }
  .main-nav { width: 100%; margin-left: 0; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; gap: 0; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 6px 8px; font-size: 12px; }
  .main { margin-top: 16px; }
  .formula-card { padding: 16px; }
  .math-input-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; }
  .input-prefix { grid-column: 1; grid-row: 1; min-width: 26px; font-size: 21px; }
  .input-shell { grid-column: 2; grid-row: 1; flex: none; width: 100%; min-width: 0; }
  #calc-draw { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .math-input { padding: 11px 12px; font-size: 14px; }
  .math-preview { min-height: 74px; padding: 12px 14px; }
  .palette-label { width: 48px; font-size: 9.5px; }
  .sym-btn { min-width: 32px; height: 30px; padding: 0 7px; font-size: 14px; }
  .plot-stage { height: 330px; }
  .outline-head { align-items: flex-start; }
  .outline-search { min-width: 100%; }
  .formula-outline { padding: 16px; }
  .module-hero { padding: 20px; border-radius: 18px; }
  .module-hero h2 { font-size: 22px; }
  .la-toolbar { padding: 12px; gap: 10px; }
  .la-dim-row { gap: 10px; }
  .dim-hint { margin-left: 0; }
  .la-editor-card, .la-result-card { padding: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .result-big { font-size: 27px; }
  .head-hint { display: none; }
  .la-editors { gap: 14px; }
  .matrix-cell { width: 44px; height: 33px; }
  .range-hint { margin-left: 0; }
}
@media (max-width: 560px) {
  .example-row { display: none; }
  .calc-topline .segmented { width: 100%; }
  .seg-btn { flex: 1; }
  .plot-stage { height: 280px; }
  .plot-badge { font-size: 10px; }
  .formula-grid { gap: 8px; }
  .outline-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .chip { white-space: nowrap; }
  .la-matrix-table td { padding: 2px 4px; font-size: 13px; }
  .matrix-input-table { border-spacing: 3px; }
  .matrix-cell { width: 40px; height: 31px; font-size: 12px; }
}
