/* sudocs — design tokens. The palette, type scale, 8px spacing grid and 4-8px radii
   were captured from a public product site with Craft Anything, then rebuilt here. */

:root {
  --accent: #1a73e8; --accent-hover: #1967d2; --accent-soft: #e8f0fe;
  --text: #202124; --text-2: #5f6368; --border: #dadce0;
  --surface: #ffffff; --surface-2: #f8f9fa; --surface-3: #f1f3f4; --hover: #f1f3f4;
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --toolbar-h: 44px; --topbar-h: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --doc-font: Arial, "Helvetica Neue", sans-serif;
  --page-w: 816px; --page-min-h: 1056px; --page-pad: 96px; --gutter: 0px;
  --radius: 4px; --radius-lg: 8px;
}
html[data-theme="dark"] {
  --accent: #8ab4f8; --accent-hover: #aecbfa; --accent-soft: #23324a;
  --text: #e8eaed; --text-2: #9aa0a6; --border: #3c4043;
  --surface: #202124; --surface-2: #292a2d; --surface-3: #303134; --hover: #3c4043;
  --shadow-1: 0 1px 2px rgba(0,0,0,.6); --shadow-2: 0 4px 12px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--surface-3);
  font-size: 14px; overflow: hidden; display: flex; flex-direction: column; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

.topbar { height: var(--topbar-h); background: var(--surface); display: flex;
  align-items: flex-start; justify-content: space-between; padding: 8px 12px 0; flex: 0 0 auto;
  position: relative; z-index: 40; }
.topbar-left { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 4px; padding-top: 4px; }
.brand { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text);
  padding: 4px 6px; border-radius: var(--radius); }
.brand-name { font-size: 20px; font-weight: 500; letter-spacing: -.2px;
  background: linear-gradient(90deg,#1a73e8,#7a3cff); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }
.doc-meta { display: flex; flex-direction: column; min-width: 0; }
.doc-title { border: none; background: transparent; font-size: 18px; padding: 3px 8px;
  border-radius: var(--radius); width: 300px; max-width: 46vw; }
.doc-title:hover { background: var(--surface-3); }
.doc-title:focus { outline: 2px solid var(--accent); background: var(--surface); }
.menu-row { display: flex; gap: 1px; margin-top: 1px; }
.menu-btn, .sb-btn { border: none; background: transparent; padding: 4px 9px; border-radius: var(--radius);
  cursor: pointer; font-size: 13.5px; color: var(--text); }
.menu-btn:hover, .sb-btn:hover { background: var(--hover); }
.menu-btn.open { background: var(--accent-soft); color: var(--accent); }

.icon-btn { border: none; background: transparent; width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
  color: var(--text); position: relative; flex: 0 0 auto; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.active, .icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.primary-btn { border: 1px solid var(--border); background: var(--surface); color: var(--accent);
  border-radius: 100px; padding: 8px 20px; cursor: pointer; font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px; }
.primary-btn:hover { background: var(--accent-soft); border-color: transparent; }
.save-state { font-size: 12px; color: var(--text-2); margin-right: 6px; }

.toolbar { height: var(--toolbar-h); background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1px; padding: 0 8px; overflow-x: auto; flex: 0 0 auto;
  z-index: 30; scrollbar-width: thin; }
.toolbar::-webkit-scrollbar { height: 4px; }
.toolbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tb-group { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 5px; flex: 0 0 auto; }
.toolbar .icon-btn { width: 30px; height: 30px; border-radius: var(--radius); font-size: 14px; }
.tb-select { height: 28px; border: 1px solid transparent; background: transparent; border-radius: var(--radius);
  padding: 0 4px; cursor: pointer; max-width: 130px; }
.tb-select:hover { background: var(--hover); border-color: var(--border); }
.style-select { min-width: 108px; } .size-select { width: 56px; }
.color-btn { cursor: pointer; }
.color-btn input[type=color] { position: absolute; width: 0; height: 0; opacity: 0; }
.color-glyph { font-weight: 700; font-size: 15px; border-bottom: 3px solid #202124; padding-bottom: 1px; line-height: 1; }
.color-glyph.hl { background: #ffff00; color: #202124; }

.workspace { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.canvas-wrap { flex: 1 1 auto; overflow: auto; position: relative; }
.ruler { position: sticky; top: 0; height: 22px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); z-index: 20; display: flex; justify-content: center; }
.ruler-inner { position: relative; width: var(--page-w); height: 100%; }
.ruler-marks { position: absolute; inset: 0; opacity: .55;
  background-image: repeating-linear-gradient(90deg, var(--text-2) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(90deg, var(--text-2) 0 1px, transparent 1px 96px);
  background-size: 100% 6px, 100% 11px; background-position: 0 16px, 0 11px; background-repeat: repeat-x; }
.ruler-margin { position: absolute; top: 0; bottom: 0; width: 0; }
.ruler-margin.left, .ruler-margin.right { border-left: 1px solid var(--text-2); }
.ruler-first { position: absolute; top: 3px; width: 10px; height: 10px; margin-left: -5px;
  background: var(--accent); clip-path: polygon(0 0,100% 0,50% 100%); cursor: ew-resize; }

.pages { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 20px 0 60px; }
.page { width: var(--page-w); min-height: var(--page-min-h); background: var(--surface);
  box-shadow: var(--shadow-1); display: flex; flex-direction: column; position: relative;
  zoom: var(--zoom, 1); }
.page-header, .page-footer { padding: 18px var(--page-pad); color: var(--text-2); font-size: 11px;
  outline: none; min-height: 34px; }
.page-header:empty::before, .page-footer:empty::before { content: attr(data-placeholder);
  color: #bdc1c6; font-style: italic; }
.doc-field { background: var(--surface-3, #eef1f5); border-radius: 3px; padding: 0 2px; }
@media print { .doc-field { background: none; } }
.page-body { flex: 1 1 auto; padding: 20px var(--page-pad) 40px; }
/* Multi-cursor overlays: thin caret bars, small number badges and the
   translucent rectangle that shows a column (block) selection. */
.mc-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.mc-caret { position: absolute; width: 2px; background: var(--accent); border-radius: 1px; }
.mc-caret-primary { background: #202124; }
html[data-theme="dark"] .mc-caret-primary { background: #e8eaed; }
.mc-badge { position: absolute; font-size: 9px; line-height: 1; color: #fff; background: var(--accent);
  border-radius: 6px; padding: 1px 4px; font-family: var(--font); }
.mc-block { position: absolute; background: rgba(26,115,232,.18); border: 1px solid rgba(26,115,232,.55);
  border-radius: 2px; }
.doc { outline: none; min-height: 300px; font-family: var(--doc-font); font-size: 11pt;
  line-height: 1.5; color: var(--text); word-wrap: break-word; }
/* Page-setup extras: binding gutter (inner edge), mirrored margins, hyphenation,
   widow/orphan control. The gutter widens one side of the page body. */
body:not(.mirror-margins) .page-body { padding-right: calc(var(--page-pad) + var(--gutter)); }
body.mirror-margins .page-body { padding-left: calc(var(--page-pad) + var(--gutter)); }
body.hyphenate .doc { hyphens: auto; -webkit-hyphens: auto; }
/* Web layout: one continuous column with no page edges, for reading and editing
   on screen (Word's View ▸ Web Layout). Scoped to screen so printing always uses
   the real page size and keeps the header/footer. */
@media screen {
  body.web-layout .pages { padding: 0 0 40px; gap: 0; }
  body.web-layout .page { width: 100%; max-width: 920px; min-height: 0; box-shadow: none; border-radius: 0; }
  body.web-layout .page-header, body.web-layout .page-footer { display: none; }
  body.web-layout .page-body { padding: 28px 40px 140px; }
}
body.no-widows .doc p, body.no-widows .doc li { widows: 1; orphans: 1; }
body:not(.no-widows) .doc p, body:not(.no-widows) .doc li { widows: 2; orphans: 2; }
/* Text-flow (pagination) rules set from Format ▸ Paragraph ▸ Text flow.
   They apply on screen and in the print / PDF output alike. */
.doc .keep-next { break-after: avoid; page-break-after: avoid; }
.doc .keep-lines { break-inside: avoid; page-break-inside: avoid; }
.doc .starts-page { break-before: page; page-break-before: always; }
.doc .no-hyphenate { hyphens: none !important; -webkit-hyphens: none !important; }
.doc:empty::before { content: attr(data-placeholder); color: #bdc1c6; }

.doc h1 { font-size: 20pt; font-weight: 400; margin: 18px 0 6px; line-height: 1.3; }
.doc h2 { font-size: 16pt; font-weight: 400; margin: 16px 0 5px; line-height: 1.3; }
.doc h3 { font-size: 14pt; color: #434343; margin: 14px 0 4px; line-height: 1.3; }
.doc h4 { font-size: 12pt; color: #666; margin: 12px 0 4px; }
.doc h5 { font-size: 11pt; color: #666; margin: 10px 0 4px; }
.doc h6 { font-size: 11pt; color: #666; font-style: italic; margin: 10px 0 4px; }
.doc .doc-title-line { font-size: 26pt; font-weight: 400; margin: 0 0 6px; }
.doc .doc-subtitle { font-size: 15pt; color: #666; margin: 0 0 18px; }
.doc p { margin: 0 0 8px; }
.doc blockquote { border-left: 3px solid var(--border); margin: 8px 0; padding: 2px 0 2px 14px; color: #5f6368; }
.doc pre { font-family: "Courier New", monospace; background: var(--surface-3); padding: 10px 12px;
  border-radius: var(--radius); white-space: pre-wrap; margin: 8px 0; font-size: 10pt; }
.doc code { font-family: "Courier New", monospace; background: var(--surface-3); padding: 1px 4px;
  border-radius: 3px; font-size: .92em; }
.doc a { color: var(--accent); }
.doc img { max-width: 100%; height: auto; cursor: pointer; }
.doc img.sel { outline: 2px solid var(--accent); }
/* Image text wrapping. The class is written by Features.applyImageWrap and
   read back by every exporter, so a picture keeps its wrap in DOCX, ODT and
   HTML. Square/tight/through float the picture and let the text run beside it;
   top-and-bottom clears both sides; behind/in-front sit on their own layer. */
.doc img.wrap-square-left, .doc img.wrap-tight-left, .doc img.wrap-through-left { float: left; margin: 4px 14px 8px 0; }
.doc img.wrap-square-right, .doc img.wrap-tight-right, .doc img.wrap-through-right { float: right; margin: 4px 0 8px 14px; }
.doc img.wrap-topbottom { display: block; margin: 12px auto; clear: both; }
.doc img.wrap-behind { display: block; margin: 12px auto; position: relative; z-index: -1; }
.doc img.wrap-front { display: block; margin: 12px auto; position: relative; z-index: 3; }
.doc img.wrap-square-left, .doc img.wrap-square-right,
.doc img.wrap-tight-left, .doc img.wrap-tight-right,
.doc img.wrap-through-left, .doc img.wrap-through-right { max-width: 60%; }
.doc hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.doc ul, .doc ol { margin: 4px 0 10px; padding-left: 30px; }
.doc li { margin: 2px 0; }
.doc ul.checklist { list-style: none; padding-left: 6px; }
.doc ul.checklist li { display: flex; align-items: flex-start; gap: 8px; }
.doc ul.checklist input { margin-top: 3px; }
.doc table { border-collapse: collapse; margin: 8px 0; width: 100%; table-layout: fixed; }
.doc table td, .doc table th { border: 1px solid #9aa0a6; padding: 5px 8px; vertical-align: top; min-width: 24px; }
.doc table th { background: var(--surface-3); font-weight: 700; }
.doc table.selected { outline: 2px solid var(--accent); }
/* Table pagination: repeat the header row at the top of every printed page and
   keep a row from being split across a page break. Both are on by class, so they
   survive a reload and travel into the HTML export. */
.doc table.repeat-header thead { display: table-header-group; }
.doc table.keep-rows tr { break-inside: avoid; page-break-inside: avoid; }
.doc .comment-anchor { background: #fff3c4; border-bottom: 2px solid #f9ab00; cursor: pointer; }
.doc .find-hit { background: #ffe08a; }
.doc .find-hit.current { background: #ffb300; }

/* ── writing tools ─────────────────────────────────────── */
.doc .doc-subtitle-line { font-size: 15pt; color: #666; margin: 0 0 18px; }
.doc .equation { font-family: "Cambria Math", "Times New Roman", serif; font-size: 13pt;
  text-align: center; margin: 10px 0; }
.doc .equation .frac { display: inline-flex; flex-direction: column; vertical-align: middle;
  text-align: center; margin: 0 3px; }
.doc .equation .frac .num { border-bottom: 1px solid currentColor; padding: 0 4px; }
.doc .equation .frac .den { padding: 0 4px; }
.doc .equation .sqrt { border-top: 1px solid currentColor; padding: 0 3px; }
.doc .equation .sqrt .rad { border-top: 1px solid currentColor; }
.doc .equation math.equation-math { font-size: 1.05em; }
.doc .equation .equation-text { font-family: "Cambria Math", "Times New Roman", serif; }
.eq-symbols { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.eq-sym { min-width: 30px; padding: 3px 6px; font-size: 15px; line-height: 1; border: 1px solid var(--border);
  border-radius: 5px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.eq-sym:hover { background: var(--accent-weak, #e8f0fe); border-color: var(--accent); }
.doc .footnote { font-size: 9pt; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 4px; }
.doc .drop-cap { float: left; font-size: 46px; line-height: .82; font-weight: 700; margin: 2px 8px 0 0; }
.doc .word-art { font-size: 30px; font-weight: 800; text-align: center; margin: 12px 0;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: .5px; }
.doc .word-art.wa-gold { background-image: linear-gradient(90deg,#f6b73c,#b8860b,#f6b73c); }
.doc .word-art.wa-ocean { background-image: linear-gradient(90deg,#1a73e8,#00c4cc,#1a73e8); }
.doc .word-art.wa-fire { background-image: linear-gradient(90deg,#e53935,#fb8c00,#e53935); }
.doc .word-art.wa-violet { background-image: linear-gradient(90deg,#7a3cff,#e040fb,#7a3cff); }
.doc .text-box { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 14px;
  margin: 10px 0; background: var(--surface-2); }
.doc .text-box[data-float] { cursor: move; }
.doc .float-box { margin: 0; box-shadow: var(--shadow-1); background: var(--surface); }
.doc .float-box.float-behind { background: var(--surface-2); }
.doc .float-box.float-front { border-color: var(--accent); }
/* the on-screen preview inside the text-box dialog */
.float-preview-page { position: relative; min-height: 130px; padding: 10px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.float-preview-text { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.float-preview-box { border: 1px solid var(--accent); border-radius: 4px; padding: 6px 8px; font-size: 12px;
  background: var(--surface); color: var(--text); margin-top: 6px; overflow: hidden; }
.float-preview-box.float-square, .float-preview-box.float-tight { margin-top: 0; }
.float-preview-box.float-right { margin-left: auto; }
.float-preview-box.float-center { margin-left: auto; margin-right: auto; }
.doc .table-caption { font-size: 10pt; color: var(--text-2); text-align: center; margin: 4px 0 10px; }
.doc .toc { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px;
  margin: 12px 0; background: var(--surface-2); }
.doc .toc-title { font-weight: 600; margin-bottom: 6px; }
.doc .toc-item { display: flex; align-items: baseline; gap: 6px; color: var(--accent); text-decoration: none; padding: 2px 0; font-size: 11pt; }
.doc .toc-item:hover { text-decoration: underline; }
.doc .toc-item .toc-text { flex: 0 1 auto; border-bottom: 1px dotted var(--border); }
.doc .toc-item .toc-pg { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted var(--border); min-width: 1.4em; text-align: right; }
.doc .toc-item:hover .toc-text, .doc .toc-item:hover .toc-pg { border-bottom-color: var(--accent); }
.doc .toc-item.lvl-2 { padding-left: 18px; font-size: 10.5pt; }
.doc .toc-item.lvl-3 { padding-left: 34px; font-size: 10pt; color: var(--text-2); }
.doc .bookmark { display: inline-block; width: 0; height: 0; }
.doc .doc-caption { font-size: 10pt; color: var(--text-2); text-align: center; margin: 4px 0 12px; }
.doc .doc-caption .cap-num { font-weight: 600; color: var(--text); }
.doc .doc-caption .cap-text { font-style: italic; }
.doc .fc { display: inline-flex; align-items: center; vertical-align: baseline; margin: 0 1px; }
.doc .fc-input { font: inherit; font-size: 11pt; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; min-width: 90px; }
.doc .fc-select .fc-input { min-width: 110px; }
.doc .fc-date .fc-input { min-width: 130px; }
.doc .fc-check .fc-input { min-width: 0; width: 15px; height: 15px; vertical-align: -2px; }
.doc .fc-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.doc.form-protected .fc-input { background: var(--accent-soft); border-color: var(--accent); }
.doc.form-protected { background: repeating-linear-gradient(45deg, transparent, transparent 12px, rgba(0,0,0,.012) 12px, rgba(0,0,0,.012) 24px); }
.doc .fc-resolved { border-bottom: 1px solid var(--border); padding: 0 4px; min-width: 40px; display: inline-block; }
.doc .redacted { background: #111; color: #111; border-radius: 2px; padding: 0 1px;
  font-family: "Courier New", monospace; letter-spacing: 0; user-select: none; }
.doc .redacted::selection { background: #111; color: #111; }
html[data-theme="dark"] .doc .redacted { background: #000; color: #000; }
.sb-forms { font-size: 11px; font-weight: 600; color: var(--accent); }
.form-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.redline-preview { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; background: var(--surface-2); font-size: 11pt; line-height: 1.5; }
.redline-preview p { margin: 4px 0; }
/* ── diagram tool ─────────────────────────────────────────── */
.doc .diagram-block { text-align: center; margin: 10px 0; }
.doc svg.diagram { max-width: 100%; height: auto; }
.dgm-cols { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.dgm-builder { flex: 1 1 340px; min-width: 300px; max-height: 420px; overflow: auto; }
.dgm-preview-wrap { flex: 1 1 260px; min-width: 240px; }
.dgm-preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  padding: 8px; overflow: auto; max-height: 420px; }
.dgm-preview svg { max-width: 100%; height: auto; }
.dgm-section { margin-bottom: 10px; }
.dgm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; font-size: 12px; }
.dgm-row { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.dgm-row input[type="text"], .dgm-row select { flex: 1 1 auto; min-width: 0; }
.dgm-row input[type="text"] { flex: 1 1 40%; }
.dgm-arrow { color: var(--text-2); }
.dgm-nodes, .dgm-edges { display: flex; flex-direction: column; }
.dgm-node .dgm-label { font-size: 12px; fill: var(--text); font-family: system-ui, Arial, sans-serif; }
.dgm-edge-label { font-size: 11px; fill: var(--text-2); font-family: system-ui, Arial, sans-serif; }

/* ── chart tool ───────────────────────────────────────────── */
.doc .chart-block { text-align: center; margin: 10px 0; }
.doc svg.chart { max-width: 100%; height: auto; }
.chart-cols { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.chart-builder { flex: 1 1 320px; min-width: 280px; max-height: 420px; overflow: auto; }
.chart-preview-wrap { flex: 1 1 260px; min-width: 240px; }
.chart-preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  padding: 8px; display: flex; align-items: center; justify-content: center; }
.chart-preview svg { max-width: 100%; height: auto; }
.chart-section { margin-bottom: 10px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; font-size: 12px; }
.chart-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart-row { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.chart-row input[type="text"] { flex: 1 1 40%; min-width: 0; }
.chart-series { display: flex; flex-direction: column; }
.chart-opts { display: flex; flex-wrap: wrap; gap: 12px; }
.chart-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.chart-title { font-size: 15px; font-weight: 600; fill: var(--text); font-family: system-ui, Arial, sans-serif; }
.chart-legend, .chart-cat, .chart-tick { font-size: 11px; font-family: system-ui, Arial, sans-serif; }
.chart-dlabel { font-size: 10.5px; font-family: system-ui, Arial, sans-serif; }
.doc .crossref { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.doc .crossref:hover { text-decoration: underline; }
.doc .crossref-missing { color: #d93025; border-bottom-color: #d93025; }
.doc .toc-captions { background: var(--surface); }
/* Heading numbers written into the heading text, so they travel into every
   export and appear in the table of contents. */
.doc .hnum { font-variant-numeric: tabular-nums; }
.tmpl-actions { display: flex; gap: 4px; }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.doc .page-break { border-top: 1px dashed #9aa0a6; margin: 18px 0; text-align: center; position: relative; }
.doc .page-break span { position: relative; top: -9px; background: var(--surface); color: #9aa0a6;
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px; padding: 0 8px; }
.doc .column-break { break-after: column; }
.doc .section-break { border-top: 1px dashed var(--accent); margin: 20px 0; text-align: center; position: relative; }
.doc .section-break[data-kind="next"], .doc .section-break[data-kind="even"], .doc .section-break[data-kind="odd"] { break-before: page; }
.doc .section-break-label { position: relative; top: -9px; background: var(--surface); color: var(--accent);
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase; padding: 0 8px; }
.doc .show-np { }
.doc.show-np p::after { content: "¶"; color: #c9ccd1; }
.doc.show-np br::after { content: "⏎"; color: #c9ccd1; }
.doc.line-numbers { counter-reset: ln; }
.doc.line-numbers p, .doc.line-numbers h1, .doc.line-numbers h2, .doc.line-numbers h3 {
  counter-increment: ln; position: relative; padding-left: 34px; }
.doc.line-numbers p::before, .doc.line-numbers h1::before, .doc.line-numbers h2::before, .doc.line-numbers h3::before {
  content: counter(ln); position: absolute; left: 0; width: 24px; text-align: right;
  color: #9aa0a6; font-size: 9pt; font-family: var(--font); }
.page-watermark { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-45deg);
  font-size: 84px; font-weight: 800; color: #202124; opacity: .1; pointer-events: none; user-select: none;
  letter-spacing: 4px; z-index: 0; white-space: nowrap; }
.eq-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px;
  min-height: 42px; font-family: "Cambria Math", "Times New Roman", serif; font-size: 14pt; text-align: center; }
.eq-preview .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; }
.eq-preview .frac .num { border-bottom: 1px solid currentColor; padding: 0 4px; }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input { flex: 1 1 auto; }
.src-list { max-height: 46vh; overflow: auto; }
.src-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.src-row:last-child { border-bottom: none; }
.src-link { color: var(--accent); font-size: 12.5px; text-decoration: none; white-space: nowrap; }
.src-link:hover { text-decoration: underline; }
.style-row { padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.style-row:hover { background: var(--hover); }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* ── AI agent ──────────────────────────────────────────── */
.ai-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 100px; padding: 6px 14px 6px 10px; cursor: pointer;
  font-weight: 500; font-size: 13.5px; color: var(--accent); }
.ai-btn:hover { background: var(--accent-soft); border-color: transparent; }
.ai-btn.on { background: var(--accent); color: #fff; border-color: transparent; }
.ai-btn.on svg.ic { stroke: #fff; }
.agent-panel { width: 380px; flex: 0 0 auto; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 26; }
.agent-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--border); }
.agent-title { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.agent-title svg.ic { stroke: var(--accent); }
.agent-head-actions { display: flex; gap: 2px; }
.agent-body { flex: 1 1 auto; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.agent-empty { color: var(--text-2); font-size: 13px; }
.agent-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.agent-chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 100px;
  padding: 6px 12px; cursor: pointer; font-size: 12.5px; text-align: left; }
.agent-chip:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 88%; border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; width: 100%; }
.agent-steps { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.agent-step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.agent-step .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto;
  animation: pulse 1s ease-in-out infinite; }
.agent-step.done .dot { background: #34a853; animation: none; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.agent-text code { background: var(--surface-3); padding: 1px 4px; border-radius: 3px; font-size: .92em; }
.agent-error { color: #c5221f; background: #fce8e6; border-radius: var(--radius); padding: 8px 10px;
  font-size: 12.5px; margin-top: 8px; }
.agent-typing { display: inline-flex; gap: 4px; padding-top: 4px; }
.agent-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite; }
.agent-typing i:nth-child(2) { animation-delay: .2s; } .agent-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.agent-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.agent-question { margin-top: 10px; padding: 9px 12px; border-radius: var(--radius-lg); background: #fff8e1;
  border: 1px solid #f6d365; color: #6b4e00; font-size: 13px; }
html[data-theme="dark"] .agent-question { background: #3a3013; border-color: #6b5a1f; color: #ffe9a8; }
#agent-voice.recording { background: #fce8e6; border-color: #f4b8b4; color: #c5221f; }
html[data-theme="dark"] #agent-voice.recording { background: #4a1f1f; border-color: #7a3a3a; color: #ffb4a8; }
.agent-compose { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.agent-compose textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 9px 12px; resize: vertical; min-height: 44px; max-height: 140px; outline: none; font-family: inherit; }
.agent-compose textarea:focus { border-color: var(--accent); }
.agent-compose-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.hidden { display: none !important; }

.side-panel { width: 300px; flex: 0 0 auto; background: var(--surface);
  border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 25; }
.side-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--border); font-weight: 500; }
.side-body { flex: 1 1 auto; overflow: auto; padding: 10px 0; }
.outline-item { padding: 5px 16px; cursor: pointer; border-radius: var(--radius); font-size: 13px;
  display: flex; align-items: center; gap: 6px; }
.outline-item:hover { background: var(--hover); }
.outline-item.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.outline-moves { margin-left: auto; display: none; gap: 2px; flex: 0 0 auto; }
.outline-item:hover .outline-moves, .outline-item:focus-within .outline-moves { display: flex; }
.outline-move { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  width: 22px; height: 22px; line-height: 1; cursor: pointer; color: var(--text-2); font-size: 12px; }
.outline-move:hover { background: var(--hover); color: var(--text); }
.outline-fold { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  width: 22px; height: 22px; line-height: 1; cursor: pointer; color: var(--text-2); font-size: 11px; flex: 0 0 auto; }
.outline-fold:hover { background: var(--hover); color: var(--text); }
.outline-actions { display: flex; align-items: center; gap: 10px; padding: 0 16px 6px; flex-wrap: wrap; }
.outline-actions .hint { font-size: 11.5px; }
.outline-item.h1 { font-weight: 500; }
.outline-item.h2 { padding-left: 30px; }
.outline-item.h3 { padding-left: 44px; font-size: 12.5px; }
.outline-item.h4, .outline-item.h5, .outline-item.h6 { padding-left: 58px; font-size: 12px; color: var(--text-2); }
.outline-filter-wrap { padding: 6px 12px 8px; }
.outline-filter { width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; font-size: 13px; outline: none; font-family: inherit; background: var(--surface); }
.outline-filter:focus { border-color: var(--accent); }
.outline-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2);
  padding: 10px 16px 4px; font-weight: 600; }
.outline-item.nav-jump { font-size: 12.5px; }
.comment-card { margin: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 12px; background: var(--surface-2); font-size: 13px; }
.comment-card .who { font-weight: 500; margin-bottom: 4px; }
.comment-card .when { color: var(--text-2); font-size: 11px; margin-left: 6px; font-weight: 400; }
.comment-card .body { margin: 4px 0 8px; white-space: pre-wrap; }
.comment-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
/* Comments panel power-ups: a search box, scope chips, bulk actions and an
   export menu, all sticky so they stay reachable in a long thread. */
.cmt-bar { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.cmt-search { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
  font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.cmt-scopes { display: flex; gap: 6px; flex-wrap: wrap; }
.cmt-scopes .chip.on { background: var(--accent); color: #fff; border-color: transparent; }
.cmt-actions { display: flex; gap: 6px; flex-wrap: wrap; position: relative; }
.cmt-menu { position: absolute; right: 0; top: 100%; margin-top: 4px; z-index: 5; display: flex;
  flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; box-shadow: var(--shadow-1); }
/* Bookmarks manager rows. */
.bm-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.bm-row .bm-name { flex: 1 1 auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
  font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.mini-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 100px;
  padding: 4px 12px; cursor: pointer; font-size: 12px; }
.mini-btn:hover { background: var(--hover); }
.mini-btn.danger:hover { background: #fce8e6; color: #c5221f; border-color: #f4b8b4; }

.statusbar { height: 28px; background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 12px;
  color: var(--text-2); flex: 0 0 auto; z-index: 30; }
.sb-left, .sb-right { display: flex; align-items: center; gap: 4px; }
.sb-btn { font-size: 12px; color: var(--text-2); padding: 2px 8px; }
.sb-sep { color: var(--border); }

/* An author `display` value would otherwise beat the UA rule for [hidden],
   leaving the modal backdrop covering the app. */
[hidden] { display: none !important; }

.dropdown { position: absolute; z-index: 100; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 6px; min-width: 240px;
  max-height: 70vh; overflow: auto; }
.dd-item { display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; font-size: 13.5px; }
.dd-item:hover { background: var(--hover); }
.dd-item.disabled { opacity: .45; pointer-events: none; }
.dd-item .shortcut { color: var(--text-2); font-size: 12px; }
.dd-item .check { width: 16px; color: var(--accent); }
.dd-sep { height: 1px; background: var(--border); margin: 5px 6px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(32,33,36,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-2); width: 520px;
  max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 500; }
.modal-body { padding: 6px 22px 14px; overflow: auto; }

/* command palette */
.cmdk-input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 11px 14px;
  font-size: 15px; outline: none; font-family: inherit; margin-bottom: 10px; }
.cmdk-input:focus { border-color: var(--accent); }
.cmdk-list { max-height: 46vh; overflow: auto; }
.cmdk-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.cmdk-row:hover, .cmdk-row.on { background: var(--hover); }
.cmdk-label { font-size: 13.5px; font-weight: 500; }
.cmdk-hint { font-size: 12px; color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-empty { padding: 16px; color: var(--text-2); font-size: 13px; }
.modal-foot { padding: 12px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* Print preview: real pages at the current paper size, zoomable */
.modal.wide { width: 900px; }
.preview-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.preview-scroll { max-height: 62vh; overflow: auto; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 18px; }
.preview-pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.preview-page { background: #fff; color: #202124; box-shadow: 0 1px 6px rgba(0,0,0,.28); position: relative;
  box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; }
.preview-page .preview-doc { flex: 1 1 auto; overflow: hidden; }
.preview-head, .preview-foot { color: #5f6368; font-size: 11px; padding: 4px 0; border-bottom: 1px solid #dadce0; }
.preview-foot { border-bottom: none; border-top: 1px solid #dadce0; margin-top: auto; }
.preview-page-num { position: absolute; right: 8px; bottom: 4px; font-size: 10px; color: #9aa0a6; }
/* The preview always looks like paper, whatever the app theme is */
.preview-page .doc { color: #202124; background: transparent; }
.preview-page .doc pre, .preview-page .doc code { background: #f1f3f4; color: #202124; }
.preview-page .doc blockquote { color: #5f6368; }
html[data-theme="dark"] .preview-scroll { background: var(--surface-2); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field input[type=url], .field input[type=password],
.field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 90px; resize: vertical; }
.field-row { display: flex; gap: 12px; } .field-row .field { flex: 1; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 100px;
  padding: 9px 20px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.hint { font-size: 12px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 100px;
  padding: 6px 14px; cursor: pointer; font-size: 13px; }
.chip:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.th-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.th-chip { cursor: pointer; }
.th-near { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 14px; }
/* Header/footer variant boxes in the Headers and footers dialog */
.hdr-box { min-height: 54px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 8px 10px; font-size: 12.5px; outline: none; }
.hdr-box:empty::before { content: attr(data-placeholder); color: #bdc1c6; font-style: italic; }
.hdr-box:focus { border-color: var(--accent); }
.hdr-box .doc-field { background: var(--surface-3, #eef1f5); border-radius: 3px; padding: 0 2px; }
.cite-list { margin: 6px 0 0; max-height: 320px; overflow: auto; }
.cite-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cite-main { flex: 1; font-size: 13px; line-height: 1.35; }
.cite-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.doc-cite { background: var(--accent-soft); border-radius: 3px; padding: 0 3px; cursor: default; }
.doc-bib { border-left: 3px solid var(--border); padding-left: 14px; margin: 8px 0; }
.doc-bib-entry { text-indent: -18px; padding-left: 18px; margin: 4px 0; }
.doc-bib-heading { margin-top: 16px; }
.endnotes { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 10px; }
.endnotes-heading { font-size: 14pt; }
.endnote-ref { color: var(--accent); font-weight: 600; cursor: default; }
.endnote { font-size: 10pt; color: var(--text-2); margin: 3px 0 3px 18px; text-indent: -18px; }
.spell-list { margin-top: 8px; max-height: 380px; overflow: auto; }
.spell-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.spell-head { display: flex; gap: 10px; align-items: baseline; }
.spell-sugg { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.spell-acts { display: flex; gap: 6px; }
.spell-menu { position: fixed; z-index: 4000; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.2)); padding: 6px; min-width: 180px; }
.spell-menu-head { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; padding: 4px 8px; }
.spell-menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px;
  border-radius: var(--radius); font: inherit; color: var(--text); cursor: pointer; }
.spell-menu-item:hover, .spell-menu-item:focus-visible { background: var(--accent-soft); color: var(--accent); }
.grid-tpl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; cursor: pointer;
  background: var(--surface-2); font-size: 13px; }
.tpl:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl b { display: block; margin-bottom: 4px; font-weight: 500; }
.tpl span { color: var(--text-2); font-size: 11.5px; }
.palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--border); cursor: pointer; }
.swatch:hover { outline: 2px solid var(--accent); }
.special-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.special-grid button { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  padding: 6px 0; cursor: pointer; font-size: 15px; }
.special-grid button:hover { background: var(--accent-soft); }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-item:hover { background: var(--hover); }
.para-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.para-grid .field { margin-bottom: 6px; }
@media (max-width: 520px) { .para-grid { grid-template-columns: 1fr 1fr; } }
#drawing-canvas { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: crosshair; touch-action: none; }

.ctx-menu { position: fixed; z-index: 300; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 6px; min-width: 200px; }
.toast-host { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 400;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #323232; color: #fff; padding: 11px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-2); font-size: 13.5px; animation: pop .18s ease; }
.toast-action { display: flex; align-items: center; gap: 12px; max-width: min(560px, 92vw); pointer-events: auto; }
.toast-msg { flex: 1; }
.toast-btn { background: #fff; color: #202124; border: none; border-radius: 100px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.toast-btn:hover { background: #e8eaed; }
.toast-x { background: none; border: none; color: #c9c9c9; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-x:hover { color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

@media print {
  body { background: #fff; }
  .topbar, .toolbar, .ruler, .statusbar, .side-panel, .agent-panel, .toast-host, .dropdown, .ctx-menu { display: none !important; }
  .canvas-wrap { overflow: visible; }
  .pages { padding: 0; gap: 0; }
  .page { box-shadow: none; zoom: 1 !important; width: auto; min-height: 0; }
  .page-body { padding: 0; }
  .doc .find-hit { background: transparent; }
  .mc-layer { display: none !important; }
}
@media (max-width: 780px) {
  :root { --page-pad: 24px; --page-w: 100%; }
  .side-panel { position: absolute; right: 0; top: 0; bottom: 0; }
  .agent-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(100%, 380px); box-shadow: var(--shadow-2); }
  .ai-btn span { display: none; }
  .ai-btn { padding: 6px 10px; }
}

/* ══════════════════════════════════════════════════════════════
   Motion — smooth, quick, and switched off when the reader asks
   ══════════════════════════════════════════════════════════════ */
:root {
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.22, 1.2, .36, 1);
  --motion: 1;                       /* scales every duration; set by applyMotion() */
  --dur-1: calc(.14s * var(--motion)); --dur-2: calc(.22s * var(--motion)); --dur-3: calc(.34s * var(--motion));
}
.icon-btn, .menu-btn, .primary-btn, .ghost-btn, .ai-btn, .sb-btn, .mini-btn, .link-btn {
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.icon-btn:active, .primary-btn:active, .ghost-btn:active, .menu-btn:active, .mini-btn:active { transform: scale(.94); }
.primary-btn:hover, .ai-btn:hover { box-shadow: var(--shadow-1); }
.primary-btn { transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease); }

.dropdown:not([hidden]) { animation: ddIn var(--dur-2) var(--ease-out) both; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.modal-backdrop:not([hidden]) { animation: fadeIn var(--dur-2) var(--ease) both; }
.modal-backdrop:not([hidden]) .modal { animation: modalIn var(--dur-3) var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.ctx-menu:not([hidden]) { animation: ddIn var(--dur-1) var(--ease-out) both; }
.toast { animation: toastIn var(--dur-3) var(--ease-out) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.side-panel:not([hidden]), .agent-panel:not([hidden]) { animation: panelIn var(--dur-3) var(--ease-out) both; }
@keyframes panelIn { from { opacity: 0; transform: translateX(18px); } }

.page { transition: box-shadow var(--dur-2) var(--ease), width var(--dur-3) var(--ease), min-height var(--dur-3) var(--ease); }
#doc > * { animation: blockIn var(--dur-2) var(--ease-out) both; }
@keyframes blockIn { from { opacity: 0; transform: translateY(4px); } }
.agent-step { animation: stepIn var(--dur-2) var(--ease-out) both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(-6px); } }
.msg { animation: msgIn var(--dur-3) var(--ease-out) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.gal-item, .tpl-card, .layout-card, .theme-card, .pic-card, .recent-card, .sa-card {
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.gal-item:hover, .tpl-card:hover, .layout-card:hover, .theme-card:hover, .pic-card:hover, .recent-card:hover, .sa-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-1); border-color: var(--accent);
}
.gal-item:active, .sa-card:active, .pic-card:active { transform: scale(.96); }
.sym-btn { transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
.sym-btn:active { transform: scale(.86); }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }

/* ── Motion & effects switchboard ───────────────────────────────
   `--motion` scales every duration; the data-* attributes gate the optional
   effects so the look can be enriched without any feature being removed. */
@keyframes sheen { from { transform: translateX(-130%) skewX(-16deg); } to { transform: translateX(230%) skewX(-16deg); } }
@keyframes haloPulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* A gentle sheen across primary buttons on hover. */
.primary-btn { position: relative; overflow: hidden; }
html[data-fx="on"] .primary-btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  transform: translateX(-130%) skewX(-16deg); pointer-events: none;
}
html[data-fx="on"] .primary-btn:hover::after { animation: sheen calc(.7s * var(--motion)) var(--ease-out); }

/* A soft halo on the focused control so the keyboard user never loses the caret. */
html[data-fx="on"] :focus-visible { animation: haloPulse calc(1.5s * var(--motion)) var(--ease-out); }

/* Card hover lift. */
html[data-lift="on"] .gal-item:hover, html[data-lift="on"] .tpl-card:hover,
html[data-lift="on"] .layout-card:hover, html[data-lift="on"] .theme-card:hover,
html[data-lift="on"] .pic-card:hover, html[data-lift="on"] .recent-card:hover,
html[data-lift="on"] .sa-card:hover { transform: translateY(-4px); }

/* Frosted glass on the floating chrome. */
html[data-glass="on"] .side-panel, html[data-glass="on"] .agent-panel {
  backdrop-filter: blur(18px) saturate(1.4);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}
html[data-glass="on"] .modal-backdrop .modal { backdrop-filter: blur(20px) saturate(1.5); }

/* Skeleton shimmer for anything loading. */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 200% 100%; animation: shimmer calc(1.2s * var(--motion)) linear infinite; border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ══════════════ intro animation ══════════════ */
.intro { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--surface-2) 60%);
  transition: opacity .5s var(--ease), visibility .5s var(--ease); }
.intro.intro-leaving { opacity: 0; visibility: hidden; }
.intro-stage { text-align: center; }
.intro-logo { animation: introPop .9s var(--ease-out) both; }
@keyframes introPop { from { opacity: 0; transform: scale(.4) rotate(-12deg); } 60% { transform: scale(1.08) rotate(2deg); } }
.intro-word { margin-top: 10px; font-family: var(--font); font-size: 52px; font-weight: 700; letter-spacing: .06em; color: var(--text); }
.intro-word span { display: inline-block; opacity: 0; transform: translateY(22px) rotateX(-60deg); animation: letterIn .6s var(--ease-out) forwards; }
.intro-word span:nth-child(1) { animation-delay: .10s; }
.intro-word span:nth-child(2) { animation-delay: .18s; }
.intro-word span:nth-child(3) { animation-delay: .26s; }
.intro-word span:nth-child(4) { animation-delay: .34s; }
.intro-word span:nth-child(5) { animation-delay: .42s; }
.intro-word span:nth-child(6) { animation-delay: .50s; }
@keyframes letterIn { to { opacity: 1; transform: none; } }
.intro-tag { margin-top: 8px; color: var(--text-2); font-size: 15px; opacity: 0; animation: letterIn .6s var(--ease-out) .72s forwards; }
.intro-bar { margin: 26px auto 0; width: 220px; height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.intro-bar i { display: block; height: 100%; width: 40%; border-radius: 4px; background: var(--accent); animation: barRun 1.1s var(--ease) .2s infinite; }
@keyframes barRun { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
body.intro-running { overflow: hidden; }

/* ══════════════ home screen ══════════════ */
.home { position: fixed; inset: 0; z-index: 800; overflow: auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 40%);
  opacity: 0; transform: translateY(10px) scale(.995); transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }
.home.home-visible { opacity: 1; transform: none; }
.home-inner { max-width: 1080px; margin: 0 auto; padding: 40px 28px 56px; }
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.home-brand { display: flex; gap: 14px; align-items: center; }
.home-brand h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
.home-brand p { margin: 4px 0 0; max-width: 44ch; }
.home-actions { display: flex; gap: 10px; align-items: center; }
.big { padding: 11px 18px; font-size: 14.5px; border-radius: var(--radius-lg); }
.ghost-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 9px 14px; border-radius: var(--radius); cursor: pointer; font: inherit; font-size: 13.5px; }
.ghost-btn:hover { background: var(--hover); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 2px 4px; }
.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 30px; }
.home-col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.home-col-head:first-child { margin-top: 0; }
.home-col-head h2 { margin: 0; font-size: 15px; letter-spacing: .02em; text-transform: uppercase; color: var(--text-2); }
.home-foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.home-platforms { color: var(--text-2); font-size: 13px; letter-spacing: .06em; }
.templates { display: flex; flex-direction: column; gap: 6px; }
.tpl-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tpl-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; cursor: pointer; font: inherit; }
.tpl-preview { display: block; width: 100%; }
.tpl-sheet { display: flex; flex-direction: column; gap: 5px; padding: 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); min-height: 66px; }
.tpl-bar { display: block; height: 7px; width: 46%; border-radius: 3px; background: var(--accent); opacity: .75; }
.tpl-line { display: block; height: 5px; border-radius: 3px; background: var(--border); }
.tpl-line.w40 { width: 40%; } .tpl-line.w60 { width: 60%; } .tpl-line.w80 { width: 80%; } .tpl-line.w90 { width: 90%; }
.recents { display: flex; flex-direction: column; gap: 8px; }
.recent-card { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px; cursor: pointer; font: inherit; }
.recent-thumb { display: grid; place-items: center; width: 38px; height: 46px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--border); font-weight: 700; color: var(--accent); }
.recent-meta { display: flex; flex-direction: column; gap: 2px; }
.recent-meta b { font-size: 14px; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }

/* ══════════════ galleries ══════════════ */
.gal-tabs { display: flex; gap: 10px; margin-bottom: 10px; }
.gal-search { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.gal-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; max-height: 52vh; overflow: auto; padding: 2px; }
.gal-grid.gal-list { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.gal-group { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 8px 0 0; }
.gal-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font: inherit; color: var(--text); }
.gal-thumb { display: grid; place-items: center; width: 64px; height: 52px; }
.gal-thumb svg { max-width: 100%; max-height: 100%; }
.gal-font-name { font-size: 12px; color: var(--text-2); align-self: flex-start; }
.gal-font-sample { font-size: 17px; align-self: flex-start; }
.gal-border-sample { display: block; padding: 6px 12px; background: var(--surface); }
.sym-grid { max-height: 52vh; overflow: auto; }
.sym-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.sym-btn { width: 36px; height: 36px; display: grid; place-items: center; font-size: 17px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.sym-btn:hover { background: var(--hover); }
.sym-char { font-size: 26px; }
.layout-grid, .theme-grid, .sa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.layout-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font: inherit; color: var(--text); }
.theme-card { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font: inherit; }
.theme-swatch { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 6px; border: 1px solid; }
.theme-swatch b { font-size: 20px; }
.theme-name { font-size: 12.5px; color: var(--text-2); }
.theme-card { position: relative; }
.theme-del { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; padding: 0; line-height: 1;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 11px; }
.theme-del:hover { background: #fdecea; color: #c5221f; border-color: #c5221f; }
.sa-group { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 14px 0 0; }
.sa-card { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font: inherit; color: var(--text); }
.sa-name { font-weight: 600; font-size: 14px; }
.sa-ext { font-family: var(--font-mono, monospace); font-size: 12px; color: var(--accent); }
.sa-note { font-size: 12px; color: var(--text-2); }
.pic-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 46vh; overflow: auto; }
.pic-card { padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; background: var(--surface-2); aspect-ratio: 4/3; }
.pic-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row { display: flex; gap: 8px; align-items: center; }
.grid-tpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl { display: flex; flex-direction: column; gap: 3px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; background: var(--surface); }
.tpl:hover { border-color: var(--accent); }
.doc-shape, .doc-clipart { user-select: none; }
.doc-shape img, .doc-clipart svg { max-width: 100%; height: auto; }


/* ══════════════ writing aids (Writer module) ══════════════ */
/* Focus mode hides the chrome and dims everything but the page. */
body.focus-mode .topbar,
body.focus-mode .toolbar,
body.focus-mode .ruler,
body.focus-mode .side-panel,
body.focus-mode .agent-panel { opacity: 0; pointer-events: none; }
body.focus-mode .topbar, body.focus-mode .toolbar, body.focus-mode .ruler { height: 0; overflow: hidden; border: none; }
body.focus-mode .workspace { padding-top: 24px; }
body.focus-mode .statusbar { opacity: .35; }
.topbar, .toolbar, .ruler, .statusbar { transition: opacity .25s ease; }

/* Typewriter mode keeps the line you are writing near the middle of the screen. */
body.typewriter-mode .page-body { padding-bottom: 55vh; }

/* Track-changes mode: mark the writing surface so suggestions read clearly. */
body.suggesting .page-body { box-shadow: inset 3px 0 0 #137333; }
body.suggesting #btn-track.on { background: #e6f4ea; color: #137333; }

/* Landscape page: the page box grows to the rotated width and the caret keeps up. */
body.landscape .page { transition: width var(--dur-3) var(--ease), min-height var(--dur-3) var(--ease); }

/* A gentle reading-time chip in the status bar. */
#sb-read { white-space: nowrap; }

/* ══════════════ in-app translate and link dialogs ══════════════ */
.translate-src, .translate-out {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-size: 13px; max-height: 190px; overflow: auto; margin-top: 8px;
  background: var(--surface-2, #f8f9fa);
}
.translate-out { border-color: var(--accent); }
.translate-text { white-space: pre-wrap; line-height: 1.5; margin-top: 4px; }
.link-view { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ══════════════ track changes (review mode) ══════════════ */
.doc ins.ins-suggestion { color: #137333; text-decoration: underline; text-decoration-color: #34a853;
  background: #e6f4ea; border-radius: 2px; padding: 0 1px; }
.doc del.del-suggestion { color: #c5221f; text-decoration: line-through; text-decoration-color: #ea4335;
  background: #fce8e6; border-radius: 2px; padding: 0 1px; }
.doc ins.ins-suggestion::before { content: "﹢"; font-size: .7em; vertical-align: super; opacity: .55; margin-right: 1px; }
.doc del.del-suggestion::before { content: "﹣"; font-size: .7em; vertical-align: super; opacity: .55; margin-right: 1px; }
@media print {
  .doc ins.ins-suggestion { color: inherit; text-decoration: none; background: transparent; }
  .doc ins.ins-suggestion::before, .doc del.del-suggestion::before { content: none; }
  .doc del.del-suggestion { display: none; }
}
.sb-suggesting { font-size: 11px; font-weight: 600; color: #137333; background: #e6f4ea;
  border: 1px solid #a8dab5; border-radius: 100px; padding: 1px 8px; }
html[data-theme="dark"] .sb-suggesting { color: #a8dab5; background: #1e3a2a; border-color: #2e5d43; }

/* Display for review: four ways to read tracked changes without touching the
   document. `All markup` is the default; the others only change how the
   existing <ins>/<del> are painted on screen. Exports are never affected. */
body.review-simple .doc ins.ins-suggestion { color: inherit; background: transparent; text-decoration: none; }
body.review-simple .doc del.del-suggestion { color: inherit; background: transparent; text-decoration: none; }
body.review-simple .doc ins.ins-suggestion::before,
body.review-simple .doc del.del-suggestion::before { content: none; }
body.review-simple .doc ins.ins-suggestion,
body.review-simple .doc del.del-suggestion { box-shadow: inset 3px 0 0 #34a853; padding-left: 3px; }
body.review-simple .doc del.del-suggestion { box-shadow: inset 3px 0 0 #ea4335; }
body.review-final .doc del.del-suggestion { display: none; }
body.review-final .doc ins.ins-suggestion { color: inherit; background: transparent; text-decoration: none; }
body.review-final .doc ins.ins-suggestion::before { content: none; }
body.review-original .doc ins.ins-suggestion { display: none; }
body.review-original .doc del.del-suggestion { color: inherit; background: transparent; text-decoration: none; }
body.review-original .doc del.del-suggestion::before { content: none; }
.review-modes { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 2px; }
.review-mode { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, #f8f9fa);
  cursor: pointer; font: inherit; color: var(--text); }
.review-mode:hover { border-color: var(--accent); }
.review-mode.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2, #f8f9fa)); }
.review-mode .rm-dot { flex: 0 0 auto; width: 12px; height: 12px; margin-top: 3px; border-radius: 50%;
  border: 2px solid var(--border); }
.review-mode.on .rm-dot { border-color: var(--accent); background: var(--accent); }
.review-mode .rm-text { display: flex; flex-direction: column; gap: 2px; }
.review-mode .rm-text .hint { margin: 0; }
#btn-track.on { background: #e6f4ea; color: #137333; }
html[data-theme="dark"] #btn-track.on { background: #1e3a2a; color: #a8dab5; }

/* ══════════════ table styles & caption ══════════════ */
.table-style-sample { display: flex; flex-direction: column; border-radius: 4px; overflow: hidden; font-size: 12px; }
.theme-card .table-style-sample { width: 100%; }
.doc .table-caption { font-size: 10pt; color: var(--text-2); text-align: center; margin: 4px 0 10px; }
.doc table caption { caption-side: top; text-align: center; font-size: 10pt; color: var(--text-2); padding: 4px 0; }
.page-border-preview { min-height: 70px; background: var(--surface-2); border-radius: 4px; }

/* ══════════════ accessibility: focus rings, skip link, motion ══════════════ */
/* Keyboard users get a clear ring on every interactive control; mouse users
   are spared the outline on click (the ring is reserved for :focus-visible). */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [contenteditable="true"]:focus-visible,
[tabindex]:focus-visible, .dd-item:focus-visible, .cmdk-row:focus-visible,
.menu-btn:focus-visible, .outline-item:focus-visible, .swatch:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:focus:not(:focus-visible), input:focus:not(:focus-visible),
select:focus:not(:focus-visible), textarea:focus:not(:focus-visible) { outline: none; }
.skip-link { position: fixed; left: 12px; top: -48px; z-index: 9500; background: var(--surface);
  color: var(--accent); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 14px; font-size: 13px; text-decoration: none; box-shadow: var(--shadow-1);
  transition: top var(--dur-2) var(--ease); }
.skip-link:focus { top: 12px; outline: 2px solid var(--accent); outline-offset: 2px; }
/* A manual "reduce motion" switch for anyone whose OS does not advertise it. */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* ══════════════ document statistics dialog ══════════════ */
.stat-hero { display: flex; gap: 16px; align-items: center; margin: 4px 0 14px; }
.stat-ease { flex: 0 0 auto; width: 88px; height: 88px; border-radius: 50%; display: flex;
  flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
  border: 3px solid var(--border); }
.stat-ease b { font-size: 26px; font-weight: 600; }
.stat-ease span { font-size: 10px; letter-spacing: .02em; text-transform: uppercase; color: var(--text-2); }
.stat-ease.stat-good { border-color: #34a853; color: #188038; }
.stat-ease.stat-ok { border-color: #fbbc04; color: #b06000; }
.stat-ease.stat-warn { border-color: #ea4335; color: #c5221f; }
html[data-theme="dark"] .stat-ease.stat-good { color: #a8dab5; }
html[data-theme="dark"] .stat-ease.stat-ok { color: #fdd663; }
html[data-theme="dark"] .stat-ease.stat-warn { color: #f28b82; }
.stat-hero-text b { font-size: 15px; }
.stat-section { font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--text-2); margin: 16px 0 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.stat-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; padding: 3px 0;
  border-bottom: 1px solid var(--border); }
.stat-label { flex: 1; color: var(--text-2); }
.stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-hint { flex-basis: 100%; font-size: 11px; color: var(--text-2); }
.stat-list { display: flex; flex-direction: column; gap: 6px; }
.stat-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  padding: 7px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.stat-item:hover { background: var(--hover); border-color: var(--accent); }
.stat-item-words { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--accent);
  font-weight: 600; font-size: 12px; padding-top: 1px; }
.stat-item-text { color: var(--text); }
.stat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-chip { background: var(--surface-3); border: 1px solid var(--border); border-radius: 100px;
  padding: 3px 11px; font-size: 12.5px; }

/* ══════════════ read aloud bar ══════════════ */
.speech-bar { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; box-shadow: var(--shadow-2); padding: 6px 10px; z-index: 150; max-width: 94vw; }
.speech-bar .icon-btn { width: 30px; height: 30px; }
.speech-status { font-size: 12.5px; color: var(--text-2); min-width: 96px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.speech-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex: 0 0 auto; }
.speech-rate, .speech-voice { height: 28px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 0 6px; cursor: pointer; font-size: 12.5px; max-width: 170px; }
.speech-voice { max-width: 190px; }
/* The sentence being read, painted with the CSS Custom Highlight API so the
   document itself is never modified. */
::highlight(sudocs-speak) { background-color: #fde293; color: #202124; }
html[data-theme="dark"] ::highlight(sudocs-speak) { background-color: #5b4a12; color: #ffe9a8; }
/* Misspellings found by the offline dictionary, painted the same way so the
   document is never modified. A wavy underline, the familiar spell-check cue. */
::highlight(sudocs-spell) { text-decoration: underline wavy #d93025; text-decoration-skip-ink: none; }
html[data-theme="dark"] ::highlight(sudocs-spell) { text-decoration-color: #f28b82; }
@media (prefers-contrast: more) { ::highlight(sudocs-spell) { text-decoration-thickness: 2px; } }

/* ══════════════ writing review ══════════════ */
.style-tag { flex: 0 0 auto; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 100px; padding: 1px 9px; font-size: 11.5px; color: var(--text-2); }
.style-clear { border: 1px solid #34a853; background: #e6f4ea; border-radius: var(--radius-lg);
  padding: 12px 14px; margin-bottom: 12px; color: #188038; }
html[data-theme="dark"] .style-clear { background: #1e3a24; border-color: #2e6b3a; color: #a8dab5; }

/* ══════════════ text ⇄ table, index, accessibility, AutoText ══════════════ */
.tt-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
  max-height: 180px; overflow: auto; white-space: pre-wrap; margin: 0; }
/* Index entries are invisible markers; the built index is a grouped list. */
.doc .index-entry { font-size: 0; line-height: 0; }
.doc .doc-index { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px;
  margin: 14px 0; background: var(--surface); column-count: 2; column-gap: 28px; }
.doc .index-letter { font-weight: 700; margin: 8px 0 2px; color: var(--accent); break-after: avoid; }
.doc .index-term { font-size: 11pt; break-inside: avoid; }
.doc .index-sub { font-size: 10.5pt; color: var(--text-2); padding-left: 16px; break-inside: avoid; }
.a11y-pass { background: #e6f4ea; border: 1px solid #34a853; border-radius: var(--radius-lg);
  padding: 10px 12px; margin-bottom: 12px; color: #188038; font-size: 13px; }
html[data-theme="dark"] .a11y-pass { background: #1e3a24; border-color: #2e6b3a; color: #a8dab5; }
.a11y-list { display: flex; flex-direction: column; gap: 8px; }
.a11y-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); }
.a11y-kind { flex: 0 0 auto; background: var(--surface-3); border: 1px solid var(--border); border-radius: 100px;
  padding: 1px 9px; font-size: 11.5px; color: var(--text-2); text-transform: capitalize; white-space: nowrap; }
.a11y-msg { flex: 1 1 auto; font-size: 13px; }
.a11y-row .btn { flex: 0 0 auto; }
.at-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; max-height: 260px; overflow: auto; }
.at-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); }
.at-row-main { flex: 1 1 auto; min-width: 0; }
.at-name { font-weight: 600; font-size: 13.5px; }
.at-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-trigger { flex: 0 0 auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--text-2); }
.at-new { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.at-new-actions { display: flex; gap: 8px; justify-content: flex-end; }
.at-new textarea { width: 100%; }
/* Table formulas: the live result and its error state. */
.tf-result { font-size: 13px; padding: 6px 10px; border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.tf-result.tf-bad { background: #fce8e6; border-color: #d93025; color: #a50e0e; }
html[data-theme="dark"] .tf-result.tf-bad { background: #3a1a18; border-color: #b3261e; color: #f2b8b5; }
/* Autolinked addresses the writer just typed. */
.doc a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.doc a[href^="mailto:"] { text-decoration-style: dotted; }
/* Text direction (right-to-left languages). */
.doc [dir="rtl"], .doc[dir="rtl"] { text-align: right; unicode-bidi: plaintext; }
.doc [dir="ltr"], .doc[dir="ltr"] { text-align: left; }
.doc [dir="rtl"] ul, .doc [dir="rtl"] ol { padding-inline-start: 0; padding-inline-end: 1.6em; }
.doc[dir="rtl"] table { direction: rtl; }
/* Picture editing: rotate, flip, crop, recolour, fade, round corners. */
.imgedit { display: flex; gap: 18px; align-items: flex-start; }
.imgedit-preview-wrap { flex: 0 0 auto; width: 300px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.imgedit-preview { max-width: 300px; max-height: 300px; background:
  repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface-2) 0 50%) 0 0 / 18px 18px;
  border: 1px solid var(--border); border-radius: var(--radius); }
.imgedit-controls { flex: 1 1 auto; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.imgedit-controls input[type="range"] { width: 100%; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1 1 auto; }
.crop-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; align-items: center; }
.crop-grid .mini { display: flex; flex-direction: column; font-size: 11.5px; color: var(--text-2); }
.crop-grid .mini input { width: 100%; }
.crop-icon { text-align: center; font-size: 18px; }
@media (max-width: 640px) { .imgedit { flex-direction: column; } .imgedit-preview-wrap { width: 100%; } }
/* Insert-a-document (master document) and its provenance markers. */
.insdoc-list { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; color: var(--text-2); max-height: 160px; overflow: auto; }
.doc-part { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3, var(--text-2));
  border-bottom: 1px dashed var(--border); padding-bottom: 2px; margin: 6px 0 10px; user-select: none; }
/* Prepare to share — the pre-flight check list. */
.share-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.share-chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px;
  padding: 2px 10px; color: var(--text-2); }
.share-chip b { color: var(--text-1); }
.share-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); margin-bottom: 6px; flex-wrap: wrap; }
.share-row.share-warn { border-color: #d93025; }
html[data-theme="dark"] .share-row.share-warn { border-color: #b3261e; }
.share-row.share-ok { border-color: #188038; }
.share-kind { flex: 0 0 auto; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  background: var(--surface-3); border-radius: 100px; padding: 2px 9px; color: var(--text-2); }
.share-warn .share-kind { background: #fce8e6; color: #a50e0e; }
.share-msg { flex: 1 1 200px; font-size: 13px; }
.share-row .mini-btn { flex: 0 0 auto; }

/* Reading aids — a focus line, an optional dimmer and a progress bar. These are
   screen-only overlays pinned to the scrolling canvas, so the document itself is
   never changed and printing/exporting are unaffected. */
.read-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.read-band { position: absolute; left: 0; right: 0; background: rgba(26,115,232,.10);
  border-top: 1px solid rgba(26,115,232,.35); border-bottom: 1px solid rgba(26,115,232,.35); }
html[data-theme="dark"] .read-band { background: rgba(138,180,248,.14); border-color: rgba(138,180,248,.4); }
.read-dim { position: absolute; left: 0; right: 0; background: rgba(255,255,255,.55); }
html[data-theme="dark"] .read-dim { background: rgba(0,0,0,.45); }
.read-bar { position: absolute; left: 0; height: 3px; background: var(--accent); opacity: .85; }
.read-chip { position: absolute; right: 14px; font-size: 11.5px; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px; padding: 3px 10px;
  color: var(--text-2); box-shadow: var(--shadow-1); }
@media print { .read-layer { display: none !important; } }
/* The state classes the reading aids toggle on <body>; each scopes a small
   layout adjustment so the overlays never sit on top of the text. */
body.reading-bar .page-body { padding-bottom: 46px; }
body.reading-focus .read-band { display: block; }
body.reading-dim .read-dim { display: block; }
.read-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13.5px; }

/* Paste as Markdown — the input box and its live preview. */
.md-paste-area { width: 100%; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; resize: vertical;
  background: var(--surface); color: var(--text); }
.md-paste-area:focus { border-color: var(--accent); outline: none; }
.md-paste-preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  padding: 10px 14px; min-height: 60px; max-height: 260px; overflow: auto; font-size: 13.5px; }
.md-paste-preview h1, .md-paste-preview h2, .md-paste-preview h3 { margin: 8px 0 4px; }
.md-paste-preview table { border-collapse: collapse; }
.md-paste-preview td, .md-paste-preview th { border: 1px solid var(--border); padding: 3px 7px; }

/* Back up & restore — the group chooser. */
.backup-groups { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 4px; }
.backup-groups .read-row { margin-bottom: 4px; text-transform: capitalize; }

/* Bullets and numbering — the marker picker and the live preview. */
.marker-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.marker-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 62px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 11px; line-height: 1.2; }
.marker-btn:hover { border-color: var(--accent); }
.marker-btn.on { border-color: var(--accent); background: var(--accent-soft, rgba(66,133,244,.12)); font-weight: 600; }
.marker-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.marker-glyph { font-size: 17px; min-height: 20px; }
.list-preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 10px 16px; }
.list-preview-list { margin: 0; padding-left: 26px; }
.list-preview-list li { margin: 2px 0; }

/* List markers set from the Bullets and numbering dialog. The `data-list`
   attribute lets the marker character show on screen exactly as it exports. */
.doc ul[data-list^="dash"] { list-style-type: "–"; }
.doc ul[data-list^="check"] { list-style-type: "✓"; }
.doc ul[data-list^="arrow"] { list-style-type: "➤"; }
.doc ul[data-list^="star"] { list-style-type: "★"; }
.doc ul[data-list^="diamond"] { list-style-type: "◆"; }
.doc ul[data-list^="none"] { list-style-type: none; padding-left: 6px; }
.doc ol[data-list] { list-style-position: outside; }

/* ── reveal formatting (Shift+F1) ─────────────────────── */
.rf-block { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--surface-2); border-radius: var(--radius); }
.rf-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2);
  margin: 12px 0 4px; }
.rf-rows { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rf-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 7px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.rf-row:last-child { border-bottom: none; }
.rf-label { color: var(--text-2); }
.rf-value { font-weight: 600; text-align: right; }

/* ── word completion popup (Ctrl+Space) ────────────────── */
.wc-pop { position: fixed; z-index: 60; min-width: 150px; max-width: 280px; max-height: 240px;
  overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: 4px; font-size: 13px; }
.wc-item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 5px 9px; border-radius: 4px; cursor: pointer; }
.wc-item.on, .wc-item:hover { background: var(--accent-soft, rgba(66,133,244,.12)); }
.wc-word { font-weight: 600; }
.wc-tail { color: var(--text-2); font-size: 11.5px; }
