/* [INPUT]: home/spine/stations 的稳定 DOM 与 cellsmith.css 语义 token。
 * [OUTPUT]: Bean 实测的 300px 侧栏、60px 工具栏、30px 方格纸与 Solarized 主题。
 * [POS]: 自有视觉实现, 不含参考产品的 CSS、图像或字标。
 * [PROTOCOL]: 几何合同见 DESIGN.md; 改动同步 e2e/bean-frame.spec.mjs。
 */
@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
:root[data-theme="dark"] {
  --paper: var(--sheet-dark-paper);
  --card: var(--sheet-dark-paper);
  --ink: var(--sheet-dark-ink);
  --ink-2: var(--sheet-dark-ink);
  --mute: var(--sheet-dark-ink);
  --surface-header: var(--sheet-dark-header);
  --surface-hover: var(--sheet-dark-header);
  --rule: var(--sheet-dark-ink);
  --rule-2: var(--sheet-dark-header);
  --grid-line: var(--sheet-dark-ink);
  --sheet-margin: var(--sheet-dark-margin);
  --sheet-button: var(--sheet-dark-header);
}
.shell { display: block; position: relative; min-width: 686px; }
.shell__body {
  height: 100%; display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
}
.spine { grid-row: 1; }
.workbench { grid-row: 1; grid-template-rows: 60px minmax(0, 1fr); position: relative; }
.top-bar {
  position: absolute; z-index: 10; right: 16px; top: 18px;
  height: 24px; padding: 0; border: 0; gap: 12px; justify-content: flex-end; background: transparent;
}
.top-bar .status-line { position: fixed; left: 0; bottom: 0; width: 299px; max-width: none; font-size: 12px; line-height: 14px; z-index: 12; }
.status-line:empty { display: none; }
.top-bar .status-line:not(:empty) { min-height: 24px; background: var(--paper); padding: 5px 16px; }
.top-bar .status-line--error { display: block; white-space: normal; -webkit-line-clamp: unset; max-height: 40vh; overflow: auto; padding: 8px; }
.has-document #open-btn { display: block; position: static; margin-left: auto; background: transparent; }
.is-folded #open-btn { display: none; }
.shell__body.is-folded { grid-template-columns: 76px minmax(0, 1fr); }
.status-line--error { padding: 8px; background: var(--verm-bg); border: 1px solid var(--verm); }
.btn, .cta {
  height: 24px; padding: 0 10px; border: 0; border-radius: 2px; font: 400 14px var(--font-ui);
  line-height: 24px; color: var(--mute); background: var(--sheet-button); box-shadow: none;
  transition: none;
}
.btn--primary, .cta:not(:disabled) { background: var(--swatch-green); color: var(--ink-press); }
.btn:hover, .cta:hover { background: var(--surface-hover); }
.btn:disabled, .cta:disabled { opacity: .6; background: var(--surface-hover); color: var(--mute); }
.cta { gap: 5px; }
.cta__n { color: var(--verm); background: transparent; padding: 0; }
.lens-bar {
  min-height: 60px; height: 60px; padding: 0; border: 0;
  display: flex; flex-wrap: nowrap; background: var(--paper);
}
.sheet-controls {
  display: flex; align-items: center; gap: 20px; height: 60px;
  width: calc(100% - 230px); padding: 0 26px 0 61px; overflow-x: auto; scrollbar-width: none;
}
.lens-bar__tools { order: 0; margin: 0; flex: none; flex-wrap: nowrap; gap: 20px; max-width: none; }
#split-btn { width: 59px; }
#xlsx-btn { width: 77px; }
.sheet-extra { order: 2; display: flex; flex: none; gap: 20px; }
.sheet-controls::-webkit-scrollbar { display: none; }
.lens-bar__tools .btn { flex: none; padding: 0 10px; }
#undo-btn, #redo-btn { order: -1; width: 29px; padding: 0; font-size: 16px; }
#open-btn { display: none; }
#merge-btn { max-width: 90px; }
.sheet-swatches { order: 1; display: flex; gap: 5px; flex: none; }
.sheet-swatch { width: 15px; height: 15px; border: 1px solid var(--faint); border-radius: 50%; padding: 0; background: transparent; cursor: pointer; }
.sheet-swatch[data-tone="gray"] { background: var(--swatch-gray); }
.sheet-swatch[data-tone="green"] { background: var(--swatch-green); }
.sheet-swatch[data-tone="blue"] { background: var(--swatch-blue); }
.sheet-swatch[data-tone="yellow"] { background: var(--swatch-yellow); }
.sheet-swatch:hover, .sheet-swatch:focus-visible { outline: 2px solid var(--sheet-selector); outline-offset: 2px; }
.name-box { order: 3; flex: none; height: 24px; width: 58px; padding: 0 5px; font: 14px var(--font-sheet); border-radius: 2px; background: transparent; border: 1px solid var(--rule-2); }
/* 镜头范围: 住在状态栏最左 (一行, 永不盖住列头); 有镜头时尺寸文字让位给它. */
.lens-scope { flex: 0 1 auto; box-sizing: border-box; height: 18px; max-width: min(520px, 60%); min-width: 0; padding: 0 2px 0 9px; border-radius: 9px; font-size: 12px; line-height: 16px; }
.lens-scope[hidden] { display: none; }
.lens-scope .lens-scope__clear { height: 14px; padding: 0 8px; font-size: 12px; line-height: 14px; border-radius: 7px; }
.workbench:has(.lens-scope:not([hidden])) .doc-size { display: none; }
.status-bar { position: absolute; bottom: 0; left: 0; right: 0; z-index: 7; height: 24px; padding: 0 10px; background: var(--paper); font-size: 12px; gap: 10px; }
.status-details { border: 0; border-radius: 2px; padding: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.status-details:hover { text-decoration: underline; text-underline-offset: 2px; }
.status-details:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.grid-area { grid-row: 2; background: var(--card); }
.shell.drop-zone--active .grid-area { outline: 2px solid var(--brand-green); outline-offset: -2px; }
.vg-viewport { font-family: var(--font-sheet); scrollbar-width: none; }
.vg-viewport::-webkit-scrollbar { width: 0; height: 0; }
.vg-cell, .vg-hcell, .vg-gcell { font-size: 14px !important; font-weight: 400 !important; padding-left: 5px !important; }
/* 横线落在下一行起点, 不占前一行最后 1px; 文本与命中几何不移动。 */
.vg-prow { border-bottom: 0 !important; box-shadow: 0 1px 0 var(--grid-line); }
.vg-cell { color: var(--ink) !important; border-bottom: 0 !important; }
.vg-hcell { background: var(--card) !important; color: var(--ink) !important; border-bottom: 0 !important; box-shadow: 0 1px 0 var(--grid-line); }
.vg-header .vg-hcell { overflow: visible !important; }
.vg-header .vg-header-label { display: block; overflow: hidden; text-overflow: clip; padding-right: 20px; }
.vg-column-letter { position: absolute; left: 0; right: -1px; top: -30px; height: 30px; padding: 0; text-align: center; background: var(--surface-header); color: var(--ink-2); border-right: 1px solid var(--rule-2); border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); line-height: 29px; }
.vg-gcell { text-align: center !important; padding: 0 !important; line-height: 26px !important; border-color: var(--rule-2) !important; border-bottom: 0 !important; box-shadow: inset 0 1px 0 var(--rule-2); }
.vg-corner { border: 1px solid var(--rule-2); text-align: center; color: var(--mute); font: 14px/30px var(--font-sheet); }
.vg-corner::after { content: "1"; display: block; line-height: 26px; margin-top: 29px; height: 30px; background: var(--surface-header); border-top: 1px solid var(--rule-2); }
.vg-viewport--empty .vg-corner::after { display: none; }
.vg-filter-trigger { opacity: 0.5; border-radius: 2px; }
.vg-hcell:hover .vg-filter-trigger, .vg-filter-trigger:focus-visible { opacity: 1; }
.vg-resize-handle { top: -30px !important; height: calc(100% + 30px) !important; }
.vg-resize-handle:hover { outline: 0; background: var(--rule-2); }
.vg-table-region { position: absolute; border: 1px solid var(--sheet-region); pointer-events: none; z-index: 4; }
.vg-table-region::after { content: ""; position: absolute; width: 10px; height: 10px; right: 0; bottom: 0; background: var(--swatch-gray); }
#sel-overlay { border-color: var(--sheet-selector); background: var(--sel-overlay); }
:root[data-selection-tone="gray"] #sel-overlay { background: color-mix(in srgb, var(--swatch-gray) 25%, transparent); }
:root[data-selection-tone="green"] #sel-overlay { background: color-mix(in srgb, var(--swatch-green) 25%, transparent); }
:root[data-selection-tone="blue"] #sel-overlay { background: color-mix(in srgb, var(--swatch-blue) 25%, transparent); }
:root[data-selection-tone="yellow"] #sel-overlay { background: color-mix(in srgb, var(--swatch-yellow) 25%, transparent); }
#cell-editor { font: 14px/30px var(--font-sheet); padding: 0 5px; }
#cell-editor.cell-editor--editing { border: 0; outline: 2px solid var(--sheet-selector); outline-offset: -2px; background: var(--card); box-shadow: none; }
/* 首页把打开入口收进文件区, 工具入口仍保留完整 SSR 落地内容。 */
.shell:not(.shell--tool) .empty-state { position: absolute; top: 30px; left: -284px; width: 274px; height: 120px; inset-inline-end: auto; padding: 0; z-index: 8; }
.shell:not(.shell--tool) .drop-zone { display: block; text-align: left; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
.shell:not(.shell--tool) .drop-zone > * { margin: 0; }
.shell:not(.shell--tool) #empty-open-btn { position: absolute; right: -9px; top: -29px; height: 28px; background: transparent; }
.home-tools { position: absolute; left: 0; top: calc(100vh - 112px); width: 220px; font: 12px var(--font-ui); color: var(--mute); }
.home-tools summary { cursor: pointer; }
.shell:not(.shell--tool) .tool-links--home { position: absolute; bottom: 100%; width: 274px; max-height: 50vh; overflow: auto; border: 0; display: grid; gap: 8px; padding: 12px 0; background: var(--paper); }
.shell:not(.shell--tool) .tool-links--home a { font-size: 12px; padding: 0; }
.shell:not(.shell--tool) .site-foot { position: absolute; top: calc(100vh - 112px); left: 228px; margin: 0; font-size: 12px; }
.shell:not(.shell--tool) .wedge-report:not([hidden]) { position: fixed; top: 250px; left: 16px; width: 272px; max-height: calc(100vh - 280px); overflow: auto; background: var(--paper); }
.shell--tool .empty-state { padding: 0; z-index: 8; background: transparent; }
/* 工具页首屏: 卡片浮在可见的 Bean 纸面网格上; 说明文字是卡片下方同一滚动区里的纸面块. */
.shell--tool .drop-zone { border: 0; border-radius: 0; background: transparent; padding: 40px 24px; }
.tool-card { box-sizing: border-box; width: min(600px, 100%); padding: 20px 24px 24px; border: 1px solid var(--rule-2); background: var(--paper); }
.tool-content { text-align: left; box-sizing: border-box; width: min(600px, 100%); margin-top: 24px; padding: 24px 32px 40px; border: 1px solid var(--rule-2); background: var(--paper); }
.sheet-help-dialog { width: min(900px, 80vw); height: calc(min(900px, 80vw) / 2 + 118px); max-height: 75vh; top: 15%; bottom: auto; padding: 20px; border: 0; border-radius: 5px; background: var(--paper); color: var(--ink); box-shadow: var(--sheet-help-shadow); font-family: var(--font-sheet); }
.sheet-help-dialog::backdrop { background: var(--sheet-scrim); }
.sheet-help-dialog[open] { display: flex; flex-direction: column; }
.sheet-help-paper { display: grid; grid-template-columns: 46% 54%; aspect-ratio: 2; flex: none; min-height: 0; background: var(--card); }
.sheet-help-dialog dl { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(13, minmax(0, 1fr)); margin: 0; padding: 0 10px; font-size: 14px; min-height: 0; overflow: auto; }
.sheet-help-dialog dt, .sheet-help-dialog dd { align-content: center; margin: 0; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.sheet-help-dialog dt { padding-right: 12px; }
.sheet-help-example { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.sheet-help-example th, .sheet-help-example td { border: 1px solid var(--rule-2); padding: 0 5px; text-align: left; font-weight: 400; overflow: hidden; white-space: nowrap; }
.sheet-help-example th { background: var(--surface-header); color: var(--mute); text-align: center; }
.sheet-help-example th:first-child { width: 10%; }
.sheet-help-dialog footer { position: absolute; bottom: 0; left: 0; right: 0; height: 30px; display: flex; justify-content: space-between; align-items: center; padding: 0 10px; background: var(--rule-2); }
.sheet-help-dialog h2 { font: 400 14px var(--font-ui); color: var(--mute); margin: 0; }
.sheet-help-close { font: 14px var(--font-ui); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.sheet-help-dialog p { font-size: 14px; color: var(--mute); margin: 8px 0 30px; flex: none; }
/* 入口卡: 首页盖住空网格居中, 工具页首屏同一组件在 h1 下流式排布。 */
.shell:not(.shell--tool) .entry-card { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; pointer-events: none; overflow: auto; }
.shell:not(.shell--tool) .entry-card__box { pointer-events: auto; }
.shell.has-document .entry-card { display: none; }
.entry-card__box { box-sizing: border-box; width: min(560px, 100%); padding: 28px; border: 1px solid var(--rule-2); background: var(--paper); text-align: left; }
.shell--tool .entry-card__box { padding: 0; border: 0; background: transparent; }
.shell--tool .entry-card__drop { padding: 22px 16px; }
.shell--tool .entry-card { margin: 0 auto; width: 100%; max-width: 560px; }
.entry-card__title { margin: 0 0 16px; font: 600 24px/1.2 var(--font-ui); letter-spacing: 0; text-wrap: balance; color: var(--ink); }
.entry-card__drop { display: grid; justify-items: center; gap: 14px; padding: 36px 16px; border: 1px dashed var(--rule); text-align: center; }
.entry-card__drop p { margin: 0; font: 14px var(--font-ui); color: var(--mute); }
.entry-card .btn, body[data-tool-destination] .entry-card #empty-open-btn { margin: 0; height: 30px; padding: 0 12px; border: 1px solid var(--brand-green); border-radius: 2px; background: var(--swatch-green); color: var(--ink); font: 500 14px var(--font-ui); }
.entry-card .btn:hover { background: color-mix(in srgb, var(--swatch-green) 80%, var(--brand-green)); }
.shell.drop-zone--active .entry-card__drop { border-style: solid; border-color: var(--brand-green); background: color-mix(in srgb, var(--swatch-green) 18%, transparent); }
.entry-card__chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.entry-chip { display: grid; align-content: center; min-height: 40px; padding: 10px 12px; font: 500 14px var(--font-ui); border: 1px solid var(--rule-2); border-radius: 0; background: var(--card); color: var(--ink); text-align: left; cursor: pointer; }
.entry-chip:hover { border-color: var(--rule); background: var(--surface-header); }
.entry-chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.entry-card__privacy { margin: 16px 0 0; font: 12px/1.45 var(--font-ui); color: var(--mute); }
@media (max-width: 1100px) {
  .top-bar { right: 12px; }
}
@media (max-width: 760px) {
  body { overflow-x: auto; }
  .top-bar { right: 12px; }
  .workbench { min-width: 386px; }
  .lens-bar { padding: 0; }
  .lens-bar__tools { gap: 20px; }
  .sheet-swatches { display: flex; }
  .sheet-help-paper { grid-template-columns: 1fr; }
  .sheet-help-dialog dl { grid-template-rows: none; grid-auto-rows: minmax(30px, max-content); }
  .sheet-help-example { display: none; }
  .shell__body, .shell__body.is-folded { grid-template-rows: minmax(0, 1fr); }
  .spine { grid-row: 1; border-top: 0; }
  .split-panel, .xlsx-panel { position: fixed; top: 65px; right: 16px; z-index: 20; }
  .entry-card__chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 首页入口卡在手机上是首屏第一个整宽元素: 铺满网格区, 不让行号/列头从边缘漏出. */
  .shell:not(.shell--tool):not(.has-document) .entry-card { display: block; padding: 0; }
  .shell:not(.shell--tool) .entry-card__box { width: 100%; height: 100%; border: 0; }
  .entry-card__box { padding: 16px; }
  .entry-card__title { font-size: 18px; margin-bottom: 12px; }
  .open-key { display: none; }
  .shell--tool .entry-card__drop { padding: 14px 12px; }
  .shell--tool { min-width: 0; }
  .shell--tool:not(.has-document) .empty-state { position: fixed; inset: 100px 0 0; padding: 0; }
  .shell--tool:not(.has-document) .top-bar { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sheet-help-dialog, .btn, .cta { transition: none; } }

/* 窄屏 (< 700px): 清单收成抽屉 (默认收起, #spine-menu 打开), 页面不横向滚动.
   第 0 行 40px 放菜单钮与 Close/Save, 工具条与网格各占其下一行; 宽屏规则不动. */
.spine-menu { display: none; }
@media (max-width: 699px) {
  body { overflow-x: hidden; }
  .shell, .shell--tool { min-width: 0; }
  .shell .shell__body, .shell .shell__body.is-folded { grid-template-columns: minmax(0, 1fr); }
  .workbench { min-width: 0; grid-column: 1; grid-template-rows: 40px 60px minmax(0, 1fr); }
  .lens-bar { grid-row: 2; }
  .grid-area { grid-row: 3; }
  .sheet-controls { width: 100%; padding: 0 12px; }
  .top-bar { top: 8px; right: 8px; left: 44px; }
  .spine-menu { display: block; position: absolute; z-index: 11; left: 8px; top: 8px; width: 28px; height: 24px; padding: 0; border: 0; border-radius: 2px; background: var(--sheet-button); color: var(--mute); font-size: 14px; line-height: 24px; cursor: pointer; }
  .spine-menu[aria-expanded="true"] { display: none; }
  .shell .spine { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(300px, 88vw); box-shadow: 4px 0 0 var(--rule-2); }
  .shell .shell__body:not(.is-drawer) .spine { visibility: hidden; }
  .lens-scope { max-width: 100%; }
  .workbench:has(.lens-scope:not([hidden]), .doctor-chip:not([hidden])) .doc-facts { display: none; }
  .split-panel, .xlsx-panel { top: 105px; right: 8px; left: 8px; }
  .top-bar .status-line { width: 100%; bottom: 24px; }
}

/* 等候 / 超限 / 编码选择: 工作台内浮在可见网格上的一张卡 (不再是整屏白页); 页面级 .open-wait--page 不受影响. */
section.open-wait:not(:empty) { position: absolute; inset: 60px 0 0; z-index: 20; align-items: center; padding: 16px; gap: 0; background: transparent; pointer-events: none; overflow: auto; }
section.open-wait .open-wait__message { box-sizing: border-box; width: min(560px, 100%); gap: 12px; padding: 20px 24px 24px; border: 1px solid var(--rule-2); background: var(--paper); pointer-events: auto; }
section.open-wait h1, section.open-wait h2 { max-width: none; font-size: 16px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
section.open-wait p, section.open-wait .open-wait__position { max-width: none; font: 14px/1.5 var(--font-ui); color: var(--ink-2); }
section.open-wait .open-wait__position { font-size: 16px; font-weight: 600; color: var(--ink); }
section.open-wait .open-wait__note { margin-top: 0; }
.enc-option { display: grid; gap: 10px; justify-items: stretch; max-width: none; }
.enc-option + .enc-option { padding-top: 12px; border-top: 1px solid var(--rule-2); }
.enc-preview { display: block; width: fit-content; max-width: 100%; overflow-x: auto; border-collapse: separate; border-spacing: 0; font: 14px var(--font-sheet); background: var(--paper); border: 1px solid var(--rule-2); }
.enc-preview th, .enc-preview td { height: 30px; padding: 0 8px; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); text-align: left; font-weight: 400; white-space: nowrap; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.enc-preview thead th, .enc-preview tbody th { background: var(--surface-header); color: var(--ink-2); text-align: center; }
.enc-preview tbody th { min-width: 34px; padding: 0 4px; }
.enc-preview tr > :last-child { border-right: 0; }
.enc-preview tbody tr:last-child > * { border-bottom: 0; }
.enc-preview tbody tr:first-child td { background: var(--card); }
section.open-wait .enc-option__facts { margin: 0; font-size: 14px; color: var(--ink-2); }
section.open-wait .open-wait__actions { gap: 8px; }
section.open-wait .enc-choice__lead { margin: 0; }
@media (max-width: 699px) { section.open-wait:not(:empty) { inset: 100px 0 0; } }
.shell:has(section.open-wait:not(:empty)) .entry-card { visibility: hidden; }
