/* Pilcrow — the spreadsheet: a full-bleed grid with Excel's furniture.
 *
 * A spreadsheet is not prose, so none of the reading column applies: it takes
 * the whole middle of the window, edge to edge and top to bottom, in the UI
 * face rather than the document serif, and the grid scrolls inside itself
 * while the toolbar, formula bar and sheet tabs stay put. The tokens below are
 * the grid's own; everything else comes from styles.css.
 */

:root {
  --sx-cell-bg: #FFFFFF;
  --sx-grid: #E4E1DA;
  --sx-head-bg: #F6F4EF;
  --sx-head-line: #DCD8CF;
  --sx-head-text: #6A655C;
  --sx-head-on-bg: #E7E5FA;
  --sx-head-on-text: #3D35B5;
  --sx-head-full-bg: #4F46D6;
  --sx-head-full-text: #FFFFFF;
  --sx-text: #1D1C1A;
  --sx-auto-line: #1D1C1A;
  --sx-sel: #4F46D6;
  --sx-sel-fill: rgba(79, 70, 214, 0.09);
  --sx-err: #B42318;
  --sx-note: #E8A31A;
  --sx-note-fill: rgba(242, 184, 48, 0.12);
  --sx-frozen: #B9B3A7;
  --sx-bar-bg: #FBFAF7;
  --sx-tool-hover: #EDEAE3;
  --sx-tool-on: #E4E1F8;
  --sx-tool-on-text: #3D35B5;
}
:root[data-theme="dark"] {
  --sx-cell-bg: #1E1C19;
  --sx-grid: #33302B;
  --sx-head-bg: #262420;
  --sx-head-line: #3A362F;
  --sx-head-text: #A39C90;
  --sx-head-on-bg: #37345A;
  --sx-head-on-text: #D4D0FF;
  --sx-head-full-bg: #8C85F0;
  --sx-head-full-text: #16151A;
  --sx-text: #ECE8E1;
  --sx-auto-line: #BDB6AA;
  --sx-sel: #9A93F5;
  --sx-sel-fill: rgba(154, 147, 245, 0.16);
  --sx-err: #F19A8F;
  --sx-note: #D9A53A;
  --sx-note-fill: rgba(217, 165, 58, 0.14);
  --sx-frozen: #5A554C;
  --sx-bar-bg: #211F1C;
  --sx-tool-hover: #2F2C27;
  --sx-tool-on: #37345A;
  --sx-tool-on-text: #D4D0FF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sx-cell-bg: #1E1C19;
    --sx-grid: #33302B;
    --sx-head-bg: #262420;
    --sx-head-line: #3A362F;
    --sx-head-text: #A39C90;
    --sx-head-on-bg: #37345A;
    --sx-head-on-text: #D4D0FF;
    --sx-head-full-bg: #8C85F0;
    --sx-head-full-text: #16151A;
    --sx-text: #ECE8E1;
  --sx-auto-line: #BDB6AA;
    --sx-sel: #9A93F5;
    --sx-sel-fill: rgba(154, 147, 245, 0.16);
    --sx-err: #F19A8F;
    --sx-note: #D9A53A;
    --sx-note-fill: rgba(217, 165, 58, 0.14);
    --sx-frozen: #5A554C;
    --sx-bar-bg: #211F1C;
    --sx-tool-hover: #2F2C27;
    --sx-tool-on: #37345A;
    --sx-tool-on-text: #D4D0FF;
  }
}

/* ---------- the page around a spreadsheet ---------- */

/* The document pane stops scrolling and hands its height to the grid. The
   reading column's measure, padding and serif all come off. */
#doc-pane:has(> #article > .sx-root) { overflow: hidden; }
#doc-pane:has(> #article > .sx-root) > #article {
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  animation: none;
}
#doc-pane:has(> #article > .sx-root) #doc-head { padding: 9px 16px; }
#doc-pane:has(> #article > .sx-root) #doc-meta {
  max-width: none;
  padding: 7px 16px 6px;
  border-bottom: 1px solid var(--border-soft);
}
#doc-pane:has(> #article > .sx-root) .document-guide { display: none; }
#doc-pane:has(> #article > .sx-root) #edit-banner,
#doc-pane:has(> #article > .sx-root) #doc-signoff { margin-left: 16px; margin-right: 16px; }

/* ---------- frame ---------- */

.sx-root {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--sx-cell-bg);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--sx-text);
}

.sx-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 16px;
  background: var(--accent-wash);
  border-bottom: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 12.5px;
}
.sx-banner[data-kind="conflict"] { background: var(--attn-bg); border-color: var(--attn-border); color: var(--attn-text); }
.sx-banner-text { flex: 1 1 260px; min-width: 0; }
.sx-banner button.primary, .sx-banner .ghost-btn { padding: 5px 11px; font-size: 12px; }
.sx-starter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.sx-starter:hover { border-color: var(--accent); color: var(--accent); }
.sx-starter .ic { width: 14px; height: 14px; }

/* ---------- toolbar ---------- */

.sx-root { container-type: inline-size; container-name: sheet; }
.sx-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--sx-bar-bg);
  border-bottom: 1px solid var(--border);
  flex: none;
}
/* The tools scroll sideways when the pane is narrow; Save never does. */
.sx-tools-main {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent);
}
.sx-tools-main::-webkit-scrollbar { display: none; }
.sx-tools-end { display: flex; align-items: center; flex: none; }
@container sheet (max-width: 700px) {
  .sx-state-text { display: none; }
  .sx-state { margin-right: 6px; }
}
@container sheet (max-width: 520px) {
  .sx-save-label { display: none; }
  .sx-save { padding: 0 9px; }
  .sx-save.primary .sx-save-label { display: inline; }
}
.sx-group { display: flex; align-items: center; gap: 1px; padding: 0 6px; border-right: 1px solid var(--border); flex: none; }
.sx-group:first-child { padding-left: 0; }
.sx-tb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-mid);
  font: inherit;
  cursor: pointer;
}
.sx-tb .ic { width: 16px; height: 16px; }
.sx-tb:hover:not(:disabled) { background: var(--sx-tool-hover); color: var(--text); }
.sx-tb[aria-pressed="true"], .sx-tb[aria-expanded="true"] { background: var(--sx-tool-on); color: var(--sx-tool-on-text); }
.sx-tb:disabled { opacity: 0.35; cursor: default; }
.sx-tb:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sx-numfmt { min-width: 92px; justify-content: space-between; font-size: 12px; font-weight: 600; padding: 0 6px 0 9px; }
.sx-numfmt .ic { width: 12px; height: 12px; opacity: 0.7; }
.sx-color { flex-direction: column; gap: 0; padding-top: 2px; }
.sx-color .ic { width: 15px; height: 15px; }
.sx-swatch { display: block; width: 16px; height: 3px; border-radius: 1px; margin-top: 1px; background: currentColor; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.sx-spacer { flex: 1 1 8px; }
.sx-csv-note, .sx-ro-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.sx-ro-badge { margin-left: 0; }
.sx-ro-badge .ic { width: 13px; height: 13px; }
.sx-root.sx-csv .sx-fmt-only { display: none; }

.sx-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}
.sx-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sx-state[data-state="dirty"] i, .sx-state[data-state="new"] i { background: var(--warn-dot); }
.sx-state[data-state="saving"] i { background: var(--accent); animation: sx-pulse 1s ease-in-out infinite; }
.sx-state[data-state="error"] { color: var(--danger); }
.sx-state[data-state="error"] i { background: var(--danger); }
@keyframes sx-pulse { 50% { opacity: 0.3; } }
.sx-discard { margin-right: 6px; padding: 5px 10px; font-size: 12px; }
.sx-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  flex: none;
}
.sx-save .ic { width: 14px; height: 14px; }
.sx-save.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sx-save:hover:not(:disabled) { filter: brightness(1.06); }
.sx-save:disabled { opacity: 0.6; cursor: default; }
.sx-save:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- formula bar ---------- */

.sx-fbar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--sx-cell-bg);
  flex: none;
  min-height: 30px;
}
.sx-name {
  width: 92px;
  flex: none;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: 600 12.5px var(--font-ui);
  padding: 0 10px;
  text-align: center;
}
.sx-name:focus { outline: 2px solid var(--accent); outline-offset: -2px; text-align: left; }
.sx-fx {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid var(--border);
  color: var(--text-soft);
  font: italic 600 13px Georgia, 'Times New Roman', serif;
  user-select: none;
}
.sx-formula {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--sx-text);
  font: 13px/18px var(--font-ui);
  padding: 6px 10px;
  height: 30px;
  overflow: hidden;
  white-space: pre;
}
.sx-formula:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); white-space: pre-wrap; height: auto; min-height: 30px; max-height: 120px; overflow: auto; }

/* ---------- the grid ---------- */

.sx-wrap { position: relative; flex: 1 1 auto; min-height: 120px; overflow: hidden; }
.sx-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  background: var(--sx-cell-bg);
}
.sx-sizer { position: relative; }
.sx-view {
  position: sticky;
  left: 0;
  top: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: cell;
}
.sx-view[data-cursor="col-resize"] { cursor: col-resize; }
.sx-view[data-cursor="row-resize"] { cursor: row-resize; }
.sx-view[data-cursor="down"] { cursor: s-resize; }
.sx-view[data-cursor="right"] { cursor: e-resize; }

.sx-pane { position: absolute; overflow: hidden; contain: strict; }
.sx-vl, .sx-hl { position: absolute; display: block; background: var(--sx-grid); pointer-events: none; }
.sx-vl { top: 0; bottom: 0; width: 1px; }
.sx-hl { left: 0; right: 0; height: 1px; }

.sx-c {
  position: absolute;
  display: flex;
  align-items: flex-end;
  padding: 0 5px 3px;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 17px;
  pointer-events: none;
}
.sx-c > span { overflow: hidden; text-overflow: clip; min-width: 0; }
.sx-c.a-left { justify-content: flex-start; }
.sx-c.a-center { justify-content: center; text-align: center; }
.sx-c.a-right { justify-content: flex-end; text-align: right; }
.sx-c.v-top { align-items: flex-start; padding-top: 3px; }
.sx-c.v-mid { align-items: center; padding-bottom: 0; }
.sx-c.wrap { white-space: pre-wrap; overflow-wrap: anywhere; align-items: flex-start; padding-top: 3px; }
.sx-c.wrap > span { overflow: visible; }
.sx-c.merged { background: var(--sx-cell-bg); }
.sx-c.spill { background: var(--sx-cell-bg); z-index: 1; }
.sx-c.err { color: var(--sx-err); }

.sx-note-tint { position: absolute; background: var(--sx-note-fill); pointer-events: none; }
.sx-note {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 2;
}
.sx-note::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--sx-note) transparent transparent;
}
.sx-note.resolved::after { border-right-color: var(--ok); opacity: 0.7; }
.sx-note.active { box-shadow: inset 0 0 0 2px var(--sx-note); }
.sx-note.pulse { animation: sx-note-pulse 1.2s ease-out; }
@keyframes sx-note-pulse { 0% { box-shadow: inset 0 0 0 3px var(--accent); } 100% { box-shadow: inset 0 0 0 0 var(--accent); } }

/* Headers sit above the cells; the corner above both. */
.sx-colhead, .sx-rowhead { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; }
.sx-colhead { right: 0; background: var(--sx-head-bg); border-bottom: 1px solid var(--sx-head-line); box-sizing: border-box; }
.sx-rowhead { bottom: 0; background: var(--sx-head-bg); border-right: 1px solid var(--sx-head-line); box-sizing: border-box; z-index: 3; }
.sx-ch, .sx-rh {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: var(--sx-head-bg);
  color: var(--sx-head-text);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.sx-ch { top: 0; bottom: 0; border-right: 1px solid var(--sx-head-line); }
.sx-rh { left: 0; right: 0; border-bottom: 1px solid var(--sx-head-line); }
.sx-ch.on, .sx-rh.on { background: var(--sx-head-on-bg); color: var(--sx-head-on-text); font-weight: 650; }
.sx-ch.on { box-shadow: inset 0 -2px 0 var(--sx-sel); }
.sx-rh.on { box-shadow: inset -2px 0 0 var(--sx-sel); }
.sx-ch.full, .sx-rh.full { background: var(--sx-head-full-bg); color: var(--sx-head-full-text); }
.sx-ch.frz { border-right: 2px solid var(--sx-frozen); }
.sx-rh.frz { border-bottom: 2px solid var(--sx-frozen); }
.sx-corner {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--sx-head-bg);
  border-right: 1px solid var(--sx-head-line);
  border-bottom: 1px solid var(--sx-head-line);
  box-sizing: border-box;
  cursor: pointer;
}
.sx-corner::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  border-style: solid;
  border-width: 0 0 9px 9px;
  border-color: transparent transparent var(--sx-head-line) transparent;
}
.sx-corner.on::after { border-bottom-color: var(--sx-sel); }
.sx-root.sx-frozen-rows [data-pane="top"] { box-shadow: 0 2px 0 var(--sx-frozen); }
.sx-root.sx-frozen-cols [data-pane="left"] { box-shadow: 2px 0 0 var(--sx-frozen); }
.sx-root.sx-frozen-rows [data-pane="top"], .sx-root.sx-frozen-cols [data-pane="left"], [data-pane="corner"] { z-index: 1; background: var(--sx-cell-bg); }

/* Selection, references and handles. */
.sx-sel { position: absolute; overflow: hidden; pointer-events: none; z-index: 2; }
.sx-range { position: absolute; background: var(--sx-sel-fill); box-shadow: inset 0 0 0 1px var(--sx-sel); }
.sx-active { position: absolute; box-shadow: inset 0 0 0 2px var(--sx-sel); }
.sx-active.editing { box-shadow: inset 0 0 0 2px var(--sx-sel), 0 2px 10px rgba(0, 0, 0, 0.12); }
.sx-refbox { position: absolute; box-shadow: inset 0 0 0 2px var(--ref); background: color-mix(in srgb, var(--ref) 10%, transparent); }
.sx-fillbox { position: absolute; box-shadow: inset 0 0 0 1px var(--sx-sel); outline: 1px dashed var(--sx-sel); outline-offset: -3px; }
.sx-marquee {
  position: absolute;
  background-image:
    linear-gradient(90deg, var(--sx-sel) 50%, transparent 50%), linear-gradient(90deg, var(--sx-sel) 50%, transparent 50%),
    linear-gradient(0deg, var(--sx-sel) 50%, transparent 50%), linear-gradient(0deg, var(--sx-sel) 50%, transparent 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 8px 2px, 8px 2px, 2px 8px, 2px 8px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: sx-ants 0.6s linear infinite;
}
@keyframes sx-ants { to { background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px; } }
.sx-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--sx-sel);
  border: 1.5px solid var(--sx-cell-bg);
  box-sizing: border-box;
  pointer-events: auto;
  cursor: crosshair;
  z-index: 3;
}

/* The keyboard's textarea: invisible until it is the editor. */
.sx-input {
  position: absolute;
  z-index: 6;
  margin: 0;
  border: 0;
  padding: 0;
  resize: none;
  overflow: hidden;
  opacity: 0;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  pointer-events: none;
  font: 13px/17px var(--font-ui);
  white-space: pre;
}
.sx-input.editing {
  opacity: 1;
  color: var(--sx-text);
  caret-color: var(--sx-text);
  background: var(--sx-cell-bg);
  pointer-events: auto;
  padding: 3px 5px;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 2px var(--sx-sel), 0 4px 14px rgba(0, 0, 0, 0.14);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
  font-variant-numeric: tabular-nums;
}

/* Formula autocomplete. */
.sx-ac {
  position: absolute;
  z-index: 20;
  width: 300px;
  max-width: calc(100% - 8px);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--e3);
  overflow: hidden;
  font-size: 12.5px;
}
.sx-ac ul { list-style: none; margin: 0; padding: 4px; }
.sx-ac li { display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; border-radius: var(--r-xs); cursor: pointer; }
.sx-ac li b { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.sx-ac li span { color: var(--text-soft); font-size: 11.5px; }
.sx-ac li.on { background: var(--accent-tint); }
.sx-ac li.on b { color: var(--accent); }
.sx-ac-sig { margin: 0; padding: 6px 12px; border-top: 1px solid var(--border-soft); background: var(--bg-soft); font-family: var(--font-mono); font-size: 11.5px; color: var(--text-mid); }
.sx-ac-sig.only { border-top: 0; display: flex; flex-direction: column; gap: 2px; }
.sx-ac-sig.only span { font-family: var(--font-ui); color: var(--text-soft); }

/* ---------- footer: sheet tabs and status ---------- */

.sx-foot {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-height: 34px;
  border-top: 1px solid var(--border);
  background: var(--sx-bar-bg);
  flex: none;
}
.sx-tabs { display: flex; align-items: stretch; min-width: 0; flex: 1 1 auto; }
.sx-addtab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  flex: none;
}
.sx-addtab .ic { width: 16px; height: 16px; }
.sx-addtab:hover { background: var(--sx-tool-hover); color: var(--text); }
.sx-tablist { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.sx-tablist::-webkit-scrollbar { display: none; }
.sx-tab {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 180px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  font: 500 12.5px var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  flex: none;
}
.sx-tab::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--tab, transparent); }
.sx-tab:hover { background: var(--sx-tool-hover); color: var(--text); }
.sx-tab.on { background: var(--sx-cell-bg); color: var(--accent); font-weight: 650; box-shadow: inset 0 2px 0 var(--accent); margin-top: -1px; }
.sx-tab.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
.sx-tablist.drop-end .sx-tab:last-child { box-shadow: inset -3px 0 0 var(--accent); }
.sx-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sx-tab-edit {
  width: 140px;
  margin: 3px 4px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: var(--r-xs);
  background: var(--card);
  color: var(--text);
  font: 600 12.5px var(--font-ui);
}
.sx-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
  flex: none;
  max-width: 60%;
  overflow: hidden;
}
.sx-status b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 3px; }
.sx-stats { display: flex; gap: 14px; }
.sx-mode { color: var(--text-faint); font-weight: 600; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.sx-warn { color: var(--attn-text); overflow: hidden; text-overflow: ellipsis; }

/* ---------- menus and popovers ---------- */

.sx-menu, .sx-pop {
  position: absolute;
  z-index: 40;
  min-width: 210px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--e3);
  font-size: 13px;
}
.sx-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sx-menu button:hover:not(:disabled), .sx-menu button:focus-visible { background: var(--accent-tint); outline: none; }
.sx-menu button:disabled { color: var(--text-faint); cursor: default; }
.sx-menu kbd { font: 11px var(--font-ui); color: var(--text-soft); }
.sx-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.sx-palette { min-width: 0; width: 232px; padding: 8px; }
.sx-auto {
  width: 100%;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--card);
  color: var(--text);
  font: 12.5px var(--font-ui);
  cursor: pointer;
}
.sx-auto:hover { border-color: var(--accent); }
.sx-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.sx-sw { aspect-ratio: 1; border: 1px solid rgba(0, 0, 0, 0.14); border-radius: 4px; cursor: pointer; padding: 0; }
.sx-sw:hover, .sx-sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sx-review { width: min(320px, calc(100% - 20px)); box-sizing: border-box; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.sx-review-label { font-size: 12px; font-weight: 600; color: var(--text-mid); }
.sx-review-label span { font-weight: 400; color: var(--text-soft); }
.sx-review input, .sx-review textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font: 13px var(--font-ui);
  resize: vertical;
}
.sx-review input:focus, .sx-review textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.sx-review-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.sx-review-actions .ic { width: 14px; height: 14px; }

/* "Suggest a fix" opens the prose editor; on a grid you just type in the cell. */
body:has(#article > .sx-root) #sel-suggest { display: none; }

/* The legacy .xls card and the rail glyph, unchanged. */
.sheet-legacy-card { margin: 24px; border: 1px dashed var(--border-strong, var(--border)); border-radius: 12px; padding: 1.5rem; background: var(--bg-soft); font-family: var(--font-ui); max-width: 560px; }
.sheet-legacy-card h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.sheet-legacy-card p { margin: 0; font-size: 0.85rem; color: var(--text-body, var(--text)); line-height: 1.55; }
.file .sheet-glyph { margin-right: 0.3rem; opacity: 0.6; font-size: 0.8em; }

/* ---------- small screens ---------- */

@media (max-width: 768px) {
  #doc-pane:has(> #article > .sx-root) #doc-meta { display: none; }
  .sx-tools { padding: 4px 6px; }
  .sx-group { padding: 0 4px; }
  .sx-tb { min-width: 34px; height: 34px; }
  .sx-state-text { display: none; }
  .sx-state { margin-right: 4px; }
  .sx-name { width: 64px; padding: 0 6px; }
  .sx-fx { padding: 0 7px; }
  .sx-status { max-width: 50%; gap: 8px; padding: 0 8px; }
  .sx-stats { gap: 8px; }
  .sx-mode { display: none; }
  .sx-tab { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sx-marquee, .sx-state[data-state="saving"] i, .sx-note.pulse { animation: none; }
}
