/* Metre2 Desktop Publishing 1.1 - the Openspace clean look (shared with Calendar 1.1 and Mail), with this
   app's own accent: press-room sienna #7a3510 (#e0956a in dark mode). Process inks keep their jobs:
   cyan = selection, magenta = Pro, yellow = highlights. Inter for the interface; JetBrains Mono only for
   numbers and measurements. Light by default; dark under ··· > Dark mode. Pages are always white paper.
   The 1.0 "press room" stylesheet is in _backup_2026-11-05/dp-1.1/. */
@font-face { font-family: 'JetBrains Mono'; src: url('fonts/jetbrains-mono-var.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }
:root {
  --ui: 'Inter', 'Segoe UI', system-ui, sans-serif; --mono: 'JetBrains Mono', Consolas, ui-monospace, monospace; --font: var(--ui);
  --accent: #7a3510; --accent-2: #8f4116; --on-accent: #ffffff; --accent-soft: rgba(122, 53, 16, .09); --accent-line: rgba(122, 53, 16, .38);
  --cyan: #0080b0; --magenta: #c8007a; --yellow: #e0b400;
  --ink: #1f1a17; --ink-2: #4f4640; --muted: #6a615a;
  --bg: #f6f4f1; --desk: #efece8; --grid-major: rgba(122, 53, 16, .06); --grid-minor: rgba(122, 53, 16, .03);
  --panel: #ffffff; --panel-solid: #ffffff; --raise: #faf9f7; --line: rgba(60, 40, 25, .11); --line-strong: rgba(60, 40, 25, .2); --hover: rgba(122, 53, 16, .06);
  --ruler-page: rgba(122, 53, 16, .07); --focus: #0080b0;
  --shadow: 0 18px 44px -18px rgba(60, 35, 15, .3), 0 2px 6px rgba(60, 35, 15, .06);
  --page-shadow: 0 1px 2px rgba(60, 35, 15, .12), 0 12px 32px -12px rgba(60, 35, 15, .3);
  --overlay: rgba(31, 26, 23, .3); --radius: 10px;
  --ks-text: var(--ink); --ks-muted: var(--ink-2); --ks-dim: var(--muted); --ks-surface: var(--panel-solid);
  --ks-raise: var(--raise); --ks-border: var(--line); --ks-border-strong: var(--line-strong); --ks-accent: var(--accent); --ks-font: var(--ui);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #e0956a; --accent-2: #eaa983; --on-accent: #1a110b; --accent-soft: rgba(224, 149, 106, .13); --accent-line: rgba(224, 149, 106, .45);
  --cyan: #4cc3f0; --magenta: #ff5cb4; --yellow: #ffd84d;
  --ink: #f2ece6; --ink-2: #cbbfb4; --muted: #a2968b;
  --bg: #14110f; --desk: #100e0c; --grid-major: rgba(255, 220, 190, .035); --grid-minor: rgba(255, 220, 190, .02);
  --panel: #1b1815; --panel-solid: #1b1815; --raise: #221e1a; --line: rgba(255, 225, 200, .09); --line-strong: rgba(255, 225, 200, .18); --hover: rgba(255, 225, 200, .06);
  --ruler-page: rgba(224, 149, 106, .08); --focus: #4cc3f0;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .75), 0 2px 6px rgba(0, 0, 0, .3);
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 16px 40px -14px rgba(0, 0, 0, .7);
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
/* the accent choice mock (Calendar's blue), only used for Rob's comparison screenshot */
:root[data-accent="blue"] { --accent: #1d5fe0; --accent-2: #2a6cf0; --accent-soft: rgba(29, 95, 224, .09); --accent-line: rgba(29, 95, 224, .4); --hover: rgba(29, 95, 224, .06); --ruler-page: rgba(29, 95, 224, .07); --grid-major: rgba(29, 95, 224, .07); --grid-minor: rgba(29, 95, 224, .035); --bg: #f3f6fb; --desk: #edf1f8; --line: rgba(29, 95, 224, .12); --line-strong: rgba(29, 95, 224, .22); --ink: #0b1b33; --ink-2: #4a5d7a; --muted: #5a6b8a; }
:root[data-theme="dark"][data-accent="blue"] { --accent: #5ad1ff; --on-accent: #04121f; --accent-soft: rgba(90, 209, 255, .12); --bg: #050d18; --desk: #040a13; --panel: #0b1626; --panel-solid: #0b1626; --raise: #0f1c30; --ink: #eaf2ff; --ink-2: #9fb0c8; --muted: #7a8ca6; --line: rgba(120, 180, 255, .1); --line-strong: rgba(120, 180, 255, .2); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.45 var(--ui); color: var(--ink); background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; }
/* UI icons only - never the SVG inside pages (shapes, lines, crop marks) */
svg:not(.pg svg):not(.psheet svg):not(#guides) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--ink); }
select, input[type=number], input[type=text], input:not([type]) { background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; min-height: 30px; }
input[type=number] { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
select:hover, input[type=number]:hover, input[type=text]:hover, input:not([type]):hover { border-color: var(--accent-line); }
input[type=color] { width: 32px; height: 28px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-solid); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }
kbd { font: 11px var(--mono); color: var(--muted); margin-left: auto; }
code { font: 12px var(--mono); background: var(--hover); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
button:focus:not(:focus-visible) { outline: none; }

#app { display: flex; flex-direction: column; height: 100vh; position: relative; }

/* ---- top bar: File · name · undo/redo ··· zoom · PDF · Pro · ··· */
.topbar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 14px; background: var(--bg); color: var(--ink); flex: none; position: relative; z-index: 7; border-bottom: 1px solid var(--line); }
.file-btn { background: var(--accent); border: 0; border-radius: 9px; padding: 0 14px; height: 32px; font-weight: 600; font-size: 12.5px; color: var(--on-accent); }
.file-btn:hover { background: var(--accent-2); }
.brand { display: flex; align-items: center; color: var(--accent); }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.brand svg { width: 18px; height: 18px; }
.doc-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.doc-name input { background: transparent; border: 1px solid transparent; color: var(--ink); font-weight: 600; font-size: 14px; letter-spacing: -.01em; width: 230px; max-width: 28vw; border-radius: 8px; }
.doc-name input:hover, .doc-name input:focus { border-color: var(--line-strong); background: var(--panel-solid); outline: none; }
.doc-name input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tb-group { display: flex; align-items: center; gap: 2px; }
.spacer { flex: 1; min-width: 4px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.zoom-val { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; height: 28px; min-width: 56px; color: var(--ink-2); font: 500 11.5px var(--mono); font-variant-numeric: tabular-nums; }
.zoom-val:hover { border-color: var(--accent-line); color: var(--ink); }
.pdf-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); border-radius: 9px; padding: 0 12px; height: 32px; font-weight: 600; font-size: 12.5px; flex: none; }
.pdf-btn:hover { border-color: var(--accent-line); background: var(--hover); }
#proPill { margin-left: 2px; flex: none; }
.more-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.more-menu { min-width: 248px; }
.more-menu kbd { margin-left: auto; }
.more-menu .pro-tag { margin-left: auto; }

/* ---- context bar */
.ctxbar { display: flex; align-items: center; gap: 4px; min-height: 46px; padding: 6px 14px 6px 86px; background: var(--bg); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: thin; z-index: 4; }
.ctx { display: flex; align-items: center; gap: 3px; flex: none; }
.ctx .hint { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.tbtn { min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; border-radius: 8px; border: 1px solid transparent; background: transparent; padding: 0 6px; font-size: 14px; color: var(--ink-2); }
.tbtn:hover { background: var(--hover); color: var(--ink); }
.tbtn.on { background: var(--accent-soft); color: var(--accent); }
.tbtn.danger:hover { color: #b42318; }
.tbtn .dd { width: 12px; height: 12px; }
.tbtn svg .f { fill: currentColor; fill-opacity: .2; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; flex: none; }
.num { display: inline-flex; align-items: center; gap: 3px; }
.num input { width: 60px; }
.num span { color: var(--muted); font-size: 11px; font-family: var(--mono); }
#tx-font { width: 150px; }
.swatch-btn { position: relative; width: 30px; height: 30px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; }
.swatch-btn:hover { background: var(--hover); }
.swatch-btn .a { font-weight: 700; font-size: 14px; line-height: 1; }
.swatch-btn .bar { width: 18px; height: 4px; border-radius: 2px; margin-top: 2px; background: #1d1d1f; box-shadow: 0 0 0 1px var(--line); }
.swatch-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.swatch-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---- preview of a Publisher file */
/* in a preview the context bar has nothing to offer, so the preview bar takes its place */
body.pub-preview .ctxbar { display: none; }
.preview-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 46px; padding: 6px 14px 6px 86px; background: color-mix(in srgb, var(--accent) 7%, var(--bg)); border-bottom: 1px solid var(--accent-line); color: var(--ink); flex: none; z-index: 6; font-size: 12.5px; }
.preview-bar svg { color: var(--accent); }
.preview-bar span { flex: 1; min-width: 200px; }
body.pub-preview .rail .tool:not(#rail-panel):not(#rail-master):not(#rail-templates), body.pub-preview .ctxbar .ctx, body.pub-preview #add-page, body.pub-preview #undo-btn, body.pub-preview #redo-btn { opacity: .45; }
body.pub-preview .pagescale .pg::after, body.pub-preview .film .pg::after { content: 'Preview'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-32deg); font: 800 34mm/1 var(--ui); letter-spacing: .02em; color: rgba(122, 53, 16, .2); -webkit-text-stroke: .5mm rgba(255, 255, 255, .55); paint-order: stroke fill; pointer-events: none; white-space: nowrap; z-index: 9999; }
body.pub-preview .pagescale { cursor: default; }

/* ---- work area */
.work { flex: 1; display: flex; min-height: 0; position: relative; }
.rail { width: 74px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; margin-top: -47px; z-index: 6; position: relative; scrollbar-width: none; }
.tool { position: relative; width: 62px; padding: 4px 0 3px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 10.5px; font-weight: 500; color: var(--ink-2); flex: none; }
.tool svg { width: 19px; height: 19px; }
.tool:hover { background: var(--hover); color: var(--ink); }
.tool.on { background: var(--accent-soft); color: var(--accent); }
.tool .pro-dot { position: absolute; top: 5px; right: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--magenta); }
body.is-pro .tool .pro-dot { display: none; }
.rail-sep { width: 36px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.rail-grow { flex: 1; min-height: 6px; }
.menu-wrap { position: relative; }

.desk-wrap { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.rulers { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ruler-x, .ruler-y { position: absolute; pointer-events: auto; background: var(--bg); }
.ruler-x { left: 20px; top: 0; width: calc(100% - 20px); height: 20px; border-bottom: 1px solid var(--line); cursor: s-resize; }
.ruler-y { top: 20px; left: 0; height: calc(100% - 20px); width: 20px; border-right: 1px solid var(--line); cursor: e-resize; }
.ruler-corner { position: absolute; left: 0; top: 0; width: 20px; height: 20px; background: var(--bg); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.desk { position: absolute; inset: 20px 0 0 20px; overflow: auto; outline: none; background-color: var(--desk);
  background-image: linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px), linear-gradient(var(--grid-minor) 1px, transparent 1px), linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 240px 240px, 240px 240px, 48px 48px, 48px 48px; }
.stage { position: relative; padding: 48px; min-width: 100%; min-height: 100%; display: flex; align-items: flex-start; justify-content: center; }
.pagewrap { position: relative; flex: none; }
.pagescale { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: var(--page-shadow); background: #fff; }
.pagescale .pg { cursor: default; }
.bleedline { position: absolute; border: 1px dashed rgba(200, 0, 122, .4); pointer-events: none; }
.guides { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; width: 100%; height: 100%; }
.guides .margin { fill: none; stroke: rgba(200, 0, 122, .45); stroke-width: 1; stroke-dasharray: 4 3; }
.guides .guide { stroke: #0093c9; stroke-width: 1; }
.guides .snap { stroke: #d6007e; stroke-width: 1; }
.guides .fold { stroke: rgba(0, 147, 201, .6); stroke-dasharray: 2 3; }
.hide-guides .guides .margin, .hide-guides .bleedline { display: none; }
.overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.overlay .hit-guide { position: absolute; pointer-events: auto; }
.overlay .hit-guide.v { width: 7px; margin-left: -3px; cursor: ew-resize; }
.overlay .hit-guide.h { height: 7px; margin-top: -3px; cursor: ns-resize; }
.selbox { position: absolute; border: 1.5px solid #0093c9; pointer-events: none; transform-origin: center center; }
.selbox.multi { border-style: dashed; }
.selbox.locked { border-color: #8a8178; border-style: dotted; }
.selbox.editing { border: 1.5px solid #0093c9; box-shadow: 0 0 0 3px rgba(0, 147, 201, .15); }
.handle { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff; border: 1.5px solid #0093c9; border-radius: 3px; pointer-events: auto; }
.handle.rot { border-radius: 50%; background: #0093c9; cursor: grab; }
.handle.rot::after { content: ''; position: absolute; left: 3px; top: 8px; width: 1px; height: 14px; background: #0093c9; }
.handle[data-h=nw], .handle[data-h=se] { cursor: nwse-resize; } .handle[data-h=ne], .handle[data-h=sw] { cursor: nesw-resize; }
.handle[data-h=n], .handle[data-h=s] { cursor: ns-resize; } .handle[data-h=e], .handle[data-h=w] { cursor: ew-resize; }
.handle[data-h=p1], .handle[data-h=p2] { border-radius: 50%; cursor: move; }
.link-port { position: absolute; width: 18px; height: 16px; margin: -8px 0 0 -9px; border-radius: 4px; background: #fff; border: 1.5px solid #0093c9; color: #006d96; font: 700 10px/12px var(--ui); text-align: center; pointer-events: auto; cursor: pointer; }
.link-port.out.full { background: #c0392b; border-color: #c0392b; color: #fff; }
.link-port.in { cursor: default; }
.chain-line { position: absolute; height: 0; border-top: 1.5px dashed #0093c9; transform-origin: 0 0; pointer-events: none; opacity: .7; }
.marquee { position: absolute; border: 1px dashed #0093c9; background: rgba(0, 147, 201, .08); pointer-events: none; }
.pagescale .it.overflowing .tb { box-shadow: inset 0 -3px 0 #c0392b; }
.pagescale .it.from-master { pointer-events: none; }
.pagescale .it.from-master::after { content: ''; position: absolute; inset: 0; }
.pagescale .it.dim { opacity: .35; }
.pagescale .it-text .tb[contenteditable] { outline: none; cursor: text; user-select: text; }
.pagescale .it-text .tb { user-select: none; }
.pagescale .it-table td.editing { outline: 2px solid #0093c9; outline-offset: -2px; cursor: text; user-select: text; background: rgba(0, 147, 201, .05); }
.pagescale.crop .it-image.cropping { overflow: visible; outline: 1.5px dashed #d6007e; }
.pagescale.crop .it-image.cropping img { opacity: .55; }
.desk.tool-draw .pagescale, .desk.tool-draw .overlay { cursor: crosshair; }
.desk.tool-text .pagescale { cursor: text; }
.master-tag { position: absolute; left: 50%; top: 32px; transform: translateX(-50%); z-index: 4; background: var(--panel-solid); color: var(--ink); border: 1px solid color-mix(in srgb, var(--magenta) 45%, transparent); padding: 5px 6px 5px 14px; border-radius: 20px; box-shadow: var(--shadow); white-space: nowrap; display: flex; align-items: center; gap: 10px; font-size: 12.5px; max-width: calc(100% - 24px); }
.master-tag b { color: var(--magenta); }
.master-tag button { background: var(--magenta); color: #fff; border: 0; border-radius: 14px; padding: 4px 12px; font-weight: 600; }
.banner { position: absolute; left: 50%; top: 30px; transform: translateX(-50%); z-index: 4; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; max-width: calc(100% - 24px); flex-wrap: wrap; }

/* ---- inspector */
.inspector { width: 280px; flex: none; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); min-height: 0; }
.inspector.closed { display: none; }
.itabs { display: flex; padding: 8px 10px; gap: 2px; flex: none; }
.itab { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 6px; color: var(--muted); font-weight: 500; }
.itab:hover { color: var(--ink); }
.itab.on { background: var(--panel-solid); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.ipanel { display: none; overflow-y: auto; padding: 4px 14px 20px; flex: 1; }
.ipanel.on { display: block; }
.ipanel h4 { margin: 16px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.ipanel h4:first-child { margin-top: 4px; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.f-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); min-width: 0; margin-bottom: 4px; }
.fld input, .fld select { width: 100%; min-width: 0; }
.fld input[type=color] { width: 44px; flex: none; }
.fld.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 12.5px; }
.fld.inline input[type=checkbox] { width: auto; }
.colrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.colrow .none { font-size: 11.5px; padding: 3px 8px; border-radius: 7px; border: 1px solid var(--line-strong); background: transparent; }
.colrow .none.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.swatches button { width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line-strong); padding: 0; }
.swatches .lock { width: auto; padding: 0 7px; font-size: 10.5px; color: var(--magenta); border-color: color-mix(in srgb, var(--magenta) 55%, transparent); background: transparent; }
.ip-empty { color: var(--muted); padding: 14px 2px; line-height: 1.55; }
.ip-empty b { color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel-solid); color: var(--ink); border-radius: 9px; padding: 6px 12px; min-height: 32px; font-weight: 500; }
.btn:hover { border-color: var(--accent-line); background: var(--raise); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.small { padding: 3px 9px; min-height: 28px; font-size: 12px; }
.btn.small svg { width: 14px; height: 14px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.pro::after { content: 'PRO'; font: 700 9px var(--ui); background: var(--magenta); color: #fff; padding: 1px 4px; border-radius: 4px; margin-left: 4px; }
body.is-pro .btn.pro::after { display: none; }
.pro-tag { font: 700 9px/1 var(--ui); font-style: normal; background: var(--magenta); color: #fff; padding: 2px 5px; border-radius: 4px; vertical-align: middle; letter-spacing: .03em; }
:root[data-theme="dark"] .pro-tag { color: #1a0712; }
body.is-pro .pro-tag, :root[data-theme="dark"] body.is-pro .pro-tag { background: var(--accent-soft); color: var(--accent); }
/* the shared Pro pill (keystone-pro.js), styled here so its text passes AA on this app's top bar */
#proPill.ks-pro-pill { height: 32px; border-radius: 9px; box-shadow: none; font-size: 12.5px; font-weight: 600; }
:root:not([data-theme="dark"]) #proPill.ks-pro-pill { color: #6b4600; background: rgba(255, 201, 77, .24); }
html[data-ks-pro="1"] #proPill.ks-pro-pill { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 500; }
html[data-ks-pro="1"] #proPill.ks-pro-pill:hover { background: var(--hover); color: var(--ink); }
.layer-list { display: flex; flex-direction: column; gap: 1px; }
.layer { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.layer:hover { background: var(--hover); }
.layer.on { background: var(--accent-soft); }
.layer .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--hover); flex: none; }
.layer .ic svg { width: 14px; height: 14px; }
.layer button { border: 0; background: transparent; padding: 2px; opacity: .6; }
.layer button:hover { opacity: 1; }
.layer button.off { opacity: .3; }
.layer .grp { font-size: 10.5px; color: var(--cyan); }
.link-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- filmstrip */
.film { height: 118px; flex: none; display: flex; align-items: stretch; gap: 10px; padding: 8px 14px; background: var(--bg); border-top: 1px solid var(--line); }
.film-strip { flex: 1; display: flex; gap: 12px; overflow-x: auto; align-items: center; padding: 2px 4px; scrollbar-width: thin; }
.thumb { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; border: 0; background: transparent; padding: 0; color: var(--muted); font: 500 11px var(--mono); position: relative; }
.thumb .tw { position: relative; overflow: hidden; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgba(0, 0, 0, .1); outline: 2px solid transparent; outline-offset: 2px; }
.thumb .tw .pg { transform-origin: 0 0; position: absolute; left: 0; top: 0; pointer-events: none; }
.thumb.on .tw { outline-color: var(--accent); }
.thumb.on { color: var(--accent); font-weight: 700; }
.thumb.master .tw { background: #fdf3f8; }
.thumb.master span { color: var(--magenta); font-family: var(--ui); }
.thumb.drop-before::before { content: ''; position: absolute; left: -8px; top: 0; bottom: 18px; width: 3px; border-radius: 2px; background: var(--cyan); }
.film-tools { display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 6px; flex: none; }
.status { color: var(--muted); font: 11px var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- backstage (File) */
.backstage { position: fixed; inset: 0; z-index: 30; display: flex; background: var(--bg); }
.bs-nav { width: 220px; flex: none; display: flex; flex-direction: column; gap: 1px; padding: 14px 10px; background: var(--bg); border-right: 1px solid var(--line); color: var(--ink); }
.bs-nav button { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; }
.bs-nav button:hover { background: var(--hover); color: var(--ink); }
.bs-nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bs-nav kbd { color: var(--muted); }
.bs-back { margin-bottom: 10px; font-weight: 600; color: var(--ink) !important; }
.bs-body { flex: 1; overflow-y: auto; padding: 28px 36px; }
.bs-pane { display: none; max-width: 1180px; }
.bs-pane.on { display: block; }
.bs-pane h2 { margin: 0 0 16px; font-size: 22px; letter-spacing: -.02em; font-weight: 650; }
.bs-pane h3 { font-size: 14px; margin: 22px 0 8px; }
.bs-pane .row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.open-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tpl-cats button { border: 1px solid var(--line-strong); background: transparent; border-radius: 16px; padding: 4px 12px; color: var(--ink-2); font-size: 12.5px; }
.tpl-cats button:hover { border-color: var(--accent-line); color: var(--ink); }
.tpl-cats button.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }
.tpl { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 7px; position: relative; color: var(--ink); }
.tpl .tw { width: 160px; height: 160px; display: grid; place-items: center; border-radius: 12px; background: var(--desk); border: 1px solid var(--line); overflow: hidden; position: relative; transition: transform .12s, box-shadow .12s; }
.tpl:hover .tw { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent-line); }
.tpl .tw .tpage { position: relative; overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); background: #fff; }
.tpl .tw .tpage .pg { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.tpl .nm { font-size: 12.5px; font-weight: 500; text-align: center; }
.tpl .badge { position: absolute; top: 6px; right: 10px; z-index: 1; }
.recent { display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
.recent button { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--panel-solid); border-radius: 10px; padding: 8px 10px; }
.recent button:hover { border-color: var(--accent-line); }
.recent button small { display: block; color: var(--muted); }
.recent .ext { font: 700 10px var(--mono); background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 3px 5px; }

/* ---- dialogs, menus, toasts */
.dlg { border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; background: var(--panel-solid); color: var(--ink); box-shadow: var(--shadow); width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px); position: relative; }
.dlg.wide { width: min(640px, calc(100vw - 24px)); }
.dlg::backdrop { background: var(--overlay); }
.dlg h3 { margin: 0 34px 12px 0; font-size: 17px; letter-spacing: -.01em; font-weight: 650; }
.dlg h4 { margin: 16px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dlg .row { display: flex; align-items: center; gap: 8px; margin: 7px 0; flex-wrap: wrap; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dlg-x { position: absolute; right: 12px; top: 12px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-size: 14px; display: grid; place-items: center; z-index: 2; }
.dlg-x:hover { background: var(--hover); color: var(--ink); }
.imp-lead { font-size: 14px; margin: 0 0 8px; }
.imp-list { margin: 4px 0 10px; padding-left: 20px; }
.imp-list li { margin: 3px 0; }
.imp-ok { color: #1a7f37; font-weight: 600; }
:root[data-theme="dark"] .imp-ok { color: #57d08a; }
.imp-preview { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.sc-body { columns: 2 240px; column-gap: 28px; }
.sc-body section { break-inside: avoid; margin-bottom: 12px; }
.sc-body h4 { margin: 4px 0 6px; }
.sc-body dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; align-items: baseline; }
.sc-body dt { margin: 0; }
.sc-body dd { margin: 0; color: var(--ink-2); }
.sc-body kbd { font-size: 11px; color: var(--ink); background: var(--raise); border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px; white-space: nowrap; margin: 0; }
.help-dlg { width: min(860px, calc(100vw - 24px)); padding: 0; }
.help-wrap { display: flex; min-height: min(560px, calc(100vh - 60px)); max-height: calc(100vh - 40px); }
.help-list { width: 230px; flex: none; border-right: 1px solid var(--line); padding: 16px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.help-list button { text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); }
.help-list button:hover { background: var(--hover); color: var(--ink); }
.help-list button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.help-body { flex: 1; padding: 20px 26px; overflow-y: auto; line-height: 1.6; }
.help-body h3 { margin-right: 40px; }
.help-body ol { padding-left: 20px; }
.help-body li { margin: 5px 0; }
.help-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.help-table th, .help-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.help-table th { color: var(--muted); font-weight: 600; }
.merge-src { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.merge-fields { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.merge-fields button { border: 1px solid var(--cyan); color: var(--cyan); background: transparent; border-radius: 14px; padding: 2px 10px; font-size: 12px; }
.merge-preview { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.brand-colours { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.brand-colours .bc { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); font-family: var(--mono); }
.brand-colours .bc span { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); position: relative; }
.brand-colours .bc button { border: 0; background: transparent; color: var(--muted); font-size: 10px; padding: 0; }
.menu { position: fixed; z-index: 40; min-width: 200px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; max-height: calc(100vh - 70px); overflow-y: auto; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; color: var(--ink); white-space: nowrap; }
.menu button svg { color: var(--ink-2); width: 16px; height: 16px; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu button:disabled { opacity: .4; cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu .lbl { font-size: 11px; color: var(--muted); padding: 6px 10px 2px; font-weight: 600; }
.toasts { position: fixed; bottom: 134px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #1f1a17; color: #f6efe8; border-radius: 12px; padding: 9px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; pointer-events: auto; max-width: calc(100vw - 24px); }
:root[data-theme="dark"] .toast { background: #f2ece6; color: #1f1a17; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 7px; padding: 2px 10px; font-weight: 600; }
.busy { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 60; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; }
.busy i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- the welcome panel ("Coming from Publisher?") */
.welcome { position: fixed; inset: 0; z-index: 45; background: var(--overlay); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.wel-card { position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 26px 28px 20px; }
.wel-kicker { margin: 0; color: var(--accent); font-weight: 600; font-size: 12px; }
.wel-card h2 { margin: 4px 40px 6px 0; font-size: 24px; letter-spacing: -.02em; font-weight: 650; }
.wel-lead { margin: 0 0 18px; color: var(--ink-2); max-width: 560px; }
.wel-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.wel-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; border: 1px solid var(--line-strong); background: var(--raise); border-radius: 14px; padding: 14px; color: var(--ink); }
.wel-opt:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.wel-opt svg { width: 22px; height: 22px; color: var(--accent); }
.wel-opt b { font-size: 14px; }
.wel-opt span { color: var(--ink-2); font-size: 12.5px; }
.wel-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 16px; }
.wel-map div { background: var(--panel-solid); padding: 8px 12px; display: flex; flex-direction: column; }
.wel-map b { font-size: 12px; }
.wel-map span { color: var(--ink-2); font-size: 12px; }
.wel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

#print-root, #measure-host { display: none; }
#measure-host { display: block; position: absolute; left: -40000px; top: 0; width: 0; height: 0; overflow: hidden; }

/* ---- printing: only the pages, each on its own sheet at the document's size */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  #app, .backstage, .toasts, .menu, dialog, .welcome, .busy, #measure-host { display: none !important; }
  #print-root { display: block !important; }
  #print-root .psheet { break-after: page; page-break-after: always; position: relative; overflow: hidden; }
  #print-root .psheet:last-child { break-after: auto; page-break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
body.printing #app { display: none; }
body.printing #print-root { display: block; }

/* ---- browser edition and smaller windows */
@media (max-height: 860px) and (min-width: 601px) { .tool span { display: none; } .tool { padding: 7px 0; } .rail-sep { margin: 4px 0; } }
@media (max-height: 720px) and (min-width: 601px) { .film { height: 100px; } .tool { padding: 5px 0; } .rail-sep { margin: 3px 0; } }
html.web .rail .pro .pro-dot { display: none; }
@media (max-width: 1279px) { .wide-only { display: none; } .doc-name input { width: 170px; } }
@media (max-width: 1100px) { .brand { display: none; } }
@media (max-width: 900px) {
  .inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 8; box-shadow: var(--shadow); background: var(--panel-solid); }
  .inspector:not(.open) { display: none; }
  .doc-name input { width: 130px; }
  .wel-cards { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { gap: 3px; padding: 0 8px; }
  .tb-group.zoom #zoom-out, .tb-group.zoom #zoom-in { display: none; }
  .doc-name input { width: 110px; max-width: none; font-size: 13px; }
  .pdf-btn span { display: none; }
  .pdf-btn { padding: 0 8px; }
  .wel-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar { height: 50px; }
  .file-btn { padding: 0 10px; }
  .doc-name input { width: 84px; }
  .zoom-val { min-width: 48px; padding: 0 4px; }
  #redo-btn { display: none; }
  .ctxbar { padding-left: 8px; }
  .work { flex-direction: column-reverse; }
  .rail { width: 100%; height: 60px; flex-direction: row; overflow-x: auto; overflow-y: hidden; margin-top: 0; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); justify-content: flex-start; }
  .rail .tool { width: 56px; flex: none; }
  .rail-sep { width: 1px; height: 36px; margin: 0 4px; }
  .rail-grow { display: none; }
  .film { height: 86px; padding: 6px 8px; }
  .film-tools .status { display: none; }
  .inspector { width: 100%; top: auto; bottom: 60px; height: 55%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
  .stage { padding: 18px; }
  .bs-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); flex: none; }
  .bs-nav button { white-space: nowrap; padding: 8px 10px; flex: none; }
  .bs-nav kbd { display: none; }
  .backstage { flex-direction: column; }
  .bs-body { padding: 16px; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tpl .tw { width: 100%; height: 140px; }
  .toasts { bottom: 160px; }
  .help-wrap { flex-direction: column; }
  .help-list { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; flex: none; }
  .help-list button { white-space: nowrap; flex: none; }
  .help-body { padding: 16px; }
  .wel-card { padding: 20px 16px 16px; }
  .wel-opt { padding: 10px 12px; }
  .wel-lead { margin-bottom: 12px; }
  .master-tag { white-space: normal; text-align: center; top: 10px; width: calc(100% - 24px); justify-content: center; flex-wrap: wrap; }
  .wel-card h2 { font-size: 20px; }
  .preview-bar span { min-width: 0; flex-basis: 100%; }
  .preview-bar { padding-left: 14px; }
}
