/*
VOICE: a calm, precise workbench; it gets out of the way of the document.
IDEA: a sheet of paper held safe at anchor: the page is the hero, tools sit at the edges.
PICTURE: the open document itself, large and white, with your edits floating on it.
COLOUR and TYPE: paper white, harbour green #1d6b47 for actions, highlighter yellow #ffd400 as the one accent; system UI type.
LAYOUT: a PDF viewer first. Tool rail left, page thumbnails and bookmarks beside it, pages centred,
tool settings in a side panel on the right so the page stays in view; on phones the rail moves to the bottom.
*/
:root {
  color-scheme: light dark;
  --brand: light-dark(#1d6b47, #5cc28f);
  --brand-strong: light-dark(#14523a, #7fd6a8);
  --brand-soft: light-dark(#e3f1e9, #1d3b2c);
  --on-brand: light-dark(#ffffff, #07130d);
  --accent: #ffd400;
  --bg: light-dark(#eceeea, #101412);
  --panel: light-dark(#ffffff, #181d1a);
  --paper: #ffffff;
  --ink: light-dark(#18201b, #e5ebe7);
  --muted: light-dark(#5b6760, #9aa9a0);
  --line: light-dark(#d9dfda, #2a322d);
  --hover: light-dark(#f1f4f1, #222924);
  --danger: light-dark(#b3261e, #ff8a80);
  --sel: #1a73e8;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 14px rgb(0 0 0 / 0.08);
  --radius: 10px;
  --rail: calc(88px * var(--text-scale, 1));
  --thumbs: 150px;
  font: calc(15px * var(--text-scale, 1))/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
/* Accent colours. Each pair is checked for contrast: white or dark text on the colour, and the colour as text
   on the panel and on the background, at least 4.5 to 1 in light and in dark (tests/a11y.py checks every pair).
   The nine hues follow the GNOME desktop's accent colours; in light mode they are darker shades, so white text
   on them stays readable (a light yellow would give 1.3 to 1). */
:root[data-accent="teal"] { --brand: light-dark(#066e7e, #41bcd2); --brand-strong: light-dark(#024f5a, #89e1f3); --brand-soft: light-dark(#dcf6fb, #07373f); --on-brand: light-dark(#ffffff, #001317); }
:root[data-accent="blue"] { --brand: light-dark(#1d4ed8, #7aa7ff); --brand-strong: light-dark(#1e3a8a, #a9c4ff); --brand-soft: light-dark(#e7eefc, #18264a); --on-brand: light-dark(#ffffff, #071228); }
:root[data-accent="purple"] { --brand: light-dark(#6d28d9, #b49cff); --brand-strong: light-dark(#4c1d95, #cdbbff); --brand-soft: light-dark(#efe9fc, #2a1d4a); --on-brand: light-dark(#ffffff, #150a2e); }
:root[data-accent="rose"] { --brand: light-dark(#bb1f74, #f78bb9); --brand-strong: light-dark(#8a0452, #ffbcd6); --brand-soft: light-dark(#ffeaf1, #442532); --on-brand: light-dark(#ffffff, #190a10); }
:root[data-accent="red"] { --brand: light-dark(#c8072d, #ff8d8b); --brand-strong: light-dark(#91021e, #ffc0bd); --brand-soft: light-dark(#ffebe9, #462625); --on-brand: light-dark(#ffffff, #1b0a09); }
:root[data-accent="orange"] { --brand: light-dark(#b53b09, #ffa266); --brand-strong: light-dark(#7c2d12, #ffc29b); --brand-soft: light-dark(#fdece3, #43230f); --on-brand: light-dark(#ffffff, #2a1204); }
:root[data-accent="yellow"] { --brand: light-dark(#7e5f03, #fac332); --brand-strong: light-dark(#5a4301, #f7cb68); --brand-soft: light-dark(#f9efdb, #3c2e0f); --on-brand: light-dark(#ffffff, #150e02); }
:root[data-accent="graphite"] { --brand: light-dark(#374151, #c3cad5); --brand-strong: light-dark(#1f2937, #e2e6ec); --brand-soft: light-dark(#eceef1, #262b33); --on-brand: light-dark(#ffffff, #0f1216); }
/* High contrast (Appearance > Contrast > High, or Automatic when the device asks for more contrast):
   text at 7 to 1 or more, solid borders, a thicker focus ring; the accent colour uses its strongest shade.
   Must stay after the accent rules, which have the same weight. */
:root[data-contrast="more"] {
  --bg: light-dark(#ffffff, #000000);
  --panel: light-dark(#ffffff, #000000);
  --ink: light-dark(#000000, #ffffff);
  --muted: light-dark(#333333, #d4d4d4);
  --line: light-dark(#5e5e5e, #a3a3a3);
  --hover: light-dark(#e8e8e8, #1f1f1f);
  --danger: light-dark(#8c1d18, #ffb4ab);
  --brand: var(--brand-strong);
  --shadow: none;
}
:root[data-contrast="more"] :focus-visible { outline: 3px solid var(--ink) !important; outline-offset: 2px; }
:root[data-contrast="more"] .secondary, :root[data-contrast="more"] .rail button[aria-pressed="true"], :root[data-contrast="more"] .seg button[aria-pressed="true"], :root[data-contrast="more"] .side-tabs button[aria-selected="true"] { outline: 2px solid var(--brand-strong); outline-offset: -2px; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- buttons and fields ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500;
}
button:hover:not(:disabled), .btn:hover { background: var(--hover); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .drop:focus-visible {
  outline: 2px solid var(--sel); outline-offset: 2px;
}
.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.primary:hover:not(:disabled) { background: var(--brand-strong); }
.secondary { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.ghost { background: transparent; border-color: transparent; }
.danger { color: var(--danger); }
.icon { padding: 0; width: 36px; }
.ic { display: inline-flex; line-height: 0; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], select, textarea {
  min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
input[type="number"] { width: 5.5em; }
input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
input[type="color"] { width: 36px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
label.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
label.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }

/* ---------- top bar ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none;
  /* the popup menus (#menu) live in the top bar, as the menu button pattern has it, so the bar sits above
     the side panel (25) and page popovers (30), below the palette, toasts and overlays (45 and up) */
  z-index: 41;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: calc(17px * var(--text-scale, 1)); letter-spacing: -0.01em; }
/* document tabs, in the top bar */
.docname { flex: 1; min-width: 0; display: flex; align-items: flex-end; align-self: stretch; gap: 2px; overflow: hidden; padding-top: 8px; font-size: calc(14px * var(--text-scale, 1)); }
.doctabs::-webkit-scrollbar { display: none; }
/* the tabs shrink to their minimum width first; only then the row of tabs scrolls, and the + button after it stays in view */
.doctabs { display: flex; align-items: flex-end; align-self: stretch; gap: 2px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
/* Document tabs: each one is a visible grey tab of equal width (so many files share the bar fairly), the
   active one is white with a coloured top edge. Names fade out instead of ending in "...", and the close
   button of a background tab only appears on hover, on top of the name, so it costs no room. */
.doctab {
  flex: 1 1 0; min-width: 64px; max-width: 220px; display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 4px 0 10px;
  border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--muted); cursor: pointer; user-select: none; position: relative;
  background: color-mix(in srgb, var(--ink) 6%, var(--panel));
}
.doctab:hover { background: color-mix(in srgb, var(--ink) 11%, var(--panel)); color: var(--ink); }
.doctab.active { background: var(--panel); border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: inset 0 3px 0 var(--brand); flex-shrink: 0.35; min-width: 132px; }
:root[data-contrast="more"] .doctab { border-color: var(--line); }
/* with three files or more the name next to the logo makes room for the tabs */
.topbar:has(.doctab:nth-child(3)) .brand span { display: none; }
.doctab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--panel); }
.doctab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dt-name { overflow: hidden; white-space: nowrap; min-width: 0; flex: 1; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); }
.dt-lock { color: var(--brand); display: inline-flex; flex: none; }
.dt-dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.doctab:hover .dt-dirty, .doctab:focus-within .dt-dirty { display: none; }
.dt-close { width: 24px; height: 24px; min-height: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; display: grid; place-items: center; flex: none; opacity: 0.55; }
.doctab:not(.active) .dt-close { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: inherit; display: none; }
.doctab:not(.active):hover .dt-close, .doctab:not(.active):focus-within .dt-close { display: grid; }
.doctab:not(:hover):not(:focus-within) .dt-dirty + .dt-close { display: none; }
.dt-close:hover { opacity: 1; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.dt-new { flex: none; align-self: center; width: 32px; min-height: 32px; margin: 0 0 4px 4px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
#app[data-view="welcome"] #btnUndo, #app[data-view="welcome"] #btnRedo, #app[data-view="welcome"] #btnDownload, #app[data-view="welcome"] #btnPrint, #app[data-view="welcome"] #btnEmail { display: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-strong); font-size: calc(12px * var(--text-scale, 1)); font-weight: 600; margin-left: 8px; vertical-align: 1px; }

/* ---------- welcome ---------- */
.welcome { grid-area: main; overflow: auto; scrollbar-gutter: stable; padding: clamp(20px, 4vw, 48px) max(3vw, 16px) 40px; }
/* parts that main.js fills in show once they are complete, so nothing on the start screen jumps */
html:not([data-ready]) :is(.top-actions, .how) { visibility: hidden; }
#app:not([data-view="welcome"]) .welcome { display: none; }
.hero { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(20px, 4vw, 56px); align-items: center; }
.hero .kicker { margin: 0 0 10px; font-size: calc(13px * var(--text-scale, 1)); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-strong); }
.hero h1 { font-size: calc(clamp(30px, 3.8vw, 46px) * var(--text-scale, 1)); line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 16px; text-wrap: balance; }
.hero p { font-size: calc(17px * var(--text-scale, 1)); color: var(--muted); margin: 0; max-width: 34em; }
.hero-drop { display: flex; flex-direction: column; gap: 8px; }
.link-btn { align-self: center; background: none; border: 0; color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.link-btn.inline { display: inline; padding: 0; min-height: 0; font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover:not(:disabled) { background: none; color: var(--ink); }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 300px; padding: 28px; border-radius: 18px; cursor: pointer;
  background: var(--panel); border: 2px dashed color-mix(in srgb, var(--brand) 45%, transparent);
  box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); transform: translateY(-1px); }
.drop strong { font-size: calc(20px * var(--text-scale, 1)); }
.drop small { color: var(--muted); }
.drop > span:not(.btn):not(.drop-icon) { color: var(--muted); }
.drop .btn { min-height: 44px; padding: 0 22px; font-size: calc(16px * var(--text-scale, 1)); }
.drop-icon { width: 88px; height: 88px; border-radius: 22px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.tasks { max-width: 1180px; margin: clamp(28px, 4vw, 48px) auto 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; }
.task {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 2px 12px; align-items: start; text-align: left;
  min-height: 76px; padding: 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
}
.task .ic { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.task strong { font-size: calc(15px * var(--text-scale, 1)); white-space: normal; line-height: 1.25; }
.task span:last-child { color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); font-weight: 400; white-space: normal; }
.task:hover { border-color: var(--brand); background: var(--panel); }
/* recent files on the start screen */
.recent { max-width: 1180px; margin: clamp(24px, 3vw, 40px) auto 0; }
.recent[hidden] { display: none; }
.recent-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 10px; }
.recent-head h2 { margin: 0; font-size: calc(17px * var(--text-scale, 1)); flex: 1; }
.recent-head .link-btn { font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.recent-item { position: relative; }
.recent-open {
  width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px; text-align: left;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--line); min-height: 0;
}
.recent-open:hover { border-color: var(--brand); background: var(--panel); }
.recent-thumb { height: 150px; display: grid; place-items: center; overflow: hidden; border-radius: 6px; background: color-mix(in srgb, var(--bg) 60%, var(--panel)); color: var(--muted); }
.recent-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 1px 4px rgb(0 0 0 / 0.18); background: #fff; }
.recent-name { font-size: calc(14px * var(--text-scale, 1)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { font-size: calc(12px * var(--text-scale, 1)); color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-x { position: absolute; top: 12px; right: 12px; width: 26px; min-height: 26px; padding: 0; border-radius: 50%; background: var(--panel); opacity: 0; }
.recent-item:hover .recent-x, .recent-x:focus-visible { opacity: 1; }
.how { max-width: 1180px; margin: 36px auto 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 20px; color: var(--muted); font-size: calc(14px * var(--text-scale, 1)); }
.how > div { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.how strong { color: var(--ink); }
.how .ic-wrap { color: var(--brand); }

/* ---------- workspace ---------- */
.workspace {
  flex: 1; display: grid; min-height: 0;
  --panel-w: 0px;
  grid-template-columns: var(--rail) var(--thumbs) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "rail ctx ctx panel" "rail find find panel" "rail note note panel" "rail side main panel" "rail status status panel";
}
#app[data-panel] .workspace { --panel-w: min(calc(380px * var(--text-scale, 1)), 42vw); }
#app[data-view="welcome"] .workspace { grid-template-columns: var(--rail) 0 minmax(0, 1fr) var(--panel-w); }
#app[data-view="welcome"] :is(.sidebar, .viewer, .organizer, .ctxbar, .findbar, .noticebar, .statusbar) { display: none; }
/* on the start screen only panels that work without a document (Appearance, Use it as your PDF viewer) open */
#app[data-view="organize"] .workspace { grid-template-columns: var(--rail) 0 minmax(0, 1fr) var(--panel-w); }
#app[data-view="organize"] .sidebar, #app[data-view="organize"] .ctxbar { display: none; }
.rail { grid-area: rail; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 6px; display: flex; flex-direction: column; gap: 2px; }
.rail button {
  flex-direction: column; gap: 1px; height: auto; min-height: 38px; padding: 3px 2px; flex: none; border: 0; border-radius: 10px;
  background: transparent; font-size: calc(11px * var(--text-scale, 1)); font-weight: 500; color: var(--muted); white-space: normal; line-height: 1.12;
}
.rail button:hover { background: var(--hover); color: var(--ink); }
.rail button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.rail hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; flex: none; }
.rail .grp { flex: none; margin: 4px 4px 0; padding: 6px 0 2px; border-top: 1px solid var(--line); font-size: calc(9.5px * var(--text-scale, 1)); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); text-align: center; user-select: none; }
.rail { scrollbar-width: thin; }
/* the switch between the narrow rail (name under the icon) and the wide one (name next to it) */
.rail .rail-toggle { margin-top: auto; flex: none; font-size: calc(10px * var(--text-scale, 1)); }
.rail .rail-toggle:hover { opacity: 1; }
.rail .rail-toggle[aria-pressed="true"] { background: transparent; color: var(--muted); }
.rail .rail-toggle[aria-pressed="true"]:hover { background: var(--hover); color: var(--ink); }
:root[data-rail-wide] #app { --rail: calc(208px * var(--text-scale, 1)); }
:root[data-rail-wide] #app .rail { padding: 6px 8px; }
:root[data-rail-wide] #app .rail button { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 32px; padding: 4px 10px; font-size: calc(13px * var(--text-scale, 1)); text-align: left; line-height: 1.2; }
/* Long names (and longer languages) wrap onto a second line instead of being cut off. */
:root[data-rail-wide] #app .rail button .lbl { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; line-height: 1.15; hyphens: auto; overflow-wrap: break-word; }
:root[data-rail-wide] #app .rail .grp { text-align: left; font-size: calc(10px * var(--text-scale, 1)); padding: 8px 10px 2px; margin: 4px 0 0; }
:root[data-rail-wide] #app .rail .rail-toggle { font-size: calc(12px * var(--text-scale, 1)); }
/* medium screens (1200p, 1440p at 125%): tighter, headings stay */
@media (max-height: 1400px) and (min-width: 761px) {
  .rail { padding: 4px 6px; gap: 1px; }
  .rail button { min-height: 31px; padding: 1px 2px; gap: 0; font-size: calc(10.5px * var(--text-scale, 1)); }
  .rail .grp { font-size: calc(8.5px * var(--text-scale, 1)); padding: 3px 0 0; margin: 2px 4px 0; }
  .rail button .lbl { line-height: 1.05; }
  .rail button .ic svg { width: 18px; height: 18px; }
  :root[data-rail-wide] #app .rail button { min-height: 28px; }
}
/* short screens (laptops, and 1080p with the browser's own bars): smaller buttons, headings become thin lines;
   the buttons touch (no gap), so 24-pixel targets stay 24 pixels apart */
@media (max-height: 1050px) and (min-width: 761px) {
  .rail { padding: 2px 6px; gap: 0; }
  .rail button { min-height: 27px; padding: 0 2px; gap: 0; font-size: calc(9.5px * var(--text-scale, 1)); }
  .rail button .lbl { line-height: 1; }
  .rail button .ic svg { width: 16px; height: 16px; }
  .rail .grp { font-size: 0; padding: 0; margin: 2px 10px; }
  :root[data-rail-wide] #app .rail button { min-height: 24px; padding: 1px 10px; font-size: calc(12px * var(--text-scale, 1)); }
  :root[data-rail-wide] #app .rail button .ic svg { width: 16px; height: 16px; }
  :root[data-rail-wide] #app .rail .grp { font-size: calc(9px * var(--text-scale, 1)); line-height: 1.1; padding: 2px 10px 0; margin: 1px 0 0; }
}
/* on really short screens the wide/narrow switch moves to the menu, to keep every tool in view */
@media (max-height: 900px) and (min-width: 761px) {
  .rail .rail-toggle { display: none; }
}
.ctxbar {
  grid-area: ctx; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 52px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.ctxbar .hint { color: var(--muted); font-size: calc(14px * var(--text-scale, 1)); }
.ctxbar .grow { flex: 1; }
.ctxbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 34px; padding: 0 10px; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.swatches { display: inline-flex; gap: 4px; }
.swatch { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
/* "More colours": a colour wheel that opens the palette */
.swatch.more { background: conic-gradient(#ef4444, #eab308, #22c55e, #14b8a6, #3b82f6, #8b5cf6, #ec4899, #ef4444); }
.palette-pop { position: fixed; z-index: 45; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgb(0 0 0 / 0.2); }
.pal-grid { display: grid; grid-template-columns: repeat(10, 24px); gap: 4px; }
.pal-cell { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.pal-cell:hover { transform: scale(1.12); }
.pal-cell[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.pal-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pal-label { font-size: calc(12px * var(--text-scale, 1)); color: var(--muted); margin: 10px 0 4px; }
.pal-other { margin-top: 10px; width: 100%; justify-content: center; }
.pal-native { position: absolute; left: 12px; bottom: 12px; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.findbar { grid-area: find; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.findbar input { width: min(320px, 100%); }
.noticebar { grid-area: note; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 14px; background: color-mix(in srgb, var(--brand) 12%, var(--panel)); border-bottom: 1px solid var(--line); font-size: calc(14px * var(--text-scale, 1)); }
.noticebar[hidden] { display: none; }
.noticebar .grow { flex: 1; min-width: 12px; }
.noticebar button { min-height: 32px; padding: 4px 12px; }
#findCount { color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); min-width: 5em; }

.sidebar { grid-area: side; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 60%, var(--bg)); }
.side-tabs { display: none; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
.sidebar.has-tabs .side-tabs { display: flex; }
.side-tabs button { flex: 1; min-height: 34px; padding: 0 6px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); }
.side-tabs button[aria-selected="true"] { border-bottom-color: var(--brand); color: var(--brand-strong); }
.thumbs { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.thumb { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 8px; border: 2px solid transparent; background: transparent; cursor: pointer; user-select: none; touch-action: pan-y; outline-offset: 2px; }
.thumb:hover { background: var(--hover); }
.thumb.current { border-color: var(--brand); }
.thumb.dragging { opacity: 0.35; }
.thumb-img { position: relative; display: grid; place-items: center; }
.thumb canvas, .thumb .ph { box-shadow: var(--shadow); background: #fff; max-width: 100%; display: block; }
.thumb small { color: var(--muted); font-size: calc(12px * var(--text-scale, 1)); }
.thumb-tools { position: absolute; top: 4px; right: 4px; display: none; flex-direction: column; gap: 3px; }
.thumb:hover .thumb-tools, .thumb:focus-within .thumb-tools { display: flex; }
.thumb-tools button { width: 26px; min-height: 26px; padding: 0; border-radius: 7px; background: color-mix(in srgb, var(--panel) 92%, transparent); box-shadow: var(--shadow); color: var(--ink); }
.thumb-tools button:hover { background: var(--brand-soft); color: var(--brand-strong); }
.thumb-mark { position: absolute; left: 10px; right: 10px; height: 3px; border-radius: 2px; background: var(--brand); pointer-events: none; }
.side-foot { padding: 6px; border-top: 1px solid var(--line); }
.side-foot button { width: 100%; justify-content: center; font-size: calc(13px * var(--text-scale, 1)); white-space: normal; height: auto; line-height: 1.2; padding-block: 5px; }
.outline { flex: 1; min-height: 0; overflow: auto; padding: 8px 4px 16px; font-size: calc(13px * var(--text-scale, 1)); }
.outline .ol { list-style: none; margin: 0; padding: 0 0 0 12px; }
.outline > .ol { padding-left: 0; }
.ol-row { display: flex; align-items: flex-start; gap: 0; }
.ol-tog { width: 22px; min-height: 26px; padding: 0; flex: none; color: var(--muted); }
.ol-tog[aria-expanded="true"] .ic { transform: rotate(90deg); }
.ol-gap { width: 22px; flex: none; }
.ol-item { flex: 1; justify-content: flex-start; text-align: left; white-space: normal; min-height: 26px; height: auto; padding: 4px 6px; border: 0; background: transparent; font-weight: 400; font-size: calc(13px * var(--text-scale, 1)); line-height: 1.3; }
.ol-item:hover:not(:disabled) { background: var(--hover); }
.ol-item:disabled { color: var(--muted); opacity: 0.7; }
.ol-src { margin: 10px 6px 4px; font-size: calc(12px * var(--text-scale, 1)); font-weight: 600; color: var(--muted); }

.viewer { grid-area: main; overflow: auto; position: relative; outline: none; }
/* the page area takes keyboard focus, so arrow keys and Page Down scroll it; the ring shows only for the keyboard */
.viewer:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 24px 80px; min-width: min-content; }
.pages.spread { display: grid; grid-template-columns: repeat(2, max-content); justify-content: center; align-items: start; gap: 22px 18px; }
.page { position: relative; background: var(--paper); box-shadow: var(--shadow); flex: none; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.page textarea, .page input, .page select { user-select: text; -webkit-user-select: text; }
.page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .pg-num { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px; font-size: calc(12px * var(--text-scale, 1)); color: var(--muted); white-space: nowrap; }
.page .pg-src { position: absolute; bottom: 100%; left: 0; margin-bottom: 3px; font-size: calc(11.5px * var(--text-scale, 1)); color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pg-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pg-layer > svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.pg-layer > svg * { pointer-events: visiblePainted; }
#app[data-tool="draw"] .page, #app[data-tool="shapes"] .page, #app[data-tool="whiteout"] .page, #app[data-tool="redact"] .page, #app[data-tool="text"] .page, #app[data-tool="note"] .page { cursor: crosshair; touch-action: none; }
#app[data-tool="highlight"] .page, #app[data-tool="select"] .page { cursor: text; }
#app[data-tool="edittext"] .page { cursor: pointer; }
#app[data-placing] .page { cursor: copy; touch-action: none; }

/* objects you add */
.obj { position: absolute; }
.obj-text { white-space: pre; line-height: 1.2; font-kerning: none; font-variant-ligatures: none; font-feature-settings: "kern" 0, "liga" 0, "clig" 0, "calt" 0; transform-origin: 0 0; cursor: move; }
.obj-text.empty::before { content: "Type here"; color: #9aa; }
textarea.obj-text { background: rgb(255 255 255 / 0.4); border: 0; outline: calc(1.5px * var(--inv)) dashed var(--sel); padding: 0; margin: 0; resize: none; overflow: hidden; cursor: text; min-width: 1em; color: inherit; border-radius: 0; min-height: 0; }
.obj-cover { background: var(--cover, #fff); }
.obj-image { transform-origin: 0 0; cursor: move; user-select: none; -webkit-user-drag: none; }
.obj-box { cursor: move; }
.obj-whiteout { background: #fff; outline: calc(1px * var(--inv)) dashed rgb(0 0 0 / 0.25); }
/* Redactions look like the result: solid black. While one is selected it turns see-through, to check what is under it. */
.obj-redact { background: #000; }
.obj-redact.sel { background: repeating-linear-gradient(-45deg, #111 0 6px, #333 6px 12px); opacity: 0.6; }
.obj-redact span { position: absolute; left: 4px; top: 2px; color: rgb(255 255 255 / 0.55); font: 700 9px/1.1 system-ui; letter-spacing: 0.04em; }
.obj-hl { background: var(--hl, #ffd400); mix-blend-mode: multiply; opacity: 0.55; cursor: pointer; }
.obj-hl.underline { background: transparent; mix-blend-mode: normal; opacity: 1; border-bottom: calc(1.6px) solid var(--hl); }
.obj-hl.strike { background: linear-gradient(transparent 45%, var(--hl) 45% 58%, transparent 58%); mix-blend-mode: normal; opacity: 1; }
.obj-note { width: 20px; height: 20px; border-radius: 4px; background: #ffd400; border: 1px solid #b38f00; display: grid; place-items: center; cursor: pointer; color: #5b4500; }
.temp-sel { position: absolute; background: rgb(26 115 232 / 0.28); pointer-events: none; }
.search-hit { position: absolute; background: rgb(255 145 0 / 0.35); outline: 1px solid rgb(255 120 0 / 0.8); pointer-events: none; }
.search-hit.current { background: rgb(255 80 0 / 0.5); }
.line-hover { position: absolute; outline: calc(1.5px * var(--inv)) solid var(--sel); background: rgb(26 115 232 / 0.08); pointer-events: none; }
.drag-box { position: absolute; border: calc(1.5px * var(--inv)) dashed var(--sel); background: rgb(26 115 232 / 0.06); pointer-events: none; }
.ghost-img { position: absolute; opacity: 0.7; pointer-events: none; outline: calc(1px * var(--inv)) dashed var(--sel); }
.preview-pn, .preview-wm { position: absolute; white-space: pre; pointer-events: none; font-kerning: none; line-height: 1.2; transform-origin: 0 0; }

/* selection */
.selbox { position: absolute; pointer-events: none; outline: calc(1.5px * var(--inv)) solid var(--sel); }
.selbox .hd { position: absolute; width: calc(12px * var(--inv)); height: calc(12px * var(--inv)); background: #fff; border: calc(1.5px * var(--inv)) solid var(--sel); border-radius: 50%; pointer-events: auto; margin: calc(-6px * var(--inv)) 0 0 calc(-6px * var(--inv)); touch-action: none; }
.hd.nw { left: 0; top: 0; cursor: nwse-resize; } .hd.ne { left: 100%; top: 0; cursor: nesw-resize; }
.hd.sw { left: 0; top: 100%; cursor: nesw-resize; } .hd.se { left: 100%; top: 100%; cursor: nwse-resize; }
.hd.p1, .hd.p2 { cursor: move; }

/* form fields: they sit on white paper, so they keep light colours in dark mode too */
.page { color-scheme: light; }
.page .field {
  position: absolute; border: 0; margin: 0; padding: 0 2px; min-height: 0; border-radius: 0; box-shadow: none;
  background: rgb(214 232 255 / 0.55); color: #000; font-family: Arial, "Liberation Sans", sans-serif; line-height: 1.15;
}
.page .field:hover { background: rgb(190 218 255 / 0.75); }
.page .field:focus { background: rgb(255 255 255 / 0.95); outline: 1px solid var(--sel); outline-offset: 0; }
.page textarea.field { resize: none; padding-top: 2px; }
.page select.field { padding: 0; }
.page .field-check { appearance: none; display: grid; place-items: center; cursor: pointer; border: 1px solid rgb(0 0 0 / 0.35); padding: 0; }
.page .field-check.radio { border-radius: 50%; }
.page .field-check:checked::after { content: ""; width: 58%; height: 58%; background: #111; clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%); }
.page .field-check.radio:checked::after { border-radius: 50%; clip-path: none; width: 46%; height: 46%; }
.page .field:disabled { background: transparent; cursor: default; }
.pg-links { position: absolute; inset: 0; pointer-events: none; }
.pg-link { position: absolute; pointer-events: auto; border-radius: 2px; cursor: pointer; }
.pg-link:hover, .pg-link:focus-visible { background: rgb(29 107 71 / 0.12); outline: 1px solid rgb(29 107 71 / 0.45); }
#app:not([data-tool="select"]) .pg-link, #app[data-placing] .pg-link { pointer-events: none; }
#app[data-tool="draw"] .field, #app[data-tool="shapes"] .field, #app[data-tool="whiteout"] .field, #app[data-tool="redact"] .field, #app[data-tool="highlight"] .field, #app[data-tool="note"] .field, #app[data-placing] .field { pointer-events: none; }

/* the floating actions after selecting text */
.popover { position: fixed; z-index: 30; display: flex; gap: 2px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.18); }
.popover button { border: 0; min-height: 32px; padding: 0 10px; font-size: calc(13px * var(--text-scale, 1)); }
.note-pop { flex-direction: column; width: 260px; padding: 10px; gap: 8px; }
.note-pop textarea { min-height: 90px; resize: vertical; }
.note-pop div { display: flex; gap: 6px; justify-content: flex-end; }

/* organizer */
.organizer { grid-area: main; overflow: auto; padding: 0 0 60px; }

/* ---------- compare two PDFs ---------- */
.comparer { grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.comparer[hidden] { display: none; }
#app[data-view="compare"] .workspace { grid-template-columns: 0 0 minmax(0, 1fr) var(--panel-w); }
#app[data-view="compare"] :is(.rail, .sidebar, .ctxbar, .findbar, .noticebar, .statusbar) { display: none; }
.cmp-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.cmp-head .grow { flex: 1; }
.cmp-names { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cmp-names strong { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-tag { font-size: calc(11px * var(--text-scale, 1)); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }
.cmp-tag.old { background: color-mix(in srgb, #dc2626 14%, var(--panel)); color: light-dark(#a11d1d, #ff9b9b); }
.cmp-tag.new { background: color-mix(in srgb, #16a34a 16%, var(--panel)); color: light-dark(#11733a, #7be0a2); margin-left: 6px; }
.cmp-sum { color: var(--muted); font-size: calc(14px * var(--text-scale, 1)); }
.cmp-nav { display: flex; align-items: center; gap: 2px; }
.cmp-count { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-size: calc(14px * var(--text-scale, 1)); }
.cmp-sync { font-size: calc(14px * var(--text-scale, 1)); }
.cmp-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.cmp-pane { overflow: auto; outline: none; background: var(--bg); }
.cmp-pane + .cmp-pane { border-left: 2px solid var(--line); }
.cmp-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 18px 12px 60px; }
.cmp-page { position: relative; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .18); flex: none; }
.cmp-page canvas { width: 100%; height: 100%; display: block; }
.cmp-num { position: absolute; left: -2px; top: -16px; font-size: calc(11px * var(--text-scale, 1)); color: var(--muted); }
.cmp-marks { position: absolute; inset: 0; }
.cmp-mark { position: absolute; border-radius: 2px; mix-blend-mode: multiply; cursor: pointer; }
.cmp-mark.changed { background: rgb(250 204 21 / .45); box-shadow: inset 0 -2px 0 rgb(202 138 4); }
.cmp-mark.added { background: rgb(74 222 128 / .42); box-shadow: inset 0 -2px 0 rgb(22 163 74); }
.cmp-mark.removed { background: rgb(248 113 113 / .38); box-shadow: inset 0 -2px 0 rgb(220 38 38); }
.cmp-mark.cur { outline: 2px solid #1d4ed8; outline-offset: 1px; mix-blend-mode: normal; }
.cmp-anchor { position: absolute; width: 3px; border-radius: 2px; cursor: pointer; }
.cmp-anchor.added { background: rgb(22 163 74); }
.cmp-anchor.removed { background: rgb(220 38 38); }
.cmp-anchor.cur { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.cmp-list { display: flex; flex-direction: column; gap: 6px; }
.cmp-item { display: flex; flex-direction: column; align-items: stretch; gap: 4px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-height: 0; font-weight: 400; white-space: normal; }
.cmp-item.cur { border-color: #1d4ed8; box-shadow: 0 0 0 1px #1d4ed8; }
.cmp-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: calc(12px * var(--text-scale, 1)); }
.cmp-item del { color: light-dark(#a11d1d, #ff9b9b); text-decoration-color: rgb(220 38 38 / .6); font-size: calc(13px * var(--text-scale, 1)); }
.cmp-item ins { color: light-dark(#11733a, #7be0a2); text-decoration: none; font-size: calc(13px * var(--text-scale, 1)); }
.cmp-badge { font-weight: 700; font-size: calc(11px * var(--text-scale, 1)); padding: 1px 7px; border-radius: 99px; }
.cmp-badge.changed { background: rgb(250 204 21 / .35); color: light-dark(#7a5a00, #ffd75e); }
.cmp-badge.added { background: rgb(74 222 128 / .3); color: light-dark(#11733a, #7be0a2); }
.cmp-badge.removed { background: rgb(248 113 113 / .3); color: light-dark(#a11d1d, #ff9b9b); }
label.stack { display: flex; flex-direction: column; gap: 6px; }

/* ---------- signing with eID ---------- */
#app[data-placing-sig] .page { cursor: crosshair; }
.esign-preview {
  position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 3px 8px; border: 1.5px dashed #1c6b47; border-radius: 2px; background: rgb(245 251 247 / .94); color: #1a1a1a;
  font-family: "Liberation Sans", Arial, sans-serif; line-height: 1.15;
}
.esign-preview small { font-size: calc(7.5px * var(--text-scale, 1)); color: #1c6b47; }
.esign-preview strong { font-size: calc(11px * var(--text-scale, 1)); }
.esign-preview small:last-child { color: #4d4d4d; }
.esign details ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.org-bar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 18px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.org-bar .count { color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); margin-right: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; padding: 22px 18px; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px 8px; border-radius: 12px; border: 2px solid transparent; user-select: none; touch-action: none; cursor: grab; }
.card:hover { background: var(--hover); }
.card.selected { border-color: var(--brand); background: var(--brand-soft); }
.card.dragging { opacity: 0.35; }
.card .thumbbox { height: 170px; display: flex; align-items: center; justify-content: center; }
.card canvas, .card .ph { box-shadow: var(--shadow); background: #fff; max-height: 170px; max-width: 100%; }
.card small { color: var(--muted); font-size: calc(12px * var(--text-scale, 1)); text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .card-actions { position: absolute; top: 14px; right: 12px; display: none; flex-direction: column; gap: 4px; }
.card:hover .card-actions, .card.selected .card-actions { display: flex; }
.card-actions button { width: 30px; min-height: 30px; padding: 0; border-radius: 8px; box-shadow: var(--shadow); }
.insert-mark { position: absolute; top: 10px; bottom: 30px; width: 4px; border-radius: 2px; background: var(--brand); pointer-events: none; }
.src-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

.statusbar { grid-area: status; display: flex; flex-wrap: wrap; row-gap: 2px; align-items: center; gap: 8px; padding: 4px 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); min-height: 44px; }
.statusbar .grow { flex: 1; }
.statusbar input[type="number"] { width: 4.2em; min-height: 30px; padding: 2px 6px; }
.statusbar button { min-height: 32px; }
.statusbar .privacy { display: inline-flex; align-items: center; gap: 6px; min-height: 0; padding: 2px 8px; font-size: inherit; color: inherit; min-width: 0; flex-shrink: 1; }
/* with large text or a narrow window the label shrinks first, the shield icon stays */
.statusbar .privacy .privacy-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.statusbar > :not(.privacy, .grow) { flex-shrink: 0; }
.privacy-proof h3 { font-size: calc(12px * var(--text-scale, 1)); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 2px; }
.proof .good strong { color: var(--brand); }
.proof .bad strong { color: var(--danger); }
.offline-hint { margin: 10px 0 0; font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); text-align: center; }
.statusbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.statusbar .zoom-btn { min-width: 64px; }
.statusbar button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); }

/* dialogs */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--panel); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 80px rgb(0 0 0 / 0.3); }
dialog.wide { width: min(820px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(10 20 14 / 0.45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 6px 22px; }
.dlg h2 { margin: 0; font-size: calc(20px * var(--text-scale, 1)); letter-spacing: -0.01em; }
.dlg-body { padding: 8px 22px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg p { margin: 0; }
.muted { color: var(--muted); }
/* Safe to send */
.safe h3 { font-size: calc(12px * var(--text-scale, 1)); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 2px; }
.safe .also { margin: 18px 0 0; padding-top: 10px; border-top: 2px solid var(--line); font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); }
.safe .safe-item { display: grid; grid-template-columns: 20px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.safe .safe-item > .ic { margin-top: 1px; }
.safe .safe-item.found > .ic, .safe .safe-item.warn > .ic { color: #c2410c; }
.safe .safe-item.info > .ic { color: var(--muted); }
.safe .safe-item .muted { font-size: calc(13px * var(--text-scale, 1)); margin-top: 2px; overflow-wrap: anywhere; }
.safe .safe-item .check { margin-top: 6px; }
.safe .safe-list { margin: 6px 0 0; padding-left: 18px; font-size: calc(13px * var(--text-scale, 1)); }
.safe .safe-list li { margin: 2px 0; overflow-wrap: anywhere; }
.safe .safe-list.hits { list-style: none; padding-left: 4px; }
.safe .safe-list.hits li { display: flex; align-items: center; gap: 6px; }
.safe .clear { font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); display: flex; gap: 4px; align-items: baseline; flex-wrap: wrap; }
.safe details { border-top: 1px solid var(--line); padding: 8px 0; }
.safe summary { cursor: pointer; display: flex; gap: 8px; align-items: center; min-height: 28px; font-weight: 600; font-size: calc(14px * var(--text-scale, 1)); }
/* targets of at least 24 by 24 px (WCAG 2.2) */
.safe input[type="checkbox"] { width: 18px; height: 18px; margin: 3px; flex: none; }
.safe .safe-all { display: flex; align-items: center; gap: 6px; min-height: 28px; font-size: calc(13px * var(--text-scale, 1)); }
.safe .hits li { min-height: 28px; }
.safe .safe-result { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 10px 12px; border-radius: 10px; font-size: calc(13.5px * var(--text-scale, 1)); }
.safe .safe-result.ok { background: var(--brand-soft); color: var(--brand-strong); }
.safe .safe-result.warn { background: light-dark(#fff1e6, #3a2414); color: light-dark(#7c2d12, #fdba74); }
.safe label.check { display: flex; gap: 8px; align-items: center; font-size: calc(13.5px * var(--text-scale, 1)); cursor: pointer; }
.safe .field { display: grid; gap: 4px; font-size: calc(13.5px * var(--text-scale, 1)); }
.note-box { padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-strong); font-size: calc(14px * var(--text-scale, 1)); }
.warn-box { padding: 10px 12px; border-radius: 10px; background: light-dark(#fff4d6, #3a2f0c); color: light-dark(#6b4b00, #ffd77a); font-size: calc(14px * var(--text-scale, 1)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > label { display: flex; flex-direction: column; gap: 4px; font-size: calc(13px * var(--text-scale, 1)); color: var(--muted); }
.row > label > * { color: var(--ink); }
.options { display: grid; gap: 8px; }
.option { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.option input { margin-top: 3px; accent-color: var(--brand); width: 18px; height: 18px; }
.option strong { display: block; }
.option span { color: var(--muted); font-size: calc(13.5px * var(--text-scale, 1)); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--brand); color: var(--brand-strong); }
.sigpad { width: 100%; height: 200px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.sig-typed { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.sig-typed button { height: 70px; background: #fff; color: #111; font-size: calc(30px * var(--text-scale, 1)); font-weight: 400; overflow: hidden; }
.sig-typed button[aria-pressed="true"] { outline: 2px solid var(--brand); }
.saved-sigs { display: flex; gap: 8px; flex-wrap: wrap; }
.saved-sigs .sig { position: relative; width: 150px; height: 64px; padding: 4px; background: #fff; }
.saved-sigs .sig img { max-width: 100%; max-height: 100%; }
.saved-sigs .sig .del { position: absolute; top: -8px; right: -8px; width: 24px; min-height: 24px; border-radius: 50%; padding: 0; font-size: calc(12px * var(--text-scale, 1)); }
.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.result div { padding: 12px; border-radius: 12px; background: var(--hover); }
.result strong { display: block; font-size: calc(24px * var(--text-scale, 1)); font-variant-numeric: tabular-nums; }
.result span { color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); }
.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.about dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: calc(14px * var(--text-scale, 1)); }
.about dt { color: var(--muted); }
.about dd { margin: 0; }
a { color: var(--brand-strong); }

/* menu, toasts, busy */
.menu { position: fixed; z-index: 40; min-width: 230px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgb(0 0 0 / 0.2); display: flex; flex-direction: column; max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.menu > * { flex: none; }
.menu button, .menu a.btn { justify-content: flex-start; border: 0; background: transparent; gap: 10px; text-decoration: none; color: inherit; font-weight: 400; }
.menu-head { padding: 8px 10px 2px; font-size: calc(12px * var(--text-scale, 1)); font-weight: 600; color: var(--muted); }
.menu .menu-note { flex: none; font-size: calc(12px * var(--text-scale, 1)); color: var(--muted); }
.menu button.menu-recent { min-height: 32px; }
.menu button.menu-recent span:not(.ic) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.menu button.menu-recent .ic { color: var(--brand); }
.menu button span:not(.ic) { flex: 1; text-align: left; }
.menu kbd { font: calc(12px * var(--text-scale, 1))/1 system-ui, sans-serif; color: var(--muted); }
.menu button.danger { color: light-dark(#a3221b, #ff8a80); }
.menu a.btn:hover { background: var(--hover); }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px; }
.toasts { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: min(560px, calc(100vw - 24px)); padding: 10px 16px; border-radius: 10px; background: #1d2621; color: #fff; box-shadow: 0 8px 30px rgb(0 0 0 / 0.25); font-size: calc(14px * var(--text-scale, 1)); transition: opacity .25s, transform .25s; }
.toast.error { background: #8c1d18; }
.toast.ok { background: var(--brand-strong); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast .toast-act { flex: none; min-height: 30px; padding: 3px 12px; border-radius: 8px; border: 1px solid rgb(255 255 255 / 0.5); background: transparent; color: #fff; font-weight: 600; cursor: pointer; }
.toast .toast-act:hover { background: rgb(255 255 255 / 0.12); }
.busy { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgb(10 20 14 / 0.35); }
.busy-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 28px; border-radius: 16px; background: var(--panel); box-shadow: 0 24px 80px rgb(0 0 0 / 0.3); min-width: 260px; text-align: center; }
.busy-card progress { width: 100%; accent-color: var(--brand); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop-overlay { position: fixed; inset: 0; z-index: 55; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; background: color-mix(in srgb, var(--bg) 55%, transparent); pointer-events: none; }
.drop-overlay .dz { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 18px; border: 3px dashed var(--brand); background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--ink); transition: background .12s; }
.drop-overlay .dz strong { font-size: calc(22px * var(--text-scale, 1)); }
.drop-overlay .dz span { color: var(--muted); font-size: calc(14px * var(--text-scale, 1)); }
.drop-overlay[data-mode="open"] .dz[data-mode="open"], .drop-overlay[data-mode="add"] .dz[data-mode="add"] { background: color-mix(in srgb, var(--brand) 28%, var(--panel)); }
.drop-overlay[data-layout="none"], .drop-overlay[data-layout="add"] { grid-template-columns: 1fr; }
.drop-overlay[data-layout="none"] .dz[data-mode="add"], .drop-overlay[data-layout="add"] .dz[data-mode="open"] { display: none; }
.drop-overlay[data-layout="none"] .dz[data-mode="open"] strong::after { content: " this file"; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- side panel: tool settings next to the page ---------- */
.sidepanel { grid-area: panel; min-height: 0; overflow: hidden; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgb(0 0 0 / 0.06); }
.sidepanel .dlg { height: 100%; max-height: none; }
.sidepanel .dlg header { padding: 12px 10px 4px 18px; }
.sidepanel .dlg h2 { font-size: calc(17px * var(--text-scale, 1)); }
.sidepanel .dlg-body { flex: 1; padding: 8px 18px 16px; }
.sidepanel .dlg footer { padding: 10px 18px 14px; }
.sidepanel .row > label { min-width: 0; }
.sidepanel input[type="range"] { width: 100% !important; }
.help h3 { margin: 6px 0 0; font-size: calc(14px * var(--text-scale, 1)); }
.help ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: calc(14px * var(--text-scale, 1)); }
.help p { font-size: calc(14px * var(--text-scale, 1)); }

/* ---------- full screen reading ---------- */
.reading-bar { display: none; }
#app.reading { background: #1a1d1b; }
#app.reading :is(.topbar, .rail, .ctxbar, .findbar, .noticebar, .sidebar, .sidepanel, .statusbar) { display: none !important; }
#app.reading .workspace { grid-template-columns: 0 0 minmax(0, 1fr) 0; grid-template-rows: 0 0 0 minmax(0, 1fr) 0; }
#app.reading .viewer { background: #1a1d1b; }
#app.reading .page .pg-num, #app.reading .page .pg-src { display: none; }
#app.reading .reading-bar {
  display: flex; position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; align-items: center; gap: 4px;
  padding: 6px; border-radius: 14px; background: rgb(20 24 22 / 0.82); color: #fff; box-shadow: 0 8px 30px rgb(0 0 0 / 0.35); opacity: 0.25; transition: opacity .2s;
}
#app.reading .reading-bar:hover, #app.reading .reading-bar:focus-within { opacity: 1; }
.reading-bar button { width: 40px; min-height: 40px; padding: 0; border: 0; background: transparent; color: #fff; }
.reading-bar button:hover { background: rgb(255 255 255 / 0.14); }
.reading-bar span { min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; font-size: calc(14px * var(--text-scale, 1)); }

/* ---------- printing: only the prepared pages are printed ---------- */
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  html, body { height: auto; overflow: visible; background: #fff; }
  #printArea { display: block; }
  #printArea .print-page { break-after: page; overflow: hidden; }
  #printArea .print-page:last-child { break-after: auto; }
  #printArea img { width: 100%; height: 100%; object-fit: contain; display: block; }
}

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  :root { --thumbs: 0px; }
  .sidebar { display: none; }
}
@media (max-width: 760px) {
  #btnTheme, #btnLook, #btnNight { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .drop { min-height: 220px; }
  .workspace, #app[data-view="welcome"] .workspace, #app[data-view="organize"] .workspace, #app[data-panel] .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "ctx" "find" "note" "main" "status" "rail";
  }
  .cmp-panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .cmp-pane + .cmp-pane { border-left: 0; border-top: 2px solid var(--line); }
  .sidepanel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgb(0 0 0 / 0.2); }
  .sidepanel .dlg { height: auto; max-height: 62vh; }
  .drop-overlay { grid-template-columns: 1fr; }
  .rail { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--line); padding: 4px; }
  .rail button { min-width: 64px; flex: none; }
  .rail hr { border-top: 0; border-left: 1px solid var(--line); margin: 6px 2px; }
  .rail .grp { font-size: 0; padding: 0; margin: 6px 2px; border-top: 0; border-left: 1px solid var(--line); }
  .rail .rail-toggle { display: none; }
  :root[data-rail-wide] #app .rail button { flex-direction: column; justify-content: center; gap: 1px; min-height: 44px; padding: 4px 2px; font-size: calc(11px * var(--text-scale, 1)); text-align: center; }
  :root[data-rail-wide] #app .rail .grp { font-size: 0; padding: 0; margin: 6px 2px; }
  .topbar { gap: 6px; padding: 0 8px; }
  .doctab { max-width: 150px; min-width: 56px; padding-left: 8px; }
  .recent-thumb { height: 110px; }
  .brand span { display: none; }
  #btnOpen .lbl { display: none; }
  .statusbar #btnSpread { display: none; }
  .pages { padding: 16px 8px 60px; }
  .statusbar .hide-sm { display: none !important; }
  .ctxbar .hint { display: none; }
  .ctxbar { min-height: 0; padding: 6px 10px; }
}

/* Command bar (Ctrl+K) and its search box in the top bar */
.cmd-open { display: inline-flex; align-items: center; gap: 8px; height: 34px; min-width: 190px; padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--muted); font-size: calc(13px * var(--text-scale, 1)); cursor: text; }
.cmd-open:hover { border-color: var(--brand); color: var(--ink); }
.cmd-open kbd { margin-left: auto; font-size: calc(11px * var(--text-scale, 1)); }
@media (max-width: 1280px) { .cmd-open { min-width: 0; padding: 0 8px; } .cmd-open span, .cmd-open kbd { display: none; } }
.cmd-veil { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 12px 0; background: rgb(0 0 0 / 0.28); }
.cmd-box { width: min(600px, 100%); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 60px rgb(0 0 0 / 0.3); overflow: hidden; }
.cmd-field { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmd-input { flex: 1; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: calc(16px * var(--text-scale, 1)); outline: none; padding: 2px 0; }
.cmd-input::-webkit-search-cancel-button { display: none; }
.cmd-list { list-style: none; margin: 0; padding: 6px; max-height: min(60vh, 520px); overflow: auto; }
.cmd-list li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: calc(14px * var(--text-scale, 1)); }
.cmd-list li .cmd-label { flex: 1; }
.cmd-list li.on { background: var(--brand-soft); color: var(--brand-strong); }
.cmd-list li kbd { font-size: calc(11px * var(--text-scale, 1)); color: var(--muted); }
.cmd-list li.empty { color: var(--muted); cursor: default; }

/* Appearance panel */
.appearance h3 { font-size: calc(12px * var(--text-scale, 1)); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 2px; }
.appearance label.check { display: flex; gap: 8px; align-items: center; font-size: calc(14px * var(--text-scale, 1)); cursor: pointer; }
.appearance .swatches { display: grid; grid-template-columns: repeat(9, minmax(24px, 34px)); gap: 8px; }
.appearance .swatch { width: 100%; height: auto; aspect-ratio: 1; min-height: 0; border-radius: 50%; border: 2px solid var(--line); padding: 0; cursor: pointer; box-shadow: none; }
.appearance .swatch[aria-checked="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.appearance .swatch, .appearance .swatch:hover:not(:disabled) { background: var(--sw); }
.appearance .swatch:hover:not(:disabled) { filter: brightness(1.15); }

/* Dark pages for night reading: the page pixels are made dark by the renderer; what you add on top follows here */
:root[data-night] .page { background: #212121; }
:root[data-night] .obj-text, :root[data-night] .obj-vec, :root[data-night] .obj-whiteout, :root[data-night] .obj-cover, :root[data-night] .obj-box:not(.obj-redact) { filter: invert(0.87) hue-rotate(180deg); }
:root[data-night] .obj-image { background: #e9e9e9; }
:root[data-night] .obj-hl { mix-blend-mode: screen; }

/* text for screen readers only */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Signatures panel */
.signatures .sig-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; }
.signatures .sig-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: calc(15px * var(--text-scale, 1)); }
.signatures .sig-status { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; font-size: calc(14px * var(--text-scale, 1)); }
.signatures .sig-status .ic { flex: none; margin-top: 2px; }
.signatures .sig-status.ok .ic { color: light-dark(#1a7f37, #6fdd8b); }
.signatures .sig-status.bad { color: light-dark(#a3221b, #ff8a80); }
.signatures .sig-status.info .ic { color: var(--muted); }
.signatures .sig-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 10px 0; font-size: calc(13px * var(--text-scale, 1)); }
.signatures .sig-details dt { color: var(--muted); }
.signatures .sig-details dd { margin: 0; overflow-wrap: anywhere; }
.safe .safe-more summary { font-weight: 400; font-size: calc(13px * var(--text-scale, 1)); color: var(--brand); min-height: 24px; }

/* Windows contrast themes (forced colours): the system picks every colour, and tints disappear. Colour samples
   keep their real colour, and pressed or selected controls get an outline in the system's highlight colour. */
@media (forced-colors: active) {
  .swatch, .pal-cell, .appearance .swatch { forced-color-adjust: none; border: 2px solid CanvasText; }
  [aria-pressed="true"], [aria-selected="true"], .thumb.current { outline: 2px solid Highlight; outline-offset: -2px; }
  .appearance .swatch[aria-checked="true"], .swatch[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 2px; }
}

/* ---------- Write a document: a page of paper, white in light and dark, in the fonts of the PDF ---------- */
@font-face { font-family: "Carlito"; src: url("../vendor/typst/fonts/Carlito-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../vendor/typst/fonts/Carlito-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../vendor/typst/fonts/Carlito-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../vendor/typst/fonts/Carlito-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../vendor/typst/fonts/Caladea-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../vendor/typst/fonts/Caladea-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../vendor/typst/fonts/Caladea-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Caladea"; src: url("../vendor/typst/fonts/Caladea-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }
dialog.writer { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); display: none; flex-direction: column; }
dialog.writer[open] { display: flex; }
dialog.writer::backdrop { background: transparent; }
/* the title bar: back, the document's title (editable, as in Word), where it is kept, undo and redo, make the PDF */
.wr-head { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.wr-head .wr-back { padding: 0 10px; }
.wr-head > button { flex: none; }
.wr-title { flex: 0 1 calc(440px * var(--text-scale, 1)); min-width: 120px; min-height: 36px; padding: 4px 10px; font-size: calc(16px * var(--text-scale, 1)); font-weight: 650; border-color: transparent; background: transparent; text-overflow: ellipsis; }
.wr-title:hover { border-color: var(--line); }
.wr-title:focus { border-color: var(--brand); background: var(--bg); }
.wr-title::placeholder { color: var(--muted); font-weight: 500; }
.wr-kept { display: inline-flex; align-items: center; gap: 5px; font-size: calc(12.5px * var(--text-scale, 1)); color: var(--muted); white-space: nowrap; }
.wr-head .grow { flex: 1; }
.wr-head .ghost.icon { width: 36px; }
/* the ribbon: groups of tools with their name underneath, like Word's Home and Insert tabs side by side */
.wr-ribbon { display: flex; flex-wrap: wrap; align-items: stretch; row-gap: 4px; padding: 4px 2px 0; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.wr-grp { position: relative; display: flex; flex-direction: column; padding: 2px 6px 0; border-right: 1px solid var(--line); }
.wr-grp:last-child { border-right: 0; }
.wr-grp-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.wr-grp.wr-flat .wr-grp-body { flex-direction: row; align-items: stretch; gap: 2px; }
.wr-row { display: flex; align-items: center; gap: 2px; }
.wr-grp-label { padding: 3px 0 4px; text-align: center; font-size: calc(11px * var(--text-scale, 1)); color: var(--muted); white-space: nowrap; }
.wr-ribbon button.ghost.icon { width: 32px; min-height: 32px; }
.wr-ribbon button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.wr-ribbon select, .wr-ribbon input[type="text"] { min-height: 32px; padding: 3px 8px; font-size: calc(13px * var(--text-scale, 1)); }
.wr-font { width: calc(100px * var(--text-scale, 1)); font-size: calc(14px * var(--text-scale, 1)) !important; }
.wr-size { width: calc(68px * var(--text-scale, 1)); padding-right: 4px !important; }
.wr-paper { width: calc(118px * var(--text-scale, 1)); }
.wr-lang { width: calc(110px * var(--text-scale, 1)); }
.wr-author { width: calc(122px * var(--text-scale, 1)); }
.wr-ribbon label.check { align-items: center; gap: 7px; min-height: 32px; font-size: calc(13px * var(--text-scale, 1)); white-space: nowrap; }
.wr-ribbon label.check input { margin-top: 0; }
.wr-big { flex-direction: column; justify-content: center; gap: 3px; min-height: 66px; min-width: calc(48px * var(--text-scale, 1)); padding: 4px 5px; font-size: calc(12px * var(--text-scale, 1)); line-height: 1.1; }
/* the style gallery: each tile shows the style it gives */
.wr-tiles { display: grid; grid-template-columns: repeat(3, auto); grid-auto-rows: 32px; gap: 3px; align-content: center; }
.wr-tile { justify-content: flex-start; min-height: 0; height: 100%; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font-weight: 400; overflow: hidden; }
.wr-tile span { white-space: nowrap; line-height: 1; }
.wr-tile-p span { font-size: calc(12.5px * var(--text-scale, 1)); }
.wr-tile-h1 span { font-size: calc(15px * var(--text-scale, 1)); font-weight: 750; }
.wr-tile-h2 span { font-size: calc(13.5px * var(--text-scale, 1)); font-weight: 700; }
.wr-tile-h3 span { font-size: calc(12.5px * var(--text-scale, 1)); font-weight: 700; }
.wr-tile-blockquote span { font-size: calc(12.5px * var(--text-scale, 1)); font-style: italic; padding-left: 6px; border-left: 3px solid var(--muted); }
.wr-ribbon .wr-tile[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
:root[data-contrast="more"] .wr-ribbon button[aria-pressed="true"] { outline: 2px solid var(--brand-strong); outline-offset: -2px; }
.wr-ask { padding: 10px 16px; background: var(--brand-soft); border-bottom: 1px solid var(--line); flex: none; }
.wr-ask[hidden] { display: none; }
.wr-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.wr-q { align-self: center; font-weight: 600; }
.wr-field { display: flex; flex-direction: column; gap: 4px; font-size: calc(14px * var(--text-scale, 1)); }
.wr-field > span { font-weight: 600; }
.wr-body { flex: 1; min-height: 0; display: flex; }
.wr-scroll { flex: 1; overflow: auto; padding: 24px; background: color-mix(in srgb, var(--ink) 6%, var(--bg)); }
.wr-page { width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 25mm; background: #fff; color: #111; box-shadow: var(--shadow); line-height: 1.35; outline: none; overflow-wrap: break-word; }
.wr-page.letter { width: 8.5in; min-height: 11in; }
.wr-page:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 3px; }
.wr-page h1, .wr-page h2, .wr-page h3 { margin: 1.3em 0 0.65em; line-height: 1.2; }
.wr-page > :first-child { margin-top: 0; }
.wr-page h1 { font-size: 1.75em; } .wr-page h2 { font-size: 1.35em; } .wr-page h3 { font-size: 1.12em; }
.wr-page p { margin: 0 0 1em; }
.wr-page ul, .wr-page ol { margin: 0 0 1em; padding-left: 1.6em; }
.wr-page blockquote { margin: 0 0 1em 1.5em; padding-left: 1em; border-left: 3px solid #bbb; }
.wr-page table { border-collapse: collapse; width: 100%; margin: 0 0 1em; table-layout: fixed; }
.wr-page th, .wr-page td { border: 1px solid #999; padding: 6px; text-align: left; vertical-align: top; min-width: 2em; }
.wr-page th { font-weight: bold; background: #f1f1f1; }
.wr-page img { display: block; max-width: 100%; margin: 0 auto; }
.wr-page img[data-width="0.75"] { width: 75%; } .wr-page img[data-width="0.5"] { width: 50%; } .wr-page img[data-width="0.3"] { width: 30%; }
.wr-page hr { border: 0; border-top: 2px dashed #aaa; margin: 1.5em 0; }
.wr-page a { color: #1d4ed8; }
/* Chrome gives pasted text that it merges into a paragraph a fixed font-size; the PDF ignores it, and here it may not show either */
.wr-page :is(span, strong, em, u, a, b, i, font)[style] { font-size: inherit !important; font-family: inherit !important; color: inherit !important; background: none !important; }
.wr-page a[style] { color: #1d4ed8 !important; }
@media (max-width: 900px) {
  .wr-scroll { padding: 10px; }
  .wr-page { padding: 14mm 10mm; min-height: 100%; box-sizing: border-box; }
}
/* phones: the ribbon is one row you swipe sideways, so the page keeps most of the screen */
@media (max-width: 600px) {
  .wr-head { gap: 4px; padding: 4px 6px; min-height: 48px; }
  .wr-head .wr-back { padding: 0; width: 36px; }
  .wr-head .wr-back > span:not(.ic), .wr-kept, .wr-head .grow { display: none; }
  .wr-title { flex: 1 1 0; min-width: 80px; font-size: calc(15px * var(--text-scale, 1)); padding: 4px 6px; }
  .wr-head .ghost.icon { width: 32px; }
  .wr-make { padding: 0 10px; gap: 4px; }
  .wr-ribbon { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; padding: 4px 4px; }
  .wr-grp { flex: none; padding: 0 6px; }
  .wr-grp-body, .wr-grp.wr-flat .wr-grp-body { flex-direction: row; align-items: center; gap: 2px; }
  .wr-grp-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; padding: 0; }
  .wr-big { flex-direction: row; min-height: 32px; min-width: 0; gap: 5px; padding: 0 8px; }
  .wr-big .ic svg { width: 18px; height: 18px; }
  .wr-tiles { display: flex; gap: 3px; }
  .wr-tile { height: 32px; }
}

