/* 场景：白天办公室，显示器亮度正常，用户一边开着表格一边对账 → 浅色。
   世界：账本蓝的外壳，左右两份名单各有固定颜色（青、赭），两边都有用紫。
   标志动作：结果区域选择用可点的两圆交集图。 */

:root {
  --ground: #f3f5f6;
  --surface: #ffffff;
  --sunk: #f6f8fa;
  --ink: #15202b;
  --ink-2: #4b5967;
  --ink-3: #586978;
  --line: #d7dde3;
  --line-2: #e6eaee;
  --shell: #12324f;
  --shell-ink: #e8eff6;
  --shell-ink-2: #a9bdd0;

  --a: #0b6f7a;
  --a-soft: #e2f1f2;
  --a-mid: #9fd0d5;
  --b: #ad4f0d;
  --b-soft: #fbeee2;
  --b-mid: #ecc09d;
  --both: #5b3e8c;
  --both-soft: #eee8f6;
  --both-mid: #c5b5df;

  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #1d6b3a;
  --bad: #a3261b;
  --focus: #2766b0;

  --r: 12px;
  --r-s: 8px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --head-h: 36px;
  color-scheme: light;
}
/* 英文页先用系统西文字体，中文字体只作后备 */
html[lang="en"] { --font: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif, "PingFang SC", "Microsoft YaHei"; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  caret-color: var(--focus);
}
::selection { background: #cfe0f3; color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

* { scrollbar-width: thin; scrollbar-color: #b9c3cc transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c3ccd4; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #a6b2bd; }

.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 外壳 ---------- */

.shell { background: var(--shell); color: var(--shell-ink); }
.shell-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 600; font-size: 17px; letter-spacing: 0.01em; }
.brand-mark { width: 32px; height: 20px; fill: none; stroke-width: 1.8; }
.brand-mark circle:first-child { stroke: var(--a-mid); }
.brand-mark circle:last-child { stroke: var(--b-mid); }
.tag { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: rgb(255 255 255 / 0.12); color: var(--shell-ink-2); }
.shell-end { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.local { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--shell-ink-2); }
.lang { color: var(--shell-ink); font-size: 13.5px; text-decoration: none; padding: 3px 10px; border: 1px solid rgb(255 255 255 / .28); border-radius: 6px; }
.lang:hover { background: rgb(255 255 255 / .1); }
.shell :focus-visible { outline-color: #9cc3ef; }

.intro { margin: 0 2px 18px; max-width: 72ch; }
.intro h1 { margin: 0; color: var(--shell); font-size: clamp(28px, 2.5vw, 36px); line-height: 1.25; font-weight: 650; letter-spacing: -0.015em; text-wrap: balance; }
.intro p { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; text-wrap: pretty; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 48px; }

.h2 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; }
.h3 { margin: 0; font-size: 14px; font-weight: 600; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--sunk); border-color: #c4ccd4; }
.btn:active:not(:disabled) { background: #e9edf1; }
.btn:disabled { color: #9aa6b1; cursor: not-allowed; background: var(--sunk); }
.btn.primary { background: var(--shell); border-color: var(--shell); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1a4469; border-color: #1a4469; }
.btn.primary:disabled { background: #c9d3dc; border-color: #c9d3dc; color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.small .ico { width: 16px; height: 16px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--sunk); color: var(--ink); border-color: transparent; }
.btn.ghost:disabled { background: transparent; }
.link { border: 0; background: none; padding: 0; color: var(--focus); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; font-size: inherit; }
.link:hover { color: #1d5395; text-decoration-thickness: 2px; }

/* ---------- 输入两边 ---------- */

.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.side {
  --c: var(--a); --soft: var(--a-soft); --mid: var(--a-mid);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column; min-width: 0;
  transition: border-color .15s, box-shadow .2s;
}
.side[data-side="b"] { --c: var(--b); --soft: var(--b-soft); --mid: var(--b-mid); }
.side.drag { border-color: var(--c); box-shadow: 0 0 0 3px var(--soft), 0 8px 24px -12px rgb(18 50 79 / .35); }
.side.busy .side-meta { color: var(--c); }

.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--mid); border-radius: var(--r) var(--r) 0 0; background: var(--soft); min-height: 48px; }
.glyph { width: 24px; height: 16px; flex: none; fill: none; stroke: var(--mid); stroke-width: 1.3; }
.glyph path { fill: var(--c); stroke: none; }
.side-name {
  flex: 1 1 auto; min-width: 4em; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; margin-left: -2px;
  background: transparent; font-weight: 600; font-size: 15.5px; color: var(--ink);
}
.side-name::placeholder { color: var(--ink); }
.side-name:hover { border-color: var(--line); }
.side-name:focus { outline: none; border-color: var(--c); background: var(--surface); box-shadow: 0 0 0 3px var(--soft); }
.side-meta { color: var(--ink-2); font-size: 13.5px; white-space: nowrap; }
.side-tools { display: inline-flex; gap: 2px; }
.side-flash { margin: 8px 12px 0; padding: 8px 12px; border-radius: var(--r-s); background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }

.side-body { position: relative; height: 232px; display: flex; }
.paste {
  flex: 1; resize: none; border: 0; padding: 14px; background: transparent;
  font-size: 14.5px; line-height: 1.6; color: var(--ink); border-radius: 0 0 var(--r) var(--r);
}
.paste::placeholder { color: var(--ink-3); }
.paste:focus { outline: none; background: linear-gradient(var(--soft), var(--soft)) bottom / 100% 2px no-repeat; }
.side:has(.paste:focus) { border-color: var(--mid); }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 8px 12px 12px; color: var(--ink-3); font-size: 13px; flex-wrap: wrap; }

.loaded { flex: 1; overflow: auto; padding: 10px 14px 12px; outline-offset: -3px; }
.source { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
.cfg { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--c); width: 15px; height: 15px; margin: 0; }
.field { display: inline-flex; align-items: center; gap: 6px; }
.field select { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 6px; font-size: 13px; max-width: 12em; }

.peek table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13.5px; }
.peek th, .peek td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; background: var(--sunk); }
.peek .key { background: var(--soft); }
.peek th.key { color: var(--c); }
.more { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }

.ask { margin: 0 0 10px; padding: 10px 12px; border-radius: var(--r-s); background: var(--sunk); border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.ask p { margin: 0; font-weight: 500; font-size: 14px; }
.ask div { display: flex; gap: 6px; flex-wrap: wrap; }

.starter { margin: 0 0 20px; padding: 14px 16px 16px; background: var(--a-soft); border: 1px solid var(--a-mid); border-radius: var(--r); }
.examples-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; margin-bottom: 10px; }
.examples-head h2 { margin: 0; font-size: 17px; color: var(--shell); }
.examples-head span, .examples-grid span { color: var(--ink-2); font-size: 13px; }
.examples-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.examples-grid button { display: grid; align-content: start; gap: 3px; padding: 10px 12px; text-align: start; background: var(--surface); color: var(--shell); border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; font: inherit; }
.more-examples { margin-top: 6px; }
.more-examples summary { width: fit-content; padding: 8px 2px; cursor: pointer; color: var(--a); font-weight: 600; }
.more-examples h3 { margin: 12px 0 6px; font-size: 14px; }
.more-examples .examples-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .more-examples .examples-grid { grid-template-columns: minmax(0, 1fr); } }
.examples-grid button:hover, .examples-grid button[aria-pressed="true"] { border-color: var(--a); }
.examples-grid button[aria-pressed="true"] strong { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 760px) {
  .starter { padding: 12px; }
  .examples-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .examples-grid button { padding: 8px 10px; }
}


/* ---------- 工作区 ---------- */

.work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

.control { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "heading heading all" "diagram groups groups"; align-items: center; gap: 4px 18px; padding: 14px 18px; }
.group-heading { grid-area: heading; }
.summary { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; }
.venn-wrap { grid-area: diagram; justify-self: start; width: 210px; max-width: 100%; }
.venn { display: block; width: 100%; height: auto; user-select: none; }
.venn .vr path:first-child { fill: var(--surface); stroke: none; transition: fill .18s cubic-bezier(.2, .8, .2, 1); }
.venn .vr-a { --c: var(--a); --soft: var(--a-soft); }
.venn .vr-b { --c: var(--b); --soft: var(--b-soft); }
.venn .vr-both { --c: var(--both); --soft: var(--both-soft); }
.venn.ready .vr { cursor: pointer; }
.venn.ready .vr:hover path:first-child { fill: var(--soft); }
.venn.ready .vr.on path:first-child { fill: var(--c); }
.venn .vo { fill: none; stroke: #9eabb7; stroke-width: 1.2; pointer-events: none; }
.venn.ready .vo:first-of-type { stroke: var(--a); }
.venn.ready .vo:last-of-type { stroke: var(--b); }
.venn .vn { font-size: 19px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; fill: var(--ink-3); pointer-events: none; font-variant-numeric: tabular-nums; }
.venn.ready .vn { fill: var(--c); }
.venn .vr.on .vn { fill: #fff; }
.venn .vtick { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .18s; pointer-events: none; }
.venn .vr.on .vtick { opacity: 1; }
.venn .vname { font-size: 13px; font-weight: 600; text-anchor: middle; fill: var(--ink-2); }
.venn.ready .vname-a { fill: var(--a); }
.venn.ready .vname-b { fill: var(--b); }

.regions { grid-area: groups; min-width: 0; border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.regions .region-row { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r-s); }
.region-row:has(input:checked) { border-color: var(--c); background: var(--soft); }
.regions .copy-note { flex-basis: 100%; }
.region-row { --c: var(--a); --soft: var(--a-soft); display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 2px; }
.region {
  --c: var(--a); --soft: var(--a-soft);
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-s); cursor: pointer; transition: background-color .15s;
}
.region-b { --c: var(--b); --soft: var(--b-soft); }
.region-both { --c: var(--both); --soft: var(--both-soft); }
.region:hover { background: var(--sunk); }
.region input { position: absolute; opacity: 0; pointer-events: none; }
.region .box { width: 20px; height: 20px; border: 1.5px solid var(--c); border-radius: 5px; display: grid; place-items: center; background: var(--surface); transition: background-color .15s; }
.region .box svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.region input:checked + .box { background: var(--c); }
.region input:checked + .box svg { opacity: 1; }
.region input:focus-visible + .box { outline: 2px solid var(--focus); outline-offset: 2px; }
.region input:disabled + .box { opacity: .5; }
.region:has(input:disabled) { cursor: default; }
.region-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-label b { font-weight: 600; color: var(--c); }
.num { font-weight: 600; font-size: 14.5px; }

/* 每部分的复制按钮：复制成功后图标换成对勾 */
.qcopy {
  width: 34px; height: 34px; border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer; transition: background-color .15s, color .15s;
}
.qcopy:hover:not(:disabled) { background: var(--sunk); color: var(--c); }
.qcopy:disabled { opacity: .35; cursor: default; }
.qcopy .ico:last-child, .copy-all .ico:nth-child(2) { display: none; }
.qcopy.done .ico:first-child, .copy-all .done .ico:first-child { display: none; }
.qcopy.done .ico:last-child, .copy-all .done .ico:nth-child(2) { display: block; }
.qcopy.done { color: var(--ok); }
.copy-all { grid-area: all; justify-self: end; }
.copy-all .btn { width: 100%; justify-content: flex-start; padding: 0 10px; }
.copy-all .btn .num { margin-left: auto; font-size: 13.5px; }
.copy-all .btn.done { color: var(--ok); }

.rules { margin: 0; }
.rules summary { cursor: pointer; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; list-style: none; padding: 4px 0; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::before { content: ""; width: 7px; height: 7px; border: solid var(--ink-3); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg) translateY(-2px); transition: transform .15s; margin-right: 2px; }
.rules[open] summary::before { transform: rotate(45deg) translateY(-2px); }
.rules-brief { font-size: 12.5px; color: var(--ink-3); }
.rules-body { display: grid; gap: 10px; padding: 8px 0 2px; }
.switch { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: #c5ced6; position: relative; transition: background-color .18s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .18s cubic-bezier(.2, .8, .2, 1); }
.switch input:checked + .track { background: var(--shell); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch small { display: block; color: var(--ink-3); font-size: 12.5px; }
.fine { margin: 0; font-size: 12.5px; color: var(--ink-3); }

.notices.panel { display: grid; gap: 8px; padding: 16px 18px; }
.notices.panel:empty { display: none; }
.notice { border-radius: var(--r-s); padding: 9px 12px; font-size: 13.5px; background: var(--sunk); }
.notice.warn { background: var(--warn-soft); }
.notice.warn p { color: #5e3d00; }
.notice.quiet { background: transparent; padding: 2px 12px; color: var(--ink-3); }
.notice p { margin: 0; }
.notice-acts { display: flex; gap: 14px; margin-top: 3px; }
.notice-acts:empty { display: none; }
.notice-list { margin-top: 8px; max-height: 220px; overflow: auto; background: var(--surface); border-radius: 6px; border: 1px solid var(--line-2); }
.notice-list .pair, .notice-list .single { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.notice-list .single { grid-template-columns: 1fr auto; }
.notice-list .pair.head { font-weight: 600; color: var(--ink-2); font-size: 12.5px; background: var(--sunk); position: sticky; top: 0; }
.notice-list .td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-list .fine { padding: 6px 8px; }
.times { color: var(--ink-3); font-size: 12.5px; }

/* 看不见的字符 */
mark.inv, mark.sp {
  display: inline-block; margin: 0 1px; padding: 0 4px; border-radius: 4px; vertical-align: 1px;
  font: 600 10.5px/16px var(--font); letter-spacing: .02em;
  background: #fde7c2; color: #7a4a00;
}
mark.sp { background: #e6ebf0; color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.nil { color: var(--ink-3); }

/* ---------- 结果 ---------- */

.result { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.result-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title actions" "context context"; align-items: center; gap: 8px 16px; padding: 16px 18px 12px; }
.result-title { grid-area: title; }
.result-actions { grid-area: actions; }
.output-context { grid-area: context; }
#output-notices:not(:empty) { margin-top: 6px; }
.result-sub { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; padding: 3px; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-s); }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgb(21 32 43 / .14); }
.undo { margin: 0 18px 8px; padding: 8px 12px; border-radius: var(--r-s); background: var(--both-soft); color: #3d2864; font-size: 13.5px; }
.undo .link { margin-left: 8px; }
.copy-note { margin: 0 18px; min-height: 0; font-size: 13.5px; color: var(--ink-2); }
.copy-note:not(:empty) { margin-bottom: 8px; }
.copy-note.ok { color: var(--ok); }
.copy-note.bad { color: var(--bad); }

.table { position: relative; flex: 1; display: flex; border-top: 1px solid var(--line); }
#table .tbody { height: auto; min-height: 112px; max-height: min(60vh, 520px); }
.tbody { position: relative; flex: 1; height: 520px; overflow: auto; outline-offset: -2px; }
.tr { display: grid; grid-template-columns: var(--cols); min-width: var(--row-w); height: 36px; align-items: center; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.thead { position: sticky; top: 0; z-index: 2; height: var(--head-h); background: var(--sunk); border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.layer { position: absolute; top: var(--head-h); left: 0; right: 0; min-width: var(--row-w); }
.layer .tr { position: absolute; left: 0; right: 0; }
.tbody.wide .tr { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); min-width: max(100%, var(--row-w)); }
.layer .tr:nth-child(even) { background: #fafbfc; }
.layer .tr:hover { background: #f7f9fb; }
.th, .td { padding: 0 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr.loading::before { content: ""; grid-column: 1 / -1; margin: 0 14px; height: 10px; border-radius: 5px; background: var(--line-2); width: 40%; }
.where { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.where::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.where-a { --c: var(--a); }
.where-b { --c: var(--b); }
.where-both { --c: var(--both); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; background: var(--surface); padding: 24px; text-align: center; }
.timing { margin: 0; padding: 10px 18px 12px; font-size: 12.5px; color: var(--ink-3); border-top: 1px solid var(--line-2); }
.timing:empty { display: none; }

/* 并排视图：三列各带区域色，列标题已说明内容，不再要表头 */
.split { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; border-top: 1px solid var(--line); }
.split-column { --c: var(--a); min-width: 0; display: flex; flex-direction: column; }
.split-column + .split-column { border-left: 1px solid var(--line); }
.split-column[data-split-region="both"] { --c: var(--both); }
.split-column[data-split-region="b"] { --c: var(--b); }
.split-header {
  display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 6px;
  padding: 8px 8px 8px 14px; border-bottom: 2px solid var(--c); background: var(--sunk);
}
.split-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; }
.split-title::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.split-empty { margin: 0; padding: 14px; color: var(--ink-3); font-size: 13.5px; }
.split-body { --head-h: 0px; flex: none; height: calc(var(--rows, 4) * 36px); }
.split-body .thead { display: none; }
.split-body .tr { grid-template-columns: minmax(0, 1fr); }
.split-empty:not([hidden]) + .split-body { display: none; }
.split-note { margin: 0 18px 8px; font-size: 13px; color: var(--ink-2); }

.notices.panel:not(:empty) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); align-items: start; }
.notices > h3, .notice.open { grid-column: 1 / -1; }
@media (max-width: 820px) {
  .result-bar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "context" "actions"; }
  .control { grid-template-columns: minmax(0, 1fr); grid-template-areas: "heading" "diagram" "groups" "all"; gap: 8px; }
  .copy-all { justify-self: start; }
  .venn-wrap { justify-self: center; width: 192px; }
  .regions { justify-content: center; }
}
@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
  .split-column + .split-column { border-left: 0; border-top: 1px solid var(--line); }
  .split .split-body { height: calc(min(var(--own, 0), 8) * 36px); }
  main { padding: 16px 12px 40px; }
  .shell-in { padding: 8px 14px; }
  .local { font-size: 12.5px; }
  .inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .side-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 6px; padding: 8px; }
  .side-name { width: 100%; min-width: 0; font-size: 14px; }
  .side-meta:not(:empty) { grid-column: 1; grid-row: 2; }
  .side-tools:not(:empty) { justify-self: end; grid-column: 2; grid-row: 2; }
  .side-head .side-meta:empty, .side-head .side-tools:empty { display: none; }
  .paste { min-width: 0; padding: 9px; font-size: 14px; }
  .loaded { min-width: 0; padding: 8px; }
  .peek table { width: max-content; min-width: 100%; table-layout: auto; }
  .field { flex-wrap: wrap; }
  .field select { max-width: 100%; }
  .side-foot { padding: 6px 8px 10px; gap: 4px; }
  .side-foot .hint { font-size: 12px; }
  .side-body { height: 200px; }
  .side:not(.has-data) .side-body { height: 118px; }
  .result { min-height: 0; }
  .tbody { height: 60vh; }
  .result-actions { width: 100%; }
  .result-actions .btn.primary { flex: 1; justify-content: center; }
  .tr { font-size: 13.5px; }
  .tbody.wide :is(.th, .td) { padding-inline: 6px; }
  .tbody:not(.wide) { --cols: minmax(0, 1fr) 7.5rem !important; }
  .intro h1 { font-size: 26px; }
  /* 名单名称优先：编辑、换一份只留图标，文字留给读屏 */
  .side-tools .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-tools .btn { padding: 0 7px; }
  .guide { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 剪贴板记录（测试模式） */
.cliplog { margin-top: 20px; padding: 16px 18px; }
.cliplog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.cliplog-list { margin: 10px 0 0; padding-left: 20px; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }

/* 处理中：旧结果变淡，说明正在重新比较 */
.busy { margin: 0 18px 8px; padding: 8px 12px; border-radius: var(--r-s); background: var(--sunk); border: 1px solid var(--line-2); font-size: 13.5px; display: flex; align-items: center; gap: 10px; }
.busy .link { margin-left: auto; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--shell); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.table.stale .tbody { opacity: .45; transition: opacity .2s; }

/* ---------- 工具下面的说明（阅读） ---------- */
.guide { margin-top: 40px; padding: 28px 32px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.guide > * { max-width: 70ch; }
.guide h2 { margin: 32px 0 8px; font-size: 19px; line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; }
.guide h2:first-child { margin-top: 0; }
.guide h3 { margin: 20px 0 4px; font-size: 15.5px; font-weight: 600; }
.guide p, .guide li, .guide dd { color: #2c3a47; text-wrap: pretty; }
.guide p { margin: 0 0 10px; }
.guide ol { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.guide dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.guide dt { font-weight: 600; }
.guide dd { margin: 0; }
.guide em { font-style: normal; font-family: var(--mono); font-size: .92em; background: var(--sunk); padding: 0 4px; border-radius: 4px; }
@media (max-width: 720px) { .guide dl { grid-template-columns: 1fr; gap: 2px; } .guide dd { margin-bottom: 8px; } }

.task-guide {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: clamp(32px, 5vw, 72px);
}
.task-guide > section { min-width: 0; max-width: none; }
.task-guide h2 { margin: 0 0 16px; }
.task-guide ol { gap: 10px; }
.task-guide li::marker { color: var(--ink-2); font-weight: 600; }
.excel-guide-link { display: inline-block; margin-top: 16px; }
.intro .guide-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-top: 10px; font-size: 0.95em; }
.intro .guide-links span { color: var(--ink-3); }
.intro .guide-links a { color: var(--focus); text-underline-offset: 3px; }
.task-guide details { border-bottom: 1px solid var(--line); }
.task-guide details:first-of-type { border-top: 1px solid var(--line); }
.task-guide summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 10px 4px; cursor: pointer; font-weight: 550; }
.task-guide summary::-webkit-details-marker { display: none; }
.task-guide summary::after { content: ''; width: 8px; height: 8px; flex: none; margin-right: 4px; border: solid var(--ink-2); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.task-guide details[open] summary::after { transform: rotate(225deg); }
.task-guide summary:hover { color: var(--focus); }
.task-guide details p { max-width: 64ch; margin: 0 20px 14px 4px; }

.foot { max-width: 1192px; width: calc(100% - 48px); margin: 0 auto; border-top: 1px solid var(--line); padding: 16px 0 24px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.foot p { margin: 0; }
.foot-brand strong { margin-right: 8px; color: var(--ink); }
.foot a { color: var(--focus); text-underline-offset: 3px; }
.foot-links { display: flex; align-items: center; flex-wrap: wrap; gap: 0 16px; }
.foot-links > * { display: inline-flex; align-items: center; min-height: 36px; }
@media (max-width: 720px) {
  .task-guide { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 20px 16px; }
  .foot { width: calc(100% - 24px); flex-direction: column; }
  .foot-links > * { min-height: 44px; }
}

/* 隐私说明页 */
.guide.doc { margin-top: 8px; }
.doc h1 { margin: 0; font-size: 26px; line-height: 1.25; font-weight: 650; letter-spacing: -0.015em; }
.doc .updated { margin: 6px 0 4px; color: var(--ink-3); font-size: 13.5px; }
.doc h2:first-of-type { margin-top: 24px; }
.guide a { color: var(--focus); text-underline-offset: 3px; }
.guide ul { margin: 0 0 10px; padding-left: 1.3em; display: grid; gap: 6px; }
.guide code { font-family: var(--mono); font-size: .9em; background: var(--sunk); padding: 0 4px; border-radius: 4px; }
/* 教程里的公式：整行显示，窄屏横向滚动，不折断公式 */
.guide li em, .guide p em { overflow-wrap: anywhere; }
.guide pre { margin: 4px 0 12px; padding: 10px 12px; overflow-x: auto; background: var(--sunk); border-radius: 6px; }
.guide pre code { padding: 0; background: none; white-space: pre; }
.foot .link { color: var(--focus); font-size: inherit; }

/* Cookie 同意横幅：贴底，不遮挡标题；同意和拒绝同样醒目 */
.consent {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  width: min(760px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px -12px rgb(18 50 79 / .35);
}
.consent p { margin: 0; flex: 1 1 320px; font-size: 14px; color: var(--ink); text-wrap: pretty; }
.consent a { color: var(--focus); text-underline-offset: 3px; }
.consent-acts { display: flex; gap: 8px; }
.consent-acts .btn { min-width: 96px; justify-content: center; }
@media (max-width: 720px) { .consent { bottom: 8px; } .consent-acts { width: 100%; } .consent-acts .btn { flex: 1; } }

.excel-example { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 1rem 0; }
.excel-example table { border-collapse: collapse; max-width: 100%; font-size: .88rem; overflow-wrap: anywhere; }
.excel-example caption, .excel-example th { text-align: start; font-weight: 600; }
.excel-example caption { padding-bottom: .4rem; color: var(--a); }
.excel-example table + table caption { color: var(--b); }
.excel-example th { background: var(--sunk); color: var(--ink-2); }
.excel-example td { background: var(--surface); }
.excel-example th, .excel-example td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); }

.copy-note { overflow-wrap: anywhere; }

.workflow-strip, .workflow-actions { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; }
.workflow-strip { margin: 12px 0; }
.workflow-actions { padding-inline: 18px; }
.workflow-actions:has(> :not([hidden]):not(:empty)) { margin-bottom: 10px; }
.workflow-actions summary, .result-evidence { color: var(--focus); cursor: pointer; }
.workflow-actions form { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
.workflow-actions input, .workflow-strip select { max-width: 100%; font: inherit; }
.evidence-hint { margin: 4px 18px 8px; }
.result-evidence { background: transparent; border: 0; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
#evidence { width: min(720px, 92vw); max-height: 85vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 20px; color: var(--ink); }
#evidence::backdrop { background: rgb(15 37 51 / .4); }
#evidence h2, #evidence h3 { margin: 0 0 8px; }
.evidence-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.evidence-sides p { overflow-wrap: anywhere; }
@media (max-width: 640px) { .evidence-sides { grid-template-columns: 1fr; gap: 8px; } }
#example-handoff:has(#use-own[hidden]) { display: none; }
.task-choice { display: grid; gap: 6px; margin-top: 12px; font-weight: 600; }
.result-bar > #notices { width: 100%; }
.result-bar { display: flex; flex-direction: column; align-items: stretch; }
.result-title { order: 0; }
.task-choice { order: 1; }
#task-note { order: 2; margin: 0; }
.output-context { order: 3; }
.result-bar > #notices { order: 4; display: grid; gap: 8px; }
.result-actions { order: 5; }
#task-attendance { white-space: normal; text-align: start; }

/* Shared language picker and site navigation. */
.shell { background: var(--surface); color: var(--shell); border-bottom: 1px solid var(--line); }
.shell .brand { font-size: 20px; letter-spacing: -.02em; }
.shell .brand-mark { width: 36px; height: 24px; }
.shell .brand-mark circle:first-child { stroke: var(--a); }
.shell .brand-mark circle:last-child { stroke: var(--b); }
.shell :focus-visible { outline-color: var(--focus); }
.shell-in { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 72px; gap: 8px 24px; padding-block: 12px; }
.shell-end { display: contents; }
.shell .local { color: var(--ink-2); justify-self: end; max-width: 48ch; font-size: 13px; }
.language-picker { position: relative; flex: none; font-size: 13px; }
.language-picker summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; list-style: none; white-space: nowrap; }
.language-picker summary::-webkit-details-marker { display: none; }
.language-picker .chevron { width: 14px; height: 14px; }
.language-picker[open] .chevron { transform: rotate(180deg); }
.shell .language-picker summary { border-color: var(--line); color: var(--shell); background: var(--sunk); }
.shell .language-picker summary:hover { background: var(--a-soft); border-color: var(--a-mid); }
.language-options { position: absolute; z-index: 60; inset: calc(100% + 8px) 0 auto auto; width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.language-options a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 10px; color: var(--ink); text-decoration: none; border-radius: 4px; }
.language-options a:hover { background: var(--sunk); }
.language-options a[aria-current] { background: var(--a-soft); color: var(--a); font-weight: 600; }
.foot { max-width: none; width: 100%; margin: 0; border: 0; background: var(--shell); color: var(--shell-ink-2); padding: 32px max(24px, calc((100% - 1192px) / 2)) 36px; align-items: start; gap: 24px 40px; }
.foot a, .foot .link { color: var(--shell-ink); }
.foot :focus-visible { outline-color: #9cc3ef; }
.foot-brand { display: grid; gap: 5px; max-width: 32ch; font-size: 13px; }
.foot-brand strong { font-size: 20px; font-weight: 600; color: var(--shell-ink); letter-spacing: -.02em; margin: 0; }
.foot-links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; align-items: start; }
.foot-legal { display: flex; flex-wrap: wrap; gap: 0 18px; }
.foot-legal > * { display: inline-flex; align-items: center; min-height: 40px; color: var(--ink-2); }
.foot-legal a { text-decoration: none; }
.foot-legal a:hover { text-decoration: underline; }
.foot-contact { grid-column: 1; width: fit-content; }
@media (max-width: 720px) {
  .shell-in { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px 14px; }
  .shell .language-picker { grid-column: 2; grid-row: 1; }
  .shell .local { grid-column: 1 / -1; grid-row: 2; justify-self: start; max-width: none; font-size: 12px; }
  .foot { gap: 16px; width: 100%; padding: 24px 16px 28px; align-items: center; text-align: center; }
  .foot-links { width: 100%; gap: 4px 12px; justify-items: center; }
  .foot-legal { gap: 0 14px; justify-content: center; }
  .foot-legal > *, .foot-contact { min-height: 44px; }
}
