:root {
  --navy: #1f4e79; --navy2: #315f88; --ink: #243447; --muted: #5b6b7b;
  --line: #dce6ee; --soft: #f4f8fb; --danger: #b43b3b; --ok: #1d7c59; --accent: #d9a621;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #eef3f7;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
.shell { max-width: 1320px; margin: 0 auto; padding: 28px 20px 56px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.eyebrow { color: #566d84; font-size: 12px; letter-spacing: 1.5px; font-weight: 700; }
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 6px; color: var(--navy); font-size: 28px; }
h2 { font-size: 17px; color: var(--navy); }
h3 { font-size: 14px; color: var(--ink); margin: 14px 0 6px; }
.subtitle { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 760px; }
.top-state { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #b9dfce; background: #f1fbf6; }
.pill.bad { color: var(--danger); border-color: #ecc4c4; background: #fff5f5; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff;
  box-shadow: 0 8px 24px rgba(31, 78, 121, 0.06); padding: 18px 20px; margin-top: 14px; }
.section-heading { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.step { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; color: #fff;
  background: var(--navy); border-radius: 50%; font-weight: 700; font-size: 12px; }
.section-heading p { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.55; }

.note { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.note.warn { background: #fffaf0; color: #7a611f; border: 1px solid #f0e2b8; }

.presets-card { padding: 14px 20px; position: sticky; top: 0; z-index: 5; }
.preset-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preset-label { flex: 0 0 auto; white-space: nowrap; font-size: 13px; font-weight: 700; color: var(--navy); }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-buttons button { padding: 6px 11px; font-size: 13px; border-radius: 999px; white-space: nowrap; }
.preset-buttons button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button, .download { border: 1px solid #b9cbd8; border-radius: 8px; background: #fff; color: var(--navy);
  padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
button:hover, .download:hover { border-color: var(--navy2); background: #f4f8fb; }
button.primary { color: #fff; background: var(--navy); border-color: var(--navy); }
button.primary:hover { background: var(--navy2); }
.msg { font-size: 12.5px; color: var(--muted); }
.msg[data-kind="busy"] { color: var(--navy2); }
.msg[data-kind="ok"] { color: var(--ok); }
.msg[data-kind="error"] { color: var(--danger); font-weight: 600; }

.layout { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 0 16px; align-items: start; }
.col-controls { display: flex; flex-direction: column; min-width: 0; }
.col-controls > .fit-card { margin-top: 14px; }
.col-results { position: sticky; top: 92px; max-height: calc(100vh - 96px); overflow-y: auto; padding-bottom: 4px; }

.knob { min-width: 0; padding: 9px 0; border-top: 1px solid #f0f4f7; }
.knob:first-of-type { border-top: 0; }
.knob-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.knob-head label { font-size: 13px; font-weight: 650; color: var(--ink); }
.unit { font-size: 12px; color: var(--muted); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 10px; align-items: center; }
.pair input[type="number"]:only-child { grid-column: 1 / -1; }
input[type="number"], select { border: 1px solid #b9cbd8; border-radius: 7px; padding: 7px 8px; color: var(--ink);
  background: #fff; font: inherit; font-size: 13px; width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--navy); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid #9cc0de; outline-offset: 1px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.switch input { width: 16px; height: 16px; accent-color: var(--navy); }
.hint { margin-top: 5px; color: #6b7785; font-size: 11.8px; line-height: 1.55; }
a.cite { color: var(--navy2); text-decoration: none; font-size: 11px; vertical-align: 1px; }
a.cite:hover { text-decoration: underline; }
details.advanced { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #f9fbfd; }
details.advanced summary { cursor: pointer; color: var(--navy); font-weight: 650; font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric-box { min-width: 0; padding: 11px 12px; background: #f7fafc; border: 1px solid var(--line); border-radius: 10px; }
.metric-box span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.metric-box strong { display: block; color: var(--navy); font-size: 21px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric-box small { display: block; color: #6b7785; margin-top: 4px; font-size: 11.5px; }
.interpret { margin-top: 12px; padding: 11px 14px; background: var(--soft); border-left: 3px solid var(--navy); border-radius: 0 8px 8px 0;
  font-size: 13.5px; line-height: 1.75; color: var(--ink); text-align: justify; }

.chart-wrap { position: relative; }
.chart { width: 100%; height: 340px; }
.loading { position: absolute; inset: 0; display: none; place-items: center; background: rgba(255,255,255,0.55);
  color: var(--navy2); font-size: 13px; }
.loading.on { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2 .chart { height: 280px; }
.saved-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid; border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; background: #fff; }
.chip button { padding: 2px 8px; font-size: 12px; border-radius: 999px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chip .dot { margin-right: 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.cmp th, table.cmp td { padding: 9px 11px; text-align: left; border-bottom: 1px solid #edf1f4; white-space: nowrap; }
table.cmp th { color: #526a7d; background: #f7fafc; font-weight: 700; }
table.cmp tr:last-child td { border-bottom: 0; }

details.methods summary { cursor: pointer; color: var(--navy); font-weight: 700; font-size: 15px; }
.methods-body { margin-top: 6px; color: #3d4c5c; font-size: 13px; line-height: 1.75; }
.methods-body a { color: var(--navy); }
.methods-body ul { margin: 6px 0; padding-left: 20px; }
ol.refs { padding-left: 26px; font-size: 12.5px; color: var(--muted); }
ol.refs li { margin: 3px 0; scroll-margin-top: 110px; }
ol.refs li:target { background: #fff7db; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col-results { position: static; max-height: none; overflow: visible; }
  .col-controls { display: flex; flex-direction: column; gap: 0; }
  #controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; align-items: start; }
  #controls .ctrl-card { margin-top: 14px; }
  .col-controls > .fit-card { margin-top: 14px; }
}
@media (max-width: 720px) {
  .shell { padding: 16px 10px 40px; }
  h1 { font-size: 22px; }
  .topbar { flex-direction: column; gap: 8px; }
  .top-state { justify-content: flex-start; }
  .card { padding: 14px 14px; border-radius: 12px; }
  .presets-card { padding: 10px 12px; position: static; }
  .preset-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .preset-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
  .preset-buttons button { padding: 7px 6px; border-radius: 8px; white-space: nowrap; text-align: center; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .toolbar button, .toolbar .download { padding: 7px 6px; font-size: 12.5px; text-align: center; white-space: nowrap; }
  .toolbar #save-btn, .toolbar .download, .toolbar .msg { grid-column: 1 / -1; }
  /* 对比表：窄屏改为分行卡片式，避免横向滚动 */
  .table-wrap { border: 0; overflow: visible; }
  table.cmp, table.cmp tbody, table.cmp tr, table.cmp td { display: block; width: 100%; }
  table.cmp thead { display: none; }
  table.cmp tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 4px 0; }
  table.cmp td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 12px; border: 0; white-space: normal; }
  table.cmp td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex: 0 0 auto; }
  table.cmp td:first-child { justify-content: flex-start; font-weight: 700; color: var(--navy); }
  table.cmp td:first-child::before { content: none; }
  .chip { max-width: 100%; }
  #controls { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .chart { height: 290px; }
  .pair { grid-template-columns: minmax(0, 1fr) 84px; }
  input[type="number"], select { font-size: 16px; } /* iOS 不自动缩放 */
}

/* v0.2.2：适用说明、上标引用、文献浮窗、模型结构 */
.note.guide { background: #f2f7fc; color: #34526e; border: 1px solid #d3e3f1; }
sup { line-height: 0; }
sup a.cite { font-size: 10.5px; vertical-align: baseline; padding: 0 1px; border-radius: 3px; }
sup a.cite:hover, sup a.cite:focus-visible { background: #e3eef8; }
.hint > span { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 4px; background: #eef3f7; color: #526a7d; font-size: 11px; font-weight: 600; }
.hint.local { margin-top: 3px; }
.hint.local > span { background: #eef8f2; color: var(--ok); }
.ref-pop { position: absolute; z-index: 50; width: min(360px, calc(100vw - 16px)); padding: 11px 13px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(31, 78, 121, 0.16);
  font-size: 12.5px; line-height: 1.55; color: var(--ink); }
.ref-pop .rp-no { color: var(--navy); font-weight: 700; font-size: 12px; }
.ref-pop .rp-title { font-weight: 650; margin: 2px 0 4px; }
.ref-pop .rp-meta { color: var(--muted); }
.ref-pop .rp-link { display: inline-block; margin-top: 6px; color: var(--navy); word-break: break-all; }
.diagram-wrap { margin: 4px 0 0; }
svg.diagram { display: block; width: 100%; height: auto; }
svg.dgn { display: none; max-width: 440px; margin: 0 auto; }
details.equations { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #f9fbfd; }
details.equations summary { cursor: pointer; color: var(--navy); font-weight: 650; font-size: 13px; }
.eq { font-size: 13px; color: #3d4c5c; line-height: 1.7; }
.eq p { margin: 8px 0 4px; }
.eq pre { margin: 0; padding: 8px 10px; background: #fff; border: 1px solid #e6edf3; border-radius: 8px;
  font: 12.5px/1.65 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 720px) {
  svg.dgw { display: none; }
  svg.dgn { display: block; }
}

/* v0.3.0：卡片焦点与状态（参照周报项目 flow-card：当前卡片描边 + 外发光；完成 / 需处理两态，无先后锁定） */
:root { --ok-ink: #17694a; --ok-bg: #eef8f3; --ok-line: #b9dfce; --warn-ink: #8a5a00; --warn-bg: #fff8e6; --warn-line: #ead8a0;
  --err-ink: #a32b2b; --err-bg: #fff4f4; --err-line: #e7b4b4; --focus: #2f6fb0; }
:where(button, a, select, input, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.card.focusable { position: relative; transition: border-color .2s, box-shadow .2s; }
.card.focusable[data-focus] { border-color: #9fbbd3; box-shadow: 0 0 0 3px rgba(47, 111, 176, .08), 0 8px 24px rgba(31, 78, 121, .08); }
.card.focusable[data-state="done"] .section-heading .step { background: var(--ok-ink); }
.card.focusable[data-state="error"] { border-color: var(--err-line); }
.card.focusable[data-state="error"][data-focus] { box-shadow: 0 0 0 3px rgba(163, 43, 43, .08), 0 8px 24px rgba(163, 43, 43, .08); }
.card.focusable[data-state="error"] .section-heading .step { background: var(--err-ink); }
.section-heading .head-main { flex: 1 1 auto; min-width: 0; }
.step-hint { font-size: 12.5px; margin-top: 3px; color: var(--muted); line-height: 1.5; }
.card[data-state="done"] .step-hint { color: var(--ok-ink); }
.card[data-state="error"] .step-hint { color: var(--err-ink); }
.card-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 650; border: 1px solid var(--line); color: var(--muted); background: #fff; white-space: nowrap; }
.card-status span { font-weight: 800; }
.card[data-state="done"] .card-status { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-line); }
.card[data-state="error"] .card-status { color: var(--err-ink); background: var(--err-bg); border-color: var(--err-line); }
input.invalid, textarea.invalid, select.invalid { border-color: var(--err-ink) !important; background: var(--err-bg); }
.field-err { color: var(--err-ink); font-size: 12px; font-weight: 600; margin-top: 4px; }
.field-err:empty { display: none; }
button:disabled, button.primary:disabled { opacity: 1; color: #4d5d6d; background: #e3eaf0; border-color: #d3dde6; cursor: not-allowed; }
.msg[data-kind="error"] { color: var(--err-ink); background: var(--err-bg); border: 1px solid var(--err-line); border-radius: 8px; padding: 6px 10px; font-weight: 600; }
.toolbar .msg { flex: 1 1 100%; }

/* 参数拟合卡片 */
.fit-card details > summary { list-style: none; cursor: pointer; }
.fit-card details > summary::-webkit-details-marker { display: none; }
.fit-card details > summary .head-main h2::after { content: " ▸"; color: var(--muted); font-size: 13px; }
.fit-card details[open] > summary .head-main h2::after { content: " ▾"; }
.fit-body { margin-top: 12px; min-width: 0; }
.fit-intro { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 0 0 6px; }
.fit-step { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.fit-step h3 { margin: 0; font-size: 13.5px; color: var(--navy); }
.substep { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--navy2); color: var(--navy2); font-size: 11.5px; font-weight: 700; }
.fit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filebtn { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--navy); border-radius: 8px; padding: 7px 12px;
  background: var(--navy); color: #fff; font-size: 13px; cursor: pointer; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.filebtn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
#fit-text { display: block; width: 100%; box-sizing: border-box; margin-top: 8px; border: 1px solid #cbd9e3; border-radius: 10px; padding: 9px 11px;
  font: 12.5px/1.6 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); background: #fbfdff; resize: vertical; }
.fit-example { margin-top: 8px; padding: 8px 11px; border: 1px dashed var(--warn-line); background: var(--warn-bg); color: #5c4a1a; border-radius: 8px; font-size: 12.5px; line-height: 1.6; }
.ex-tag { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 4px; background: var(--warn-ink); color: #fff; font-weight: 700; font-size: 12px; }
.fit-status { margin-top: 6px; font-size: 12.5px; color: var(--ok-ink); line-height: 1.6; }
.fit-status:empty { display: none; }
.ok-mark { font-weight: 800; margin-right: 4px; }
.fit-params { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; border-radius: 10px; }
.fit-params.invalid { outline: 2px solid var(--err-line); outline-offset: 3px; }
.fp { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "cb name mode" "cb cur cur"; column-gap: 8px; align-items: center;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font-size: 13px; min-width: 0; }
.fp input { grid-area: cb; width: 16px; height: 16px; accent-color: var(--navy); }
.fp-name { grid-area: name; font-weight: 650; color: var(--ink); }
.fp-mode { grid-area: mode; font-size: 11.5px; color: var(--muted); }
.fp-cur { grid-area: cur; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fp.on { border-color: var(--navy2); background: #f1f6fb; }
.fp.on .fp-mode { color: var(--navy2); font-weight: 700; }
.fit-param-note { margin-top: 8px; }
.fit-run-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.fit-run-row .msg { flex: 1 1 240px; min-width: 0; }
.chart.chart-fit { height: 380px; }
.fit-metrics { margin-top: 10px; }
table.fit-est { margin-top: 10px; }
table.fit-est td { white-space: normal; min-width: 0; }
table.fit-est tr.fixed td { color: var(--muted); }
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11.5px; font-weight: 650; background: #eef3f7; color: #526a7d; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.fit-interpret ul.fit-guide { margin: 8px 0 0; padding-left: 18px; }
.fit-interpret ul.fit-guide li { margin: 3px 0; }
@media (max-width: 720px) {
  .card-status { padding: 1px 7px; font-size: 11.5px; }
  .fit-params { grid-template-columns: minmax(0, 1fr); }
  .chart.chart-fit { height: 340px; }
  .fit-actions > * { flex: 1 1 140px; justify-content: center; }
}

/* v0.3.0：干预配色与所选干预 */
.chip { border-color: var(--c, var(--line)); padding: 2px 3px 2px 2px; gap: 2px; }
.chip button { border: 0; background: transparent; }
.chip .chip-main { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; color: var(--ink); font-weight: 600; min-width: 0; }
.chip .chip-main:hover { background: #f4f8fb; }
.chip.on { box-shadow: 0 0 0 2px var(--c); background: #fbfdff; }
.chip-cur { font-size: 11px; font-weight: 700; color: var(--ok-ink); }
.sel-scn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 2px; font-size: 13px; color: var(--ink); }
.sel-scn .dot { margin-right: 0; width: 11px; height: 11px; }
.metric-box.scn { border-top: 3px solid var(--line); }
table.cmp tr.sel td { background: #f7fafc; font-weight: 650; }

/* v0.3.1：拟合卡片位序后，窄屏估计表标签不溢出 */
table.fit-est td { min-width: 0; overflow-wrap: anywhere; }
table.fit-est .tag { max-width: 100%; white-space: normal; }
.fit-card, .fit-body, .fit-result, .chart-wrap { min-width: 0; max-width: 100%; }

/* v0.3.2：两层界面与本地化参数折叠 */
.ui-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--navy); font-weight: 650;
  border: 1px solid #b9cbd8; border-radius: 8px; padding: 6px 10px; background: #fff; cursor: pointer; user-select: none; }
.ui-toggle input { width: 15px; height: 15px; accent-color: var(--navy); }
html:not(.show-refs) .hint { display: none; }
html:not(.show-refs) .hint.local { display: none; }
html.show-refs .hint, html.show-refs .hint.local { display: block; }
details.local-params, details.advanced { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #f9fbfd; }
details.local-params > summary, details.advanced > summary, #structure-details > summary, #methods-details > summary {
  cursor: pointer; color: var(--navy); font-weight: 650; font-size: 13px; list-style: none; }
details.local-params > summary::-webkit-details-marker,
details.advanced > summary::-webkit-details-marker,
#structure-details > summary::-webkit-details-marker,
#methods-details > summary::-webkit-details-marker { display: none; }
details.local-params > summary::before, details.advanced > summary::before { content: "▸ "; color: var(--muted); }
details.local-params[open] > summary::before, details.advanced[open] > summary::before { content: "▾ "; }
.sum-sub { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
#structure-details > summary .section-heading { margin: 0; }
#structure-details > summary .step { background: #8aa4bb; }
.fit-chip { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; padding: 1px 8px; border-radius: 999px;
  background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.fit-chip[hidden] { display: none !important; }
.fit-chip .unlock { border: 0; background: transparent; color: var(--navy); font-size: 11.5px; font-weight: 700; padding: 0 2px; text-decoration: underline; cursor: pointer; }
.knob.locked .pair input, .knob.locked select, .knob.locked input[type="range"] { opacity: 0.75; cursor: not-allowed; }
.knob-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .ui-toggle { flex: 1 1 140px; justify-content: center; }
  .fit-chip { margin-left: 0; }
}

/* v0.3.4：参考文献开关不换行 */
.ui-toggle { white-space: nowrap; }

/* ---------- AI 助手 ---------- */
.ai-log { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 2px 2px 4px; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-suggest[hidden] { display: none; }
.ai-suggest button { padding: 5px 10px; font-size: 12.5px; border-radius: 999px; }
.ai-msg { max-width: 92%; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.7; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-radius: 10px 10px 2px 10px; white-space: pre-wrap; }
.ai-msg.bot { align-self: flex-start; background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 10px 10px 10px 2px; }
.ai-msg.bot.notice { background: #fffaf0; border-color: #f0e2b8; color: #7a611f; }
.ai-msg.bot.err { background: #fff5f5; border-color: #ecc4c4; color: var(--danger); }
.ai-msg.pending { color: var(--muted); }
.ai-msg .ai-ctx-tag { display: block; font-size: 11px; opacity: .8; margin-bottom: 2px; }
.ai-form { margin-top: 10px; }
.ai-form textarea { width: 100%; resize: vertical; min-height: 52px; border: 1px solid #b9cbd8; border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 13px; color: var(--ink); }
.ai-form textarea:focus-visible { outline: 2px solid #9cc0de; outline-offset: 1px; }
.ai-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.ai-row .switch { font-size: 12.5px; color: var(--muted); }
.ai-count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; align-items: baseline; }
.ai-note { font-size: 11.5px; color: #6b7785; line-height: 1.55; }

/* ---------- 周病例图坐标切换 ---------- */
.axis-toggle { display: inline-flex; flex: 0 0 auto; border: 1px solid #b9cbd8; border-radius: 8px; overflow: hidden; }
.axis-toggle button { border: 0; border-radius: 0; padding: 5px 11px; font-size: 12.5px; }
.axis-toggle button + button { border-left: 1px solid #b9cbd8; }
.axis-toggle button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.scale-note { margin: -4px 0 6px; font-size: 12px; color: var(--navy2); }
.scale-note[hidden] { display: none; }
