@font-face {
  font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  --bg: #ededf0;
  --panel: #ffffff;
  --panel-soft: #f7f7f9;
  --hover: #f1f1f4;
  --line: #e3e3e8;
  --line-soft: #ededf0;
  --line-strong: #dcdce3;
  --text: #17171c;
  --text-2: #2a2a33;
  --text-3: #3f3f4a;
  --muted: #62626e;
  --muted-2: #6b6b78;
  --faint: #8a8a96;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --accent-text: #3730a3;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --danger-ink: #7f1d1d;
  --warn: #c2410c;
  --warn-bg: #fff7ed;
  --warn-line: #fed7aa;
  --warn-text: #7c2d12;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-line: #bbf7d0;
  --ok-ink: #14532d;
  --stage: #ededf0;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 20, 40, .08);
  --shadow-pop: 0 18px 50px rgba(20, 20, 40, .16), 0 2px 6px rgba(20, 20, 40, .06);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.small { font-size: 12px; }
h2 { font-size: 13px; font-weight: 600; margin: 0; }
h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

/* ---------- Top bar ---------- */
.topbar {
  height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; padding-right: 8px; }
.logo { width: 26px; height: 26px; }
.vsep { width: 1px; height: 22px; background: var(--line); }
.doc { display: flex; flex-direction: column; padding: 0 6px; min-width: 150px; }
.doc-name {
  border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 2px 6px; margin-left: -6px;
  width: 170px; font-weight: 600; font-size: 13px;
}
.doc-name:hover { border-color: var(--line); }
.doc-name:focus { outline: none; border-color: var(--accent); background: #fff; }
.doc-status { font-size: 11px; color: var(--muted-2); display: flex; align-items: center; gap: 4px; min-height: 14px; white-space: nowrap; }
.doc-status svg { width: 10px; height: 10px; stroke: var(--ok); stroke-width: 1.6; }
.doc-status.error { color: var(--warn); }
.btn-group { display: flex; gap: 2px; }
.sep { width: 1px; height: 24px; background: var(--line); }
.spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 500; font-size: 13px;
  white-space: nowrap; color: var(--text);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--hover); }
.btn.line { border-color: var(--line-strong); background: #fff; }
.btn.line:hover { background: var(--panel-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 0 14px; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:disabled { background: #c7c9f0; border-color: #c7c9f0; opacity: 1; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn.danger.line { border-color: #f3d0d0; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.topbar .btn.primary { height: 34px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:disabled { color: #a3a3ae; cursor: default; background: transparent; }
.machine-btn { height: 34px; padding: 0 10px 0 8px; gap: 10px; }
.machine-btn > svg { stroke: #4b4b57; }
.machine-btn .chev { stroke: var(--muted-2); }
.machine-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.machine-txt > :first-child { font-size: 12.5px; font-weight: 600; }
.machine-txt > :last-child { font-size: 11px; color: var(--muted-2); font-weight: 400; }
select {
  height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; background: #fff; cursor: pointer;
}
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); margin: 0; }
.help { font-size: 12px; color: var(--muted); margin: 4px 0 0; line-height: 1.4; }
.kbd {
  font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; background: #fff; color: var(--text-2); white-space: nowrap;
}

/* ---------- Popovers ---------- */
.popover {
  position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 14px; overflow-y: auto; animation: pop-in .12s ease-out;
}
.popover[hidden] { display: none; }
.popover::before {
  content: ""; position: absolute; top: -7px; left: calc(var(--arrow-x, 24px) - 6px); width: 12px; height: 12px;
  background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.machine-pop { width: 300px; }
.pop-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.pop-opt {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left;
  padding: 7px 8px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.pop-opt:hover { background: var(--hover); }
.pop-opt.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.pop-sub { display: block; font-size: 11px; color: var(--muted-2); font-weight: 400; }
.radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #a3a3ae; background: #fff; box-sizing: border-box; }
.on > .radio, .radio.on { border: 5px solid var(--accent); }

/* ---------- Layout ---------- */
.workspace { --left-w: 272px; position: relative; display: grid; grid-template-columns: 64px var(--left-w) minmax(0, 1fr) 320px; height: calc(100% - 52px); }
.splitter { position: absolute; top: 0; bottom: 0; left: calc(64px + var(--left-w) - 3px); width: 6px; cursor: col-resize; z-index: 5; }
.splitter:hover { background: rgba(67,56,202,.25); }
.panel { background: var(--panel); overflow-y: auto; }

/* ---------- Tools ---------- */
.toolrail {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; overflow-y: auto;
}
.tool {
  position: relative; width: 56px; min-height: 52px; border: none; background: transparent; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--text-3);
  padding: 4px 0;
}
.tool .key { position: absolute; top: 4px; right: 6px; font-size: 9px; color: #9a9aa6; font-family: var(--mono); }
/* Small corner mark: this tool has sub-tools. */
.tool .tool-more {
  position: absolute; right: 5px; bottom: 5px; width: 0; height: 0;
  border-left: 5px solid transparent; border-bottom: 5px solid #9a9aa6;
}
.tool .tool-label { font-size: 10.5px; font-weight: 500; line-height: 1.1; text-align: center; }
.tool svg { width: 22px; height: 22px; }
.tool:hover { background: var(--hover); }
.tool.active { background: var(--accent-soft); color: var(--accent-text); }
.tool.active .tool-more { border-bottom-color: var(--accent); }
.tool:disabled { opacity: .35; cursor: default; }
.tool-sep { width: 32px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }

/* ---------- Left panel: tabs ---------- */
.left-panel { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ltabs { display: flex; padding: 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.lpane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lpane[hidden] { display: none; }
.lhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.lhead-title { display: flex; align-items: baseline; gap: 8px; }
.lempty { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.accent-text { color: var(--accent); height: 26px; padding: 0 8px; }
.btn.small svg { width: 15px; height: 15px; }
#btnLibrary.active { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Background images ---------- */
.images-section { padding: 14px 14px 12px; border-bottom: 1px solid var(--line-soft); flex: none; }
.images-section.dragover { background: var(--accent-soft); }
.image-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 170px; overflow-y: auto; }
.image-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px; border-radius: 8px;
  background: var(--panel-soft); cursor: pointer; user-select: none; border: 1px solid transparent;
}
.image-item:hover { background: #f1f1f4; }
.image-item.selected { background: var(--accent-soft); border-color: #d9dcfb; }
.img-thumb { width: 36px; height: 36px; border-radius: 6px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.hidden-img .img-thumb img { opacity: .35; }
.img-txt { min-width: 0; }
.img-name { display: block; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.img-meta { display: block; font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-item .icon-btn { width: 26px; height: 26px; color: var(--muted-2); }
.image-item .icon-btn svg { width: 15px; height: 15px; }
.image-item .icon-btn.on { color: var(--text); }

/* ---------- Sequence ---------- */
.seq-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.seq-section > .lhead { padding: 14px 14px 0; margin-bottom: 2px; }
.seq-count { font-size: 11px; color: var(--muted-2); background: var(--hover); border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }
.seq-count:empty { display: none; }
.lhead .eyebrow { white-space: nowrap; }
.sequence:empty { display: none; }
.sequence { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.seq-colorbreak { display: flex; align-items: center; gap: 8px; padding: 12px 8px 4px; }
.seq-colorbreak .swatch { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); flex: none; }
.cb-name { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.cb-line { flex: 1; height: 1px; background: var(--line-soft); min-width: 8px; }
.cb-pts { font-size: 11px; color: var(--faint); white-space: nowrap; }
.seq-item {
  display: grid; grid-template-columns: 22px 18px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; height: 30px; padding: 0 8px;
  border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none;
}
.seq-item:has(.seq-group) { grid-template-columns: 22px 18px minmax(0, 1fr) auto auto auto; }
.seq-item:hover { background: #f5f5f7; }
.seq-item.selected { background: var(--accent-soft); color: #1e1b4b; }
.seq-item.dragging { opacity: .4; }
.seq-item.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.seq-item.drop-after { box-shadow: 0 2px 0 var(--accent); }
.seq-item.hidden-obj .seq-name { opacity: .45; text-decoration: line-through; }
.seq-num { font-size: 11px; color: var(--faint); text-align: right; }
.seq-type { color: var(--muted-2); display: inline-flex; }
.seq-type svg { width: 15px; height: 15px; }
.seq-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.seq-group { font-size: 10px; font-weight: 600; color: var(--accent-text); background: #e0e3ff; padding: 1px 5px; border-radius: 4px; }
.seq-pts { font-size: 11px; color: var(--faint); }
.seq-item .icon-btn { width: 24px; height: 24px; display: none; color: var(--muted-2); }
.seq-item .icon-btn svg { width: 15px; height: 15px; }
.seq-item:hover .icon-btn, .seq-item .icon-btn.on { display: inline-flex; }
.seq-item:hover .seq-pts, .seq-item:has(.icon-btn.on) .seq-pts { display: none; }
.seq-item.locked-obj .seq-type { opacity: .5; }
.seq-empty { margin: 10px 14px; border: 1px dashed var(--line-strong); border-radius: 10px; padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.seq-empty p { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.skel { display: flex; gap: 6px; }
.skel i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.skel b { height: 10px; border-radius: 5px; background: var(--line-soft); }

/* ---------- Library ---------- */
.lib-top { padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.lib-top .help { margin: 0; font-size: 11.5px; }
.lib-grid { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; }
.lib-card { text-align: left; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: grab; }
.lib-card:hover { border-color: #c4c4ce; box-shadow: 0 2px 8px rgba(20, 20, 40, .06); }
.lib-card:active { cursor: grabbing; }
.lib-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.lib-thumb svg { width: 72%; height: 72%; stroke-linecap: round; }
.lib-name { display: block; font-size: 12px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-tag { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.lib-empty { grid-column: 1 / -1; border: 1px dashed var(--line-strong); border-radius: 10px; padding: 20px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lib-empty svg { width: 28px; height: 28px; stroke: #a3a3ae; margin-bottom: 4px; }
.lib-empty strong { font-size: 13px; font-weight: 600; }
.lib-empty p { margin: 0 0 6px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.lib-foot { border-top: 1px solid var(--line-soft); padding: 10px 14px; font-size: 12px; color: var(--muted); flex: none; }

/* ---------- Stage ---------- */
.stage { position: relative; overflow: hidden; background: var(--stage); container-type: inline-size; }

#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hint {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 3px 8px; border-radius: 5px; font-size: 11px; font-family: var(--mono);
  box-shadow: 0 2px 8px rgba(0,0,0,.15); pointer-events: none; white-space: nowrap; z-index: 4;
}
.hint:empty { display: none; }
.hint kbd { background: rgba(255,255,255,.16); border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 11px; }
.dropzone {
  position: absolute; inset: 16px; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(67, 56, 202, .06);
  display: none; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; color: var(--accent-text);
  pointer-events: none;
}
.stage.dragover .dropzone { display: flex; }
.stage.dragover .empty-card { visibility: hidden; }
.empty-card {
  position: absolute; left: calc(50% + 10px); top: calc(50% - 26px); transform: translate(-50%, -50%); width: 300px; z-index: 3;
  background: #fff; border: 1.5px dashed #a5a8e8; border-radius: 16px; padding: 26px 22px 22px; text-align: center;
  box-shadow: 0 8px 30px rgba(20, 20, 40, .06);
}
.empty-card[hidden] { display: none; }
.empty-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; }
.empty-ico svg { width: 26px; height: 26px; stroke: var(--accent); }
.empty-card h1 { margin: 0; font-size: 17px; font-weight: 600; }
.empty-card > p { margin: 6px 0 16px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.empty-card .btn.primary { height: 38px; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; font-size: 11px; color: var(--faint); }
.or span { flex: 1; height: 1px; background: var(--line); }
.empty-card .empty-alt { margin: 0; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.empty-alt .link { font-size: 12.5px; }
.empty-alt .mono { font-size: 11.5px; }
.bottombar {
  position: absolute; left: 34px; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px;
}
.bottombar > * { flex-shrink: 0; }
.bottombar > .vsep { height: 26px; }
.sim { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 200px; }
.bottombar > .sim { flex-shrink: 1; }
.play { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--text); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.play:hover { background: #33333d; }
.play svg { width: 16px; height: 16px; }
#simPlay .i-pause { display: none; }
#simPlay.playing .i-pause { display: block; }
#simPlay.playing .i-play { display: none; }
.sim-track { flex: 1; min-width: 0; }
.sim-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted-2); margin-top: 3px; white-space: nowrap; }
.sim-meta span { overflow: hidden; text-overflow: ellipsis; }
#simSlider {
  --p: 100%; -webkit-appearance: none; appearance: none; width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer; display: block;
}
#simSlider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p)); }
#simSlider::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p)); }
#simSlider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -4px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-sizing: border-box; }
#simSlider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-sizing: border-box; }
.sim select { height: 28px; font-size: 12px; border-radius: 7px; padding: 0 4px; flex: none; }
.dock-empty { display: none; margin: 0; font-size: 12px; color: var(--muted-2); flex: 1 1 200px; }
.bottombar.empty .sim { display: none; }
.bottombar.empty .dock-empty { display: block; }
.bottombar.empty > :not(.zoom):not(.vsep) { opacity: .72; }
.stats { display: flex; gap: 14px; margin: 0; white-space: nowrap; }
.stats dt { font-size: 10px; color: var(--muted-2); }
.stats dd { margin: 0; font-size: 13px; font-weight: 600; }
.stats-empty { font-size: 12px; color: var(--muted-2); }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom .icon-btn { width: 28px; height: 28px; font-size: 15px; }
.zoom-val { border: none; background: transparent; min-width: 52px; cursor: pointer; border-radius: 6px; height: 28px; font-size: 12px; font-weight: 500; }
.zoom-val:hover { background: var(--hover); }

/* ---------- Properties (right panel) ---------- */
.right-panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.props-head { padding: 14px 16px 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border-bottom: 1px solid var(--line-soft); }
.props-head:has(.tabs) { padding-bottom: 0; border-bottom-color: var(--line); }
.right-panel.next-mode { background: #fbfbfc; }
.props-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.props-foot { border-top: 1px solid var(--line); padding: 10px 16px; background: var(--panel); }
.head-row { display: flex; align-items: center; justify-content: space-between; align-self: stretch; gap: 8px; }
.meta { font-size: 11px; color: var(--muted-2); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.chip svg { width: 10px; height: 10px; }
.chip.next { background: #fff; color: #4b4b57; border: 1px dashed #a3a3ae; }
.chip.next svg { stroke: #8a8a96; stroke-width: 1.2; }
.chip.sel { background: var(--accent-soft); color: var(--accent-text); }
.chip.sel svg { fill: var(--accent); stroke: none; }
.chip.neutral { background: var(--hover); color: var(--text-3); }
.chip.neutral svg { width: 12px; height: 12px; }
.title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.title-input {
  font-size: 18px; font-weight: 600; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin-left: -6px;
  width: calc(100% + 6px); background: transparent; letter-spacing: -.01em;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: none; border-color: var(--accent); background: #fff; }
.tool-head { display: flex; align-items: center; gap: 10px; }
.tool-head svg { width: 22px; height: 22px; color: var(--accent-text); }
.props-head > .help { margin: 0; }
.thread-btn {
  align-self: stretch; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 6px 8px 6px 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; margin-top: 2px;
}
.thread-btn:hover { border-color: #c4c4ce; }
.thread-btn.open { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67, 56, 202, .15); }
.sw { display: block; width: 36px; height: 36px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sw.mixed { background-image: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.55) 50%) !important; }
.thread-txt { min-width: 0; }
.thread-txt > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-txt > :first-child { font-size: 13px; font-weight: 600; }
.thread-txt > :last-child { font-size: 11px; color: var(--muted-2); }
.thread-change { font-size: 12px; color: var(--accent); font-weight: 500; display: flex; align-items: center; gap: 2px; }
.thread-change svg { width: 14px; height: 14px; }
.tabs { display: flex; align-self: stretch; margin-top: 2px; }
.tab { border: 0; background: transparent; padding: 10px 2px; margin-right: 18px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; font-size: 13px; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.obj-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.obj-chips span { display: flex; align-items: center; gap: 6px; font-size: 12px; background: #f5f5f7; border-radius: 6px; padding: 4px 8px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-chips i { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }

.psec { display: flex; flex-direction: column; gap: 8px; }
.psec > .eyebrow { margin-bottom: 0; }
.psep { height: 1px; background: var(--line-soft); }
.fld { display: flex; flex-direction: column; }
.fld > .help { margin-top: 4px; }
.fld-label { font-size: 12px; color: #4b4b57; margin-bottom: 6px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 124px; align-items: center; gap: 10px; }
.field > label, .fld-text { font-size: 13px; color: var(--text-2); }
.field select { width: 100%; min-width: 0; }
.field-top { display: flex; justify-content: space-between; font-size: 13px; }
.mini-label { font-size: 11px; color: var(--muted-2); display: block; margin-bottom: 2px; }
.size-grid { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr); gap: 6px; align-items: end; }
.size-grid .stepper button { display: none; }
.ratio { width: 28px; height: 32px; color: var(--muted-2); }
.ratio.on { color: var(--accent); }
.ratio svg { width: 17px; height: 17px; }
.io-legend { display: flex; gap: 6px; align-items: center; font-size: 12.5px; }
.io-legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.io-legend .dot.in { background: #16a34a; }
.io-legend .dot.out { background: #dc2626; margin-left: 8px; }
.io-legend span { margin-left: auto; color: var(--muted-2); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; font-size: 12px; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-grid .btn { font-size: 12.5px; }
.btn-grid .wide { grid-column: 1 / -1; }
.pf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pf-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 6px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 500; color: var(--text-3);
}
.pf-btn svg { width: 26px; height: 26px; stroke-width: 1.4; color: var(--accent); }
.pf-btn:hover { background: var(--accent-soft); border-color: #c7caf5; }
.pf-btn:disabled { opacity: .45; cursor: default; background: #fff; border-color: var(--line-strong); }
.kbd-hint { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); font-weight: 400; }
.acts { display: flex; justify-content: space-between; gap: 4px; }
.act { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--text-3); cursor: pointer; }
.act:hover { background: #f5f5f7; }
.act svg { width: 17px; height: 17px; }
.act.danger { color: var(--danger); }
.act.danger:hover { background: var(--danger-bg); }
.act.off { color: #a3a3ae; }
.img-preview { align-self: stretch; height: 120px; border-radius: 10px; background: var(--panel-soft); border: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: center; padding: 8px; }
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.range { width: 100%; accent-color: var(--accent); }
.red { color: #d6455b; }
.note { background: var(--panel-soft); border-radius: 8px; padding: 8px 10px; color: var(--muted); font-size: 12px; line-height: 1.45; margin: 0; }
.warn-box {
  border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 10px 12px;
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; font-size: 12.5px; color: var(--warn-text); line-height: 1.4;
}
.warn-box svg { width: 18px; height: 18px; stroke: var(--warn); }
.warn-box strong { font-weight: 600; }
.warn-actions { display: flex; gap: 12px; margin-top: 6px; }
.warn-actions .link { color: #9a3412; font-weight: 600; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: var(--text-2); }
.steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; line-height: 1.4; }
.steps b { font-weight: 600; }
.step-n { width: 22px; height: 22px; border-radius: 50%; background: var(--hover); color: #4b4b57; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.step-n.on { background: var(--accent-soft); color: var(--accent-text); }
.kbd-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 10px; font-size: 12px; color: var(--text-3); align-items: center; }
.kbd-list .kbd { justify-self: start; }
.fabrics { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.fabrics button, .fabric-custom { width: 100%; aspect-ratio: 1; height: auto; border-radius: 8px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); padding: 0; }
.fabrics .active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.fabric-custom { position: relative; display: flex; align-items: center; justify-content: center; color: var(--muted-2); background: #fff; font-size: 15px; }
.fabric-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* Switch (on / off) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; cursor: pointer; }
.switch-row .help { display: block; margin: 2px 0 0; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 10px; background: #d4d4dc; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Advanced settings (folded) */
.adv { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.adv-head { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 0; background: transparent; font-weight: 500; cursor: pointer; text-align: left; border-radius: 10px; }
.adv-sub { display: block; font-size: 11px; font-weight: 400; color: var(--muted-2); }
.adv-head svg { width: 16px; height: 16px; stroke: var(--muted-2); transition: transform .15s; }
.adv.open .adv-head svg { transform: rotate(180deg); }
.adv-body { display: none; padding: 0 12px 12px; flex-direction: column; gap: 12px; }
.adv.open .adv-body { display: flex; }
.defaults-links { display: flex; gap: 14px; }
.link { border: none; background: none; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; font-weight: 500; }
.link.muted { color: var(--muted); }
.link:hover { text-decoration: underline; }

/* Thread popover */
.thread-pop { width: 300px; }
.thread-pop .search { margin-top: 12px; }
.pop-title { margin: 14px 0 8px; }
.sw-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.sw-btn { aspect-ratio: 1; border-radius: 7px; border: 0; padding: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sw-btn:hover { transform: scale(1.1); }
.sw-btn.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.thread-pop .help { margin-top: 12px; }
.my-threads { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.my-thread { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px; border: 0; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; }
.my-thread:hover, .my-thread.active { background: var(--hover); }
.my-thread .sw { width: 28px; height: 28px; border-radius: 7px; }
.my-thread > span:last-child > span { display: block; }
.my-thread .mono { font-size: 11px; color: var(--muted-2); }
.thread-pop .psep { margin: 12px 0; }
.add-thread { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.add-thread input[type=color] { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px; background: #fff; }
.add-thread .text, .add-thread .btn { height: 34px; }
.search { display: flex; align-items: center; gap: 8px; height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; background: #fff; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 14px; height: 14px; stroke: var(--muted-2); stroke-width: 2; }
.search input { border: 0; flex: 1; min-width: 0; outline: none; font-size: 13px; background: transparent; }
.text { height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; min-width: 0; font-size: 13px; }
.text:focus { outline: none; border-color: var(--accent); }

/* ---------- Dialogs ---------- */
.dialog { border: none; border-radius: 14px; padding: 22px; width: 440px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); color: var(--text); }
.dialog::backdrop { background: rgba(20, 20, 30, .45); }
.dialog h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions .spacer { flex: 1; }

/* ---------- Export dialog ---------- */
.export-dialog { width: 560px; max-width: calc(100vw - 32px); padding: 0; }
.dlg-head { padding: 20px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg-head h2 { margin: 0; }
.dlg-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.export-summary { padding: 16px 22px; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: center; }
.export-thumb { width: 112px; height: 112px; border-radius: 12px; background: #fff; border: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 6px; }
.export-thumb img { max-width: 100%; max-height: 100%; }
.export-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.export-stats dt { font-size: 11px; color: var(--muted-2); }
.export-stats dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
.dd-sub { font-weight: 400; color: var(--muted-2); font-size: 12px; }
.dlg-sec { padding: 0 22px 14px; }
.dlg-sec > .eyebrow { margin-bottom: 8px; }
.checks-ok { padding: 10px 12px; border-radius: 10px; background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-ink); font-size: 13px; display: flex; gap: 10px; align-items: center; line-height: 1.4; }
.checks-ok svg { width: 20px; height: 20px; stroke: var(--ok); flex: none; }
.checks-ok strong { font-weight: 600; }
.checks-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.checks-head span { font-size: 12px; color: var(--muted); }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.issue { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; }
.issue svg { width: 18px; height: 18px; }
.issue strong { display: block; font-weight: 600; }
.issue.block { background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger-ink); }
.issue.block > svg { stroke: var(--danger); }
.issue.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); }
.issue.warn > svg { stroke: var(--warn); }
.voir { border: 0; background: transparent; font-weight: 600; font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 0 2px; }
.voir svg { width: 14px; height: 14px; }
.issue.block .voir { color: var(--danger); }
.issue.warn .voir { color: var(--warn); }
.voir:hover { text-decoration: underline; }
.formats { display: flex; flex-direction: column; gap: 6px; }
.fmt { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-size: 13px; }
.fmt:hover { background: var(--panel-soft); }
.fmt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.fmt:has(input:checked) .radio { border: 5px solid var(--accent); }
.fmt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmt strong { font-weight: 600; }
.fmt-rec { font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; }
.fmt:has(input:checked) .fmt-rec { background: #fff; }
.dlg-foot { margin-top: 4px; padding: 14px 22px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; gap: 8px; }
.dlg-note { margin: -6px 22px 14px; font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- Numeric field with −/+ buttons ---------- */
.stepper { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; height: 32px; background: #fff; }
.stepper:focus-within { border-color: var(--accent); }
.stepper button {
  width: 28px; height: 100%; border: none; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; color: #4b4b57;
  flex: none; touch-action: manipulation; border-radius: 7px;
}
.stepper button:hover { background: var(--hover); }
.stepper button:active { background: #e6e6ec; }
.stepper input { width: 100%; min-width: 0; border: none; text-align: center; height: 100%; font-variant-numeric: tabular-nums; padding: 0 2px; background: transparent; font-size: 13px; }
.stepper input:focus { outline: none; }
.stepper .unit { font-size: 11px; color: var(--muted-2); padding-right: 6px; flex: none; }
.seg { display: flex; background: var(--hover); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
  border: none; background: transparent; min-height: 28px; padding: 0 10px; border-radius: 6px; cursor: pointer; color: #4b4b57;
  font-weight: 500; font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.seg button span { overflow: hidden; text-overflow: ellipsis; }
.seg button:hover { color: var(--text); }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(20, 20, 30, .14); }
.seg svg { width: 15px; height: 15px; }
.seg.full { width: 100%; }
.seg.icons-only button span { display: none; }
.seg.stack button { flex-direction: column; gap: 2px; padding: 5px 2px 4px; font-size: 11px; }
.seg.stack svg { width: 17px; height: 17px; }
.seg.icons-only svg { width: 18px; height: 18px; }
.seg.full button { flex: 1; min-width: 0; padding: 0 6px; }

/* ---------- Contextual help (bottom left) ---------- */
.keyhints {
  position: absolute; left: 34px; bottom: 84px; width: 270px; z-index: 2;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 16px rgba(20, 20, 40, .06); padding: 4px 12px 10px; font-size: 12px; color: var(--text-3);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.kh-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent;
  padding: 6px 0; font-weight: 600; color: var(--text); font-size: 12px; cursor: pointer; text-align: left;
}
.kh-head svg { width: 16px; height: 16px; stroke: var(--muted-2); transition: transform .2s; }
.kh-list { display: flex; flex-direction: column; gap: 4px; line-height: 1.35; }
.kh-txt { color: var(--muted); }
.kh-key { font-weight: 500; color: var(--text-2); }
.keyhints.collapsed { width: auto; padding-bottom: 4px; }
.keyhints.collapsed .kh-list { display: none; }
.keyhints.collapsed .kh-head { gap: 8px; }
.keyhints.collapsed .kh-head svg { transform: rotate(180deg); }

/* ---------- Renaming ---------- */
.rename { flex: 1; min-width: 0; height: 24px; border: 1px solid var(--accent); border-radius: 5px; padding: 0 6px; font: inherit; }
.rename:focus { outline: none; }

/* ---------- Order dialog ---------- */
.rules { margin: 6px 0 12px; padding-left: 18px; line-height: 1.45; }
.rules li { margin-bottom: 4px; }
.compare { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
.compare th, .compare td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.compare th { color: var(--muted); font-weight: 500; }
.compare td.num { text-align: right; font-variant-numeric: tabular-nums; }
.compare .better { color: #1f7a45; font-weight: 600; }
.compare .worse { color: var(--danger); font-weight: 600; }

/* ---------- Production sheet ---------- */
.sheet-dialog { width: min(760px, calc(100vw - 32px)); }
.sheet-dialog iframe { width: 100%; height: min(70vh, 720px); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; background: #fff; }

/* ---------- Sub-tools (fly-out menu) ---------- */
.flyout {
  position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(20, 20, 40, .14);
  animation: fly-in .14s ease-out;
}
.flyout[hidden] { display: none; }
@keyframes fly-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.fly-items { display: flex; gap: 2px; }
.fly-item {
  width: 72px; min-height: 56px; padding: 8px 4px 6px; border: none; background: transparent; border-radius: 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3); font-size: 10.5px; font-weight: 500; line-height: 1.2; text-align: center;
}
.fly-item svg { width: 22px; height: 22px; }
.fly-item:hover { background: var(--hover); }
.fly-item.active { background: var(--accent-soft); color: var(--accent-text); }
.fly-tips { border-top: 1px solid var(--line-soft); padding: 6px 8px 2px; font-size: 11.5px; color: var(--muted); display: flex; gap: 12px; }

/* ---------- Alert while drawing ---------- */
.draw-alert {
  position: absolute; z-index: 4; width: 240px; pointer-events: none; display: flex; gap: 8px; align-items: flex-start;
  background: #fff; border: 1px solid var(--warn-line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 20, 40, .12);
  padding: 10px 12px; font-size: 12.5px; color: var(--warn-text); line-height: 1.4;
}
.draw-alert svg { width: 16px; height: 16px; stroke: var(--warn); margin-top: 1px; }
.draw-alert strong { font-weight: 600; }

/* ---------- Custom hoop ---------- */
.small-dialog { width: 340px; }
.hoop-fields { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 18px; }
.hoop-fields label { display: flex; align-items: center; gap: 8px; }
.hoop-fields input { width: 90px; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; margin-left: auto; }

/* ---------- Toasts ---------- */
.toast {
  position: fixed; top: 66px; left: 50%; transform: translate(-50%, -8px); opacity: 0; z-index: 50; pointer-events: none;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: 12px; max-width: min(560px, calc(100vw - 32px));
  background: var(--text); color: #f4f4f6; font-size: 13px; line-height: 1.35; box-shadow: 0 12px 30px rgba(20, 20, 40, .2);
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast svg { width: 16px; height: 16px; stroke-width: 2.4; flex: none; }
.toast .t-ok { stroke: #86efac; }
.toast .t-warn { stroke: #fdba74; }
.toast .t-info { stroke: #a5b4fc; }
.toast button { border: 0; background: transparent; color: #a5b4fc; font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; padding: 2px 0; }
.toast button:hover { color: #c7d2fe; }

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 64px var(--left-w) minmax(0, 1fr) 296px; --left-w: 236px; }
  .topbar .lbl { display: none; }
}
@media (max-width: 1080px) {
  nav.btn-group, .doc-status { display: none; }
}

/* ---------- Narrow work area: compact dock ---------- */
@container (max-width: 860px) {
  .bottombar { gap: 8px; }
  .bottombar .seg svg { display: none; }
  .bottombar .seg button { padding: 0 8px; }
  .sim { flex-basis: 120px; min-width: 120px; gap: 8px; }
  .stats { gap: 12px; }
  .sim-meta span:last-child { display: none; }
}
@container (max-width: 700px) {
  .stats > div:nth-child(4) { display: none; }
}
