/* BridgeBack. Neutral chrome so image colors read true; prepress cyan as the single accent. */

:root {
  --ground: #eceef1;
  --surface: #f8f9fa;
  --raised: #ffffff;
  --stage: #d5d8dc;
  --ink: #14171b;
  --ink-2: #4c545d;
  --ink-3: #5e6670;
  --line: #d0d5da;
  --line-2: #e1e4e8;
  --accent: #086f91;
  --accent-hover: #065c78;
  --accent-soft: #dbeff6;
  --accent-ink: #ffffff;
  --warn: #9a5b00;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --shadow: 0 10px 30px -12px rgba(20, 30, 40, .35), 0 2px 6px rgba(20, 30, 40, .08);
  --ui: "Schibsted Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 7px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #111316;
    --surface: #171a1e;
    --raised: #1e2227;
    --stage: #0b0c0e;
    --ink: #e7eaed;
    --ink-2: #a3acb6;
    --ink-3: #8b95a0;
    --line: #2b3036;
    --line-2: #22262b;
    --accent: #3cb8de;
    --accent-hover: #62c8e7;
    --accent-soft: #10303d;
    --accent-ink: #03161d;
    --warn: #f0b35a;
    --shadow: 0 14px 40px -12px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #111316;
  --surface: #171a1e;
  --raised: #1e2227;
  --stage: #0b0c0e;
  --ink: #e7eaed;
  --ink-2: #a3acb6;
  --ink-3: #8b95a0;
  --line: #2b3036;
  --line-2: #22262b;
  --accent: #3cb8de;
  --accent-hover: #62c8e7;
  --accent-soft: #10303d;
  --accent-ink: #03161d;
  --warn: #f0b35a;
  --shadow: 0 14px 40px -12px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 13.5px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .01em; }
.dim { color: var(--ink-3); }
.small { font-size: 10.5px; }

/* ---------- frame ---------- */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 356px;
  grid-template-rows: 52px minmax(0, 1fr);
  grid-template-areas: "top top top" "rail stage panel";
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 6px; flex: none; }
.mark { width: 22px; height: 22px; color: var(--accent); }
.wordmark { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.wordmark b { font-weight: 700; color: var(--accent); }
.top-group { display: flex; align-items: center; gap: 4px; padding-left: 12px; border-left: 1px solid var(--line-2); }
.top-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--raised);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.primary, .btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover, .btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn .kbd { font-family: var(--mono); font-size: 10px; opacity: .92; font-weight: 400; }
#btn-handoff { min-width: 15.5rem; justify-content: center; }
#handoff-label { overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--line-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.ico { display: inline-grid; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; }
.icon-btn.sm .ico { width: 16px; height: 16px; }
.qmark { font-weight: 700; font-size: 14px; }

.link { border: 0; background: none; padding: 4px 2px; min-height: 24px; color: var(--accent); font-weight: 500; font-size: 12.5px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
input, textarea { caret-color: var(--accent); }
* { scrollbar-color: color-mix(in srgb, var(--ink-3) 55%, transparent) transparent; }
details.more { border-top: 1px solid var(--line-2); padding-top: 12px; }
details.more > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px; color: var(--ink-2); padding-block: 2px;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s ease;
}
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > summary .val { margin-left: auto; }
details.more[open] > summary { margin-bottom: 12px; }
.warn-line {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0;
  padding: 9px 12px; border-radius: 8px; font-size: 12.5px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--ink);
}
.warn-line .link { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { text-decoration: underline; }

/* ---------- tool rail ---------- */

.toolrail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-block: 8px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  scrollbar-width: thin;
}
.tool {
  position: relative;
  flex: none;
  width: 54px;
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
}
.tool .ico { width: 19px; height: 19px; }
.tool-name { font-size: 10.5px; font-weight: 500; line-height: 1; letter-spacing: .01em; }
.tool:hover { background: var(--line-2); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tool[aria-pressed="true"] .tool-name { font-weight: 600; }
.tool-key { display: none; }
.tool-sep { flex: none; width: 30px; height: 1px; margin-block: 4px; background: var(--line); }

/* ---------- stage ---------- */

.stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--stage);
  min-height: 0;
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.toolopts {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  z-index: 2;
  flex-wrap: wrap;
  justify-content: center;
}
.opt-hint { color: var(--ink-2); font-size: 12.5px; padding-inline: 4px; }
.toolopts .slider.compact { width: 170px; gap: 0; }
.toolopts .slider.compact .slider-head { margin-bottom: -2px; }

.stage-foot {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 2;
}
.stage-foot > * { pointer-events: auto; }
.foot-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rounds-btn {
  flex: none;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  font-variant-numeric: tabular-nums;
}
.rounds-btn .ico { width: 15px; height: 15px; }
.rounds-btn.has-history { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.docinfo {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 5px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  font-size: 12px;
}
.docname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28ch; }
.docinfo .dim { white-space: nowrap; }
.zoom {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
}
.zoom button {
  height: 26px; min-width: 26px; padding: 0 7px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2);
}
.zoom button:hover { background: var(--line-2); color: var(--ink); }
#zoom-level { font-family: var(--mono); font-size: 11px; min-width: 52px; font-variant-numeric: tabular-nums; }

.compare-flag {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 12px; border-radius: 99px;
  background: var(--ink); color: var(--surface);
  font: 500 10.5px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  z-index: 3;
  white-space: nowrap;
}
.compare-flag:not(:has(.flag-btn)) { padding-right: 12px; }
.flag-btn {
  border: 0; border-radius: 99px; padding: 3px 10px;
  background: color-mix(in srgb, var(--surface) 18%, transparent); color: var(--surface);
  font: 600 11px/1.4 var(--ui); letter-spacing: 0; text-transform: none;
}
.flag-btn:hover { background: color-mix(in srgb, var(--surface) 30%, transparent); }

.dropzone {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  pointer-events: none;
}
.dropzone div {
  padding: 18px 26px; border-radius: 14px;
  border: 2px dashed var(--accent);
  background: var(--surface);
  font-weight: 600; font-size: 16px;
  box-shadow: var(--shadow);
}

.empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; z-index: 1;
}
.empty h2 { margin: 0 0 6px; font-size: 20px; text-wrap: balance; }
.empty p { margin: 0 0 16px; color: var(--ink-2); }
.empty .row { justify-content: center; }

/* ---------- panel ---------- */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tabs [role=tab] {
  position: relative;
  height: 36px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tabs [role=tab]:hover { color: var(--ink); }
.tabs [role=tab][aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs [role=tab][aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent);
}
.count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--line-2); color: var(--ink-2);
  font: 500 10px/18px var(--mono); text-align: center; font-variant-numeric: tabular-nums;
}
.tabpanel {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.help { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; max-width: 60ch; }
.help.pad { padding: 4px 2px; }
.warn { margin: 0; color: var(--warn); font-size: 12.5px; }

.group { display: flex; flex-direction: column; gap: 12px; border: 0; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--line-2); min-width: 0; }
.group.is-muted { opacity: .45; }
.group-label, .field-label {
  font: 500 10px/1.3 var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0;
}
legend.group-label { float: left; width: 100%; margin-bottom: 2px; }
legend.group-label + * { clear: both; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

select, textarea, input[type=text] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--raised);
  padding: 7px 9px;
}
select { height: 34px; padding-block: 0; }
textarea { resize: vertical; line-height: 1.45; min-height: 64px; }
textarea::placeholder { color: var(--ink-3); }
select:hover, textarea:hover { border-color: var(--ink-3); }

input[type=color] {
  width: 38px; height: 28px; padding: 2px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--raised);
}
input[type=color]:disabled { opacity: .4; }

.selects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sliders.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.seg.wrap { flex-wrap: wrap; }
.selects .field:first-child { grid-column: 1 / -1; }

.checks { display: flex; flex-direction: column; gap: 10px; }
.checks.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.35; }
.check input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--line-2); border-radius: 8px;
}
.seg-btn {
  height: 28px; padding: 0 11px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2); font-weight: 500; font-size: 12.5px;
}
.seg-btn[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 26px; padding: 0 9px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 12px;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }

.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font: 500 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}

/* ---------- sliders ---------- */

.sliders { display: flex; flex-direction: column; gap: 14px; }
.slider { display: flex; flex-direction: column; gap: 3px; position: relative; }
.slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; cursor: default; user-select: none; }
.slider-head label { font-weight: 500; font-size: 13px; }
.val { font: 500 11px/1 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.slider.is-set .val { color: var(--accent); }
.ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: -1px; }

input[type=range] {
  --a: 50%; --b: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--line) 0 var(--a), var(--accent) var(--a) var(--b), var(--line) var(--b) 100%);
}
input[type=range]::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--line) 0 var(--a), var(--accent) var(--a) var(--b), var(--line) var(--b) 100%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -5.5px; border-radius: 50%;
  background: var(--raised); border: 2px solid var(--ink-2);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
input[type=range]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--raised); border: 2px solid var(--ink-2);
}
.slider.is-set input[type=range]::-webkit-slider-thumb { border-color: var(--accent); }
.slider.is-set input[type=range]::-moz-range-thumb { border-color: var(--accent); }
input[type=range]:focus-visible { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: var(--focus); }

/* ---------- regions ---------- */

.num {
  --c: var(--accent);
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #fff;
  font: 600 11px/1 var(--mono);
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.75);
}
.num.lg { width: 26px; height: 26px; font-size: 12px; }
.num.off { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--line); }
.tag.sm { height: 16px; padding: 0 6px; font-size: 8.5px; margin-left: 6px; vertical-align: 1px; }
.tag.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.banner {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.banner p { margin: 0; }
.banner > p:first-child { font-weight: 600; }
.help.warnish { color: var(--warn); }

.region-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.region-item {
  display: flex; align-items: center; gap: 2px;
  border-radius: 9px; border: 1px solid transparent;
  padding-right: 4px;
}
.region-item:hover { background: var(--line-2); }
.region-item.is-selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.region-item.is-off .region-sum { text-decoration: line-through; color: var(--ink-3); }
.region-pick {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  border: 0; background: none; text-align: left; padding: 7px 8px;
}
.region-text { display: flex; flex-direction: column; min-width: 0; }
.region-kind { font: 500 9.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.region-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }

.region-editor { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.editor-head { display: flex; align-items: center; gap: 10px; }
.editor-head h3 { margin: 0; font-size: 15px; flex: 1; }
.num-row { display: flex; gap: 3px; flex-wrap: wrap; max-width: 50%; }
.empty .row { flex-wrap: wrap; }
#empty-resume { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; }
.empty-note { padding: 16px; border: 1px dashed var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.empty-note p { margin: 0; }

/* ---------- handoff ---------- */

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: s; }
.step {
  display: grid;
  grid-template-columns: 22px 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
}
.step.is-done { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.step-n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font: 500 10.5px/1 var(--mono); color: var(--ink-2);
}
.step.is-done .step-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.thumb {
  width: 64px; height: 44px; object-fit: contain; border-radius: 5px;
  background: var(--stage);
  display: grid; place-items: center;
}
canvas.thumb { display: block; }
.thumb.text { font: 600 15px/1 var(--ui); color: var(--ink-3); border: 1px dashed var(--line); background: transparent; }
.step-label { font-weight: 600; font-size: 13px; }
.step-sub { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.prompt-head { display: flex; align-items: center; gap: 8px; }
.prompt-head .field-label { margin-right: auto; }
textarea.prompt {
  font: 400 11.5px/1.6 var(--mono);
  min-height: 220px;
  background: var(--ground);
  white-space: pre-wrap;
}
.row.wrap { flex-wrap: wrap; }

/* ---------- popovers, toasts, help ---------- */

.popover {
  position: fixed; z-index: 40; width: 328px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.pop-head { font: 500 10px/1.3 var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); padding: 4px 4px 0; }
.pop-foot { display: flex; justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--line-2); }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.recent { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.recent:hover { background: var(--line-2); }
.recent.is-current { background: var(--accent-soft); }
.recent-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px; text-align: left; }
.recent-open img, .thumb-empty { width: 56px; height: 40px; object-fit: cover; border-radius: 5px; background: var(--stage); flex: none; }
.thumb-empty.current { display: grid; place-items: center; font: 600 13px/1 var(--mono); color: var(--accent); background: var(--accent-soft); }
.handoff-bar { display: flex; align-items: center; gap: 6px; }
.empty-tour { margin-top: 14px !important; }
.opt-hint.busy::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.recent-text { display: flex; flex-direction: column; min-width: 0; }
.recent-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-when { color: var(--ink-3); font-size: 11.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60;
  max-width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  background: var(--ink); color: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast .btn { background: transparent; color: var(--surface); border-color: color-mix(in srgb, var(--surface) 40%, transparent); }

.overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(8, 10, 12, .45); }
.sheet {
  width: min(560px, 100%); max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 20px 22px;
}
.sheet.wide { width: min(860px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.preview-step { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.preview-step:first-child { border-top: 0; padding-top: 0; }
.preview-head { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.preview-img { display: block; width: 100%; height: auto; max-height: 62vh; object-fit: contain; border-radius: 8px; background: var(--stage); }
.preview-prompt {
  margin: 0; padding: 12px 14px; border-radius: 8px; max-height: 40vh; overflow: auto;
  background: var(--ground); border: 1px solid var(--line-2);
  font: 400 11.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word;
}

/* ---------- tour ---------- */

.tour { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.tour-spot {
  position: fixed; border-radius: 12px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(8, 10, 12, .55);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.tour-card {
  position: fixed; pointer-events: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: left .25s ease, top .25s ease;
}
.tour-count { font: 500 11px/1.3 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tour-title { margin: 0; font-size: 16px; font-weight: 700; text-wrap: balance; }
.tour-text { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.tour-actions .spacer { flex: 1; }
.sheet h2 { margin: 0; font-size: 17px; }
.sheet p { color: var(--ink-2); margin: 0 0 14px; max-width: 60ch; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.keys dt { text-align: right; white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-2); }
kbd {
  display: inline-block; min-width: 20px; padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--raised);
  font: 500 10.5px/1.3 var(--mono); text-align: center;
}

/* ---------- narrow screens ---------- */

@media (max-width: 1100px) {
  .app { grid-template-columns: 64px minmax(0, 1fr) 316px; }
  .btn .kbd { display: none; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .app {
    height: auto;
    min-height: 100%;
    padding-inline: 16px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto max(55vh, 300px) auto;
    grid-template-areas: "top" "rail" "stage" "panel";
    gap: 10px;
  }
  .topbar {
    flex-wrap: wrap; padding: 10px 0; row-gap: 8px; background: transparent; border-bottom: 0;
  }
  .top-group { border-left: 0; padding-left: 0; }
  .top-end { margin-left: auto; }
  #btn-compare { padding-inline: 10px; }
  .toolrail {
    flex-direction: row; justify-content: flex-start; overflow-x: auto; overflow-y: hidden;
    padding: 4px; border: 1px solid var(--line); border-radius: 10px;
  }
  .tool-sep { width: 1px; height: 30px; margin: 0 4px; }
  .handoff-bar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
  }
  .handoff-bar #btn-handoff { flex: 1; min-width: 0; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .sliders.two { grid-template-columns: 1fr; }
  .preview-head { position: sticky; top: -20px; z-index: 1; background: var(--surface); padding-block: 6px; }
  .stage { border-radius: 12px; border: 1px solid var(--line); }
  .panel { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 84px; }
  .tabpanel { overflow: visible; padding-inline: 14px; }
  .toolopts { top: 8px; font-size: 12px; padding: 4px 6px; }
  .toolopts .seg + .opt-hint { display: none; }
  .docinfo .dim:last-child { display: none; }
  .foot-left .docinfo { display: none; }
}

@media (max-width: 520px) {
  .wordmark { font-size: 14.5px; }
  #btn-recent, #btn-help { display: none; }
  .selects { grid-template-columns: 1fr; }
  .checks.two { grid-template-columns: 1fr; }
  .step { grid-template-columns: 22px 52px minmax(0, 1fr) auto; }
  .thumb { width: 52px; height: 38px; }
}

/* ---------- touch screens: bigger targets ---------- */

@media (pointer: coarse) {
  .btn, .btn.sm { min-height: 44px; }
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .tool { width: 58px; height: 52px; }
  .seg-btn { height: 44px; min-width: 44px; }
  .tabs [role=tab] { height: 44px; }
  .chip { height: 38px; padding-inline: 12px; }
  .zoom button { height: 44px; min-width: 44px; }
  .link { min-height: 44px; }
  .region-pick { padding-block: 10px; }
  input[type=range] { height: 44px; }
  input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }
  input[type=range]::-moz-range-thumb { width: 18px; height: 18px; }
  .check input { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
