/* Metre2 Desktop Publishing - "the press room". Accent #7a3510 (sienna) with process inks:
   cyan #0093c9 = selection, magenta #d6007e = Pro, yellow #ffd200 = highlights. */
:root {
  --accent: #7a3510; --accent-2: #a64b1c; --accent-soft: rgba(122, 53, 16, .12);
  --cyan: #0093c9; --magenta: #d6007e; --yellow: #ffd200;
  --ink: #2a1a10; --ink-2: #5e4a3b; --muted: #8a776a;
  --bg: #efe6d9; --desk: #e3d7c6; --desk-dot: rgba(122, 53, 16, .07);
  --panel: rgba(255, 252, 247, .82); --panel-solid: #fffcf7; --line: rgba(84, 52, 30, .16); --hover: rgba(122, 53, 16, .08);
  --bar: linear-gradient(180deg, #3a1f10 0%, #2a160b 100%); --bar-ink: #f6e9da;
  --shadow: 0 1px 2px rgba(60, 30, 10, .12), 0 8px 24px rgba(60, 30, 10, .12);
  --page-shadow: 0 2px 4px rgba(60, 30, 10, .18), 0 18px 40px rgba(60, 30, 10, .22);
  --radius: 10px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  /* 2026-11-01: colours for the shared Pro / More from Metre2 / settings code (keystone-pro.js). Without these it fell
     back to dark-mode colours, so app names and notes were near-white on the light theme. They follow the theme. */
  --ks-text: var(--ink); --ks-muted: var(--ink-2); --ks-dim: var(--muted); --ks-surface: var(--panel-solid);
  --ks-raise: var(--desk); --ks-border: var(--line); --ks-border-strong: var(--line); --ks-accent: var(--accent); --ks-font: var(--font);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #e08a52; --accent-2: #f0a272; --accent-soft: rgba(224, 138, 82, .16);
  --ink: #f3e7da; --ink-2: #cdb9a6; --muted: #9c8877;
  --bg: #1b130e; --desk: #140e0a; --desk-dot: rgba(255, 220, 190, .05);
  --panel: rgba(40, 28, 21, .86); --panel-solid: #281c15; --line: rgba(255, 220, 190, .13); --hover: rgba(255, 220, 190, .08);
  --bar: linear-gradient(180deg, #2c1a10 0%, #1f120a 100%);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
  --page-shadow: 0 2px 6px rgba(0, 0, 0, .5), 0 20px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.4 var(--font); color: var(--ink); background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
/* 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.8; 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); border-radius: 7px; padding: 4px 6px; min-height: 28px; }
input[type=color] { width: 30px; height: 26px; padding: 1px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-solid); cursor: pointer; }
kbd { font: 11px var(--font); color: var(--muted); margin-left: auto; }
code { font: 12px Consolas, monospace; background: var(--hover); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

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

/* ---- top bar */
.topbar { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 10px; background: var(--bar); color: var(--bar-ink); flex: none; position: relative; z-index: 5; box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--cyan) 0 33.3%, var(--magenta) 33.3% 66.6%, var(--yellow) 66.6%); opacity: .9; }
.file-btn { background: linear-gradient(180deg, #a64b1c, #7a3510); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 6px 14px; font-weight: 600; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.file-btn:hover { filter: brightness(1.1); }
.brand { display: flex; align-items: center; color: var(--yellow); }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.08); }
.brand svg { width: 20px; height: 20px; }
.doc-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.doc-name input { background: transparent; border: 1px solid transparent; color: var(--bar-ink); font-weight: 600; font-size: 14px; width: 220px; max-width: 30vw; border-radius: 6px; }
.doc-name input:hover, .doc-name input:focus { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.06); outline: none; }
.dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); flex: none; }
.tb-group { display: flex; align-items: center; gap: 2px; }
.spacer { flex: 1; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: inherit; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.zoom-val { background: rgba(255,255,255,.08); border: 0; border-radius: 6px; padding: 4px 8px; min-width: 56px; color: inherit; }
.pdf-btn { display: flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: inherit; border-radius: 8px; padding: 6px 10px; font-weight: 600; }
.pdf-btn:hover { background: rgba(255,255,255,.16); }
#proPill { margin-left: 4px; }

/* ---- context bar */
.ctxbar { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 10px 6px 76px; background: var(--panel); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: thin; z-index: 4; }
.ctx { display: flex; align-items: center; gap: 4px; flex: none; }
.ctx .hint { color: var(--muted); white-space: nowrap; }
.tbtn { min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; border-radius: 7px; border: 1px solid transparent; background: transparent; padding: 0 6px; font-size: 14px; }
.tbtn:hover { background: var(--hover); border-color: var(--line); }
.tbtn.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.tbtn.danger:hover { color: #c0392b; }
.tbtn .dd { width: 12px; height: 12px; }
.tbtn svg .f { fill: currentColor; fill-opacity: .25; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: none; }
.num { display: inline-flex; align-items: center; gap: 2px; }
.num input { width: 58px; }
.num span { color: var(--muted); font-size: 11px; }
#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: 7px; 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; }
.swatch-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* ---- work area */
.work { flex: 1; display: flex; min-height: 0; position: relative; }
.rail { width: 66px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: linear-gradient(180deg, color-mix(in srgb, var(--panel-solid) 92%, var(--accent)), var(--panel-solid)); border-right: 1px solid var(--line); overflow-y: auto; margin-top: -44px; z-index: 6; position: relative; }
.tool { position: relative; width: 56px; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 10.5px; color: var(--ink-2); }
.tool svg { width: 21px; height: 21px; }
.tool:hover { background: var(--hover); color: var(--ink); }
.tool.on { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 2px 8px rgba(122,53,16,.35); }
:root[data-theme="dark"] .tool.on { color: #1b130e; }
.tool .pro-dot { position: absolute; top: 5px; right: 9px; width: 7px; height: 7px; 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; }
.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(--panel-solid); }
.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(--panel-solid); 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: radial-gradient(var(--desk-dot) 1px, transparent 1.2px); background-size: 14px 14px; }
.stage { position: relative; padding: 48px; display: inline-block; min-width: 100%; min-height: 100%; }
.stage { 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); }
.pagescale .pg { cursor: default; }
.bleedline { position: absolute; border: 1px dashed rgba(214, 0, 126, .45); 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(214, 0, 126, .55); stroke-width: 1; stroke-dasharray: 4 3; }
.guides .guide { stroke: var(--cyan); stroke-width: 1; }
.guides .snap { stroke: var(--magenta); 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 var(--cyan); pointer-events: none; transform-origin: center center; }
.selbox.multi { border-style: dashed; }
.selbox.locked { border-color: var(--muted); border-style: dotted; }
.selbox.editing { border: 1.5px solid var(--cyan); 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 var(--cyan); border-radius: 2px; pointer-events: auto; }
.handle.rot { border-radius: 50%; background: var(--cyan); cursor: grab; }
.handle.rot::after { content: ''; position: absolute; left: 3px; top: 8px; width: 1px; height: 14px; background: var(--cyan); }
.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: var(--panel-solid); border: 1.5px solid var(--cyan); color: var(--cyan); font: 700 10px/12px var(--font); 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 var(--cyan); transform-origin: 0 0; pointer-events: none; opacity: .7; }
.marquee { position: absolute; border: 1px dashed var(--cyan); 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.crop .it-image.cropping { overflow: visible; outline: 1.5px dashed var(--magenta); }
.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: linear-gradient(90deg, var(--magenta), #a3005f); color: #fff; padding: 6px 8px 6px 14px; border-radius: 20px; box-shadow: var(--shadow); white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.master-tag button { background: #fff; color: var(--magenta); border: 0; border-radius: 14px; padding: 3px 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: 10px; padding: 8px 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; }

/* ---- inspector */
.inspector { width: 268px; flex: none; display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(14px); border-left: 1px solid var(--line); min-height: 0; }
.inspector.closed { display: none; }
.itabs { display: flex; padding: 6px; gap: 4px; border-bottom: 1px solid var(--line); flex: none; }
.itab { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 6px; color: var(--ink-2); font-weight: 600; }
.itab.on { background: var(--accent-soft); color: var(--accent); }
.ipanel { display: none; overflow-y: auto; padding: 10px 12px 20px; flex: 1; }
.ipanel.on { display: block; }
.ipanel h4 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ipanel h4:first-child { margin-top: 2px; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.f-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.fld { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); min-width: 0; }
.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: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: transparent; }
.colrow .none.on { background: var(--accent-soft); color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.swatches button { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--line); padding: 0; }
.swatches .lock { width: auto; padding: 0 6px; font-size: 10px; color: var(--magenta); border-color: var(--magenta); background: transparent; }
.ip-empty { color: var(--muted); padding: 16px 4px; }
.ip-empty b { color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-solid); border-radius: 8px; padding: 6px 12px; min-height: 30px; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #1b130e; }
.btn.small { padding: 3px 8px; min-height: 26px; font-size: 12px; }
.btn.small svg { width: 14px; height: 14px; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.pro::after { content: 'PRO'; font: 700 9px var(--font); 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(--font); font-style: normal; background: var(--magenta); color: #fff; padding: 2px 5px; border-radius: 4px; vertical-align: middle; }
body.is-pro .pro-tag { background: var(--accent-soft); color: var(--accent); }
.layer-list { display: flex; flex-direction: column; gap: 2px; }
.layer { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 7px; border: 1px solid transparent; cursor: pointer; }
.layer:hover { background: var(--hover); }
.layer.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.layer .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .ic { width: 22px; height: 22px; border-radius: 5px; 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: .55; }
.layer button:hover { opacity: 1; }
.layer button.off { opacity: .25; }
.layer .grp { font-size: 10px; color: var(--cyan); }
.link-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- filmstrip */
.film { height: 118px; flex: none; display: flex; align-items: stretch; gap: 8px; padding: 8px 10px; background: var(--panel); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.film-strip { flex: 1; display: flex; gap: 10px; overflow-x: auto; align-items: center; padding: 2px 4px; scrollbar-width: thin; }
.thumb { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; border: 0; background: transparent; padding: 0; color: var(--ink-2); font-size: 11px; position: relative; }
.thumb .tw { position: relative; overflow: hidden; background: #fff; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.18); 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: 600; }
.thumb.master .tw { background: #fdf0f7; }
.thumb.master span { color: var(--magenta); }
.thumb.drop-before::before { content: ''; position: absolute; left: -7px; 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-size: 11.5px; white-space: nowrap; }

/* ---- backstage */
.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: 2px; padding: 14px 10px; background: var(--bar); color: var(--bar-ink); }
.bs-nav button { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 8px; color: inherit; }
.bs-nav button:hover { background: rgba(255,255,255,.08); }
.bs-nav button.on { background: rgba(255,255,255,.14); font-weight: 600; }
.bs-nav kbd { color: rgba(255,255,255,.5); }
.bs-back { margin-bottom: 10px; font-weight: 600; }
.bs-body { flex: 1; overflow-y: auto; padding: 24px 32px; }
.bs-pane { display: none; max-width: 1180px; }
.bs-pane.on { display: block; }
.bs-pane h2 { margin: 0 0 14px; font-size: 22px; }
.bs-pane .row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tpl-cats button { border: 1px solid var(--line); background: var(--panel-solid); border-radius: 16px; padding: 4px 12px; }
.tpl-cats button.on { background: var(--accent); color: #fff; border-color: transparent; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.tpl { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.tpl .tw { width: 160px; height: 160px; display: grid; place-items: center; border-radius: 10px; background: var(--panel-solid); 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: color-mix(in srgb, var(--accent) 50%, transparent); }
.tpl .tw .tpage { position: relative; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.2); 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: 8px; padding: 8px 10px; }
.recent button small { display: block; color: var(--muted); }
.recent .ext { font: 700 10px var(--font); background: var(--accent); color: #fff; border-radius: 4px; padding: 3px 5px; }

/* ---- dialogs, menus, toasts */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; background: var(--panel-solid); color: var(--ink); box-shadow: var(--shadow); width: min(440px, calc(100vw - 24px)); }
.dlg.wide { width: min(620px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(30, 15, 5, .35); backdrop-filter: blur(2px); }
.dlg h3 { margin: 0 0 10px; font-size: 17px; }
.dlg h4 { margin: 14px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dlg .row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.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); }
.brand-colours .bc span { width: 36px; height: 36px; border-radius: 8px; 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: 10px; box-shadow: var(--shadow); padding: 5px; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; }
.menu button:hover { background: var(--hover); }
.menu button:disabled { opacity: .4; cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .lbl { font-size: 10.5px; color: var(--muted); padding: 4px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }
.toasts { position: fixed; bottom: 132px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #2a160b; color: #f6e9da; border-radius: 10px; padding: 8px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; pointer-events: auto; max-width: calc(100vw - 24px); }
.toast button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: var(--yellow); border-radius: 6px; padding: 2px 10px; }

#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, #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 small screens */
html.web .rail .pro .pro-dot { display: none; }
@media (max-width: 900px) {
  .inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 8; box-shadow: var(--shadow); }
  .inspector:not(.open) { display: none; }
  .doc-name input { width: 140px; }
}
@media (max-width: 600px) {
  .topbar { gap: 4px; padding: 0 6px; }
  .brand, #theme-btn, #print-btn, .tb-group.zoom #zoom-out, .tb-group.zoom #zoom-in { display: none; }
  .doc-name input { width: 96px; max-width: none; font-size: 13px; }
  .pdf-btn span { display: none; }
  .ctxbar { padding-left: 8px; }
  .work { flex-direction: column-reverse; }
  .rail { width: 100%; height: 58px; 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: 54px; flex: none; }
  .rail-sep { width: 1px; height: 36px; margin: 0 4px; }
  .rail-grow { display: none; }
  .film { height: 86px; padding: 6px; }
  .film-tools .status { display: none; }
  .inspector { width: 100%; top: auto; bottom: 58px; height: 55%; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; }
  .stage { padding: 18px; }
  .bs-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .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; }
}
