/* ============================================================
   style.css — 网状结构实验室
   ------------------------------------------------------------
   三档主题：日间 / 夜间 / 魔法。颜色只在变量层出现，
   业务规则里不写死色值，切主题 = 换变量块 + 重绘 Canvas。

   字号尺度（参照已落地的几台，不回到 10px 密排）：
     正文 14 / 次级 12.5 / 标签 11.5 / 卡片标题 13.5 / 页签 13 / 顶栏标题 17
   ============================================================ */

/* ---------------- 日间模式（默认） ---------------- */
:root {
  --bg: #faf7fc;
  --panel: #ffffff;
  --panel2: #faf8fe;
  --fg: #1f1830;
  --fg2: #4a4458;
  --muted: #6a6078;
  --faint: #918aa3;
  --line: #ece3f5;
  --axis: #ded3ec;

  --accent: #7a4bc8;
  --accent-deep: #3f2170;
  --accent-soft: #f6f0fe;
  --solid: #5e33a0;
  --chip: #efe4fb;
  --gold: #b8802f;
  --ok: #1a7f37;
  --danger: #d9534f;

  --hdr-bg: linear-gradient(135deg,#3f2170 0%,#7a4bc8 56%,#b06bc9 100%);
  --hdr-fg: #ffffff;
  --hdr-btn-bg: rgba(255, 255, 255, .16);
  --hdr-btn-bd: rgba(255, 255, 255, .30);
  --hdr-btn-fg: rgba(255,255,255,.86);
  --hdr-tab-on-bg: #ffffff;
  --hdr-tab-on-fg: #3f2170;
  --hdr-logo-bd: rgba(255, 255, 255, .78);
  --hdr-shadow: 0 2px 12px rgba(63,33,112,.18);

  --plotbg: #fffdfe;
  --bond: #9a93ab;
  --shadow: 0 1px 2px rgba(38,22,66,.06), 0 8px 24px rgba(38,22,66,.06);
}

/* ---------------- 夜间模式 ---------------- */
[data-theme="dark"] {
  --bg: #130d1e;
  --panel: #1e1630;
  --panel2: #251f33;
  --fg: #efe9f8;
  --fg2: #cdc4dd;
  --muted: #a79dc0;
  --faint: #857ba0;
  --line: #342a4a;
  --axis: #453a5e;

  --accent: #b98cf0;
  --accent-deep: #dcc0ff;
  --accent-soft: #271c3c;
  --solid: #b98cf0;
  --chip: #302448;
  --gold: #d8a45f;
  --ok: #2f7d52;
  --ok: #57c785;

  --hdr-bg: linear-gradient(135deg,#1b0f2e 0%,#3d1f66 58%,#5b2a7d 100%);
  --hdr-fg: #f2ecff;
  --hdr-btn-bg: rgba(255, 255, 255, .08);
  --hdr-btn-bd: rgba(255, 255, 255, .16);
  --hdr-btn-fg: rgba(242,236,255,.86);
  --hdr-tab-on-bg: #efe9f8;
  --hdr-tab-on-fg: #2a1450;
  --hdr-logo-bd: rgba(255, 255, 255, .28);
  --hdr-shadow: 0 2px 14px rgba(0,0,0,.5);

  --plotbg: #1a1526;
  --bond: #6d6386;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px rgba(0,0,0,.3);
}

/* ---------------- 魔法模式（淡樱 + 星金） ---------------- */
[data-theme="magic"] {
  --bg: #fff6fa;
  --panel: #ffffff;
  --panel2: #fff8fb;
  --fg: #3b1526;
  --fg2: #5e2941;
  --muted: #8c5c72;
  --faint: #b38d9e;
  --line: #f8dce8;
  --axis: #f1c9d9;

  --accent: #ec6e9c;
  --accent-deep: #a83a64;
  --accent-soft: #ffeff6;
  --solid: #a83a64;
  --chip: #ffdcea;
  --gold: #d8a45f;

  --hdr-bg: linear-gradient(135deg,#ffd9e8 0%,#f7bcd4 52%,#e8a8c6 100%);
  --hdr-fg: #7b2f4d;
  --hdr-btn-bg: rgba(255, 255, 255, .62);
  --hdr-btn-bd: rgba(214, 120, 155, .36);
  --hdr-btn-fg: #8a4260;
  --hdr-tab-on-bg: #ffffff;
  --hdr-tab-on-fg: #a83a64;
  --hdr-logo-bd: rgba(255, 255, 255, .9);
  --hdr-shadow: 0 1px 3px rgba(122,28,66,.07), inset 0 -2px 0 #e8b84b;

  --plotbg: #fffdfe;
  --bond: #c99aae;
  --shadow: 0 1px 2px rgba(122,28,66,.06), 0 8px 24px rgba(122,28,66,.07);
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  height: 60px;
  background: var(--hdr-bg);
  color: var(--hdr-fg);
  box-shadow: var(--hdr-shadow);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand .logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #fbe6f0;
  border: 1.5px solid var(--hdr-logo-bd);
  object-fit: cover;
  flex: 0 0 auto;
}
.titles h1 { font-size: 17px; letter-spacing: .3px; line-height: 1.25; white-space: nowrap; }
.titles .h-tail { font-weight: 400; opacity: .88; font-size: 15px; }
.titles p { margin: 0; font-size: 11.5px; opacity: .78; letter-spacing: .6px; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0;
  background: transparent;
  color: var(--hdr-btn-fg);
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: .82;
  transition: background .15s, opacity .15s, color .15s;
}
.tabs button:hover { background: var(--hdr-btn-bg); opacity: 1; }
.tabs button.on {
  background: var(--hdr-tab-on-bg);
  color: var(--hdr-tab-on-fg);
  opacity: 1;
  font-weight: 600;
}

.top-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.tbtn {
  border: 1px solid var(--hdr-btn-bd);
  background: var(--hdr-btn-bg);
  color: var(--hdr-btn-fg);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background .15s;
}
.tbtn:hover { background: var(--hdr-tab-on-bg); color: var(--hdr-tab-on-fg); }

.tseg { position: relative; }
.tseg-cur {
  border: 1px solid var(--hdr-btn-bd);
  background: var(--hdr-btn-bg);
  color: var(--hdr-btn-fg);
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 8px;
}
.tseg-cur::after { content: " ▾"; opacity: .7; }
.tseg-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  display: none;
  min-width: 124px;
  z-index: 60;
}
.tseg-menu.open { display: block; }
.tseg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg2);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 7px;
}
.tseg-menu button:hover { background: var(--accent-soft); }
.tseg-menu button.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

/* 桌面（> 900px）：三档写全称，排成一段分段控件，当前档白底高亮。
   手机才收成「当前档 + ▾」的浮层菜单（见文件末尾的 max-width: 900px 段）。 */
@media (min-width: 901px) {
  .tseg {
    display: flex; gap: 2px; padding: 2px;
    background: var(--hdr-btn-bg);
    border: 1px solid var(--hdr-btn-bd);
    border-radius: 9px;
  }
  .tseg-cur { display: none; }
  .tseg-menu, .tseg-menu.open {
    position: static; display: flex; gap: 2px; min-width: 0;
    background: transparent; border: 0; box-shadow: none; padding: 0;
  }
  .tseg-menu button {
    width: auto; text-align: center; white-space: nowrap;
    background: transparent; color: var(--hdr-btn-fg);
    font-size: 12.5px; padding: 5px 10px; border-radius: 7px;
  }
  .tseg-menu button:hover { background: var(--hdr-btn-bg); color: var(--hdr-btn-fg); }
  .tseg-menu button.on {
    background: var(--hdr-tab-on-bg); color: var(--hdr-tab-on-fg); font-weight: 600;
  }
}

/* ---------------- 主区三栏 ---------------- */
#main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr) 316px;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  align-items: stretch;
  min-height: 0;
}

.parambar, .settings {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 13px 13px 16px;
  overflow-y: auto;
  max-height: calc(100vh - 84px);
  scrollbar-width: thin;
}
.parambar::-webkit-scrollbar, .settings::-webkit-scrollbar { width: 7px; }
.parambar::-webkit-scrollbar-thumb, .settings::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 4px;
}

/* ---------------- 卡片块 ---------------- */
.blk { margin-bottom: 15px; }
.blk:last-child { margin-bottom: 0; }
.blk-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.blk-hd .sub { font-size: 11.5px; font-weight: 400; color: var(--faint); }

.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .3px;
  margin-bottom: 4px;
}
.field > label b { color: var(--accent-deep); font-weight: 600; font-size: 12.5px; }

select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--fg);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
select:focus { border-color: var(--accent); }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--solid);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
input[type="range"]::-moz-range-track {
  height: 5px; border-radius: 3px; background: var(--accent-soft); border: 1px solid var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--solid); border: 2px solid var(--panel);
}

.seg {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel2);
}
.seg button {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 7px 4px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--accent-soft); }
.seg button.on { background: var(--solid); color: #fff; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--fg2);
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); }
.chip.on {
  background: var(--chip);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}

.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg2);
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
}
.chk input { width: 15px; height: 15px; accent-color: var(--solid); cursor: pointer; }

.hint {
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.58;
  margin-top: 6px;
}

/* ---------------- 绘图卡 ---------------- */
.plotcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative;
}
.plot-hd {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--panel2);
}
.plot-hd #stageHd { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.plot-hd .hd-sub {
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.stage-body { flex: 1 1 auto; position: relative; min-height: 0; background: var(--plotbg); }

.view3d, .view2d, .viewhtml { position: absolute; inset: 0; }
.view3d canvas, .view2d canvas { width: 100%; height: 100%; display: block; }

.view2d { padding: 6px; }
.view2d canvas { border-radius: 8px; }

.viewhtml { overflow: auto; padding: 12px; }

.view-hint {
  position: absolute;
  left: 12px; bottom: 10px;
  font-size: 11.5px;
  color: var(--faint);
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  pointer-events: none;
  white-space: nowrap;
}

/* 覆盖层读数：量距离 / 共用 C₂ 轴的即时反馈，贴在画布左上角 */
.ov-note {
  position: absolute;
  left: 12px; top: 12px;
  max-width: calc(100% - 96px);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--fg);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  padding: 6px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 6;
}
.ov-note .dim { color: var(--faint); }

.view-tools {
  position: absolute;
  right: 12px; top: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 5;
}.vt {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--fg2);
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 7px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.vt:hover { background: var(--accent-soft); color: var(--accent-deep); }
.vt.on { background: var(--solid); color: #fff; border-color: var(--solid); }

/* ---------------- 右侧读数 ---------------- */
.kv { display: flex; flex-direction: column; gap: 6px; }
.kv .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}
.kv .row:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); flex: 0 0 auto; }
.kv .v { color: var(--fg); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 15px; color: var(--accent-deep); }
.kv .v.gold { color: var(--gold); }

.tagline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid var(--line);
  margin: 0 6px 6px 0;
}
.tagline.gold { background: color-mix(in srgb, var(--gold) 14%, var(--panel)); color: var(--gold); }

.bigcode {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--accent-deep);
  line-height: 1.25;
}
.bigcode small { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

.verdict {
  font-size: 12.5px;
  color: var(--fg2);
  line-height: 1.62;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 9px 11px;
  margin-top: 8px;
}

.netlist { display: flex; flex-direction: column; gap: 6px; }
.netrow {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 12.5px;
}
.netrow .sw {
  width: 13px; height: 13px;
  border-radius: 4px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, .12);
}
.netrow .nm { flex: 1 1 auto; color: var(--fg2); }
.netrow .st { font-size: 11.5px; color: var(--faint); }
.netrow button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
}
.netrow button.on { background: var(--solid); color: #fff; border-color: var(--solid); }
.netrow.off .nm, .netrow.off .st { opacity: .45; }

/* ---------------- 案例卡（左栏） ---------------- */
.caselist { display: flex; flex-direction: column; gap: 5px; }
.casebtn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 9px;
  padding: 7px 9px;
  transition: all .14s;
}
.casebtn:hover { border-color: var(--accent); background: var(--accent-soft); }
.casebtn.on { border-color: var(--accent); background: var(--chip); }
.casebtn .cid {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--accent-deep);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  flex: 0 0 auto;
}
.casebtn .cbody { min-width: 0; flex: 1 1 auto; }
.casebtn .cn { font-size: 13px; color: var(--fg); font-weight: 500; display: block; line-height: 1.3; }
.casebtn .cs { font-size: 11.5px; color: var(--faint); display: block; line-height: 1.35; }

/* ---------------- 图注 ---------------- */
.cvcap {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
  padding: 7px 2px 0;
}
.cvcap b { color: var(--accent-deep); font-weight: 600; }

/* ---------------- 页脚 ---------------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px 11px;
  font-size: 11.5px;
  color: var(--faint);
  flex-wrap: wrap;
}
.foot .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 11.5px;
}
.foot .pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------------- 弹层 ---------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(24, 12, 42, .46); backdrop-filter: blur(2px); }
.modal-box {
  position: relative;
  width: min(880px, calc(100vw - 36px));
  max-height: min(84vh, 880px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 18px 54px rgba(20, 8, 40, .34);
  overflow: hidden;
}
.modal-hd {
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--hdr-bg);
  flex: 0 0 auto;
}
.modal-x {
  position: absolute;
  right: 10px; top: 9px;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 19px;
  line-height: 1;
  opacity: .82;
}
.modal-x:hover { background: rgba(255, 255, 255, .16); opacity: 1; }
.modal-bd {
  padding: 16px 20px 22px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.78;
  color: var(--fg2);
}
.modal-bd h3 {
  font-size: 14.5px;
  color: var(--fg);
  margin: 16px 0 6px;
  padding-left: 9px;
  border-left: 3px solid var(--accent);
}
.modal-bd h3:first-child { margin-top: 0; }
.modal-bd p { margin: 6px 0; }
.modal-bd ul, .modal-bd ol { margin: 6px 0; padding-left: 20px; }
.modal-bd li { margin: 3px 0; }
.modal-bd b, .modal-bd strong { color: var(--fg); }
.modal-bd code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 1px 5px;
  border-radius: 4px;
}
.modal-bd table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12.5px; }
.modal-bd th, .modal-bd td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.modal-bd th { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.modal-bd .qa { margin: 13px 0; padding: 11px 13px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.modal-bd .qa .q { font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.modal-bd .qa .a { font-size: 12.5px; color: var(--fg2); }
.modal-bd .qa .a::before { content: "答："; font-weight: 600; color: var(--accent-deep); }
.modal-bd .opt { font-size: 12.5px; color: var(--muted); }

/* ---------------- 折叠按钮（手机） ---------------- */
.pane-tog { display: none; }

/* ---------------- 窄桌面 ---------------- */
@media (max-width: 1340px) {
  #main { grid-template-columns: 250px minmax(0, 1fr) 276px; }
  .titles .h-tail { display: none; }
}

@media (max-width: 1100px) {
  #main { grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .settings { grid-column: 1 / -1; max-height: none; }
}

/* ---------------- 真题页 ---------------- */
.exnav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.exnav button {
  border: 1px solid var(--line); background: var(--panel2); color: var(--fg2);
  font-size: 12.5px; padding: 7px 9px; border-radius: 9px; text-align: left;
  line-height: 1.35; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s;
}
.exnav button:hover { background: var(--accent-soft); }
.exnav button.on { background: var(--solid); color: #fff; border-color: transparent; font-weight: 600; }

.exgiven { margin: 6px 0 0; padding-left: 17px; color: var(--fg2); font-size: 12.5px; line-height: 1.66; }
.exgiven li { margin-bottom: 5px; }
.exgiven li::marker { color: var(--accent); }

.qa2 { border-top: 1px dashed var(--line); padding: 10px 0 4px; }
.qa2:first-of-type { border-top: 0; padding-top: 2px; }
.q2 { font-size: 13px; color: var(--fg); line-height: 1.55; }
.q2 b { color: var(--accent-deep); margin-right: 4px; }
.pts {
  font-size: 11.5px; color: var(--muted); background: var(--chip);
  padding: 1px 6px; border-radius: 999px; white-space: nowrap;
}
.ansBtn {
  margin-top: 7px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--accent-deep); font-size: 12px; padding: 4px 11px; border-radius: 7px;
  font-family: inherit; cursor: pointer;
}
.ansBtn:hover { background: var(--accent-soft); }
.ans2 {
  display: none; margin-top: 8px; font-size: 12.5px; line-height: 1.64; color: var(--fg2);
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; padding: 9px 11px;
}
.qa2.open .ans2 { display: block; }
.ans2 b { color: var(--accent-deep); }

/* ---------------- 手机 / 平板 ---------------- */
@media (max-width: 900px) {
  body { font-size: 14px; }

  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px 9px;
    gap: 8px;
  }
  .brand .logo { width: 27px; height: 27px; }
  .titles h1 { font-size: 15.5px; }
  .titles p { display: none; }
  .tabs { order: 3; width: 100%; flex: 0 0 100%; padding: 3px 0 0; }
  .tabs button { font-size: 12.5px; padding: 6px 10px; }
  .top-actions { margin-left: auto; gap: 5px; }
  .tbtn { padding: 5px 9px; font-size: 12px; }
  .tseg-cur { padding: 5px 9px; font-size: 12px; }

  #main {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  /* 绘图区置顶并撑满 */
  .plotcard { order: 1; height: 58vh; min-height: 330px; }
  /* 顺序：图 → 参数按钮 → 参数面板 → 结论按钮 → 结论面板
     按钮必须排在面板前面，否则要先滚过整个面板才找得到折叠开关 */
  .parambar { order: 3; max-height: none; }
  .settings { order: 5; max-height: none; }

  /* 参数栏与结论栏折叠 */
  .parambar.collapsed, .settings.collapsed { display: none; }

  .pane-tog { display: block; }
  #togP { order: 2; }
  #togS { order: 4; }
  .pane-tog {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--accent-deep);
    font-size: 13px;
    font-weight: 600;
    padding: 10px;
    border-radius: 11px;
    box-shadow: var(--shadow);
    min-height: 42px;
  }
  .pane-tog::after { content: " ▾"; opacity: .6; }
  .pane-tog[aria-expanded="true"]::after { content: " ▴"; }

  /* 触控目标 */
  .chip { padding: 8px 13px; font-size: 13px; min-height: 36px; }
  .casebtn { padding: 9px 10px; min-height: 44px; }
  .seg button { padding: 9px 4px; min-height: 38px; }
  select { padding: 9px 10px; font-size: 14px; }
  .chk { padding: 8px 0; min-height: 40px; }
  .netrow { padding: 9px; }
  .netrow button { min-height: 30px; padding: 4px 11px; }

  /* 手机上按钮有七八个，竖排在右上角会盖掉大半个结构；
     改成贴着画布底部横滑的一条，触控目标抬到 38px。 */
  .view-tools {
    top: auto; bottom: 8px; left: 8px; right: 8px;
    flex-direction: row; gap: 5px;
    overflow-x: auto; padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .view-tools::-webkit-scrollbar { display: none; }
  .vt { padding: 9px 11px; font-size: 12px; min-height: 38px; flex: 0 0 auto; }
  .view-hint { display: none; }
  .ov-note { left: 8px; right: 8px; max-width: none; top: 8px; font-size: 12px; }

  .foot { padding: 8px 12px 14px; font-size: 11px; gap: 6px; }
  .foot .pill { font-size: 11px; }

  .modal-box { width: calc(100vw - 20px); max-height: 88vh; }
  .modal-bd { padding: 13px 14px 18px; font-size: 13px; }
}

@media (max-width: 480px) {
  .plotcard { height: 52vh; }
  .titles h1 { font-size: 14.5px; }
}

/* ---------------- 补充：按钮 / 序列 / 小图 ---------------- */
.wbtn {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 9px;
  transition: all .15s;
}
.wbtn:hover { background: var(--chip); border-color: var(--accent); }

.evi {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--fg2);
  line-height: 1.55;
  padding: 5px 0;
}
.evi b {
  flex: 0 0 auto;
  width: 17px; height: 17px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.seqbox {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.chartbox {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 7px;
  overflow: hidden;
}
.chartbox canvas { display: block; width: 100%; }

@media (max-width: 900px) {
  .wbtn { min-height: 42px; font-size: 13.5px; }
  .evi {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--fg2);
  line-height: 1.55;
  padding: 5px 0;
}
.evi b {
  flex: 0 0 auto;
  width: 17px; height: 17px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.seqbox { font-size: 12px; }
  .chartbox { padding: 5px; }
}


/* ---------------- 结构库（弹层） ---------------- */
.lib { display: flex; flex-direction: column; gap: 12px; }
.libbar { display: flex; flex-direction: column; gap: 9px; }
#libQ {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel2);
  font-size: 13.5px;
  color: var(--fg);
  outline: none;
}
#libQ:focus { border-color: var(--accent); }
.chip .cnt { font-size: 10.5px; opacity: .68; margin-left: 2px; }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 7px; }
.libcard {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  transition: all .14s;
  font-family: inherit;
}
.libcard:hover { border-color: var(--accent); background: var(--accent-soft); }
.libcard.on { border-color: var(--accent); background: var(--chip); }
.lc-top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.lc-top b { font-size: 13.5px; color: var(--fg); font-weight: 600; }
.lc-tag {
  font-size: 10.5px;
  color: var(--accent-deep);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  flex: 0 0 auto;
}
.lc-sub { font-size: 12px; color: var(--fg2); line-height: 1.42; }
.lc-meta { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; line-height: 1.4; }
.libempty { padding: 18px 4px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.libfoot { font-size: 11.5px; color: var(--faint); line-height: 1.7; border-top: 1px dashed var(--line); padding-top: 9px; }
.libfoot b { color: var(--accent-deep); }

@media (max-width: 900px) {
  .libgrid { grid-template-columns: 1fr 1fr; }
  .libcard { padding: 10px 11px; }
}
@media (max-width: 620px) {
  .libgrid { grid-template-columns: 1fr; }
}
