/* ══════════════════════════════════════════════════════════════════
   Barova — Precision Barcode Studio
   UI stylesheet · light "Porcelain" / dark "Nocturne"
   ══════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  --font-ui: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
             "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", "Consolas", "Liberation Mono", monospace;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, "Malgun Gothic", sans-serif;

  --bg: #f4f2ee;
  --bg-2: #efece6;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f3f0ea;
  --ink: #1a1814;
  --ink-2: #3d3932;
  --muted: #7b756a;
  --faint: #a49d90;
  --line: #e6e1d8;
  --line-2: #d8d2c6;

  --accent: #8c6b3f;
  --accent-2: #a9814f;
  --accent-soft: #f3ebdd;
  --accent-ink: #6f5330;
  --accent-ring: rgba(140, 107, 63, .18);

  --ok: #2e6b50;
  --ok-soft: #e8f1eb;
  --warn: #95640f;
  --warn-soft: #fbf1dd;
  --bad: #a53a2b;
  --bad-soft: #fbe9e6;

  --primary-bg: #1a1814;
  --primary-ink: #fbf9f5;

  --stage-bg: #efede7;
  --dot: #dcd6ca;
  --paper: #ffffff;
  --checker: #f0ede7;

  --shadow-sm: 0 1px 2px rgba(26, 24, 20, .05);
  --shadow-md: 0 1px 2px rgba(26, 24, 20, .04), 0 10px 30px -12px rgba(26, 24, 20, .16);
  --shadow-lg: 0 28px 70px -24px rgba(26, 24, 20, .32), 0 2px 8px rgba(26, 24, 20, .06);

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;

  --left-w: 312px;
  --right-w: 356px;
  --gap: 14px;
  --top-h: 58px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d0d0e;
  --bg-2: #111113;
  --surface: #161618;
  --surface-2: #1b1b1e;
  --surface-3: #222226;
  --ink: #f2efe9;
  --ink-2: #cfc9be;
  --muted: #979186;
  --faint: #6c675e;
  --line: #28282c;
  --line-2: #3a3a40;

  --accent: #cba971;
  --accent-2: #ddbe8a;
  --accent-soft: #2a2418;
  --accent-ink: #e3c896;
  --accent-ring: rgba(203, 169, 113, .2);

  --ok: #7cc79e;
  --ok-soft: #16261e;
  --warn: #e0b269;
  --warn-soft: #2a2317;
  --bad: #e38a7b;
  --bad-soft: #2c1b18;

  --primary-bg: #e9d7b4;
  --primary-ink: #1a1509;

  --stage-bg: #101012;
  --dot: #232327;
  --checker: #1a1a1c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -18px rgba(0, 0, 0, .7);
  --shadow-lg: 0 34px 90px -26px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .04);
}

/* ───────────── reset ───────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[data-theme="dark"] body { background: var(--bg); }
h1, h2, h3, p, dl, dd, dt, ul, li, figure { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
input[type="color"]:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon .fill, symbol .fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; border: 3px solid transparent; }

/* ───────────── app shell ───────────── */
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  background:
    radial-gradient(1100px 520px at 4% -12%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
    var(--bg);
}

/* ───────────── top bar ───────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  position: relative;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 6px; }
.logo { width: 32px; height: 32px; display: block; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.logo svg { width: 100%; height: 100%; display: block; }
.logo-bg { fill: var(--ink); }
.logo-bar { fill: var(--surface); }
.logo-accent { fill: var(--accent); }
[data-theme="dark"] .logo-bg { fill: #f2efe9; }
[data-theme="dark"] .logo-bar { fill: #161618; }
[data-theme="dark"] .logo-accent { fill: #a9814f; }
.brand-text { display: flex; flex-direction: column; line-height: 1.06; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -.015em;
}
.brand-text small {
  font-size: 11px;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.command {
  flex: 1;
  max-width: 420px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--faint);
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.command:hover { border-color: var(--line-2); background: var(--surface); box-shadow: var(--shadow-sm); }
.command .icon { color: var(--faint); }
.command-text { flex: 1; text-align: left; font-size: 12.5px; }
.command kbd { flex: none; }

kbd {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.vsep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; flex: none; }

.fmt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
  transition: all .16s;
}
.fmt-chip:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface); }
.fmt-chip .icon { width: 14px; height: 14px; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn .icon { width: 17px; height: 17px; }
.theme-sun { display: none; }
[data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, filter .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .icon { width: 15px; height: 15px; }
.btn.primary {
  background: var(--primary-bg);
  color: var(--primary-ink);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--primary-bg); border-color: transparent; }
.btn.primary kbd { background: color-mix(in srgb, var(--primary-ink) 14%, transparent); color: inherit; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { height: 30px; padding: 0 11px; font-size: 11.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.danger-text { color: var(--bad); }
.topbar .btn.primary { height: 34px; padding: 0 14px; }

/* ───────────── workspace ───────────── */
.workspace {
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  gap: var(--gap);
  padding: var(--gap);
  min-height: 0;
}
.column { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.column.left { overflow-y: auto; padding-right: 2px; margin-right: -2px; }
.column.right { gap: 8px; }

/* ───────────── cards / left column ───────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-note { font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }
.text-btn {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-ink);
  padding: 2px 4px;
  border-radius: 5px;
  transition: background .15s;
}
.text-btn:hover { background: var(--accent-soft); }

/* symbology picker */
.picker { position: relative; }
.picker-btn {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.picker-btn:hover { border-color: var(--line-2); background: var(--surface); }
.picker-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.picker-mark {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
[data-theme="dark"] .picker-mark { background: var(--surface-3); color: var(--accent); border: 1px solid var(--line-2); }
.picker-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.picker-text b { font-size: 13.5px; font-weight: 650; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-text small { font-size: 11.5px; color: var(--faint); letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-btn .chev { color: var(--faint); transition: transform .18s; }
.picker-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.picker-hint { margin-top: 8px; }

.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  max-height: min(420px, 62vh);
  animation: pop-in .14s ease-out;
}
.pop-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  color: var(--faint);
  border-radius: 8px;
  transition: background .15s, border-color .15s;
}
.pop-search:focus-within { background: var(--surface-2); border-bottom-color: var(--accent); }
.pop-search input:focus-visible { outline: none; }
.pop-search input {
  flex: 1;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
}
.pop-search input::placeholder { color: var(--faint); }
.pop-list { overflow-y: auto; min-height: 0; padding: 2px; }
.sym-group {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 8px 4px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.sym-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
  color: var(--ink);
  transition: background .12s;
}
.sym-item:hover, .sym-item.is-cursor { background: var(--surface-3); }
.sym-item.is-active { background: var(--accent-soft); }
.sym-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sym-item-main b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sym-item-main small { font-size: 11.5px; color: var(--faint); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sym-item .tick { color: var(--accent); width: 14px; height: 14px; opacity: 0; }
.sym-item.is-active .tick { opacity: 1; }
.pop-empty { padding: 18px 10px; text-align: center; color: var(--faint); font-size: 12px; }

/* data */
.input-wrap { position: relative; }
.data-input {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: .03em;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.data-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.data-input.is-error { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 14%, transparent); }
.input-x {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--faint);
  transition: background .15s, color .15s;
}
.input-x:hover { background: var(--surface-3); color: var(--ink); }
.input-x .icon { width: 13px; height: 13px; }
.data-meta { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.data-ok { margin-left: auto; color: var(--ok); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-top: 10px; }
.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
}
.field em { font-style: normal; font-weight: 500; color: var(--faint); font-size: 11.5px; letter-spacing: .02em; }
.field > span label { cursor: pointer; }
.stepper { position: relative; width: 100%; display: flex; }
.stepper > input[type="number"] { width: 100%; padding-right: 30px; }
.stepper-btns {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 20px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.step-btn {
  flex: 1;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  transition: background .12s, color .12s, transform .08s;
}
.step-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.step-btn:active { transform: translateY(.5px); }
.step-btn .icon { width: 10px; height: 10px; stroke-width: 2.2; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type="text"]:hover, input[type="number"]:hover, select:hover { border-color: var(--line-2); }
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input::placeholder { color: var(--faint); }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b857a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 13px;
}

.msg { min-height: 16px; margin-top: 8px; font-size: 11.5px; line-height: 1.4; color: var(--bad); }
.msg.ok { color: var(--ok); }
.msg:empty { margin-top: 2px; }

.facts { display: flex; flex-direction: column; margin-top: 10px; border-top: 1px solid var(--line); }
.facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dt { font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }
.facts dd { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

/* guide */
.guide { padding: 0; overflow: hidden; }
.guide summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.guide summary::-webkit-details-marker { display: none; }
.guide-ico {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  flex: none;
}
.guide-ico .icon { width: 13px; height: 13px; }
.guide-title { flex: 1; font-size: 11.5px; font-weight: 650; color: var(--ink-2); }
.guide summary .chev { color: var(--faint); transition: transform .18s; }
.guide[open] summary .chev { transform: rotate(180deg); }
.guide-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.guide-body > p { margin-top: 11px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.guide-sample { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.guide-sample span { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--faint); text-transform: uppercase; }
.guide-sample code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 4px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guide-facts { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.guide-facts > div { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; }
.guide-facts dt { color: var(--faint); }
.guide-facts dd { color: var(--ink-2); font-family: var(--font-mono); text-align: right; overflow-wrap: anywhere; }

/* quick start */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.quick-chip:hover { border-color: var(--accent); background: var(--surface); }
.quick-chip:active { transform: translateY(.5px); }
.quick-chip b { font-size: 11.5px; font-weight: 600; letter-spacing: -.005em; }
.quick-chip small { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--faint); }
.quick-chip.is-active { border-color: var(--accent); background: var(--accent-soft); }
.quick-chip.is-active small { color: var(--accent-ink); }

.left-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 2px; flex: none; }.left-actions .btn { flex: 1; height: 38px; font-size: 12px; background: var(--surface); }
.left-actions .btn .icon { width: 14px; height: 14px; color: var(--muted); }

/* ───────────── stage ───────────── */
.stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-height: 60px;
}
.stage-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.badge {
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 2.5px 7px;
  border-radius: 99px;
  white-space: nowrap;
}
.stage-id h1 {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.zoom-group { display: flex; align-items: center; gap: 1px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--surface-2); }
.zoom-label {
  min-width: 46px;
  height: 26px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  transition: background .15s;
}
.zoom-label:hover { background: var(--surface-3); }
.tool {
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 5px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.tool:hover { background: var(--surface-3); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.tool .icon { width: 15px; height: 15px; }
.tool b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tool.wide { padding: 0 8px; font-size: 11.5px; letter-spacing: .02em; }

.stage-scroll {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  padding: 58px 52px;
  overflow: auto;
  background-color: var(--stage-bg);
  background-image: radial-gradient(circle, var(--dot) .8px, transparent .8px);
  background-size: 18px 18px;
  background-position: center;
}
.paper-wrap { position: relative; display: block; flex: none; margin: auto; }
.paper {
  position: relative;
  line-height: 0;
  border-radius: 2px;
  overflow: hidden;
  background-color: var(--paper);
  background-image:
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%),
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08), 0 16px 34px -14px rgba(26, 24, 20, .38), 0 0 0 1px rgba(0, 0, 0, .04);
}
#cv { display: block; }
[data-theme="dark"] .paper {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .5), 0 22px 50px -18px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
}

/* dimension labels */
.dim {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dim-top { top: -27px; left: 0; right: 0; justify-content: center; }
.dim-top i { display: block; height: 1px; width: 22px; background: var(--line-2); }
.dim-left { left: -25px; top: 0; bottom: 0; flex-direction: column; justify-content: center; }
.dim-left::before, .dim-left::after { content: ""; display: block; width: 1px; flex: 1; max-height: 40px; background: var(--line-2); }
.dim-left span { writing-mode: vertical-rl; transform: rotate(180deg); }

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  background: color-mix(in srgb, var(--stage-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.empty-ico {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bad-soft);
  color: var(--bad);
  margin-bottom: 4px;
}
.empty-ico .icon { width: 20px; height: 20px; }
.stage-empty b { font-size: 14px; }
.stage-empty p { font-size: 12px; color: var(--muted); max-width: 340px; }

.stage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.foot-metrics { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.foot-metrics > div { display: flex; align-items: baseline; gap: 6px; }
.foot-metrics span { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.foot-metrics b { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bg-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 2px 7px;
  white-space: nowrap;
}

.safety {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 4px 0 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s;
}
.safety:hover { background: var(--surface-3); }
.safety .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--faint) 16%, transparent); }
.safety.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent); }
.safety.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.safety.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.safety.ok span { color: var(--ok); }
.safety.warn span { color: var(--warn); }
.safety.bad span { color: var(--bad); }
.safety .icon { width: 12px; height: 12px; color: var(--faint); }

/* ───────────── inspector ───────────── */
.inspector {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.tabs {
  display: flex;
  gap: 2px;
  margin: 10px 10px 0;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  flex: none;
}
.tab {
  flex: 1;
  height: 28px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .16s, color .16s, box-shadow .16s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 .5px rgba(0, 0, 0, .04); }
.tab-panels { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.tab-panel { display: flex; flex-direction: column; animation: fade-in .18s ease; }
.panel-note {
  margin-top: 9px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.group-head h3 { font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.value-chip {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.unit-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; text-transform: uppercase; }
.divider { height: 1px; background: var(--line); margin: 16px 0 14px; }
.hint { font-size: 11.5px; line-height: 1.55; color: var(--faint); margin-top: 8px; }
.hint b { color: var(--muted); font-weight: 600; }
.warn-note { color: color-mix(in srgb, var(--warn) 85%, var(--muted)); }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; }
.range-row .num { width: 62px; height: 30px; text-align: center; padding: 0 4px; flex: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: var(--line-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  transition: transform .1s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.1); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: var(--line-2); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  cursor: pointer;
}
.switch-row > span { display: flex; flex-direction: column; gap: 1px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.switch-row small { font-size: 11.5px; font-weight: 400; color: var(--faint); line-height: 1.4; }
.switch-row code { font-family: var(--font-mono); font-size: .95em; color: var(--muted); }
.switch {
  appearance: none;
  width: 36px;
  height: 21px;
  border-radius: 99px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background .18s;
  border: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s cubic-bezier(.2, .8, .3, 1.2);
}
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(15px); background: var(--surface); }
[data-theme="dark"] .switch:checked::after { background: #161618; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field-grid .field { margin-top: 10px; }
.field.span2 { grid-column: 1 / -1; }

.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin-top: 12px; }
.toggle-grid.two { grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; letter-spacing: -.002em; }
.check.mb { margin: 8px 0 2px; }
.check input {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1.4px solid var(--line-2);
  border-radius: 4.5px;
  background: var(--surface-2);
  flex: none;
  display: grid;
  place-items: center;
  transition: background .14s, border-color .14s;
  cursor: pointer;
}
.check input:hover { border-color: var(--faint); }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.8px solid var(--surface);
  border-bottom: 1.8px solid var(--surface);
  transform: rotate(-45deg) translate(.5px, -1px);
}
[data-theme="dark"] .check input:checked::after { border-color: #161618; }

.type-preview {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
  text-align: center;
  font-size: 17px;
  letter-spacing: .12em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* colour panel */
.color-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.color-card:hover { border-color: var(--line-2); }
.color-card.is-active { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, .12);
  flex: none;
  background-color: #000;
  background-size: 10px 10px;
}
.color-card-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.color-card-text b { font-size: 11.5px; font-weight: 650; }
.color-card-text small { font-family: var(--font-mono); font-size: 11px; color: var(--faint); text-transform: uppercase; }

.slider-rows { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.slider-row { display: grid; grid-template-columns: 16px 1fr 52px; align-items: center; gap: 8px; }
.slider-row > label { font-size: 11.5px; font-weight: 700; color: var(--faint); letter-spacing: .04em; }
.slider-row input[type="range"] { width: 100%; }
.slider-row input[type="number"] { height: 27px; padding: 0 4px; text-align: center; font-size: 11px; }

.picker-row { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.picker-row > span { font-size: 11.5px; font-weight: 600; color: var(--muted); flex: 1; }
.picker-row input[type="color"] {
  width: 42px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}
.picker-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.picker-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.picker-row code { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); width: 64px; text-align: right; }

input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
input:disabled:hover, select:disabled:hover { border-color: var(--line); }

.preset-swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 11px 16px; }
.preset-swatches button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .15);
  box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 1px var(--line);
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.preset-swatches button:hover { transform: translateY(-1px) scale(1.06); box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 1.5px var(--accent); }

.contrast-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px; }
.contrast-head { display: flex; align-items: baseline; justify-content: space-between; }
.contrast-head span { font-size: 11.5px; font-weight: 650; letter-spacing: .04em; color: var(--muted); }
.contrast-head b { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.contrast-track { height: 5px; border-radius: 99px; background: var(--line); margin: 8px 0 9px; overflow: hidden; }
.contrast-track i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--ok); transition: width .25s, background .25s; }
.contrast-card p { margin: 0; font-size: 11.5px; }

.inline-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* output panel */
.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.format-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
}
.format-card:hover { border-color: var(--line-2); background: var(--surface); }
.format-card.is-active { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
.format-card b { font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.format-card small { font-size: 11px; color: var(--faint); }
.format-card.is-active b { color: var(--accent-ink); }

.file-preview {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.file-preview span { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.file-preview code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.output-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.output-actions .btn { height: 38px; }

.link-list { display: flex; flex-direction: column; }
.link-list button {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 4px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: left;
  transition: background .14s, color .14s;
}
.link-list button:hover { background: var(--surface-3); color: var(--ink); }
.link-list button > span { flex: 1; }
.link-list button .icon { width: 14px; height: 14px; color: var(--faint); }
.link-list button .chev { width: 12px; height: 12px; opacity: .6; }
.link-list button.danger-text { color: var(--bad); }
.link-list button.danger-text .icon { color: var(--bad); }

.engine-note { flex: none; text-align: center; font-size: 11px; letter-spacing: .02em; color: var(--faint); padding: 1px 0 2px; }

/* ───────────── dialogs ───────────── */
dialog.dlg {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  max-height: min(86dvh, 820px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.dlg.wide { width: min(600px, calc(100vw - 32px)); }
dialog.dlg.small { width: min(400px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(12, 11, 9, .42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
[data-theme="dark"] dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
dialog.dlg[open] { animation: dlg-in .18s cubic-bezier(.2, .8, .3, 1); }
.dlg-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dlg-head > div { flex: 1; min-width: 0; }
.dlg-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.dlg-head p { margin-top: 3px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.dlg-head .icon-btn { margin: -4px -6px 0 0; }
.dlg-body { padding: 16px 20px; overflow-y: auto; max-height: calc(86dvh - 150px); }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.dlg-foot .grow { flex: 1; }
.dlg .field-grid .field { margin-top: 0; }
.dlg .field-grid { gap: 12px 12px; }

/* palette */
.palette-dlg { width: min(620px, calc(100vw - 32px)); margin-top: 10vh; }
.palette { display: flex; flex-direction: column; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); transition: background .15s; }
.palette-search:focus-within { background: var(--surface-2); }
.palette-search .icon { color: var(--faint); width: 18px; height: 18px; }
.palette-search input { flex: 1; border: 0; background: transparent; height: 30px; font-size: 15px; letter-spacing: -.01em; }
.palette-search input:focus-visible { outline: none; }
.palette-search kbd { flex: none; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.pal-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  text-align: left;
  color: var(--ink);
  transition: background .12s;
}
.pal-item:hover, .pal-item.is-cursor { background: var(--surface-3); }
.pal-item.is-cursor { box-shadow: inset 2px 0 0 var(--accent); }
.pal-item-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--muted);
  flex: none;
}
.pal-item-icon .icon { width: 13px; height: 13px; }
.pal-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-item-text b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item-text small { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item-kind { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); flex: none; }
.palette-empty { padding: 24px; text-align: center; color: var(--faint); font-size: 12.5px; }
.palette-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 11.5px; color: var(--faint); }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* serial */
.count-badge {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.serial-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  padding: 11px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.serial-preview i { color: var(--faint); font-style: normal; letter-spacing: .15em; }
.serial-preview span { max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* presets */
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; height: 36px; }
.preset-list { margin-top: 14px; max-height: 44vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.preset-item { display: flex; align-items: center; gap: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.preset-thumb {
  width: 76px;
  height: 44px;
  flex: none;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.preset-thumb canvas { max-width: 70px; max-height: 38px; display: block; }
.preset-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.preset-meta b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-meta small { font-size: 11.5px; color: var(--faint); }
.preset-actions { display: flex; gap: 4px; flex: none; }
.preset-actions .icon-btn { width: 28px; height: 28px; }
.preset-actions .icon-btn .icon { width: 14px; height: 14px; }
.preset-empty { padding: 26px; text-align: center; border: 1px dashed var(--line-2); border-radius: 11px; color: var(--faint); font-size: 12px; }

/* safety list */
.safety-list { display: flex; flex-direction: column; gap: 10px; }
.safety-item { display: flex; gap: 11px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.safety-item .s-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.safety-item .s-ico .icon { width: 13px; height: 13px; }
.safety-item.ok .s-ico { background: var(--ok-soft); color: var(--ok); }
.safety-item.warn .s-ico { background: var(--warn-soft); color: var(--warn); }
.safety-item.bad .s-ico { background: var(--bad-soft); color: var(--bad); }
.safety-item.info .s-ico { background: var(--surface-3); color: var(--muted); }
.safety-item-text { flex: 1; min-width: 0; }
.safety-item-text b { display: block; font-size: 12px; font-weight: 650; }
.safety-item-text p { margin-top: 1px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

/* help */
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.shortcut { display: flex; align-items: center; gap: 4px; padding: 6px 0; }
.shortcut span { margin-left: 7px; font-size: 11px; color: var(--muted); text-align: left; }
.about { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.about h3 { font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.about p { font-size: 11.5px; line-height: 1.65; color: var(--ink-2); }
.about p.hint { color: var(--faint); margin-top: 6px; }

/* ───────────── toasts ───────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  animation: toast-in .22s cubic-bezier(.2, .8, .3, 1);
  pointer-events: auto;
}
.toast .t-ico { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.toast .t-ico .icon { width: 12px; height: 12px; }
.toast.ok .t-ico { background: var(--ok-soft); color: var(--ok); }
.toast.error .t-ico { background: var(--bad-soft); color: var(--bad); }
.toast.info .t-ico { background: var(--accent-soft); color: var(--accent-ink); }
.toast.is-out { animation: toast-out .18s ease forwards; }

/* ───────────── animations ───────────── */
@keyframes fade-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }

/* ───────────── responsive ───────────── */
@media (max-width: 1420px) {
  :root { --left-w: 292px; --right-w: 338px; }
}
@media (max-width: 1280px) {
  :root { --left-w: 276px; --right-w: 320px; --gap: 12px; }
  .command { max-width: 300px; }
  .foot-metrics { gap: 12px; }
  .stage-scroll { padding: 50px 40px; }
}
@media (max-width: 1120px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-rows: var(--top-h) auto; }
  .command { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .column.left { overflow: visible; }
  .column.right { order: 3; }
  .stage { order: 1; height: 560px; }
  .column.left { order: 2; }
  .inspector { min-height: 520px; }
  .tab-panels { overflow: visible; }
  .stage-scroll { padding: 46px 36px; }
}
@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 15px; }
  .topbar-actions .vsep { display: none; }
  .workspace { padding: 10px; gap: 10px; }
  .stage-head { flex-wrap: wrap; padding: 10px; }
  .stage-tools { width: 100%; justify-content: space-between; }
  .stage { height: 480px; }
  .stage-scroll { padding: 40px 26px; }
  .foot-metrics { gap: 8px 14px; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr 1fr; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .fmt-chip { display: none; }
  .toasts { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
