/* ============================================================================
   Waiver Merge — editor styles
   ========================================================================= */

:root {
  --accent:        #4f46e5;
  --accent-600:    #4338ca;
  --accent-50:     #eef2ff;
  --accent-100:    #e0e7ff;
  --pink:          #ec4899;
  --green:         #10b981;
  --green-50:      #ecfdf5;
  --amber:         #f59e0b;
  --danger:        #ef4444;
  --danger-50:     #fef2f2;

  --bg:            #eef1f6;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --text:          #0f172a;
  --text-2:        #475569;
  --text-3:        #94a3b8;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --sh-2: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --sh-3: 0 12px 32px rgba(15,23,42,.14), 0 4px 8px rgba(15,23,42,.06);
  --sh-pop: 0 18px 50px rgba(15,23,42,.22);

  --sidebar-w: 316px;
  --topbar-h:  56px;
  --t: 140ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Primitives ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background var(--t), border-color var(--t), box-shadow var(--t), transform var(--t);
  white-space: nowrap; user-select: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--sh-1); }
.btn.primary:hover:not(:disabled) { background: var(--accent-600); border-color: var(--accent-600); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(15,23,42,.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-50); border-color: #fecaca; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.icon { padding: 6px; width: 30px; height: 30px; }
.btn.on { background: var(--accent-50); border-color: var(--accent-100); color: var(--accent-600); }

/* ── Icons ────────────────────────────────────────────────────────────────
   One rule styles the whole sprite. Stroke-only, inheriting currentColor, so
   an icon always matches the text it sits beside. */
.ic {
  width: 16px; height: 16px; display: block; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic.sm { width: 13px; height: 13px; }
.ic.lg { width: 20px; height: 20px; stroke-width: 1.75; }
.ic.xl { width: 40px; height: 40px; stroke-width: 1.25; }
.ic.fill { fill: currentColor; stroke: none; }

.field { display: block; margin-bottom: 10px; }
.field > label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 5px;
}
input[type=text], input[type=number], select, textarea.ctl {
  width: 100%; padding: 7px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.14); }
input[type=color] {
  width: 100%; height: 34px; padding: 2px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.tiny { font-size: 11.5px; }
kbd {
  display: inline-block; font: 600 10.5px/1.4 ui-monospace, Menlo, Consolas, monospace;
  background: #fff; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; color: var(--text-2); white-space: nowrap;
}

/* ── App shell ────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  z-index: 40; box-shadow: var(--sh-1);
  /* Anything that somehow still doesn't fit gets clipped rather than widening
     the document — an over-wide document is what lets a phone pinch-zoom out
     and shrink the whole page. overflow-y stays visible, which `clip` allows. */
  min-width: 0; max-width: 100%;
  overflow-x: clip; overflow-y: visible;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; min-width: 0; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; font-size: 14px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Step tracker — the primary "what do I do next" affordance */
.steps { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.steps li {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 6px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--text-3);
  transition: all var(--t); white-space: nowrap; cursor: pointer;
}
.steps li .n {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center;
  background: var(--border); color: var(--text-2); font-size: 11px; font-weight: 700;
  transition: all var(--t);
}
.steps li:hover { background: var(--surface-2); }
.steps li.current { background: var(--accent-50); color: var(--accent-600); font-weight: 600; }
.steps li.current .n { background: var(--accent); color: #fff; }
.steps li.done { color: var(--green); }
.steps li.done .n { background: var(--green); color: #fff; }
.steps li .n .ck { display: none; width: 11px; height: 11px; stroke-width: 3; }
.steps li.done .n .num { display: none; }
.steps li.done .n .ck { display: block; }
.steps .sep { color: var(--text-3); font-size: 11px; }

.body { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain; z-index: 30;
}
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb { background: #dbe2ea; border-radius: 6px; border: 3px solid var(--surface); }

.panel { border-bottom: 1px solid var(--border); }
.panel-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 16px; background: none; border: 0; cursor: pointer; text-align: left;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2);
}
.panel-head:hover { background: var(--surface-2); }
.panel-head .chev { margin-left: auto; color: var(--text-3); transition: transform var(--t); font-size: 10px; }
.panel.collapsed .chev { transform: rotate(-90deg); }
.panel.collapsed .panel-body { display: none; }
.panel-head .badge {
  margin-left: auto; background: var(--accent-50); color: var(--accent-600);
  border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 700; letter-spacing: 0;
}
.panel-head .badge + .chev { margin-left: 6px; }
.panel-body { padding: 0 16px 16px; }

/* Drop zones */
.dropzone {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 12px; margin-bottom: 9px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r);
  background: var(--surface-2); cursor: pointer; transition: all var(--t);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-50); }
.dropzone.over { border-color: var(--accent); background: var(--accent-50); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.dropzone.filled { border-style: solid; border-color: #a7f3d0; background: var(--green-50); }
.dropzone .dz-icon { flex: 0 0 auto; color: var(--text-2); }
.dropzone.filled .dz-icon { color: #047857; }
.dropzone .dz-text { min-width: 0; }
.dropzone .dz-title { font-size: 13px; font-weight: 600; }
.dropzone .dz-sub {
  font-size: 11.5px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropzone.filled .dz-sub { color: #047857; }
.dropzone input[type=file] { display: none; }
.dropzone .dz-clear {
  margin-left: auto; flex: 0 0 auto; border: 0; background: none; cursor: pointer;
  color: var(--text-3); font-size: 15px; padding: 2px 4px; border-radius: 4px;
}
.dropzone .dz-clear:hover { background: rgba(15,23,42,.08); color: var(--danger); }

/* Field chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font: 500 11.5px/1 ui-monospace, Menlo, Consolas, monospace;
  padding: 5px 9px; border-radius: 999px;
  background: var(--accent-50); color: var(--accent-600); border: 1px solid var(--accent-100);
  cursor: grab; user-select: none; transition: all var(--t); max-width: 100%;
}
.chip:hover { background: var(--accent-100); border-color: #c7d2fe; transform: translateY(-1px); }
.chip:active { cursor: grabbing; }
.chip.dragging { opacity: .4; }
.chip .ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Record navigator */
.recnav { display: flex; align-items: center; gap: 6px; }
.recnav select { flex: 1; min-width: 0; }

/* Guide list */
.guide { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.guide li { display: flex; gap: 9px; padding: 6px 0; color: var(--text-2); align-items: flex-start; }
.guide li .g-ico { flex: 0 0 16px; margin-top: 2px; color: var(--text-3); }
.guide li b { color: var(--text); font-weight: 600; }

/* Validation warnings */
.warnlist { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.warnlist li {
  display: flex; gap: 7px; padding: 7px 9px; margin-bottom: 5px;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--r-sm); color: #92400e;
}
.warnlist .ic { margin-top: 2px; }

/* ── Stage ────────────────────────────────────────────────────────────── */
.stage-wrap {
  flex: 1; position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  overflow: auto; background:
    radial-gradient(circle at 1px 1px, rgba(15,23,42,.055) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  padding: 22px 22px 84px;
  scroll-behavior: auto;
}
.stage {
  position: relative; flex: 0 0 auto;
  background: #fff; border-radius: 3px;
  box-shadow: 0 2px 6px rgba(15,23,42,.10), 0 12px 40px rgba(15,23,42,.13);
  transition: width 0s, height 0s;
}
#pdfCanvas { display: block; width: 100%; height: 100%; border-radius: 3px; }

.layer { position: absolute; inset: 0; display: none; }
.layer.active { display: block; }

/* Empty state */
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 30px;
}
.empty.hidden { display: none; }
.empty .e-art { color: var(--text-3);
  width: 168px; height: 200px; border-radius: 8px; margin-bottom: 20px;
  background: #fff; border: 2px dashed var(--border-strong); position: relative;
  display: grid; place-items: center; font-size: 44px;
  box-shadow: var(--sh-2);
}
.empty h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--text-2); max-width: 380px; }
.empty .e-actions { margin-top: 16px; display: flex; gap: 8px; }

/* Page bar */
.pagebar {
  position: sticky; bottom: 0; align-self: center;
  display: flex; align-items: center; gap: 4px;
  margin-top: 16px; padding: 5px; border-radius: 999px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--border); box-shadow: var(--sh-2); z-index: 20;
}
.pagebar.hidden { display: none; }
.pagebar .pnum {
  font-size: 12.5px; font-weight: 600; padding: 0 8px; min-width: 84px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.pagedots { display: flex; gap: 3px; padding: 0 6px; max-width: 260px; overflow-x: auto; }
.pagedot {
  width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--border);
  background: #fff; font-size: 10px; color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto; transition: all var(--t);
  font-variant-numeric: tabular-nums;
}
.pagedot:hover { border-color: var(--accent); color: var(--accent); }
.pagedot.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pagedot.has-fields::after {
  content: ''; position: absolute; margin: 14px 0 0 12px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--pink);
}

/* Hint bar */
.hintbar {
  position: fixed; left: calc(var(--sidebar-w) + 22px); bottom: 16px; z-index: 25;
  display: flex; align-items: center; gap: 10px; max-width: min(620px, calc(100vw - var(--sidebar-w) - 60px));
  padding: 9px 13px; border-radius: 999px;
  background: rgba(15,23,42,.93); color: #fff; font-size: 12.5px;
  box-shadow: var(--sh-3); backdrop-filter: blur(8px);
  animation: hintIn .25s ease;
}
.hintbar.hidden { display: none; }
.hintbar kbd { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.28); color: #fff; }
.hintbar .hb-x { margin-left: 4px; background: none; border: 0; color: rgba(255,255,255,.6); cursor: pointer; font-size: 15px; }
.hintbar .hb-x:hover { color: #fff; }
@keyframes hintIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Text boxes ───────────────────────────────────────────────────────── */
.tb {
  position: absolute; border-radius: 3px;
  outline: 1px dashed rgba(79,70,229,.55); outline-offset: 0;
  background: rgba(79,70,229,.045);
  transition: outline-color var(--t), background var(--t);
  cursor: default;
}
.tb:hover { outline-color: var(--accent); background: rgba(79,70,229,.08); }
.tb.selected {
  outline: 2px solid var(--accent); background: rgba(79,70,229,.05);
  z-index: 5;
}
.tb.dragging { outline-color: var(--pink); background: rgba(236,72,153,.06); z-index: 6; }
.tb.editing { outline: 2px solid var(--pink); background: rgba(255,255,255,.9); z-index: 7; }

.tb-ta {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; background: transparent; resize: none;
  overflow: hidden; outline: none; color: inherit;
  white-space: pre-wrap; word-break: break-word;
  pointer-events: none;                 /* click selects the box, not the text */
  caret-color: var(--pink);
}
.tb.editing .tb-ta { pointer-events: auto; }
.tb-ta::placeholder { color: rgba(100,116,139,.55); font-style: italic; }

.tb-render {
  position: absolute; inset: 0; margin: 0; padding: 0;
  white-space: pre-wrap; word-break: break-word; pointer-events: none;
  display: none;
}
.tb.show-render .tb-ta { visibility: hidden; }
.tb.show-render .tb-render { display: block; }

/* Live substitution hint under the box */
.tb-hint {
  position: absolute; left: 0; top: 100%; margin-top: 3px;
  max-width: 320px; padding: 2px 7px; border-radius: 4px;
  background: rgba(15,23,42,.86); color: #fff; font: 500 10.5px/1.5 'Inter', system-ui, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; opacity: 0; transition: opacity var(--t);
}
.tb:hover .tb-hint, .tb.selected .tb-hint { opacity: 1; }
/* When selected, above the box belongs to the floating toolbar — so the hint
   drops below and clears the move handle instead of colliding with either. */
.tb.selected .tb-hint { margin-top: 34px; }

/* Canva-style move handle */
.tb-move {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 8px);
  display: none; align-items: center; justify-content: center; gap: 2px;
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--sh-2); cursor: grab; z-index: 3;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
}
.tb.selected .tb-move { display: flex; }
.tb-move:hover { background: var(--accent); border-color: var(--accent); box-shadow: var(--sh-3); }
.tb-move:hover .dot { background: #fff; }
.tb-move:active { cursor: grabbing; transform: translate(-50%, 8px) scale(.94); }
.tb-move .dots { display: grid; grid-template-columns: repeat(3, 3px); gap: 2.5px; }
.tb-move .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }
/* Flip above the box when it would fall off the bottom of the page */
.tb.flip-handle .tb-move { top: auto; bottom: 100%; transform: translate(-50%, -8px); }
.tb.flip-handle .tb-move:active { transform: translate(-50%, -8px) scale(.94); }
/* Handle flipped above the box, so nothing is below it to clear. */
.tb.selected.flip-handle .tb-hint { margin-top: 3px; }

/* Resize handles */
.tb-h {
  position: absolute; background: #fff; border: 1.5px solid var(--accent);
  border-radius: 2px; display: none; z-index: 4;
}
.tb.selected .tb-h { display: block; }
.tb-h.corner { width: 9px; height: 9px; border-radius: 50%; }
.tb-h[data-h=nw] { left: -5px;  top: -5px;    cursor: nwse-resize; }
.tb-h[data-h=ne] { right: -5px; top: -5px;    cursor: nesw-resize; }
.tb-h[data-h=sw] { left: -5px;  bottom: -5px; cursor: nesw-resize; }
.tb-h[data-h=se] { right: -5px; bottom: -5px; cursor: nwse-resize; }
.tb-h[data-h=w]  { left: -3.5px;  top: 50%; transform: translateY(-50%); width: 6px;  height: 18px; cursor: ew-resize; }
.tb-h[data-h=e]  { right: -3.5px; top: 50%; transform: translateY(-50%); width: 6px;  height: 18px; cursor: ew-resize; }
.tb-h[data-h=n]  { top: -3.5px;    left: 50%; transform: translateX(-50%); height: 6px; width: 18px; cursor: ns-resize; }
.tb-h[data-h=s]  { bottom: -3.5px; left: 50%; transform: translateX(-50%); height: 6px; width: 18px; cursor: ns-resize; }

/* Preview mode strips all editor chrome */
.preview .tb { outline: none !important; background: transparent !important; }
.preview .tb-move, .preview .tb-h, .preview .tb-hint { display: none !important; }
.preview .tb-ta { visibility: hidden; }
.preview .tb-render { display: block; }

/* Snap guides + marquee */
.guides { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 8; }
.guides line { stroke: var(--pink); stroke-width: 1; shape-rendering: crispEdges; }
.marquee {
  position: absolute; display: none; z-index: 9; pointer-events: none;
  border: 1px solid var(--accent); background: rgba(79,70,229,.09); border-radius: 2px;
}
.drop-ghost {
  position: absolute; display: none; z-index: 9; pointer-events: none;
  border: 2px dashed var(--accent); background: rgba(79,70,229,.10); border-radius: 3px;
}

/* Double-click-and-drag preview of a new text box */
.draw-rect {
  position: absolute; display: none; z-index: 10; pointer-events: none;
  border: 1.5px solid var(--pink); background: rgba(236,72,153,.10); border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.6);
}
.draw-rect .draw-size {
  position: absolute; left: 0; top: 100%; margin-top: 5px; white-space: nowrap;
  padding: 3px 7px; border-radius: 4px; background: var(--pink); color: #fff;
  font: 600 10.5px/1.4 'Inter', system-ui, sans-serif; font-variant-numeric: tabular-nums;
}

/* ── Floating selection toolbar ───────────────────────────────────────── */
.seltool {
  position: absolute; z-index: 35; display: none; align-items: center; gap: 3px;
  padding: 5px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--sh-3);
}
.seltool.show { display: flex; }
.seltool .sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; }
.seltool select { width: auto; padding: 5px 7px; font-size: 12.5px; }
.seltool select.fam { max-width: 132px; }
.seltool input[type=number] { width: 54px; padding: 5px 6px; font-size: 12.5px; text-align: center; }
.seltool input[type=color] { width: 28px; height: 28px; padding: 2px; }
.seltool .count {
  font-size: 11.5px; font-weight: 600; color: var(--accent-600);
  background: var(--accent-50); border-radius: 999px; padding: 3px 8px; margin-right: 2px;
}

/* ── Modals ───────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15,23,42,.55); backdrop-filter: blur(3px);
  animation: fade .14s ease;
}
.overlay.show { display: flex; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-pop);
  animation: pop .18s cubic-bezier(.16,1,.3,1);
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985) } to { opacity: 1; transform: none } }
.modal-head { padding: 20px 24px 0; }
.modal-head h2 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.01em; }
.modal-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.modal-body { padding: 18px 24px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0;
}

.opt {
  display: flex; gap: 11px; padding: 12px; margin-bottom: 8px; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: var(--r); transition: all var(--t);
}
.opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt.sel { border-color: var(--accent); background: var(--accent-50); }
.opt input { margin: 2px 0 0; accent-color: var(--accent); }
.opt .o-title { font-weight: 600; font-size: 13.5px; }
.opt .o-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.opt .o-tag {
  margin-left: auto; align-self: flex-start; font-size: 10.5px; font-weight: 700;
  background: var(--green-50); color: #047857; padding: 2px 7px; border-radius: 999px;
}

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; }
.keys h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 12.5px; }
.keys dt { justify-self: start; }
.keys dd { margin: 0; color: var(--text-2); }

/* Progress */
.prog { display: none; }
.prog.show { display: block; }
.prog-track { height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.prog-bar {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transition: width .12s linear;
}
.prog-text {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: 7px;
  font-variant-numeric: tabular-nums;
}

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 9px; max-width: 400px;
  padding: 11px 15px; border-radius: var(--r); font-size: 13px;
  background: #0f172a; color: #fff; box-shadow: var(--sh-3);
  animation: toastIn .22s cubic-bezier(.16,1,.3,1);
}
.toast.out { animation: toastOut .18s ease forwards; }
.toast.ok    { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warn  { background: #92400e; }
.toast .ic { align-self: flex-start; margin-top: 2px; }
.toast a { color: #93c5fd; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px) } }

/* Global file-drop overlay */
.dropveil {
  position: fixed; inset: 0; z-index: 150; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  background: rgba(79,70,229,.14); backdrop-filter: blur(4px);
  border: 4px dashed var(--accent); font-size: 19px; font-weight: 600; color: var(--accent-600);
}
.dropveil.show { display: flex; }
.dropveil .dv-ico { color: var(--accent); }

.spinner {
  display: inline-block; flex: 0 0 auto;
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Small-screen notice ──────────────────────────────────────────────────
   Shown on a narrow viewport, or on a coarse (touch) primary pointer at any
   size a phone or tablet is likely to be. Deliberately dismissible — it is
   advice, not a wall. */
.mobile-gate {
  position: fixed; inset: 0; z-index: 300; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 13px; padding: 34px 26px; text-align: center; background: var(--surface);
}
.mobile-gate .mg-icon { color: var(--accent); margin-bottom: 2px; }
.mobile-gate h2 { margin: 0; font-size: 21px; letter-spacing: -.015em; }
.mobile-gate p { margin: 0; max-width: 36ch; color: var(--text-2); font-size: 14px; }
.mobile-gate .mg-list {
  margin: 4px 0 6px; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 11px; max-width: 38ch; text-align: left;
}
.mobile-gate .mg-list li { display: flex; gap: 11px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); }
.mobile-gate .mg-list .ic { color: var(--text-3); margin-top: 2px; }
.mobile-gate .mg-actions { display: flex; gap: 9px; margin-top: 4px; }
.mobile-gate .btn { padding: 10px 18px; font-size: 14px; }

@media (max-width: 820px), (pointer: coarse) and (max-width: 1180px) {
  html:not(.mobile-ok) .mobile-gate { display: flex; }
}

.zoomctl {
  display: flex; align-items: center; gap: 2px; padding: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.zoomctl .zval {
  font-size: 12px; font-weight: 600; min-width: 46px; text-align: center; color: var(--text-2);
  font-variant-numeric: tabular-nums; cursor: pointer; user-select: none;
}

@media (max-width: 1180px) {
  .steps li span.lbl { display: none; }
  .steps li { padding: 5px 6px; }
}
@media (max-width: 900px) {
  .body { flex-direction: column; }
  .sidebar { width: 100%; max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .hintbar { left: 12px; right: 12px; max-width: none; }
  .steps { display: none; }
}

/* Narrow screens: collapse the top bar to icons so its content fits the
   viewport. Measured at 390px the full bar is 503px wide, which made the
   document wider than the screen; this brings it to roughly 230px. Labels are
   in .lbl spans purely so they can be dropped here — the title/aria-label on
   each control still says what it does. */
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand .brand-name { display: none; }
  .topbar .zoomctl { display: none; }
  .topbar-right { gap: 6px; }
  .topbar .btn .lbl { display: none; }
  .topbar .btn { padding: 8px 10px; }
  .topbar .btn.primary { padding: 8px 13px; }

  /* Toasts move to the top so they stop piling on top of the hint bar —
     there isn't room for both at the bottom of a phone screen. */
  .toasts { top: calc(var(--topbar-h) + 8px); bottom: auto; left: 10px; right: 10px; align-items: stretch; }
  .toast { max-width: none; animation: toastInTop .22s cubic-bezier(.16,1,.3,1); }
  .toast.out { animation: toastOutTop .18s ease forwards; }
  .hintbar { bottom: 10px; }
}
@keyframes toastInTop  { from { opacity: 0; transform: translateY(-14px) } to { opacity: 1; transform: none } }
@keyframes toastOutTop { to { opacity: 0; transform: translateY(-14px) } }
