/* ═══════════════════════════════════════════════════════════════════════
   FileCarpenter PDF Editor — v1.9.22 application stylesheet

   One stylesheet for the whole editor. It replaces the four stacked layers
   used up to v1.9.21 (style.css + direct-manipulation.css +
   direct-manipulation-hardening.css + desktop-experience.css), which fought
   each other with !important and made [hidden] unreliable.

   Structure
     1  tokens            8  bench, pages and overlays
     2  base              9  panel (edit / changes)
     3  modes            10  status bar, toast, mode bar
     4  app bar          11  popovers and menus
     5  find bar         12  dialogs and tool palettes
     6  tool rail        13  signature studio
     7  page thumbnails  14  welcome / landing
                         15  responsive, touch, motion

   Swiss-coral system: warm neutral canvas, white paper, ink text, coral only
   for actions, active tools, selection and status.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── 1 tokens ─────────────────────────────────────────────────────────── */
:root {
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --canvas: #faf9f6;
  --paper: #ffffff;
  --bench: #efece8;
  --sunk: #f4f2ee;
  --hover: #f1eeea;
  --ink: #171a1d;
  --ink-2: #3a3f44;
  --muted: #6b6f73;
  --faint: #9a9da1;
  --line: #e5e1dc;
  --line-2: #d8d3cd;

  --coral: #d76552;
  --coral-strong: #b94e3d;
  --coral-wash: #f8e9e5;
  --coral-soft: #fbf1ee;
  --coral-ring: rgba(215, 101, 82, .26);
  --select: #d76552;
  --select-fill: rgba(215, 101, 82, .10);

  --good: #2f7d57;
  --good-wash: #e8f4ed;
  --warn: #9a6512;
  --warn-wash: #fbf2e1;
  --bad: #b3261e;
  --bad-wash: #fbeceb;

  --r-xs: 5px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --sh-1: 0 1px 2px rgba(23, 26, 29, .06);
  --sh-2: 0 1px 2px rgba(23, 26, 29, .05), 0 6px 18px rgba(23, 26, 29, .08);
  --sh-3: 0 2px 6px rgba(23, 26, 29, .06), 0 18px 44px rgba(23, 26, 29, .16);
  --sh-page: 0 0 0 1px rgba(23, 26, 29, .06), 0 2px 6px rgba(23, 26, 29, .06), 0 14px 34px rgba(23, 26, 29, .09);

  --chrome-h: 56px;
  --status-h: 34px;
  --rail-w: 76px;
  --pages-w: 208px;
  --panel-w: 360px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

/* ─── 2 base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
svg { flex: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  background: var(--paper); color: var(--ink-2); font: 600 11px/1 var(--mono);
}
select, input[type="text"], input[type="url"], input[type="number"], input[type="search"], textarea {
  min-height: 36px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink); font-size: 13.5px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:hover, input[type="text"]:hover, input[type="url"]:hover, input[type="number"]:hover, textarea:hover { border-color: #c9c3bc; }
select:focus, input[type="text"]:focus, input[type="url"]:focus, input[type="number"]:focus, textarea:focus {
  outline: none; border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-ring);
}
textarea { resize: vertical; line-height: 1.45; }
input[type="range"] { accent-color: var(--coral); cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--coral); width: 16px; height: 16px; margin: 0; cursor: pointer; }
input[type="color"] {
  width: 34px; height: 34px; padding: 3px; border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--paper); cursor: pointer; overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }

/* Buttons. `.tool` is the editor's single button primitive. */
.tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; min-width: 34px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink-2);
  font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover:not(:disabled) { background: var(--hover); border-color: #cdc7c0; color: var(--ink); }
.tool:active:not(:disabled) { transform: translateY(.5px); }
.tool:disabled { opacity: .42; }
.tool-solid { background: var(--coral); border-color: var(--coral); color: #fff; }
.tool-solid:hover:not(:disabled) { background: var(--coral-strong); border-color: var(--coral-strong); color: #fff; }
.tool-quiet { background: transparent; border-color: transparent; }
.tool-quiet:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
.tool-danger { color: var(--bad); border-color: #efcfcb; background: var(--paper); }
.tool-danger:hover:not(:disabled) { background: var(--bad-wash); border-color: #e6b3ad; color: var(--bad); }
.tool-icon { padding: 0; width: 34px; }
.tool-icon > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon-close {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1;
}
.icon-close:hover { background: var(--hover); color: var(--ink); }
.checkline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }

/* ─── 3 modes ──────────────────────────────────────────────────────────
   Welcome mode is the default (no document). desktop-experience.js sets
   body[data-mode="document"] as soon as a PDF is open.                    */
.chrome, .toolrail, .rail, .panel, footer.status, .findbar, .optbar { display: none; }

body[data-mode="document"] {
  height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
  display: grid; grid-template-rows: auto auto 1fr auto;
  background: var(--bench);
}
body[data-mode="document"] .fc-sitebar,
body[data-mode="document"] .fc-language-control,
body[data-mode="document"] .fc-language-suggestion { display: none !important; }
body[data-mode="document"] .chrome { display: grid; }
body[data-mode="document"] footer.status { display: flex; }
body[data-mode="document"] .findbar:not([hidden]) { display: flex; }

/* ─── 4 app bar ────────────────────────────────────────────────────────── */
.chrome {
  grid-row: 1; position: relative; z-index: 40;
  height: var(--chrome-h); padding: 0 12px 0 10px;
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.chrome-start, .chrome-end { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chrome-end { justify-content: flex-end; }
.identity {
  display: flex; align-items: center; gap: 9px; flex: none;
  height: 40px; padding: 0 8px 0 6px; border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none;
}
.identity:hover { background: var(--hover); }
.glyph {
  position: relative; display: block; width: 22px; height: 26px; flex: none;
  border: 1.5px solid var(--coral); border-radius: 2px;
}
.glyph::before {
  content: ""; position: absolute; left: 4px; right: 4px; top: 6px; height: 1.5px;
  background: var(--coral); box-shadow: 0 5px 0 var(--coral), 0 10px 0 var(--coral);
}
.glyph::after {
  content: ""; position: absolute; width: 11px; height: 1.8px; right: -4px; bottom: 4px;
  background: var(--ink); transform: rotate(-43deg);
}
.wordmark { font-size: 15px; font-weight: 720; letter-spacing: -.02em; white-space: nowrap; }
.wordmark span { color: var(--coral); }
.wordmark i { display: none; }
.editor-beta-badge, .welcome-beta-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px;
  border: 1px solid #efc6bd; border-radius: 999px; background: var(--coral-soft);
  color: var(--coral-strong); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

.product-switch { position: relative; flex: none; }
.product-switch-button {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 10px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.product-switch-button .editor-beta-badge { margin-left: 3px; }
.product-switch-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.product-switch-button:hover, .product-switch-button[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.product-switch::before { content: ""; position: absolute; left: -4px; top: 9px; bottom: 9px; width: 1px; background: var(--line); }
.product-menu {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 210; width: 280px; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.product-menu > a {
  display: grid; gap: 1px; padding: 9px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink);
}
.product-menu > a strong { font-size: 13.5px; font-weight: 650; }
.product-menu > a span { font-size: 12px; color: var(--muted); }
.product-menu > a:hover, .product-menu > a:focus-visible { background: var(--hover); outline: none; }
.product-menu > a[aria-current="page"] { background: var(--coral-soft); }
.product-menu > a[aria-current="page"] strong { color: var(--coral-strong); }
.product-menu-foot { display: flex; gap: 14px; margin-top: 4px; padding: 8px 10px 4px; border-top: 1px solid var(--line); }
.product-menu-foot a { font-size: 12px; color: var(--muted); text-decoration: none; }
.product-menu-foot a:hover { color: var(--coral); }

/* Application menus (installed by desktop-experience.js). */
.fc-app-menubar { display: flex; align-items: center; gap: 1px; min-width: 0; margin-left: 4px; }
.fc-app-menubar > button {
  height: 30px; padding: 0 9px; border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.fc-app-menubar > button:hover, .fc-app-menubar > button[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.fc-app-menu-popover {
  position: fixed; z-index: 220; min-width: 232px; padding: 5px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.fc-app-menu-popover button {
  width: 100%; min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 10px; border: 0; border-radius: var(--r-xs); background: transparent;
  color: var(--ink); font-size: 13px; text-align: left;
}
.fc-app-menu-popover button:hover, .fc-app-menu-popover button:focus-visible { background: var(--hover); outline: none; }
.fc-app-menu-popover kbd { min-width: 0; height: auto; padding: 0; border: 0; background: none; color: var(--faint); font: 500 11.5px var(--font); }

/* Document identity, centered in the app bar. */
.docmeta {
  justify-self: stretch; justify-content: center; display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  height: 36px; padding: 0 6px 0 8px;
}
.fc-doc-icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--coral); flex: none; }
.fc-doc-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.docname {
  min-width: 40px; max-width: 280px; padding: 3px 6px; border: 1px solid transparent; border-radius: var(--r-xs);
  font-size: 14px; font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none;
}
.docname[contenteditable]:hover { border-color: var(--line-2); cursor: text; }
.docname[contenteditable]:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-ring); text-overflow: clip; }
.docstat { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fc-doc-ready {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 7px;
  border-radius: 999px; background: var(--good-wash); color: var(--good); font-size: 11.5px; font-weight: 650;
}
.fc-doc-ready::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.fc-doc-ready[data-state="working"] { background: var(--warn-wash); color: var(--warn); }
.fc-doc-ready[data-state="working"]::before { animation: fc-pulse 1s ease-in-out infinite; }
.fc-server-copy {
  flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.fc-server-copy:hover { border-color: var(--line-2); color: var(--ink); }
.fc-server-copy-label { overflow: hidden; text-overflow: ellipsis; }
.fc-server-copy-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #d49a2a; }
.fc-server-copy[data-state="deleted"] .fc-server-copy-dot { background: var(--good); }
.fc-server-copy[data-state="unknown"] .fc-server-copy-dot { background: var(--faint); }

.toolgroup { display: flex; align-items: center; gap: 4px; }
.toolgroup + .toolgroup { margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.chrome .tool { min-height: 34px; }
.chrome .toolgroup-history .tool { border-color: transparent; background: transparent; }
.chrome .toolgroup-history .tool:hover:not(:disabled) { background: var(--hover); }
.changes-trigger { position: relative; }
.changes-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--coral); color: #fff; font-size: 10.5px; font-weight: 700;
}
.changes-trigger.has-changes { border-color: #efc6bd; background: var(--coral-soft); color: var(--coral-strong); }

/* ─── 5 find bar ───────────────────────────────────────────────────────── */
.findbar {
  grid-row: 2; position: relative; z-index: 35;
  align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 14px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.find-fields { display: flex; gap: 10px; flex: 1 1 420px; min-width: 0; }
.find-field { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.find-field input { flex: 1; min-width: 0; font-weight: 400; }
.find-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.find-count { min-width: 64px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.find-acts { display: flex; align-items: center; gap: 4px; }
.find-acts .tool-icon { font-size: 17px; }

/* Legacy option strip: kept in the DOM for compatibility, never shown. */
.optbar { display: none !important; }

/* ─── workspace grid (document mode) ─── */
.workspace { position: relative; }
body[data-mode="document"] .workspace {
  grid-row: 3; min-height: 0;
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--pages-w);
  grid-template-areas: "tools bench pages";
}
@media (min-width: 901px) {
  body[data-mode="document"].fc-pages-collapsed .workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; }
}
body[data-mode="document"] .toolrail { display: flex; grid-area: tools; }
body[data-mode="document"] .rail { display: flex; grid-area: pages; }
body[data-mode="document"].fc-pages-collapsed .rail { display: none; }
body[data-mode="document"] .bench { grid-area: bench; }
body[data-mode="document"] .panel { display: flex; }

/* ─── 6 tool rail ──────────────────────────────────────────────────────── */
.toolrail {
  position: relative; z-index: 30; min-height: 0;
  flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 12px; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
  background: var(--paper); border-right: 1px solid var(--line);
}
.toolrail::-webkit-scrollbar { display: none; }
.toolrail-section-label { width: 36px; height: 1px; margin: 7px 0; background: var(--line); font-size: 0; flex: none; }
.toolrail > .toolrail-section-label:first-child { display: none; }
.trig, .tools-more {
  position: relative; flex: none;
  width: 62px; min-height: 52px; padding: 6px 2px 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink-2);
  transition: background .12s ease, color .12s ease;
}
.trig svg, .tools-more svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tools-more svg circle { fill: currentColor; stroke: none; }
.trig-label { font-size: 10.5px; font-weight: 600; line-height: 1.15; text-align: center; letter-spacing: -.005em; max-width: 60px; }
.trig:hover:not(:disabled), .tools-more:hover { background: var(--hover); color: var(--ink); }
.trig[aria-pressed="true"], .trig[aria-expanded="true"] { background: var(--coral-wash); color: var(--coral-strong); }
.trig[aria-pressed="true"] svg { stroke-width: 1.8; }
.trig:disabled { opacity: .34; }
.trig.secondary-tool, #t-find { display: none; }
.trig-gap { display: none; }
.tools-more { margin-top: 2px; color: var(--muted); }
.tools-more[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.tools-more-dot { position: absolute; top: 8px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 2px var(--paper); opacity: 0; }
.tools-more.has-active-tool { color: var(--coral-strong); background: var(--coral-soft); }
.tools-more.has-active-tool .tools-more-dot { opacity: 1; }

/* More tools popover */
.more-tools-popover {
  position: fixed; z-index: 210;
  left: calc(var(--rail-w) + 10px); top: calc(var(--chrome-h) + 10px);
  width: min(560px, calc(100vw - var(--rail-w) - 24px)); max-height: calc(100vh - var(--chrome-h) - 40px); overflow: auto;
  padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: fc-pop .14s var(--ease);
}
.more-tools-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.more-tools-head strong { display: block; font-size: 15px; font-weight: 700; }
.more-tools-head span { font-size: 12px; color: var(--muted); }
.more-tools-close { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 20px; }
.more-tools-close:hover { background: var(--hover); color: var(--ink); }
.more-tools-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.more-tools-group { padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); }
.more-tools-group h3 { margin: 2px 4px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.palette-tool {
  width: 100%; min-height: 36px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); text-align: left; font-size: 13px; font-weight: 550;
}
.palette-tool small { font-size: 11px; font-weight: 400; color: var(--muted); }
.palette-tool small:empty { display: none; }
.palette-tool:hover:not(:disabled) { background: var(--hover); }
.palette-tool[aria-pressed="true"] { background: var(--coral-wash); color: var(--coral-strong); }
.palette-tool:disabled { color: var(--faint); cursor: not-allowed; }

/* First-use tool tip next to the rail. */
.tool-guide {
  position: fixed; z-index: 190; width: 290px; display: flex; gap: 10px; padding: 11px 34px 11px 11px;
  background: var(--ink); color: #f4f2ef; border-radius: var(--r-md); box-shadow: var(--sh-3);
  opacity: 0; transform: translateX(-4px); transition: opacity .14s ease, transform .14s var(--ease); pointer-events: none;
}
.tool-guide.show { opacity: 1; transform: none; pointer-events: auto; }
.tool-guide[data-mobile="true"] { transform: translate(-50%, 4px); }
.tool-guide[data-mobile="true"].show { transform: translate(-50%, 0); }
.tool-guide-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: var(--r-sm); background: rgba(255,255,255,.1); color: #fff; }
.tool-guide-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-guide-kicker { font-size: 10.5px; font-weight: 600; color: #b9b5b0; text-transform: uppercase; letter-spacing: .06em; }
.tool-guide-copy strong { display: block; font-size: 13.5px; font-weight: 650; margin: 1px 0 2px; }
.tool-guide-copy p { margin: 0; font-size: 12.5px; line-height: 1.4; color: #d9d5d0; }
.tool-guide-close { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: var(--r-xs); background: transparent; color: #b9b5b0; font-size: 17px; }
.tool-guide-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ─── 7 page thumbnails ────────────────────────────────────────────────── */
.rail {
  position: relative; z-index: 30; min-height: 0; min-width: 0;
  flex-direction: column; background: var(--paper); border-left: 1px solid var(--line);
}
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 13px 14px 9px; }
.rail-head strong { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rail-head span { display: none; }
.rail-list {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 14px; padding: 4px 22px 24px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.thumb {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: 0; background: transparent; cursor: pointer; outline: none;
}
.thumb canvas, .thumb .thumb-blank {
  display: block; width: 100% !important; height: auto !important; aspect-ratio: auto;
  border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px rgba(23,26,29,.10), 0 2px 6px rgba(23,26,29,.06);
  transition: box-shadow .12s ease, transform .12s ease;
}
.thumb .thumb-blank { aspect-ratio: 8.5 / 11; }
.thumb:hover canvas, .thumb:hover .thumb-blank { box-shadow: 0 0 0 1px rgba(23,26,29,.18), 0 4px 12px rgba(23,26,29,.10); }
.thumb[aria-current="true"] canvas, .thumb[aria-current="true"] .thumb-blank { box-shadow: 0 0 0 2px var(--coral), 0 4px 12px rgba(23,26,29,.10); }
.thumb:focus-visible canvas, .thumb:focus-visible .thumb-blank { box-shadow: 0 0 0 2px var(--coral), 0 0 0 5px var(--coral-ring); }
.thumb-n { font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; padding: 3px 7px; border-radius: 999px; }
.thumb[aria-current="true"] .thumb-n { background: var(--coral); color: #fff; }
.thumb-dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: #d49a2a; box-shadow: 0 0 0 2px var(--paper); }
.thumb-actions {
  position: absolute; top: 6px; right: 6px; z-index: 3; display: flex; gap: 1px; padding: 2px;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--sh-2);
  opacity: 0; transform: translateY(-2px); pointer-events: none; transition: opacity .12s ease, transform .12s ease;
}
.thumb:hover .thumb-actions, .thumb:focus-within .thumb-actions { opacity: 1; transform: none; pointer-events: auto; }
.thumb-actions button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--ink-2); font: 600 14px/1 var(--font); }
.thumb-actions button:hover { background: var(--hover); color: var(--ink); }
.thumb-actions button[data-pa="delete"]:hover { background: var(--bad-wash); color: var(--bad); }
.thumb[draggable="true"] { cursor: grab; }
.thumb.drag-source { opacity: .45; }
.thumb.drag-target canvas, .thumb.drag-target .thumb-blank { box-shadow: 0 0 0 2px var(--coral), 0 0 0 6px var(--coral-ring); }

/* ─── 8 bench, pages and overlays ─────────────────────────────────────── */
.bench { position: relative; min-width: 0; min-height: 0; }
body[data-mode="document"] .bench { overflow: hidden; background: var(--bench); }
.bench.dragover::after {
  content: "Drop the PDF to open it"; position: absolute; inset: 12px; z-index: 60;
  display: grid; place-items: center; border: 2px dashed var(--coral); border-radius: var(--r-xl);
  background: rgba(251, 241, 238, .86); color: var(--coral-strong); font-size: 17px; font-weight: 650; pointer-events: none;
}
.viewer { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr; }
.viewer > .corner, .viewer > .ruler { display: none; }
.scroll {
  grid-area: 1 / 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 32px 96px; scroll-padding-block: 24px;
  scrollbar-gutter: stable both-edges; scrollbar-width: thin; scrollbar-color: #cbc5be transparent;
}
body.fc-continuous-pages .scroll { display: block; }
.fc-page-stack { width: 100%; min-width: max-content; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 18px; }
.fc-page-slot {
  position: relative; isolation: isolate; display: flex; align-items: flex-start; justify-content: center;
  width: max(var(--page-w, 612px), 1px); min-height: var(--page-h, 792px);
  background: #fff; border-radius: 2px; box-shadow: var(--sh-page); overflow: hidden;
  transition: box-shadow .14s ease;
}
.fc-page-slot.is-active { box-shadow: 0 0 0 1px rgba(215, 101, 82, .35), 0 2px 6px rgba(23,26,29,.06), 0 14px 34px rgba(23,26,29,.10); overflow: visible; }
.fc-page-slot:not(.is-active)::before { content: ""; position: absolute; inset: 0; z-index: -1; background: #fff; pointer-events: none; }
.fc-page-slot > .sheet { margin: 0; box-shadow: none; }
.fc-passive-page { display: block; max-width: none; background: #fff; }
.fc-page-badge {
  position: absolute; right: -40px; top: 2px; min-width: 28px; padding: 3px 6px; border-radius: 999px;
  color: var(--faint); font-size: 11px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
}
.fc-page-slot.is-active .fc-page-badge { color: var(--coral-strong); }

.sheet { position: relative; flex: none; background: #fff; box-shadow: var(--sh-page); }
.sheet > canvas#canvas { display: block; background: #fff; }
.layer { position: absolute; inset: 0; }

/* Text runs: invisible until hover, selection or search. */
.run {
  position: absolute; border: 1px solid transparent; border-radius: 3px;
  cursor: text; touch-action: none; transition: background .1s ease, border-color .1s ease;
}
.run:hover { background: var(--select-fill); border-color: rgba(215, 101, 82, .45); }
.run[aria-selected="true"] { background: rgba(215, 101, 82, .12); border-color: var(--select); box-shadow: 0 0 0 3px rgba(215, 101, 82, .14); }
.run:focus-visible { outline: 2px solid var(--select); outline-offset: 1px; }
.run[data-modified="true"] { border-color: rgba(212, 154, 42, .75); background: rgba(212, 154, 42, .08); }
.run[data-readonly="true"] { cursor: help; }
.run[data-readonly="true"]:hover { background: rgba(107, 111, 115, .10); border-color: rgba(107, 111, 115, .45); border-style: dotted; }
.run[data-compatibility="true"]:hover, .run[data-shaping="true"]:hover { border-style: dashed; }
.run[data-kind="image"] { border-style: dashed; }
.run.dragging { opacity: .6; border-style: dashed; cursor: grabbing; }
.run.match { background: rgba(212, 154, 42, .18); border-color: rgba(212, 154, 42, .6); }
.run.match-current { background: rgba(212, 154, 42, .34); border-color: #c98a1a; box-shadow: 0 0 0 2px rgba(212, 154, 42, .25); }
.run.found { animation: fc-found 1s ease-out 2; }
.run[data-logical-word="true"] { border-radius: 4px; }
.sheet[data-tool="select"] .run:not(:hover):not([aria-selected="true"]):not([data-modified="true"]):not(.match):not(.match-current) { background: transparent; border-color: transparent; box-shadow: none; }
.layer[data-outline="false"] .run:not(:hover):not([aria-selected="true"]) { border-color: transparent; }
/* Edit text owns the text hit-targets: added/vector objects sitting over a
   word are hidden while the mode is armed so they cannot steal the click that
   should edit that word. The object layer returns as soon as the mode exits. */
body.fc-edit-text-armed #object-layer { visibility: hidden !important; pointer-events: none !important; }
body.fc-edit-text-armed #sheet { cursor: text !important; }
body.fc-edit-text-armed #layer { pointer-events: auto !important; }
body.fc-edit-text-armed .sheet .run:not([data-readonly="true"]) { border-color: rgba(215, 101, 82, .28); }

.semantic-target-outline {
  position: absolute; z-index: 2; box-sizing: border-box; pointer-events: none;
  border: 1.5px solid var(--select); border-radius: 4px; opacity: .8;
  box-shadow: 0 0 0 3px rgba(215, 101, 82, .10);
}
.semantic-target-outline::before {
  content: attr(data-label); position: absolute; left: -1.5px; top: -20px; padding: 2px 6px; border-radius: 4px 4px 0 0;
  background: var(--select); color: #fff; font-size: 9.5px; font-weight: 650; line-height: 16px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}

/* Interactive AcroForm layer (positions come from app-core.js). */
.form-layer { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.form-control-wrap { position: absolute; min-width: 10px; min-height: 10px; pointer-events: auto; }
.form-control-wrap[data-readonly="true"] { pointer-events: none; }
.form-control {
  width: 100%; height: 100%; min-height: 24px; margin: 0; padding: 1px 4px;
  border: 1px solid rgba(46, 98, 160, .5); border-radius: 3px; background: rgba(238, 245, 253, .92);
  color: #0f2944; font: 500 12px/1.2 Arial, Helvetica, sans-serif; outline: none; box-shadow: none;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.form-control:hover { border-color: #2e62a0; background: rgba(232, 242, 253, .98); }
.form-control:focus, .form-control:focus-visible { border-color: #1f5fae; background: #fff; box-shadow: 0 0 0 2px rgba(31, 95, 174, .22); }
textarea.form-control { resize: none; overflow: auto; }
select.form-control { padding-right: 18px; }
.form-control[type="checkbox"], .form-control[type="radio"] { appearance: auto; -webkit-appearance: auto; padding: 0; border: 0; box-shadow: none; background: #fff; accent-color: #1f5fae; }
.form-control-wrap[data-kind="checkbox"], .form-control-wrap[data-kind="radio"] { min-width: 22px; min-height: 22px; }
.form-control-wrap[data-required="true"]::after { content: ""; position: absolute; right: -6px; top: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--bad); pointer-events: none; }
.form-control-wrap[data-pending="true"] .form-control { cursor: progress; opacity: .78; }
.form-control-wrap[data-saved="true"] .form-control { border-color: var(--good); box-shadow: 0 0 0 1px rgba(47, 125, 87, .14); }
.form-control-wrap[data-error="true"] .form-control { border-color: var(--bad); box-shadow: 0 0 0 2px rgba(179, 38, 30, .14); }
.form-control-wrap[data-readonly="true"] .form-control { opacity: .55; border-style: dashed; background: rgba(244, 246, 248, .88); }
.form-widget-unsupported { position: absolute; pointer-events: none; border: 1px dashed rgba(107, 111, 115, .55); border-radius: 3px; }
/* Form widgets only take pointer input in Select / Fill forms; every other tool
   (markup, drawing, crop, signature placement…) gets the page to itself. */
.sheet:not([data-tool="select"]):not([data-tool="forms"]) .form-layer { display: none; }

/* Added objects (images, shapes, comments, links). */
.object-layer { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.objbox {
  position: absolute; box-sizing: border-box; pointer-events: auto; touch-action: none; cursor: grab;
  border: 1.5px solid transparent; border-radius: 2px; background: transparent;
}
.objbox:hover { border-color: rgba(215, 101, 82, .55); background: rgba(215, 101, 82, .04); }
.objbox[aria-selected="true"] { border-color: var(--select); box-shadow: 0 0 0 1px rgba(255,255,255,.9), 0 0 0 4px rgba(215, 101, 82, .14); }
.objbox:focus-visible { outline: 2px solid var(--select); outline-offset: 3px; }
.objbox.dragging { cursor: grabbing; border-style: dashed; }
.objtag {
  position: absolute; left: -1.5px; top: -19px; padding: 2px 6px; border-radius: 4px 4px 0 0;
  background: var(--select); color: #fff; font: 650 9.5px/1.3 var(--font); letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; pointer-events: none; opacity: 0;
}
.objbox:hover .objtag, .objbox[aria-selected="true"] .objtag { opacity: .92; }
.objresize {
  position: absolute; z-index: 4; display: none; width: 12px; height: 12px; margin: 0; padding: 0;
  border: 1.5px solid var(--select); border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(23,26,29,.22);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.objbox[aria-selected="true"] .objresize { display: block; }
.objresize-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.objresize-n { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.objresize-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.objresize-e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.objresize-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.objresize-s { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.objresize-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.objresize-w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.objrotate-stem { position: absolute; left: 50%; top: -26px; width: 1px; height: 19px; background: var(--select); transform: translateX(-50%); display: none; pointer-events: none; }
.objrotate {
  position: absolute; left: 50%; top: -40px; z-index: 5; display: none; width: 16px; height: 16px;
  border: 1.5px solid var(--select); border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(23,26,29,.22);
  transform: translateX(-50%); cursor: grab;
}
.objrotate:active { cursor: grabbing; }
.objbox[aria-selected="true"] .objrotate, .objbox[aria-selected="true"] .objrotate-stem { display: block; }

/* Floating actions for the selected object. Position comes from app-core.js. */
.object-actions {
  position: fixed; z-index: 150; transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; max-width: calc(100vw - 24px);
  padding: 5px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.object-actions .tool { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.object-actions-copy { display: grid; gap: 0; padding: 0 8px 0 6px; margin-right: 2px; border-right: 1px solid var(--line); line-height: 1.2; }
.object-actions-copy strong { font-size: 12.5px; font-weight: 650; text-transform: capitalize; }
.object-actions-copy span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.object-lock { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 12px; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.object-inline-editor, .object-inline-size { display: flex; align-items: center; gap: 5px; }
.object-inline-editor input { width: min(260px, 28vw); min-height: 30px; }
.object-inline-size label { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.object-inline-size input { width: 70px; min-height: 30px; padding: 4px 6px; }

/* Measure / draw / ghost / badges. */
.mlayer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.mlayer line { stroke: var(--coral); stroke-width: 1.5; stroke-dasharray: 5 3; }
.mlayer circle { fill: #fff; stroke: var(--coral); stroke-width: 1.5; }
.mbadge {
  position: absolute; z-index: 12; pointer-events: none; padding: 3px 8px; border-radius: 999px;
  background: var(--ink); color: #fff; font: 600 11px/1.4 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: var(--sh-2);
}
.draw-layer { position: absolute; left: 0; top: 0; z-index: 10; pointer-events: none; overflow: visible; }
.text-selection-preview .text-selection-segment, .text-selection-preview .text-selection-mark { filter: saturate(.96); }
.ghost { position: absolute; z-index: 11; pointer-events: none; border: 1px dashed var(--coral); border-radius: 3px; background: rgba(215, 101, 82, .05); }
.ghost img { width: 100%; height: 100%; object-fit: contain; opacity: .6; }

/* Cursors answer to the active tool. */
.sheet.placing { cursor: crosshair; }
.sheet.placing .run { pointer-events: none; }
#sheet[data-tool="select"] { cursor: default; }
#sheet[data-tool="text"], #sheet[data-tool="measure"], #sheet[data-tool="draw"], #sheet[data-tool="shape"],
#sheet[data-tool="link"], #sheet[data-tool="crop"], #sheet[data-tool="redact"], #sheet[data-tool="replace-area"] { cursor: crosshair; }
#sheet[data-tool="erase"] { cursor: pointer; }
#sheet[data-tool="image"], #sheet[data-tool="sign"] { cursor: copy; }
#sheet[data-tool="comment"] { cursor: cell; }
#sheet[data-tool="stamp"] { cursor: cell; }
#sheet[data-tool="markup"] { cursor: url("/pdf-editor/assets/highlighter-cursor.svg") 5 27, text; }
#sheet[data-tool="markup"].markup-selecting { user-select: none; }
#sheet[data-tool="markup"] #draw-layer { pointer-events: none; }
.sheet[data-tool="move"] .run { cursor: grab; }
.sheet[data-tool="erase"] .run:hover { background: rgba(179, 38, 30, .12); border-color: var(--bad); cursor: pointer; }
.sheet:is([data-tool="text"], [data-tool="measure"], [data-tool="draw"], [data-tool="markup"], [data-tool="shape"], [data-tool="image"], [data-tool="sign"], [data-tool="object"], [data-tool="comment"], [data-tool="stamp"], [data-tool="link"], [data-tool="crop"], [data-tool="redact"], [data-tool="replace-area"]) .run { pointer-events: none; }
.sheet.placing, .sheet[data-tool="image"], .sheet[data-tool="sign"] { outline: 2px solid rgba(215, 101, 82, .22); outline-offset: 4px; }
.sheet.signature-adjusting { cursor: default; outline: 2px solid rgba(215, 101, 82, .22); outline-offset: 4px; }

/* Signature draft: staged on the page, written to the PDF only on Done. */
.fc-sign-draft {
  position: absolute; z-index: 70; box-sizing: border-box; cursor: move; touch-action: none; user-select: none; -webkit-user-select: none;
  border: 1.5px dashed var(--select); border-radius: 3px; background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9);
}
.fc-sign-draft:focus { outline: none; border-style: solid; box-shadow: 0 0 0 1px rgba(255,255,255,.9), 0 0 0 4px var(--coral-ring); }
.fc-sign-draft-image { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.fc-sign-resize-handle {
  position: absolute; z-index: 2; width: 14px; height: 14px; padding: 0; touch-action: none;
  border: 1.5px solid var(--select); border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(23,26,29,.24);
}
.fc-sign-resize-handle:focus-visible { outline: 3px solid var(--coral-ring); outline-offset: 2px; }
.fc-sign-resize-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.fc-sign-resize-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.fc-sign-resize-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.fc-sign-resize-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.fc-sign-controls {
  position: absolute; z-index: 72; display: flex; align-items: center; gap: 6px; min-height: 44px; max-width: calc(100% - 16px);
  padding: 5px 5px 5px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
  line-height: 1.2; white-space: nowrap; touch-action: manipulation;
}
.fc-sign-size-control { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; font-weight: 650; color: var(--ink-2); }
.fc-sign-size-control input[type="range"] { width: 140px; min-width: 80px; margin: 0; }
.fc-sign-size-control output { min-width: 46px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.fc-sign-controls .tool { min-height: 32px; padding: 0 12px; }

/* Upload / open progress card. */
.document-open-status {
  position: fixed; left: 50%; top: calc(var(--chrome-h) + 14px); z-index: 160; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: fc-drop .18s var(--ease);
}
body:not([data-mode="document"]) .document-open-status { top: 84px; }
.document-open-icon { display: grid; place-items: center; width: 38px; height: 44px; border: 1.5px solid var(--coral); border-radius: 4px; color: var(--coral); font-size: 10px; font-weight: 750; letter-spacing: .04em; }
.document-open-copy { min-width: 0; display: grid; gap: 2px; }
.document-open-copy strong { font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.document-open-copy span { font-size: 12px; color: var(--muted); }
.document-open-meter { height: 4px; margin-top: 6px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.document-open-meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--coral); transition: width .2s ease; }
.document-open-status[data-state="processing"] .document-open-meter i,
.document-open-status[data-state="opening"] .document-open-meter i { width: 100% !important; animation: fc-shimmer 1.2s ease-in-out infinite; }
.document-open-status[data-state="ready"] .document-open-meter i { background: var(--good); }
.document-open-status[data-state="error"] { border-color: #efcfcb; }
.document-open-status[data-state="error"] .document-open-meter i { background: var(--bad); width: 100% !important; }
.document-open-state { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--coral); animation: fc-spin .8s linear infinite; }
.document-open-status[data-state="ready"] .document-open-state { border: 0; background: var(--good-wash); animation: none; }
.document-open-status[data-state="ready"] .document-open-state::after { content: "✓"; display: grid; place-items: center; height: 100%; color: var(--good); font-size: 12px; font-weight: 800; }
.document-open-status[data-state="error"] .document-open-state { border: 0; background: var(--bad-wash); animation: none; }
.document-open-status[data-state="error"] .document-open-state::after { content: "!"; display: grid; place-items: center; height: 100%; color: var(--bad); font-size: 13px; font-weight: 800; }
.document-open-status[data-state="selected"] .document-open-state, .document-open-status[data-state="queued"] .document-open-state { animation-duration: 1.6s; }
#progress, .progress { display: none !important; }

/* ─── 9 panel (edit / changes) ─────────────────────────────────────────── */
.panel {
  position: fixed; z-index: 60; top: calc(var(--chrome-h) + 10px); right: 10px; bottom: calc(var(--status-h) + 10px);
  width: min(var(--panel-w), calc(100vw - 24px)); flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  transform: translateX(calc(100% + 24px)); visibility: hidden;
  transition: transform .22s var(--ease), visibility 0s linear .22s;
}
.panel.open { transform: none; visibility: visible; transition: transform .22s var(--ease), visibility 0s; }
.panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.panel-head-copy { flex: 1; min-width: 0; }
.panel-eyebrow { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--coral-strong); }
.panel-head h2 { margin: 2px 0 2px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.panel-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.panel-head-actions { display: flex; gap: 2px; }
.tab-help, .panel-close { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 16px; }
.panel-close { font-size: 21px; }
.tab-help:hover, .panel-close:hover { background: var(--hover); color: var(--ink); }
.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 20px; }
.ins-idle, .chg-idle { display: grid; justify-items: center; gap: 6px; padding: 28px 12px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 50%; background: var(--sunk); color: var(--muted); font-size: 18px; font-weight: 700; }
.empty-icon-check { background: var(--good-wash); color: var(--good); }
.idle-lede { margin: 0; font-size: 14px; font-weight: 650; }
.idle-body { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 260px; }
.ins-live { display: grid; gap: 14px; }
.quick-current > span, .composer-label, .spec-head, .control-label {
  display: block; margin-bottom: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; color: var(--muted);
}
.current-text { max-height: 96px; overflow: auto; padding: 9px 11px; border-radius: var(--r-sm); background: var(--sunk); font-size: 13px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.composer textarea { width: 100%; min-height: 84px; font-size: 14px; }
.smart-target { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #efd5ce; border-radius: var(--r-md); background: var(--coral-soft); }
.smart-target-copy { flex: 1; min-width: 0; display: grid; }
.smart-target-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--coral-strong); }
.smart-target[data-active="true"] .smart-target-kicker::after { content: " · adaptive reflow"; }
.smart-target-copy strong { font-size: 13px; }
.smart-target-copy small { font-size: 11.5px; color: var(--muted); }
.verdict { min-height: 0; padding: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.verdict:not(:empty) { padding: 10px 12px; border-radius: var(--r-sm); background: var(--sunk); }
.verdict b { font-weight: 650; }
.verdict.ok { background: var(--good-wash); color: #1f5a3d; }
.verdict.warn { background: var(--warn-wash); color: #6e4a0e; }
.verdict-simple-block { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.verdict-help { display: inline-grid; place-items: center; width: 24px; height: 24px; min-width: 24px; padding: 0; border: 1px solid rgba(154, 101, 18, .35); border-radius: 50%; background: #fff; color: var(--warn); font: 800 12px/1 var(--font); }
.quick-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.quick-actions .quick-apply { margin-left: auto; }
.advanced { border-top: 1px solid var(--line); padding-top: 12px; }
.advanced > summary, .technical-details > summary { list-style: none; cursor: pointer; user-select: none; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.advanced > summary::-webkit-details-marker, .technical-details > summary::-webkit-details-marker { display: none; }
.advanced > summary::before, .technical-details > summary::before { content: "›"; display: inline-block; width: 14px; transition: transform .12s ease; color: var(--muted); }
.advanced[open] > summary::before, .technical-details[open] > summary::before { transform: rotate(90deg); }
.advanced-body { display: grid; gap: 14px; margin-top: 12px; }
.advanced-status { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.plan-detail { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.tier { flex: none; padding: 3px 7px; border-radius: 999px; background: var(--sunk); color: var(--muted); font: 700 10px/1.3 var(--mono); letter-spacing: .06em; }
.tier[data-tier="A"], .tier[data-tier="P"] { background: var(--good-wash); color: var(--good); }
.gauge { display: flex; align-items: center; gap: 10px; }
.gauge-track { flex: 1; height: 5px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.gauge-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--coral); transition: width .2s ease; }
.gauge-read { min-width: 44px; font: 600 11.5px var(--mono); color: var(--muted); text-align: right; }
.control { display: grid; }
.control select { width: 100%; }
.opt-reflow { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sunk); font-size: 12.5px; cursor: pointer; }
.spec { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; margin: 10px 0 0; font-size: 12px; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }
.advanced-danger { padding-top: 4px; }
.changes-summary { display: grid; gap: 2px; margin-bottom: 12px; }
.changes-summary strong { font-size: 13.5px; }
.changes-summary span { font-size: 12px; color: var(--muted); }
.chg-list { display: grid; gap: 8px; }
.chg { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.chg:hover { border-color: var(--line-2); background: var(--canvas); }
.chg[data-current="true"] { border-color: var(--coral); background: var(--coral-soft); }
.chg-where { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.chg-kind { padding: 2px 7px; border-radius: 999px; background: var(--sunk); color: var(--ink-2); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.chg-kind[data-k="added"] { background: var(--good-wash); color: var(--good); }
.chg-kind[data-k="deleted"] { background: var(--bad-wash); color: var(--bad); }
.chg-text { display: grid; gap: 3px; font-size: 12.5px; overflow-wrap: anywhere; }
.chg-before { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(179, 38, 30, .5); }
.chg-after { color: var(--ink); }
.chg-after::before { content: "→ "; color: var(--good); }
.chg-undo { justify-self: start; }

.text-safety-popover {
  position: fixed; z-index: 350; padding: 12px 14px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.text-safety-popover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.text-safety-popover-head strong { font-size: 13.5px; }
.text-safety-popover-head button { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--r-xs); background: var(--sunk); color: var(--muted); font-size: 16px; }
.text-safety-popover p { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

/* Near-text inline editor (direct-manipulation.js). */
.dm-inline-editor {
  position: fixed; z-index: 140; display: grid; gap: 6px; width: min(420px, calc(100vw - 20px)); padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.dm-inline-editor-main textarea { width: 100%; min-height: 64px; border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-ring); }
.dm-inline-editor-main .verdict:not(:empty) { margin-top: 6px; }
.dm-inline-editor-actions { display: flex; justify-content: flex-end; gap: 4px; }
.dm-inline-editor-actions .tool { min-height: 30px; }
.dm-editor-control { width: 100%; }

/* Floating composer for new text. */
.inline {
  position: fixed; z-index: 140; display: grid; gap: 6px; width: 260px; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.inline textarea { width: 100%; min-height: 40px; font-size: 14px; border-color: var(--coral); }
.inline-acts { display: flex; justify-content: flex-end; gap: 4px; }
.inline-acts .tool { min-height: 30px; }

/* ─── 10 status bar, toast and mode bar ───────────────────────────────── */
footer.status {
  grid-row: 4; position: relative; z-index: 35; box-sizing: border-box; overflow: clip;
  height: var(--status-h); align-items: center; gap: 12px; padding: 0 10px 0 14px;
  background: var(--paper); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.stat { white-space: nowrap; }
.stat-runs, #stat-coord, .fc-stat-page-hidden { display: none; }
.status .sep { width: 1px; height: 16px; background: var(--line); }
.status .sep:has(+ .stat-runs), .status .stat-runs + .sep { display: none; }
.status-spacer { flex: 1; }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom button, .fc-page-nav button {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border: 0; border-radius: var(--r-xs); background: transparent; color: var(--ink-2); font: 600 14px/1 var(--font);
}
.zoom #zoom-fit { font-size: 12px; }
.zoom button:hover:not(:disabled), .fc-page-nav button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.fc-page-nav button:disabled { opacity: .35; }
#zoom-read { min-width: 42px; text-align: center; color: var(--ink-2); font-weight: 600; }
.fc-page-nav { display: flex; align-items: center; gap: 4px; order: -1; }
.fc-status-doc { display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--line); }
.fc-status-doc .fc-doc-ready { height: 20px; font-size: 11px; }
.fc-status-doc .fc-server-copy { height: 22px; font-size: 11px; }
.fc-page-nav label { display: flex; }
.fc-page-nav input {
  width: 42px; min-height: 24px; height: 24px; padding: 0 4px; text-align: center;
  border: 1px solid var(--line-2); border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--ink);
}
.fc-page-nav [data-page-total] { color: var(--muted); white-space: nowrap; }
.fc-footer-view-button, #fc-pages-toggle {
  display: grid; place-items: center; width: 28px; min-width: 28px; height: 26px; min-height: 26px; padding: 0;
  border: 0; border-radius: var(--r-xs); background: transparent; color: var(--ink-2);
}
#fc-pages-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
#fc-pages-toggle[aria-pressed="true"] { background: var(--coral-wash); color: var(--coral-strong); }
#fc-pages-toggle:hover { background: var(--hover); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--status-h) + 16px); z-index: 400; transform: translateX(-50%);
  width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px 10px 14px; border-radius: var(--r-md);
  background: var(--ink); color: #f6f4f1; font-size: 13px; line-height: 1.45; box-shadow: var(--sh-3);
  display: flex; align-items: flex-start; gap: 10px; animation: fc-rise .18s var(--ease);
}
body:not([data-mode="document"]) .toast { bottom: 24px; }
/* While a dialog is open, feedback appears above it instead of covering it. */
body:has(.modal-scrim:not([hidden])) .toast { top: 14px; bottom: auto; animation-name: fc-drop; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #9a9da1; }
.toast[data-kind="good"]::before { background: #6bd49a; }
.toast[data-kind="error"]::before { background: #ff8a7e; }
.toast[data-kind="info"]::before { background: #f0b36b; }

/* Active-tool bar and placement banner share one slot at the top of the page. */
.fc-mode-bar, .placement-banner {
  position: fixed; z-index: 150; left: calc(var(--rail-w) + (100vw - var(--rail-w) - var(--pages-w)) / 2); top: calc(var(--chrome-h) + 12px);
  transform: translateX(-50%); width: max-content; max-width: min(640px, calc(100vw - var(--rail-w) - var(--pages-w) - 32px));
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--sh-2);
  animation: fc-drop .16s var(--ease);
}
body.fc-pages-collapsed .fc-mode-bar, body.fc-pages-collapsed .placement-banner { left: calc(var(--rail-w) + (100vw - var(--rail-w)) / 2); }
.fc-mode-dot, .placement-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px var(--coral-ring); }
.fc-mode-copy, .placement-banner > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.fc-mode-copy strong, .placement-banner strong { font-size: 13px; font-weight: 700; white-space: nowrap; }
.fc-mode-copy span, .placement-banner span:not(.placement-dot) { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-mode-bar .tool, .placement-banner .tool { min-height: 30px; border-radius: 999px; padding: 0 12px; }
.fc-mode-bar [data-mode-options] { border-color: var(--line-2); }
body:has(.sheet.signature-adjusting) #placement-cancel { display: none; }

.fc-selection-chip {
  position: fixed; z-index: 130; display: flex; align-items: center; gap: 4px; padding: 3px 3px 3px 10px;
  background: var(--ink); color: #fff; border-radius: 999px; box-shadow: var(--sh-2); font-size: 11.5px; font-weight: 600;
}
.fc-selection-chip button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 11px; font-weight: 800; }
.fc-selection-chip button:hover { background: rgba(255,255,255,.24); }

/* ─── 11 popovers ──────────────────────────────────────────────────────── */
.fc-edit-text-popover, .fc-server-copy-popover {
  position: fixed; z-index: 220; padding: 12px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3); animation: fc-pop .14s var(--ease);
}
.fc-edit-text-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.fc-edit-text-head > div { flex: 1; display: grid; }
.fc-edit-text-head strong { font-size: 14px; }
.fc-edit-text-head span { font-size: 12px; color: var(--muted); }
.fc-edit-text-head button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 19px; }
.fc-edit-text-head button:hover { background: var(--hover); }
.fc-edit-text-icon, .fc-edit-choice-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--r-sm); background: var(--coral-wash); color: var(--coral-strong); font-size: 13px; font-weight: 700; }
.fc-edit-choice {
  width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 8px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); text-align: left;
}
.fc-edit-choice:hover { border-color: #efc6bd; background: var(--coral-soft); }
.fc-edit-choice strong { display: block; font-size: 13px; }
.fc-edit-choice small { font-size: 12px; color: var(--muted); }

.fc-server-copy-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fc-server-copy-head > div { display: grid; }
.fc-server-copy-head strong { font-size: 14px; }
.fc-server-copy-head span { font-size: 12px; color: var(--muted); }
.fc-server-copy-close { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 19px; }
.fc-server-copy-close:hover { background: var(--hover); }
.fc-server-copy-state-row { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--warn-wash); }
.fc-server-copy-popover[data-state="deleted"] .fc-server-copy-state-row { background: var(--good-wash); }
.fc-server-copy-state-dot { width: 8px; height: 8px; margin-top: 6px; flex: none; border-radius: 50%; background: #d49a2a; }
.fc-server-copy-popover[data-state="deleted"] .fc-server-copy-state-dot { background: var(--good); }
.fc-server-copy-state-row > div { display: grid; gap: 1px; }
.fc-server-copy-state-row strong { font-size: 13px; }
.fc-server-copy-state-row span { font-size: 12px; color: var(--ink-2); }
.fc-server-copy-facts { display: grid; gap: 6px; margin: 12px 0; }
.fc-server-copy-facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.fc-server-copy-facts dt { color: var(--muted); }
.fc-server-copy-facts dd { margin: 0; text-align: right; font-weight: 600; }
.fc-server-copy-note { margin: 0 0 12px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.fc-server-copy-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fc-server-copy-actions a { font-size: 12.5px; color: var(--coral-strong); }

.markup-flyout {
  --markup-arrow-top: 52px;
  position: fixed; z-index: 220; width: 360px; padding: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: fc-pop .14s var(--ease);
}
/* Highlight is an attached sub-tool, never the generic centered setup palette. */
#tool-setup-scrim[data-tool="markup"] { display: none !important; }
.markup-flyout-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.markup-flyout-head > div { display: grid; gap: 2px; }
.markup-flyout-head strong { font-size: 15px; }
.markup-flyout-head span { font-size: 12px; color: var(--muted); }
.markup-flyout-close { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 20px; }
.markup-flyout-close:hover { background: var(--hover); }
.markup-flyout-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.markup-flyout-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 12px 6px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); color: var(--ink-2); text-align: center;
  transition: border-color .12s ease, background .12s ease;
}
.markup-flyout-choice:hover { border-color: var(--line-2); background: var(--canvas); }
.markup-flyout-choice[aria-pressed="true"], .markup-flyout-choice.active { border-color: var(--coral); background: var(--coral-soft); color: var(--ink); }
.markup-flyout-choice strong { font-size: 12.5px; }
.markup-flyout-choice small { font-size: 11px; color: var(--muted); line-height: 1.25; }
.markup-flyout-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 2px; border-radius: var(--r-sm); background: var(--sunk); }
.markup-flyout-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.markup-flyout-icon svg .nib { stroke: #e5b700; stroke-width: 3; }
.markup-flyout-icon svg .ink { stroke: #e5b700; }
.markup-flyout-icon span { font: 700 17px/1 Georgia, serif; color: var(--ink); }
.markup-flyout-icon-underline span { text-decoration: underline; text-decoration-color: var(--coral); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.markup-flyout-icon-strike span { text-decoration: line-through; text-decoration-color: var(--coral); text-decoration-thickness: 2px; }
.markup-flyout-appearance { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.markup-flyout-appearance-label, .markup-flyout-strength span { font-size: 12px; font-weight: 650; color: var(--muted); min-width: 52px; }
.markup-flyout-swatches { display: flex; gap: 6px; }
.markup-flyout-swatches button, .markup-swatch {
  width: 24px; height: 24px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line-2); transition: transform .1s ease, box-shadow .1s ease;
}
.markup-flyout-swatches button:hover, .markup-swatch:hover { transform: scale(1.08); }
.markup-flyout-swatches button.active, .markup-flyout-swatches button[aria-pressed="true"], .markup-swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.markup-flyout-swatches button { display: grid; place-items: center; }
.markup-flyout-swatches button.active::after { content: "✓"; font-size: 11px; font-weight: 800; color: rgba(23, 26, 29, .78); }
.markup-flyout-custom { display: grid; place-items: center; margin-left: auto; }
.markup-flyout-custom input { width: 30px; height: 30px; }
.markup-flyout-strength { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.markup-flyout-strength input { flex: 1; }
.markup-flyout-strength output { min-width: 36px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.markup-flyout-tip { margin-top: 12px; padding: 9px 11px; border-radius: var(--r-sm); background: var(--sunk); font-size: 12px; color: var(--ink-2); }
.markup-flyout-tip::after { content: " After applying, the editor returns to the normal PDF view."; }
.markup-flyout-done { width: 100%; margin-top: 12px; }

/* ─── 12 dialogs and tool palettes ────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px;
  background: rgba(23, 26, 29, .34); animation: fc-fade .14s ease;
}
.modern-dialog, .sheetcard {
  position: relative; width: min(520px, 100%); max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--paper); border-radius: var(--r-xl); box-shadow: 0 30px 80px rgba(23, 26, 29, .28), 0 2px 8px rgba(23, 26, 29, .08);
  animation: fc-lift .18s var(--ease);
}
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.dialog-head > div { flex: 1; min-width: 0; }
.dialog-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.dialog-head p { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.dialog-icon, .tool-palette-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--r-md); background: var(--coral-wash); color: var(--coral-strong); }
.dialog-icon svg, .tool-palette-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-palette-icon:empty { display: none; }
.dialog-actions { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper); }
.dialog-spacer { flex: 1; }
.dialog-width { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dialog-width input { width: 72px; min-height: 32px; }
.dm-signature-initial-size { display: none !important; }
.field-stack { display: grid; gap: 6px; }
.field-stack > span { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field-stack input, .field-stack select { width: 100%; }
.task-dialog-body { display: grid; gap: 14px; padding: 18px 20px; }
.task-dialog-note { padding: 10px 12px; border-radius: var(--r-sm); background: var(--sunk); font-size: 12.5px; color: var(--ink-2); }

/* Keyboard shortcuts */
.sheetcard { width: min(460px, 100%); }
.sheetcard header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.sheetcard h2 { margin: 0; font-size: 16px; font-weight: 700; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 16px 20px 20px; font-size: 13px; }
.keys dt { display: flex; gap: 4px; }
.keys dd { margin: 0; color: var(--ink-2); align-self: center; }

/* Page organizer */
.pages-dialog { width: min(920px, 100%); display: flex; flex-direction: column; }
.pages-dialog-toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.compact-field { display: grid; gap: 4px; font-size: 11.5px; font-weight: 650; color: var(--muted); }
.compact-field input, .compact-field select { min-height: 34px; }
.pages-dialog-list {
  flex: 1; min-height: 220px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 16px; padding: 20px; align-content: start; background: var(--bench);
}
.page-card {
  position: relative; min-width: 0; display: grid; gap: 8px; padding: 8px; border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; text-align: center; cursor: grab; color: var(--ink-2); font-size: 12px; font-weight: 650;
}
.page-card:hover { background: rgba(255, 255, 255, .6); }
.page-card[aria-selected="true"] { border-color: var(--coral); background: var(--coral-soft); color: var(--coral-strong); }
.page-card canvas, .page-card img, .page-card-preview { display: block; width: 100%; height: auto; border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px rgba(23,26,29,.10), 0 2px 6px rgba(23,26,29,.06); }
.page-card-preview { aspect-ratio: 8.5 / 11; display: grid; place-items: center; overflow: hidden; }
.page-card-preview canvas { box-shadow: none; }
.page-card.dragging { opacity: .5; }
.page-card.drag-target { box-shadow: 0 0 0 2px var(--coral); }
.page-actions { flex-wrap: wrap; }

/* Tool palettes attached to the rail (non-modal, no veil). */
.tool-palette-host { background: transparent; pointer-events: none; display: block; padding: 0; animation: none; }
.tool-palette {
  position: fixed; pointer-events: auto;
  left: var(--palette-left, calc(var(--rail-w) + 12px)); top: var(--palette-top, calc(var(--chrome-h) + 12px));
  width: var(--palette-width, 340px); max-width: calc(100vw - 24px); max-height: calc(100dvh - var(--chrome-h) - 28px);
  display: flex; flex-direction: column; overflow: visible;
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: fc-pop .14s var(--ease);
}
/* Only the fields scroll, so the pointer arrow can sit outside the card. */
.tool-palette .setup-fields { flex: 1 1 auto; min-height: 0; overflow: auto; }
.tool-palette .dialog-head, .tool-palette .dialog-actions { flex: none; }
.tool-palette .dialog-actions { border-radius: 0 0 var(--r-lg) var(--r-lg); }
/* Attached palettes point back at the rail button that opened them.
   direct-manipulation.js sets data-dm-side and --dm-arrow-offset. */
.tool-palette::before, .markup-flyout::before {
  content: ""; position: absolute; z-index: 1; width: 13px; height: 13px;
  left: -7px; top: var(--dm-arrow-offset, var(--markup-arrow-top, 28px)); transform: rotate(45deg);
  background: var(--paper); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.tool-palette[data-dm-side="left"]::before, .markup-flyout[data-dm-side="left"]::before { left: auto; right: -7px; transform: rotate(225deg); }
.tool-palette[data-dm-side="below"]::before, .markup-flyout[data-dm-side="below"]::before { top: -7px; left: var(--dm-arrow-offset, 44px); transform: rotate(135deg); }
.tool-palette[data-dm-side="above"]::before, .markup-flyout[data-dm-side="above"]::before { top: auto; bottom: -7px; left: var(--dm-arrow-offset, 44px); transform: rotate(-45deg); }
.tool-palette .dialog-head { padding: 14px 12px 12px 14px; }
.tool-palette .dialog-head h2 { font-size: 15px; }
.tool-palette .dialog-head p { font-size: 12.5px; }
.tool-palette .dialog-actions { padding: 12px 14px; }
.setup-fields { display: grid; gap: 14px; padding: 14px; }
.setup-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 10px; }
.setup-row > span { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.setup-row input:not([type="color"]):not([type="range"]), .setup-row select { width: 100%; }
.setup-row input[type="color"] { justify-self: start; }
.setup-inline-value { display: flex; align-items: center; gap: 6px; }
.setup-inline-value span { font-size: 12px; color: var(--muted); }
.setup-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.setup-choice {
  min-height: 38px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.setup-choice:hover { background: var(--hover); }
.setup-choice[aria-pressed="true"] { border-color: var(--coral); background: var(--coral-soft); color: var(--coral-strong); }
.setup-message { padding: 10px 12px; border-radius: var(--r-sm); background: var(--sunk); font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.setup-message.compact { padding: 8px 10px; font-size: 12px; }
.setup-message.danger { background: var(--bad-wash); color: #7d1c16; }
.setup-message.danger-soft { background: var(--warn-wash); color: #6e4a0e; }
.setup-consent { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.setup-consent input { margin-top: 2px; }
.setup-error { min-height: 0; font-size: 12.5px; color: var(--bad); }
.setup-error:empty { display: none; }
.setup-image-picker { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--canvas); }
.setup-image-picker span { min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-preview { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 64px; border-radius: var(--r-md); background: var(--canvas); border: 1px solid var(--line); }
.pen-preview-line { display: block; width: 62%; min-height: 2px; border-radius: 999px; }
.pen-preview small { font-size: 11px; color: var(--muted); }
.markup-setup { display: grid; gap: 14px; }
.markup-style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.markup-style-choice { min-height: 62px; display: grid; justify-items: center; gap: 4px; padding: 8px 4px; }
.markup-style-choice strong { display: block; font-size: 12px; }
.markup-style-choice small { display: block; font-size: 10.5px; font-weight: 400; color: var(--muted); }
.markup-style-icon { font: 700 16px/1 Georgia, serif; color: var(--ink); }
.markup-style-icon-highlight { background: #fff176; padding: 1px 4px; border-radius: 3px; }
.markup-style-icon-underline { text-decoration: underline; text-decoration-color: var(--coral); }
.markup-style-icon-strike { text-decoration: line-through; text-decoration-color: var(--coral); }
.markup-live-preview { display: grid; justify-items: center; gap: 4px; padding: 12px; border-radius: var(--r-md); background: var(--canvas); border: 1px solid var(--line); }
.markup-live-preview small { font-size: 11px; color: var(--muted); }
.markup-setting-block { display: grid; gap: 8px; }
.markup-setting-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.markup-setting-head small, .markup-setting-head output { font-weight: 500; color: var(--muted); }
.markup-color-row { display: flex; align-items: center; gap: 10px; }
.markup-swatches { display: flex; gap: 6px; }
.markup-custom-color { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 12px; color: var(--muted); }
.markup-opacity-slider { width: 100%; }
.markup-selection-tip { display: flex; gap: 10px; padding: 10px; border-radius: var(--r-md); background: var(--sunk); font-size: 12px; color: var(--ink-2); }
.markup-selection-tip strong { display: block; font-size: 12.5px; }
.markup-selection-cursor { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; color: var(--coral-strong); font: 700 16px/1 Georgia, serif; }

/* Reviewed visual edits (native <dialog>). */
.fc-review-dialog {
  width: min(760px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(23, 26, 29, .28);
}
.fc-review-dialog::backdrop { background: rgba(23, 26, 29, .34); }
.fc-review-dialog h2 { margin: 0; padding: 18px 20px 4px; font-size: 17px; }
.fc-review-dialog > p { margin: 0; padding: 0 20px 12px; font-size: 13px; color: var(--muted); }
.fc-review-content { padding: 0 20px 16px; }
.fc-review-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fc-review-pair figure { margin: 0; display: grid; gap: 6px; }
.fc-review-pair figcaption { font-size: 12px; font-weight: 650; color: var(--muted); }
.fc-review-pair img { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.fc-review-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }

.text-preview-dialog {
  position: fixed; z-index: 320; right: 20px; top: calc(var(--chrome-h) + 16px); width: min(560px, calc(100vw - 40px));
  max-height: calc(100dvh - var(--chrome-h) - 40px); overflow: auto; padding: 0 0 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-3);
}
.text-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 14px 8px 18px; }
.text-preview-head span { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--coral-strong); }
.text-preview-head h2 { margin: 2px 0 0; font-size: 16px; }
.text-preview-dialog > p { margin: 0 18px 12px; font-size: 12.5px; color: var(--muted); }
.text-preview-image-wrap { margin: 0 18px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--canvas); }
.text-preview-image-wrap img { display: block; width: 100%; }
.text-preview-note { margin-top: 12px !important; }
.text-preview-actions { display: flex; justify-content: flex-end; padding: 0 18px; }

/* ─── 13 signature studio ──────────────────────────────────────────────── */
.sigcard { width: min(640px, 100%); display: flex; flex-direction: column; }
.sig-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 14px 20px 0; padding: 4px; border-radius: var(--r-md); background: var(--sunk); }
.sig-tab {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 650;
}
.sig-tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sig-tab:hover { color: var(--ink); }
.sig-tab.active, .sig-tab[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--sh-1), 0 0 0 1px rgba(23,26,29,.04); }
.sig-panels { padding: 16px 20px 4px; }
.sig-panel { display: grid; gap: 14px; }
.sig-type-preview {
  display: grid; place-items: center; min-height: 118px; padding: 12px 20px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: linear-gradient(to bottom, transparent calc(100% - 34px), var(--line) calc(100% - 34px), var(--line) calc(100% - 33px), transparent calc(100% - 33px)), var(--paper);
}
#sig-type-preview {
  max-width: 100%; color: var(--sig-ink, #111a3a); font-family: var(--sig-font, "Segoe Script", cursive); font-size: 48px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sig-type-preview[data-empty="true"] { color: #c9c3bc; }
.sig-style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sig-style {
  position: relative; display: grid; gap: 2px; min-width: 0; height: 64px; padding: 6px 10px; align-content: center;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); color: var(--sig-ink, #111a3a); text-align: left;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.sig-style:hover { border-color: var(--line-2); background: var(--canvas); }
.sig-style[aria-checked="true"] { border-color: var(--coral); background: var(--coral-soft); box-shadow: 0 0 0 1px var(--coral); }
.sig-style-sample { display: block; font-size: 24px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-style-name { display: block; font: 600 10.5px/1 var(--font); color: var(--muted); letter-spacing: .02em; }
.sig-style[aria-checked="true"] .sig-style-name { color: var(--coral-strong); }
.sigpad {
  position: relative; overflow: hidden; border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--paper); box-shadow: inset 0 1px 2px rgba(23,26,29,.04);
}
.sigpad canvas { position: relative; z-index: 2; display: block; width: 100%; height: auto; aspect-ratio: 1600 / 520; cursor: crosshair; touch-action: none; }
.sig-rule { position: absolute; left: 6%; right: 6%; bottom: 24%; z-index: 1; border-bottom: 1.5px solid var(--line-2); pointer-events: none; }
.sig-rule span { position: absolute; left: 0; top: 6px; font-size: 11px; color: var(--faint); }
.sig-rule::before { content: "×"; position: absolute; left: -18px; bottom: -3px; font-size: 16px; color: var(--faint); }
.sigpad-hint { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; margin: 0; padding-bottom: 8%; font-size: 14px; color: var(--faint); pointer-events: none; }
.sigpad[data-has-ink="true"] .sigpad-hint { display: none; }
.sigbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sigbar .opt { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.sigbar .opt input[type="range"] { width: 120px; }
.opt-spacer { flex: 1; }
.upload-drop {
  display: grid; justify-items: center; gap: 6px; padding: 22px 16px; text-align: center;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-md); background: var(--canvas);
  transition: border-color .12s ease, background .12s ease;
}
.upload-drop.dragover { border-color: var(--coral); background: var(--coral-soft); }
.upload-drop strong { font-size: 14px; }
.upload-drop > span { font-size: 12.5px; color: var(--muted); }
.upload-drop .tool { margin-top: 6px; }
.file-state { font-size: 12px; color: var(--muted); }
.sig-upload-preview {
  display: grid; place-items: center; width: 100%; max-width: 420px; height: 110px; margin-bottom: 4px; padding: 10px;
  border-radius: var(--r-sm); background-color: #fff;
  background-image: linear-gradient(45deg, #f1eeea 25%, transparent 25%), linear-gradient(-45deg, #f1eeea 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f1eeea 75%), linear-gradient(-45deg, transparent 75%, #f1eeea 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.sig-upload-preview img { max-height: 90px; max-width: 100%; object-fit: contain; }
.sig-ink { display: flex; align-items: center; gap: 10px; padding: 12px 20px 16px; }
.sigcard[data-sig-mode="upload"] .sig-ink { display: none; }
.sig-ink-label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.sig-ink-swatches { display: flex; gap: 6px; }
.sig-ink-swatches button {
  width: 26px; height: 26px; padding: 0; border: 3px solid #fff; border-radius: 50%; background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line-2); transition: box-shadow .1s ease;
}
.sig-ink-swatches button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--coral); }
.sig-ink-custom { position: relative; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(#e0533d, #e8b33b, #4caf6a, #3b82d6, #8e5bd6, #e0533d); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.sig-ink-custom::after { content: "+"; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: var(--ink-2); font: 700 13px/1 var(--font); }
.sig-ink-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* ─── 14 welcome / landing ─────────────────────────────────────────────── */
.welcome { padding: 40px 32px 72px; }
.welcome-card {
  width: min(1160px, 100%); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-areas: "intro upload" "summary summary" "copy copy";
  gap: 36px 56px; align-items: center;
}
.welcome-intro { grid-area: intro; }
.seo-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--coral-strong); }
.welcome h1 { margin: 0; font-size: clamp(34px, 4.2vw, 54px); line-height: 1.04; font-weight: 760; letter-spacing: -.035em; color: var(--ink); }
#seo-lede { margin: 18px 0 0; max-width: 520px; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.seo-trust { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; }
.seo-trust span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seo-trust span::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--good-wash) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.3l2.2 2.2 4.8-5' fill='none' stroke='%232f7d57' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat; }
.upload-stage { grid-area: upload; }
.upload-tile {
  position: relative; width: 100%; min-height: 330px; display: grid; justify-items: center; align-content: center; gap: 14px; padding: 36px 28px;
  border: 1.5px dashed #e3b9ae; border-radius: 24px; background: var(--paper); color: var(--ink); text-align: center;
  box-shadow: 0 1px 2px rgba(23,26,29,.04), 0 24px 60px rgba(120, 60, 40, .08);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s var(--ease), background .16s ease;
}
.upload-tile:hover, .upload-tile:focus-visible { border-color: var(--coral); background: #fffdfc; box-shadow: 0 1px 2px rgba(23,26,29,.04), 0 28px 70px rgba(120, 60, 40, .12); transform: translateY(-2px); outline: none; }
.bench.dragover .upload-tile { border-color: var(--coral); background: var(--coral-soft); }
.upload-tile-icon { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 22px; background: var(--coral-wash); color: var(--coral); }
.upload-tile-icon svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.upload-tile-copy { display: grid; gap: 3px; }
.upload-tile-copy strong { font-size: 20px; font-weight: 720; letter-spacing: -.015em; }
.upload-tile-copy span { font-size: 14px; color: var(--muted); }
.upload-tile-cta { display: inline-flex; align-items: center; height: 44px; padding: 0 24px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 15px; font-weight: 650; box-shadow: 0 6px 16px rgba(215, 101, 82, .28); }
.upload-tile:hover .upload-tile-cta { background: var(--coral-strong); }
.upload-tile-limit { font-size: 12px; color: var(--faint); }
.welcome-summary { grid-area: summary; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.welcome-summary > div { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); }
.welcome-summary > div > span { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--coral-wash); color: var(--coral-strong); }
.welcome-summary > div > span svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.welcome-summary p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.welcome-summary p strong { display: block; margin-bottom: 2px; font-size: 14.5px; color: var(--ink); }
.welcome-summary .session-note { grid-column: 1 / -1; font-size: 12.5px; text-align: center; color: var(--faint); }
.seo-intent-copy { grid-area: copy; width: min(820px, 100%); margin: 16px auto 0; padding-top: 44px; border-top: 1px solid var(--line); }
.seo-intent-copy h2 { margin: 36px 0 12px; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.seo-intent-copy h2:first-child { margin-top: 0; }
.seo-intent-copy h3 { margin: 0 0 6px; font-size: 15px; }
.seo-intent-copy p, .seo-intent-copy li { font-size: 15px; line-height: 1.7; color: var(--ink-2); }
.seo-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 20px 0; }
.seo-feature-grid article { padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); }
.seo-feature-grid article p { margin: 0; font-size: 14px; line-height: 1.6; }
.seo-steps { padding-left: 22px; }
.seo-steps li { margin: 6px 0; }
.seo-tool-links { margin-top: 32px; }
.seo-tool-links > div { display: flex; flex-wrap: wrap; gap: 8px; }
.seo-tool-links a { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper); color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; }
.seo-tool-links a:hover { border-color: var(--coral); color: var(--coral-strong); }
.seo-faq { margin-top: 32px; }
.seo-faq details { border-bottom: 1px solid var(--line); }
.seo-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; cursor: pointer; list-style: none; font-size: 15px; font-weight: 650; color: var(--ink); }
.seo-faq summary::-webkit-details-marker { display: none; }
.seo-faq summary::after { content: "+"; font-size: 20px; font-weight: 400; color: var(--muted); }
.seo-faq details[open] summary::after { content: "−"; }
.seo-faq details p { margin: 0 0 16px; }

/* ─── animations ─── */
@keyframes fc-pop { from { opacity: 0; transform: translateY(-4px) scale(.985); } }
@keyframes fc-lift { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes fc-drop { from { opacity: 0; transform: translate(-50%, -6px); } }
@keyframes fc-rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes fc-fade { from { opacity: 0; } }
@keyframes fc-spin { to { transform: rotate(360deg); } }
@keyframes fc-pulse { 50% { opacity: .35; } }
@keyframes fc-shimmer { 0% { opacity: .45; } 50% { opacity: 1; } 100% { opacity: .45; } }
@keyframes fc-found { 0% { box-shadow: 0 0 0 0 rgba(212, 154, 42, .6); } 100% { box-shadow: 0 0 0 10px rgba(212, 154, 42, 0); } }

/* ─── 15 responsive, touch and motion ─────────────────────────────────── */
@media (max-width: 1400px) {
  body[data-mode="document"] .wordmark, .docstat { display: none; }
  .chrome #btn-open { width: 34px; padding: 0; }
  .chrome #btn-open > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

@media (max-width: 1320px) {
  :root { --pages-w: 180px; }
  .fc-app-menubar > button { padding: 0 7px; }
  .fc-server-copy-label { max-width: 150px; }
}

@media (max-width: 1180px) {
  .docstat { display: none; }
  .chrome .toolgroup:not(.toolgroup-history) .tool:not(.tool-solid):not(.changes-trigger) { width: 34px; padding: 0; }
  .chrome .toolgroup:not(.toolgroup-history) .tool:not(.tool-solid):not(.changes-trigger) > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .welcome-card { gap: 32px 40px; }
}

@media (max-width: 1060px) {
  .fc-app-menubar { display: none; }
  .fc-server-copy { width: 26px; padding: 0; justify-content: center; }
  .fc-server-copy-label { display: none; }
}

/* Tablet: thumbnails become an overlay drawer, panel stays a floating sheet. */
@media (max-width: 900px) {
  :root { --chrome-h: 52px; --rail-w: 68px; }
  body[data-mode="document"] .workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; }
  body[data-mode="document"] .rail {
    position: fixed; z-index: 90; top: calc(var(--chrome-h) + 8px); right: 8px; bottom: calc(var(--status-h) + 8px);
    width: 196px; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  }
  .fc-mode-bar, .placement-banner, body.fc-pages-collapsed .fc-mode-bar, body.fc-pages-collapsed .placement-banner {
    left: calc(var(--rail-w) + (100vw - var(--rail-w)) / 2); max-width: calc(100vw - var(--rail-w) - 24px);
  }
  .trig, .tools-more { width: 56px; }
  .trig-label { font-size: 10px; }
  .editor-beta-badge, .wordmark { display: none; }
  .docmeta { max-width: 42vw; }
  .fc-doc-ready { display: none; }
  .scroll { padding: 18px 16px 80px; }
  .fc-page-badge { display: none; }
  .welcome { padding: 28px 22px 60px; }
  .welcome-card { grid-template-columns: 1fr; grid-template-areas: "intro" "upload" "summary" "copy"; }
  .welcome-summary { grid-template-columns: 1fr; }
  .upload-tile { min-height: 280px; }
  .seo-feature-grid { grid-template-columns: 1fr; }
}

/* Phone: tools move to a bottom bar, dialogs become bottom sheets. */
@media (max-width: 760px) {
  :root { --chrome-h: 52px; --status-h: 40px; --dock-h: 62px; }
  body[data-mode="document"] { grid-template-rows: auto auto 1fr auto auto; }
  body[data-mode="document"] .workspace { grid-row: 3; grid-template-columns: minmax(0, 1fr); grid-template-areas: "bench"; }
  body[data-mode="document"] .toolrail {
    grid-area: auto; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom)); padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    flex-direction: row; align-items: center; gap: 2px; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(23,26,29,.06);
  }
  body[data-mode="document"] footer.status { grid-row: 4; margin-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); gap: 8px; padding: 0 8px; }
  .toolrail-section-label { width: 1px; height: 30px; margin: 0 4px; }
  .trig, .tools-more { width: 58px; min-height: 52px; flex: none; }
  .chrome { padding: 0 6px 0 4px; gap: 6px; }
  .product-switch-label { display: none; }
  .product-switch::before { display: none; }
  .docmeta { max-width: none; justify-content: center; padding: 0; }
  .fc-doc-icon { display: none; }
  .docname { max-width: 100%; font-size: 13.5px; }
  .fc-status-doc { padding-left: 8px; margin-left: 0; }
  .toolgroup + .toolgroup { margin-left: 2px; padding-left: 4px; border-left: 0; }
  #btn-redo, #btn-open { display: none; }
  .chrome .toolgroup-history .tool, #btn-changes { width: 38px; min-width: 38px; padding: 0; }
  #btn-changes > span:not(.changes-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #btn-changes .changes-badge { position: absolute; top: -4px; right: -4px; }
  .chrome .tool-solid { width: 38px; padding: 0; }
  .chrome .tool-solid > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .zoom #zoom-read { min-width: 38px; }
  .stat-edits, .status .sep { display: none; }
  .scroll { padding: 12px 8px 40px; scrollbar-gutter: auto; }
  body[data-mode="document"] .rail { top: calc(var(--chrome-h) + 8px); bottom: calc(var(--status-h) + var(--dock-h) + 16px); right: 8px; width: min(200px, 60vw); }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom); }
  .panel.open { transform: none; }
  .fc-mode-bar, .placement-banner, body.fc-pages-collapsed .fc-mode-bar, body.fc-pages-collapsed .placement-banner {
    left: 50%; top: calc(var(--chrome-h) + 8px); max-width: calc(100vw - 16px); padding-left: 12px; border-radius: var(--r-lg);
  }
  .fc-mode-copy span, .placement-banner span:not(.placement-dot) { display: none; }
  .toast { bottom: calc(var(--status-h) + var(--dock-h) + 14px + env(safe-area-inset-bottom)); }
  .more-tools-popover { left: 8px; right: 8px; top: auto; bottom: calc(var(--dock-h) + 10px + env(safe-area-inset-bottom)); width: auto; max-height: 70dvh; }
  .more-tools-grid { grid-template-columns: 1fr; }
  .object-actions { left: 8px !important; right: 8px; top: auto !important; bottom: calc(var(--status-h) + var(--dock-h) + 12px); transform: none; overflow-x: auto; }
  .object-inline-editor input { width: 170px; }
  .scrim { place-items: end center; padding: 0; }
  .modern-dialog, .sheetcard { width: 100%; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); animation-name: fc-sheet; }
  .tool-palette-host { display: grid; place-items: end center; pointer-events: auto; background: rgba(23,26,29,.28); }
  .tool-palette { position: relative; left: auto !important; top: auto !important; width: 100% !important; max-height: 85dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .tool-palette::before { display: none; }
  .tool-palette .dialog-actions { border-radius: 0; }
  .markup-flyout { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .markup-flyout::before { display: none; }
  .setup-row { grid-template-columns: 1fr; gap: 6px; }
  .sig-tabs { margin: 12px 14px 0; }
  .sig-panels { padding: 14px 14px 2px; }
  .sig-ink { padding: 10px 14px 12px; }
  .dialog-head { padding: 16px 12px 12px 16px; }
  .dialog-actions { padding: 12px 14px; }
  .sig-style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sig-type-preview { min-height: 96px; }
  #sig-type-preview { font-size: 38px; }
  .pages-dialog-list { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px; gap: 10px; }
  .fc-review-pair { grid-template-columns: 1fr; }
  .text-preview-dialog { left: 8px; right: 8px; width: auto; }
  .welcome { padding: 20px 16px 48px; }
  .welcome h1 { font-size: clamp(32px, 9vw, 42px); }
  #seo-lede { font-size: 16px; }
  .upload-tile { min-height: 250px; padding: 28px 18px; border-radius: 20px; }
  .seo-intent-copy { padding-top: 32px; }
  .seo-intent-copy h2 { font-size: 21px; }
  /* 16px text prevents unwanted iOS zoom on focus. */
  input, select, textarea { font-size: 16px !important; }
  .fc-page-nav input { font-size: 16px !important; width: 44px; }
}
@keyframes fc-sheet { from { transform: translateY(40px); opacity: .6; } }

@media (max-width: 420px) {
  .trig, .tools-more { width: 54px; }
  .trig-label { font-size: 9.5px; }
  .welcome-summary > div { padding: 14px; }
  .fc-sign-controls { flex-wrap: wrap; white-space: normal; }
  .fc-sign-size-control { flex: 1 1 100%; }
  .fc-sign-size-control input[type="range"] { flex: 1; width: auto; }
}

/* Short landscape screens: keep the rail usable. */
@media (max-height: 620px) and (min-width: 761px) {
  .trig, .tools-more { min-height: 44px; padding: 4px 2px; }
  .trig-label { display: none; }
  .toolrail-section-label { margin: 4px 0; }
}

/* Coarse pointers get 44px targets. */
@media (pointer: coarse) {
  .tool, .icon-close { min-height: 44px; min-width: 44px; }
  .trig, .tools-more { min-height: 54px; }
  .fc-sign-resize-handle { width: 24px; height: 24px; }
  .fc-sign-resize-nw { left: -13px; top: -13px; }
  .fc-sign-resize-ne { right: -13px; top: -13px; }
  .fc-sign-resize-sw { left: -13px; bottom: -13px; }
  .fc-sign-resize-se { right: -13px; bottom: -13px; }
  .objresize { width: 20px; height: 20px; }
  .objresize-nw, .objresize-sw, .objresize-w { left: -11px; }
  .objresize-ne, .objresize-se, .objresize-e { right: -11px; }
  .objresize-nw, .objresize-n, .objresize-ne { top: -11px; }
  .objresize-sw, .objresize-s, .objresize-se { bottom: -11px; }
  .objrotate { width: 22px; height: 22px; top: -46px; }
  .objrotate-stem { top: -30px; height: 22px; }
  .thumb-actions { opacity: 1; transform: none; pointer-events: auto; }
  .thumb-actions button { width: 30px; height: 30px; }
  .zoom button, .fc-page-nav button { min-width: 36px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .modern-dialog, .placement-banner, .fc-mode-bar, .panel { animation: none !important; transition: none !important; }
}
