/* Layout concept: a print shop's light table. Navy brand bar on top, the form on the left,
   the flyer pages on a cool paper-gray table on the right. Square corners, like the print system. */
:root {
  --bg: #e9ecf1;          /* the light table the pages sit on */
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --line: #d6dbe3;
  --line-2: #c3cad5;
  --text: #172033;
  --muted: #586378;
  --brand: #01448F;
  --brand-2: #0b5bb5;
  --on-brand: #ffffff;
  --gold: #8f7438;        /* gold darkened for text contrast on white */
  --gold-soft: #c3ad74;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --tip-bg: #eaf1fb;
  --ok: #17663f;
  --shadow-page: 0 1px 2px rgba(16, 24, 40, .10), 0 8px 24px rgba(16, 24, 40, .10);
  --focus: 0 0 0 3px rgba(1, 68, 143, .35);
  --r: 3px;
  --font: "Urbanist", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --panel: #151c27; --panel-2: #1b2331; --line: #283345; --line-2: #36435a;
    --text: #e6ebf3; --muted: #9ba7ba; --brand: #6ea5ec; --brand-2: #8db8f1; --on-brand: #06203f;
    --gold: #d2bd85; --gold-soft: #c3ad74; --danger: #ff8a7a; --danger-bg: #3a1714; --warn: #f3c25b; --warn-bg: #33270d;
    --tip-bg: #14263f; --ok: #6fd3a0; --shadow-page: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45);
    --focus: 0 0 0 3px rgba(110, 165, 236, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1219; --panel: #151c27; --panel-2: #1b2331; --line: #283345; --line-2: #36435a;
  --text: #e6ebf3; --muted: #9ba7ba; --brand: #6ea5ec; --brand-2: #8db8f1; --on-brand: #06203f;
  --gold: #d2bd85; --gold-soft: #c3ad74; --danger: #ff8a7a; --danger-bg: #3a1714; --warn: #f3c25b; --warn-bg: #33270d;
  --tip-bg: #14263f; --ok: #6fd3a0; --shadow-page: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45);
  --focus: 0 0 0 3px rgba(110, 165, 236, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

/* ---------- Brand bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background-color: #01448F;
  background-image: url("../assets/brand/grain.png"), linear-gradient(100deg, #013a7a 0%, #01448F 55%, #034a99 100%);
  background-size: 120px 120px, 100% 100%;
  color: #fff; min-height: 56px; display: flex; align-items: center; gap: 12px;
  padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 2px solid #c3ad74;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 40; background: #01448F; }
.bar-logo { height: 30px; width: auto; display: block; }
.bar-title { font-weight: 700; font-size: 15px; color: #e4dcc4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar-sep { width: 1px; align-self: stretch; background: rgba(195, 173, 116, .6); margin: 4px 4px; }
.bar-spacer { flex: 1; }
.bar .save-state { font-size: 13px; color: #cfd8e6; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.bar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.28); }
.bar .btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-weight: 700; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; touch-action: manipulation; }
.btn:hover { background: var(--panel-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #c3ad74; border-color: #c3ad74; color: #10223f; }
.btn-primary:hover { background: #d3c08d; border-color: #d3c08d; }
.btn-blue { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-blue:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; min-height: 32px; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Home ---------- */
.home { flex: 1; overflow: auto; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.home-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--brand); padding-bottom: 14px; }
.home-head h1 { margin: 0; font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -0.02em; color: var(--brand); }
.home-head p { margin: 6px 0 0; color: var(--muted); }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-width: 0; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--line-2); box-shadow: 0 6px 20px rgba(16,24,40,.08); }
.card-open { all: unset; cursor: pointer; display: flex; flex-direction: column; }
.card-open:focus-visible { box-shadow: inset var(--focus); }
.card-thumb { aspect-ratio: 16 / 10; background: var(--panel-2); position: relative; overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-status { position: absolute; left: 0; bottom: 0; background: #01448F; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 5px 10px; border-top: 2px solid #c3ad74; }
.card-body { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-name { font-weight: 800; font-size: 17px; line-height: 1.2; color: var(--text); overflow-wrap: anywhere; }
.card-addr { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 8px 14px; color: var(--muted); font-size: 13px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--muted); border-radius: 2px; }
.empty { border: 1px dashed var(--line-2); background: var(--panel); padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; border-radius: var(--r); }
.empty h2 { margin: 0; font-size: 22px; color: var(--text); }
.empty p { margin: 0; color: var(--muted); max-width: 46ch; }

/* ---------- Editor ---------- */
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); }
.form { overflow: auto; background: var(--panel); border-right: 1px solid var(--line); min-width: 0; }
.preview { overflow: auto; min-width: 0; display: flex; flex-direction: column; }
.tabs { display: none; }

.sec { border-bottom: 1px solid var(--line); }
/* Step flow: one step of the form at a time */
.form { display: flex; flex-direction: column; }
.step-top { position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); }
.stepper { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.step { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 6px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 700; font-size: 14px; }
.step:hover { color: var(--text); background: var(--panel-2); }
.step.is-on { color: var(--text); border-bottom-color: var(--brand); }
.step-n { flex-shrink: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.step-n svg { width: 14px; height: 14px; }
.step.is-on .step-n { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.step.is-done:not(.is-on) .step-n { border-color: var(--ok); color: var(--ok); }
.step-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-body { flex: 1; }
.step-nav { position: sticky; bottom: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); }
.step-nav .btn { min-height: 42px; padding: 0 18px; font-size: 15px; }
.sec.is-static { border-bottom: 1px solid var(--line); }
.sec-st { margin: 0; padding: 18px 18px 8px; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.sec.is-static .sec-b { padding-top: 6px; }
.more { border-top: 1px solid var(--line); }
.more:first-child { border-top: 0; }
.more-t { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; background: none; border: 0; text-align: left; font-weight: 700; font-size: 14px; color: var(--brand); }
.more-t .chev { display: inline-flex; transform: rotate(-90deg); transition: transform .15s; }
.more-t[aria-expanded="true"] .chev { transform: none; }
.more-b { display: flex; flex-direction: column; gap: 12px; padding: 2px 0 14px; }
.quick-cta { margin: 16px 18px 0; display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: calc(100% - 36px); text-align: left; background: var(--tip-bg); border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--text); }
.quick-cta:hover { border-color: var(--brand); }
.quick-cta > svg { flex-shrink: 0; color: var(--brand); width: 22px; height: 22px; }
.quick-cta span span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.quick-cta b { font-size: 14.5px; }
.seg .sel-seg { width: auto; flex: 0 0 auto; min-height: 34px; height: 34px; font-weight: 700; font-size: 13.5px; padding-right: 28px; }
.sel-seg.is-on { background-color: var(--brand); color: var(--on-brand); border-color: var(--brand); }
@media (max-width: 420px) { .step-l { font-size: 12.5px; } .step { gap: 5px; } }
@media (prefers-reduced-motion: reduce) { .more-t .chev { transition: none; } }
.sec-h { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: none; border: 0; text-align: left; }
.sec-h:hover { background: var(--panel-2); }
.sec-title { font-weight: 800; font-size: 15px; flex: 1; display: flex; align-items: center; gap: 8px; }
.sec-sub { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
.sec-h .chev { transition: transform .2s; color: var(--muted); }
.sec[data-open="true"] .sec-h .chev { transform: rotate(180deg); }
.sec-b { padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.count { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; font-weight: 800; color: var(--muted); }
.count.bad { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.row { display: grid; gap: 10px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1.6fr .7fr 1fr; }
.row-price { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 700; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.inp, .sel, .ta {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); color: var(--text); font-weight: 600; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.inp::placeholder, .ta::placeholder { color: var(--muted); opacity: .75; font-weight: 500; }
.inp:hover, .sel:hover, .ta:hover { border-color: var(--muted); }
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.ta { resize: vertical; min-height: 96px; line-height: 1.45; }
.sel { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.inp.is-flag { border-color: var(--danger); }
.prefix { position: relative; }
.prefix > span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.prefix > .inp { padding-left: 22px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--r); font-weight: 700; font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.li-n { font-size: 12px; font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.li-act { display: flex; gap: 2px; }
.li-act .btn { color: var(--muted); }
.li-act .btn:hover { color: var(--text); }
.stat-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.space-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 90px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.fact-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 6px; align-items: center; }
.charc { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.charc.over { color: var(--warn); font-weight: 700; }
.addrow { align-self: flex-start; }
.note { font-size: 13px; color: var(--muted); background: var(--panel-2); border-left: 3px solid var(--gold-soft); padding: 8px 10px; }

/* Photos */
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); background: var(--panel-2); transition: border-color .15s, background .15s; }
.drop.is-over { border-color: var(--brand); background: var(--tip-bg); color: var(--text); }
.drop strong { color: var(--text); }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ph { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); display: flex; flex-direction: column; min-width: 0; }
.ph.is-hero { border-color: var(--gold-soft); box-shadow: inset 0 3px 0 var(--gold-soft); }
.ph-img { position: relative; aspect-ratio: 4 / 3; background: var(--panel-2); overflow: hidden; }
.ph-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-img img.is-plan { object-fit: contain; background: #fff; }
.ph-badges { position: absolute; left: 6px; top: 6px; right: 6px; display: flex; gap: 4px; flex-wrap: wrap; pointer-events: none; }
.badge { height: 20px; padding: 0 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; letter-spacing: .04em; border-radius: 2px; background: rgba(1, 34, 72, .86); color: #fff; }
.badge.gold { background: #c3ad74; color: #10223f; }
.badge.warn { background: #fff1c7; color: #6b4600; }
.ph-b { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ph-b .inp, .ph-b .sel { min-height: 34px; font-size: 13.5px; padding: 5px 8px; }
.ph-b .sel { padding-right: 26px; }
.ph-acts { display: flex; gap: 2px; justify-content: space-between; }
.ph-acts .btn { color: var(--muted); }
.ph-acts .btn:hover { color: var(--text); }
.ph-acts .btn[aria-pressed="true"] { color: var(--gold); }
.adj { grid-column: 1 / -1; border: 1px solid var(--brand); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); }
.adj-stage { position: relative; background: #fff; border: 1px solid var(--line); user-select: none; touch-action: none; cursor: crosshair; }
.adj-stage img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: contain; pointer-events: none; }
.adj-dot { position: absolute; width: 22px; height: 22px; transform: translate(-50%, -50%); border: 2px solid #fff; box-shadow: 0 0 0 2px #01448F, 0 1px 6px rgba(0,0,0,.4); border-radius: 50%; pointer-events: none; }
.adj-pin { position: absolute; transform: translate(-50%, -100%); pointer-events: none; background: #01448F; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border: 2px solid #fff; outline: 2px solid #c3ad74; }
.adj-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.adj-row input[type=range] { flex: 1; accent-color: var(--brand); min-width: 120px; }

/* Pages */
.pages-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); }
.pg { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.pg:last-child { border-bottom: 0; }
.pg-name { font-weight: 700; font-size: 14px; }
.pg-sub { font-size: 12.5px; color: var(--muted); }
.pg.is-missing .pg-name { color: var(--muted); }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--line-2); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.switch input:disabled + span { opacity: .45; }

/* ---------- Preview ---------- */
.pv-head { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: 14px 24px 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.pv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pv-label { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tpls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tpl { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: start; text-align: left; padding: 9px 10px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); min-width: 0; }
.tpl:hover { border-color: var(--line-2); }
.tpl[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.tpl-name { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tpl-why { font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.tpl-pick { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #10223f; background: #c3ad74; padding: 2px 5px; border-radius: 2px; }
.mini { width: 44px; height: 57px; background: #fff; border: 1px solid #c9ced8; display: flex; flex-direction: column; overflow: hidden; }
.mini i { display: block; flex-shrink: 0; }
.mini .ph1 { background: #9fb3c9; }
.mini .bd { background: #01448F; }
.mini .tx { background: #dfe3ea; margin: 2px 4px 0; height: 3px; }
.mini .split { flex: 1; display: grid; grid-template-columns: 42% 1fr; gap: 3px; margin-top: 3px; }
.mini .split i:first-child { background: #9fb3c9; }
.mini .split i:last-child { background: repeating-linear-gradient(#dfe3ea 0 3px, transparent 3px 6px); margin-top: 1px; }
.mini .ft { margin-top: auto; height: 6px; background: #01448F; }
.auto-note { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; padding: 7px 10px; border-radius: var(--r); background: var(--tip-bg); text-align: left; border: 0; width: 100%; color: var(--text); font-weight: 600; }
.issue.warn { background: var(--warn-bg); }
.issue.block { background: var(--danger-bg); }
.issue svg { margin-top: 1px; }
.issue.warn svg { color: var(--warn); }
.issue.block svg { color: var(--danger); }
.issue.tip svg { color: var(--brand); }
.issues-toggle { font-size: 13px; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 0; display: inline-flex; gap: 6px; align-items: center; }

.pv-pages { padding: 24px 24px 80px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.pv-item { display: flex; flex-direction: column; gap: 8px; }
.pv-cap { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pv-cap .over { color: var(--danger); letter-spacing: 0; text-transform: none; font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
.pv-scaler { position: relative; box-shadow: var(--shadow-page); background: #fff; overflow: hidden; }
.pv-zoom { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pv-divider { display: flex; flex-direction: column; gap: 2px; border-top: 2px solid var(--line-2); padding-top: 14px; margin-top: 8px; }
.pv-divider span { font-size: 12.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text); }
.pv-divider small { color: var(--muted); font-size: 13px; }
.pv-item.is-over .pv-scaler { outline: 2px solid var(--danger); outline-offset: 3px; }
.zoom { display: flex; gap: 4px; }

/* ---------- Menus, toasts, overlays ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(340px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: 0 16px 40px rgba(16,24,40,.22); padding: 6px; display: flex; flex-direction: column; }
.menu button { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; text-align: left; padding: 10px; border: 0; background: none; border-radius: var(--r); }
.menu button:hover, .menu button:focus-visible { background: var(--panel-2); }
.menu b { display: block; font-size: 14.5px; }
.menu small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; margin-top: 1px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

.toast-wrap { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast { pointer-events: auto; background: #10223f; color: #fff; border-left: 4px solid #c3ad74; padding: 10px 12px 10px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 12px 30px rgba(0,0,0,.25); font-weight: 600; font-size: 14px; animation: toast-in .22s ease-out; max-width: 100%; }
.toast.err { border-left-color: #ff8a7a; }
.toast .linkish { color: #e4dcc4; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.overlay { position: fixed; inset: 0; z-index: 90; background: rgba(8, 14, 24, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--panel); color: var(--text); width: min(440px, 100%); border-radius: var(--r); border-top: 4px solid #c3ad74; padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.dialog h2 { margin: 0; font-size: 20px; }
.dialog p { margin: 0; color: var(--muted); }
.dialog-acts { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .25s ease-out; }

.banner { background: var(--warn-bg); color: var(--text); padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); font-size: 14px; font-weight: 600; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }

.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Narrow screens: Edit / Preview tabs ---------- */
@media (max-width: 1000px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor[data-tab="edit"] .preview { display: none; }
  .editor[data-tab="preview"] .form { display: none; }
  .form { border-right: 0; }
  .tabs { display: flex; gap: 4px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); }
  .tabs button { flex: 1; min-height: 40px; border: 0; background: none; font-weight: 800; border-bottom: 3px solid transparent; color: var(--muted); }
  .tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
  .pv-head { padding: 12px 16px; position: static; backdrop-filter: none; background: var(--bg); }
  .pv-pages { padding: 16px 16px 80px; }
}
@media (max-width: 560px) {
  .tpl { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 6px; padding: 8px; }
  .tpl .tpl-why { display: none !important; }
  .mini { width: 34px; height: 44px; }
  .zoom { display: none; }
  .bar-title, .bar-sep { display: none; }
  .bar .save-state span { display: none; }
  .photos { grid-template-columns: minmax(0, 1fr); }
  .row-3, .row-price { grid-template-columns: 1fr 1fr; }
  .row-3 > :first-child, .row-price > :first-child { grid-column: 1 / -1; }
  .stat-row { grid-template-columns: 92px minmax(0, 1fr) auto; }
  .space-row { grid-template-columns: minmax(0, 1fr) 80px auto; }
  .space-row .sp-rate { display: none; }
  .home-head h1 { font-size: 28px; }
  .btn-label-wide { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Print: just the pages, at true size ---------- */
@page { size: letter; margin: 0; }
@media print {
  html, body { height: auto; background: #fff; }
  body::before { display: none; }
  .bar, .form, .tabs, .pv-head, .pv-cap, .toast-wrap, .banner, .overlay { display: none !important; }
  #app, .editor, .preview { display: block !important; height: auto !important; overflow: visible !important; }
  .pv-pages { padding: 0 !important; gap: 0 !important; display: block !important; }
  .pv-social, .pv-divider { display: none !important; }
  .pv-item { display: block !important; break-after: page; page-break-after: always; }
  .pv-item.is-lastpage { break-after: auto; page-break-after: auto; }
  .pv-scaler { width: 8.5in !important; height: 11in !important; box-shadow: none !important; outline: 0 !important; }
  .pv-zoom { transform: none !important; }
}

/* Preview header: one-line layout summary */
.layout-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.layout-line b { font-size: 15px; }
.layout-line .auto-note { font-size: 13px; }

/* AI helpers */
.ai-card { background: linear-gradient(0deg, var(--panel), var(--panel)), var(--panel); }
.ai-card .sec-b { padding-top: 16px; }
.ai-head { display: flex; gap: 12px; align-items: flex-start; }
.ai-head b { font-size: 15px; }
.ai-mark { flex-shrink: 0; width: 32px; height: 32px; display: grid; place-items: center; background: var(--tip-bg); color: var(--brand); border: 1px solid var(--line); border-radius: var(--r); }
.ai-mark svg { width: 17px; height: 17px; }
.ai-checks { display: block; margin-top: 4px; }
.draft { display: flex; flex-direction: column; gap: 12px; }
.draft-part { border: 1px solid var(--line); border-left: 3px solid var(--gold-soft); padding: 10px 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 6px; }
.draft-part ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.draft-part p { margin: 0; font-size: 14px; line-height: 1.5; }
.draft-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.review li { border: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.review li.is-done { opacity: .6; }
.review-f { display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 8px; }
.review-fix { color: var(--ok); font-weight: 600; }
.review-a .hint { display: inline-flex; align-items: center; gap: 4px; }
.review-a .hint svg { width: 14px; height: 14px; }
.pdf-row { display: flex; gap: 8px; align-items: center; }
.pdf-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid var(--line-2); background: var(--panel-2); font-size: 13.5px; font-weight: 600; max-width: 100%; }
.pdf-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog .inp { width: 100%; }
