:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #5b6675;
  --line: #e2e8f0;
  --brand: #1f3a5f;
  --brand2: #aec6e0;
  --accent: #2f7ff0;
  --accent2: #e8553a;
  --chip: #eef3f9;
}
[data-theme="dark"] {
  --bg: #0f1620;
  --panel: #16202c;
  --ink: #e6edf5;
  --muted: #93a2b5;
  --line: #283545;
  --brand: #4a7bb5;
  --brand2: #6f93ba;
  --accent: #4f9bff;
  --accent2: #ff7a5c;
  --chip: #1e2a3a;
}
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .topbar { background: linear-gradient(90deg, #16202c, #1d2c3d); }
[data-theme="dark"] .sidebar { background: var(--panel); border-right-color: var(--line); }
[data-theme="dark"] .sidebar .mod.active { background: var(--brand); color: #fff; }
[data-theme="dark"] .field input, [data-theme="dark"] .field select { background: #0f1822; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .field input:focus, [data-theme="dark"] .field select:focus { outline-color: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .sb-search { background: #0f1822; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .plot { background: #0f1822; border-color: var(--line); }
[data-theme="dark"] .rtab td.rv { color: #7db4ff; }
[data-theme="dark"] .rtab .rgrp { background: #3a241c; color: #ff9b80; }
[data-theme="dark"] .desc, [data-theme="dark"] .note { color: var(--muted); }
[data-theme="dark"] .actions button:not(.primary):not(#btn-share) { background: var(--chip); color: var(--ink); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  font-size: 13px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--brand), #2c5282);
  color: #fff; padding: 10px 18px;
}
.brand-cn { font-size: 18px; font-weight: 700; }
.brand-en { margin-left: 12px; font-size: 12px; color: var(--brand2); }
.brand-en small { opacity: .8; }
.lang { display: flex; gap: 6px; }
.lang-btn {
  border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff;
  padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.lang-btn.active { background: #fff; color: var(--brand); font-weight: 700; }
.layout { display: flex; height: calc(100vh - 52px); }
.sidebar {
  width: 256px; flex: 0 0 256px; overflow-y: auto; background: var(--panel);
  border-right: 1px solid var(--line); padding: 8px 6px;
}
.sidebar .grp {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 8px 4px; font-weight: 700;
}
.sidebar .mod {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--ink); padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.sidebar .mod:hover { background: var(--chip); }
.sidebar .mod.active { background: var(--brand); color: #fff; font-weight: 600; }
.panel { flex: 1; overflow-y: auto; padding: 18px 26px; }
.panel .empty { color: var(--muted); margin-top: 40px; text-align: center; }
.mod-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.mod-head h2 { margin: 0; font-size: 20px; }
.grp-tag { font-size: 11px; color: var(--muted); background: var(--chip); padding: 3px 10px; border-radius: 20px; }
.desc { color: var(--muted); margin: 10px 0 16px; max-width: 760px; line-height: 1.55; }
.inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px 18px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field .fl { font-size: 12px; color: var(--ink); }
.field .fl em { font-style: normal; color: var(--muted); margin-left: 4px; font-size: 11px; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 13px;
  background: #fbfdff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field-ta { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 12px; font-family: "Consolas", "SF Mono", monospace; background: #fbfdff; color: var(--ink); resize: vertical; }
.field-ta:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.actions { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.actions button {
  border: 0; border-radius: 6px; padding: 9px 20px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.actions .primary { background: var(--brand); color: #fff; }
.plot { background: #fff; border: 1px solid var(--line); border-radius: 8px; width: 100%; max-width: 760px; }
.plots { margin-top: 12px; }
.plots .plot { margin-bottom: 12px; }
.up { margin: 4px 0 10px; }
.up .lang-btn { font-size: 12px; padding: 4px 10px; }
.examples { margin: 10px 0 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.examples-l { font-size: 12px; color: var(--muted); }
.ex-btn { font-size: 12px; margin: 2px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); cursor: pointer; }
.ex-btn:hover { border-color: var(--accent); color: var(--accent); }
.sweep { margin: 8px 0; }
.sweep-c { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-size: 12px; }
.sweep-c label { display: flex; gap: 4px; align-items: center; color: var(--muted); }
.sweep-c input { width: 70px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; }
.bm { margin: 8px 0; display: flex; gap: 8px; align-items: center; }
.bm select { padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
[data-theme="dark"] .bm select { background: #0f1822; color: var(--ink); border-color: var(--line); }
.actions .primary:hover { background: #16305a; }
.actions button:not(.primary) { background: var(--chip); color: var(--ink); }
.actions button:disabled { opacity: .5; cursor: not-allowed; }
.rtab { border-collapse: collapse; width: 100%; max-width: 820px; font-size: 13px; }
.rtab th, .rtab td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.rtab th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.rtab td.rv { font-family: "Consolas", "SF Mono", monospace; color: var(--brand); white-space: nowrap; }
.rtab .rgrp { display: inline-block; font-size: 10px; color: var(--accent2); background: #fdeee9; padding: 1px 7px; border-radius: 10px; margin-right: 6px; }
.note { margin-top: 10px; color: var(--muted); font-size: 12px; max-width: 760px; line-height: 1.5; }
.plot { margin-top: 14px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---- animation player (NLSE / Raman) ---- */
.anim-wrap { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel); }
.anim-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.anim-btn { border: 1px solid var(--line); background: var(--chip); border-radius: 6px; width: 34px; height: 30px; cursor: pointer; font-size: 14px; color: var(--ink); }
.anim-btn:hover { border-color: var(--accent); }
.anim-slider { flex: 1; min-width: 160px; }
.anim-z { font-size: 12px; color: var(--muted); min-width: 150px; }
.anim-sp { font-size: 12px; color: var(--muted); }
.anim-sp select { border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); padding: 2px 4px; }
.anim-canvas { width: 100%; max-width: 760px; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
[data-theme="dark"] .anim-canvas { background: #0f1620; border-color: var(--line); }
[data-theme="dark"] .anim-wrap { background: var(--panel); border-color: var(--line); }

/* ---- experience pack: search, favorites, share toast ---- */
.sb-tools {
  display: flex; gap: 6px; padding: 4px 4px 8px; position: sticky; top: 0;
  background: var(--panel); z-index: 2; border-bottom: 1px solid var(--line);
}
.sb-search { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.sb-search:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.sb-fav { flex: 0 0 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--chip); color: var(--muted); cursor: pointer; font-size: 14px; }
.sb-fav.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.sidebar .mod { position: relative; padding-right: 24px; }
.sidebar .mod .star { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #c2cad6; font-size: 14px; line-height: 1; }
.sidebar .mod .star.on { color: #f5b50a; }
.sidebar .mod .star:hover { color: var(--accent2); }
.sb-empty { color: var(--muted); padding: 16px 10px; font-size: 12px; }
.actions button#btn-share { background: var(--chip); color: var(--ink); }
.actions button#btn-share:hover { background: var(--brand2); }
#toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  background: rgba(29,39,51,.94); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- batch input ---- */
.batch { margin-top: 16px; border: 1px dashed var(--line); border-radius: 8px; padding: 12px; background: var(--panel); }
.batch-hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; line-height: 1.5; }
.batch-in { width: 100%; min-height: 92px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-family: "Consolas", "SF Mono", monospace; font-size: 12px; background: #fbfdff; color: var(--ink); resize: vertical; }
.batch-out { margin-top: 12px; }
.batch-set { margin-bottom: 14px; }
.batch-set > b { display: block; margin-bottom: 4px; color: var(--brand); }
.batch-cmp { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.batch-cmp-h { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.batch-cmp-h select { margin-left: 6px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
[data-theme="dark"] .batch-in { background: #0f1822; color: var(--ink); border-color: var(--line); }

/* ---- bilingual brand (toggle by body lang class) ---- */
body:not(.lang-zh) .brand-cn { display: none; }
body.lang-zh .brand-en { display: none; }
#btn-home-site { text-decoration: none; }
#btn-home-site:hover { background: #fff; color: var(--brand); }

/* ---- sidebar Home nav button ---- */
.sb-home {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--ink); padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 600; margin-bottom: 6px;
}
.sb-home:hover { background: var(--chip); }
.sb-home.active { background: var(--brand); color: #fff; }
[data-theme="dark"] .sidebar .sb-home.active { background: var(--brand); color: #fff; }

/* ---- Home / category overview page ---- */
.home { max-width: 1040px; }
.home-hero { margin-bottom: 18px; }
.top-contact {
  display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.top-contact:hover { background: var(--accent2); border-color: var(--accent2); color: #fff; }
body:not(.lang-zh) .tc-zh { display: none; }
body.lang-zh .tc-en { display: none; }
.home-hero h1 { margin: 0 0 6px; font-size: 26px; color: var(--brand); }
.home-sub { color: var(--muted); margin: 0; line-height: 1.6; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 14px; }
.cat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cat-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.cat-items { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-item {
  border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  border-radius: 14px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.cat-item:hover { border-color: var(--accent); color: var(--accent); }

/* ---- module theory / derivation panel ---- */
.theory-btn { margin-left: auto; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.theory-btn:hover { border-color: var(--accent); color: var(--accent); }
.theory-box { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 8px; background: var(--chip); color: var(--ink); line-height: 1.7; font-size: 13px; }

/* ---- constants reference panel ---- */
.sb-const { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 6px; background: var(--chip); color: var(--muted); cursor: pointer; font-size: 12px; padding: 6px 10px; }
.sb-const:hover { border-color: var(--accent); color: var(--accent); }
.const-panel { position: fixed; top: 60px; right: 12px; width: 400px; max-width: 92vw; max-height: 72vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 40; padding: 10px 12px; }
.const-h { font-weight: 700; color: var(--brand); margin-bottom: 8px; padding-right: 28px; }
.const-t { width: 100%; border-collapse: collapse; font-size: 12px; }
.const-t td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.const-t .cs { font-weight: 700; white-space: nowrap; }
.const-t .ca { color: var(--muted); font-family: "Consolas", "SF Mono", monospace; white-space: nowrap; }
.const-t .cv { font-family: "Consolas", "SF Mono", monospace; color: var(--brand); white-space: nowrap; }
.const-t .cu { color: var(--muted); white-space: nowrap; }
.const-t .cd { color: var(--muted); }

/* ---- dashboard / standards / new sidebar buttons ---- */
.sb-dash, .sb-std { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 6px; background: var(--chip); color: var(--muted); cursor: pointer; font-size: 12px; padding: 6px 10px; }
.sb-dash:hover, .sb-std:hover { border-color: var(--accent); color: var(--accent); }
.dash-n { color: var(--muted); font-weight: 400; }
.dash-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; background: var(--chip); }
.dash-t { font-weight: 700; color: var(--brand); margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-rm { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 5px; padding: 1px 8px; cursor: pointer; font-size: 11px; }
.dash-rm:hover { border-color: var(--accent); color: var(--accent); }
.std-list { max-height: 64vh; overflow: auto; }
.std-item { border-bottom: 1px solid var(--line); padding: 8px 2px; }
.std-id { font-weight: 700; color: var(--brand); font-family: "Consolas", "SF Mono", monospace; }
.std-t { color: var(--ink); margin: 2px 0; }
.std-s { color: var(--muted); font-size: 12px; line-height: 1.6; }
.sweep-c2 { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; }

/* ---- live slider inputs (real-time recompute) ---- */
.live-range { width: 100%; accent-color: var(--accent); margin-top: 4px; }
.field-val { display: inline-block; margin-left: 8px; font-family: "Consolas", "SF Mono", monospace; font-size: 12px; color: var(--brand); }
.label-live { font-size: 11px; color: var(--muted); }

/* ---- glossary modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,22,32,.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 560px; max-width: 94vw; max-height: 80vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head b { font-size: 15px; color: var(--brand); }
.gloss-list { padding: 8px 16px 16px; }
.gloss-item { padding: 9px 0; border-bottom: 1px solid var(--line); }
.gloss-item:last-child { border-bottom: 0; }
.gloss-term { font-weight: 700; color: var(--ink); font-size: 13px; margin-bottom: 3px; }
.gloss-def { color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---- interactive data cursor tooltip (v11) ---- */
.plot-tip {
  position: fixed; z-index: 9999; display: none; pointer-events: none;
  background: rgba(17, 24, 39, 0.92); color: #fff;
  font: 11px/1.5 -apple-system, "Segoe UI", sans-serif;
  padding: 6px 8px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  white-space: nowrap;
}

/* ---- changelog modal (v10) ---- */
.chlog-list { padding: 8px 16px 16px; }
.chlog-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.chlog-item:last-child { border-bottom: 0; }
.chlog-ver { font-weight: 700; color: var(--brand); font-size: 13px; }
.chlog-date { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 8px; }
.chlog-body { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 3px; }

