/* Design Studio (preview.html) — editor UI, plus the shared top bar.
 * Same look as the landing page and the app: every colour, radius, shadow and
 * font comes from css/tokens.css. Only the editor's own working colours live
 * here (selection blue, same as the canvas overlay in js/editor/stage.js). */
:root{
  --ed-sel:#4da3ff;               /* drop markers in the layer list, = selection on the canvas */
  --ed-ctl:30px;                  /* height of the dense controls */
}

/* ---- top bar (both modes) ---- */
.topbar{ display:flex; align-items:center; gap:14px; padding:10px 16px; background:var(--bg);
  border-bottom:1px solid var(--line); min-height:60px; flex-wrap:wrap; }
.tb-brand{ display:inline-flex; align-items:center; gap:10px; text-decoration:none; color:var(--ink); white-space:nowrap; }
.tb-brand .brand-name{ font-weight:200; letter-spacing:-.01em; white-space:nowrap; font-size:17px; }
.tb-brand .brand-name b{ font-weight:700; }
.tb-sub{ font-size:13px; font-weight:600; color:var(--muted); padding-left:12px; border-left:1px solid var(--line); white-space:nowrap; }
.seg{ display:inline-flex; background:var(--canvas); border:1px solid var(--line); border-radius:var(--radius-pill); padding:3px; }
.seg button{ background:none; border:0; color:var(--muted); font:inherit; font-size:13px; font-weight:600; padding:6px 14px;
  border-radius:var(--radius-pill); cursor:pointer; }
.seg button:hover{ color:var(--ink); }
.seg button[aria-selected="true"]{ background:var(--fill); color:var(--ink); box-shadow:inset 0 0 0 1px var(--line-strong); }
/* document name with its save state underneath */
.tb-doc{ display:flex; flex-direction:column; align-items:flex-start; min-width:0; }
.tb-name{ background:transparent; border:1px solid transparent; color:var(--ink); font:inherit; font-size:15px;
  font-weight:700; padding:3px 10px; border-radius:var(--radius-sm); width:min(280px, 22vw); }
.tb-name:hover{ border-color:var(--line); }
.tb-name:focus{ outline:none; border-color:var(--accent); background:var(--bg); box-shadow:0 0 0 3px var(--accent-ring); }
.tb-state{ font-size:11.5px; color:var(--muted); white-space:nowrap; padding:0 11px; line-height:1.3; }
.tb-state.dirty{ color:var(--signal-ink); font-weight:600; } /* unsaved: the one signal in the studio */
.tb-actions{ display:flex; align-items:center; gap:6px; }
.tb-btn{ display:inline-flex; align-items:center; justify-content:center; gap:6px; height:36px; background:var(--bg); color:var(--ink);
  border:1px solid var(--line); border-radius:var(--radius-pill); font:inherit; font-size:13px; font-weight:600; padding:0 14px;
  cursor:pointer; white-space:nowrap; transition:border-color .15s, box-shadow .15s, transform .15s; }
.tb-btn:hover{ border-color:var(--line-strong); box-shadow:var(--shadow-sm); }
.tb-btn:disabled{ opacity:.4; cursor:default; border-color:var(--line); box-shadow:none; }
.tb-btn.icon{ width:36px; padding:0; }
.tb-btn svg{ pointer-events:none; width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.tb-btn.primary{ background:var(--grad); color:var(--on-grad); border-color:transparent; font-weight:600; padding:0 18px; box-shadow:var(--shadow-btn); }
.tb-btn.primary:hover{ transform:translateY(-1px); box-shadow:var(--shadow-btn-hover); }
.tb-sep{ width:1px; height:22px; background:var(--line); margin:0 4px; }
.spacer{ flex:1; }

/* ---- layout ---- */
.ed{ flex:1; min-height:0; display:grid; grid-template-columns:292px minmax(0,1fr) 316px; }
.ed-left, .ed-right{ background:var(--bg); min-height:0; overflow:auto; font-size:13px; }
.ed-left{ border-right:1px solid var(--line); display:flex; flex-direction:column; overflow-x:hidden; }
.ed-right{ border-left:1px solid var(--line); }
.ed-tabs{ display:grid; grid-template-columns:repeat(4, minmax(0, auto)); justify-content:stretch; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:var(--bg); z-index:2; }
.ed-tabs button{ background:none; border:0; border-bottom:2px solid transparent; color:var(--muted); font:inherit; font-size:12px; font-weight:600;
  padding:12px 2px 10px; cursor:pointer; line-height:1.2; min-width:0; }
.ed-tabs button:hover{ color:var(--ink); }
.ed-tabs button[aria-selected="true"]{ color:var(--ink); border-bottom-color:var(--accent-2); }
.ed-panel{ padding:12px 14px 40px; }
.ed-center{ display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--canvas); }
.ed-formatbar{ display:flex; align-items:center; gap:10px; padding:8px 12px; border-bottom:1px solid var(--line); background:var(--bg); flex-wrap:wrap; }
.fmt-tabs{ display:flex; gap:4px; flex-wrap:wrap; }
.fmt-tabs button{ background:var(--bg); border:1px solid var(--line); color:var(--muted); font:inherit; font-size:12.5px; font-weight:600;
  padding:6px 12px; border-radius:var(--radius-sm); cursor:pointer; display:flex; flex-direction:column; align-items:flex-start; gap:1px; }
.fmt-tabs button:hover{ border-color:var(--line-strong); color:var(--ink); }
.fmt-tabs button.card-first{ margin-left:14px; }
.fmt-tabs button small{ font-size:10px; font-weight:500; color:var(--muted); }
.fmt-tabs button[aria-selected="true"]{ border-color:var(--ink); color:var(--canvas); background:var(--ink); }
.fmt-tabs button[aria-selected="true"] small{ color:inherit; opacity:.7; }
.ed-tools{ display:flex; align-items:center; gap:4px; }
.tool-btn{ display:inline-grid; place-items:center; background:var(--bg); color:var(--ink); border:1px solid var(--line); border-radius:var(--radius-sm);
  font:inherit; font-size:14px; font-weight:600; min-width:34px; height:34px; padding:0 8px; cursor:pointer; }
.tool-btn:hover{ border-color:var(--line-strong); }
.tool-btn svg{ pointer-events:none; width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.tool-btn[aria-pressed="true"]{ border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.tool-btn.zoom-val{ font-size:12px; min-width:60px; }
.ed-stage{ flex:1; min-height:0; overflow:auto; position:relative; display:grid; place-items:center; padding:40px;
  background:radial-gradient(900px 520px at 50% 0%, var(--light-soft), transparent 70%); }
.ed-stage.panning{ cursor:grab; }
.ed-board{ position:relative; box-shadow:var(--shadow); background:var(--fill); }
#edCanvas{ display:block; width:100%; height:100%; }
#edOverlay{ position:absolute; inset:0; width:100%; height:100%; overflow:visible; touch-action:none; cursor:default; user-select:none; }
#edOverlay.pen{ cursor:crosshair; }
#edOverlay.crop{ cursor:move; }
.ed-hintbar{ font-size:12px; color:var(--muted); padding:7px 14px; border-top:1px solid var(--line); background:var(--bg); min-height:30px; }
.ed-hintbar kbd{ font:inherit; font-size:11px; font-weight:600; background:var(--fill); border:1px solid var(--line); padding:0 5px; color:var(--ink); }

/* ---- generic panel widgets ---- */
.sec{ border-bottom:1px solid var(--line); padding:14px 0 16px; }
.sec:first-child{ padding-top:4px; }
.sec:last-child{ border-bottom:0; }
.sec-h{ display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12.5px;
  color:var(--ink-2); margin:0 0 10px; font-weight:650; }
.sec-h .sub{ font-weight:500; color:var(--muted); }
.ed-right .sec{ padding-left:14px; padding-right:14px; }
.row{ display:flex; gap:8px; align-items:center; margin-bottom:7px; }
.row > *{ min-width:0; }
.row.stack{ flex-direction:column; align-items:stretch; }
.fld{ display:flex; flex-direction:column; gap:4px; flex:1; min-width:0; }
.fld > span, .lbl{ font-size:11.5px; font-weight:600; color:var(--ink-2); }
.ed input[type=text], .ed input[type=number], .ed select, .ed textarea, .dlg input[type=text], .dlg select{
  background:var(--canvas); color:var(--ink); border:1px solid var(--line-strong); border-radius:var(--radius-xs); font:inherit; font-size:13px;
  padding:6px 9px; width:100%; min-width:0; min-height:var(--ed-ctl); }
.ed select, .dlg select{ appearance:none; -webkit-appearance:none; padding-right:28px; cursor:pointer;
  background:var(--canvas) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238D9097' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; }
.ed textarea{ resize:vertical; min-height:58px; font-family:ui-monospace, Menlo, Consolas, monospace; font-size:12px; }
.ed input:focus, .ed select:focus, .ed textarea:focus, .dlg input:focus, .dlg select:focus{
  outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.ed input[type=number]{ -moz-appearance:textfield; }
.ed input[type=number]::-webkit-inner-spin-button{ opacity:.4; }
.num{ position:relative; flex:1; min-width:0; }
.num > b{ position:absolute; left:8px; top:50%; transform:translateY(-50%); font-size:11px; font-weight:600; color:var(--muted);
  cursor:ew-resize; user-select:none; }
.num > input{ padding-left:22px !important; }
.num.wide > input{ padding-left:52px !important; }
.range{ display:flex; align-items:center; gap:8px; flex:1; }
.range input[type=range]{ flex:1; accent-color:var(--accent-2); min-width:60px; }
.range input[type=number]{ width:62px; flex:none; }
.segb{ display:inline-flex; border:1px solid var(--line-strong); border-radius:var(--radius-xs); overflow:hidden; flex:none; background:var(--bg); }
.segb button{ background:var(--bg); color:var(--muted); border:0; border-right:1px solid var(--line); font:inherit; font-weight:600;
  font-size:12.5px; min-width:30px; height:28px; padding:0 8px; cursor:pointer; }
.segb button:last-child{ border-right:0; }
.segb button:hover{ color:var(--ink); }
.segb button[aria-pressed="true"]{ background:var(--accent-soft); color:var(--accent); }
.segb.grow{ display:flex; flex:1; }
.segb.grow button{ flex:1; }
.chk{ display:flex; align-items:center; gap:8px; cursor:pointer; font-size:13px; color:var(--ink); }
.chk input{ accent-color:var(--accent-2); width:16px; height:16px; margin:0; }
.btn-s{ display:inline-flex; align-items:center; justify-content:center; gap:6px; background:var(--bg); color:var(--ink);
  border:1px solid var(--line-strong); border-radius:var(--radius-pill); font:inherit; font-size:12.5px; font-weight:600;
  min-height:var(--ed-ctl); padding:5px 12px; cursor:pointer; line-height:1.2; text-align:center; }
.btn-s:hover{ border-color:var(--ink-2); box-shadow:var(--shadow-sm); }
.btn-s.danger:hover{ border-color:var(--danger); color:var(--danger); }
.btn-s.full{ width:100%; }
.btn-s:disabled{ opacity:.45; cursor:default; box-shadow:none; }
.hint-s{ font-size:12px; color:var(--muted); line-height:1.5; margin:4px 0 8px; }
.note{ font-size:12px; line-height:1.5; color:var(--ink-2); background:var(--fill); border:1px solid var(--line);
  border-radius:var(--radius-sm); padding:9px 11px; margin:6px 0; }
.note.warn{ color:var(--warn); background:var(--warn-bg); border-color:transparent; }
.ed a, .dlg a{ color:var(--accent); font-weight:600; }

/* add panel */
.add-grid{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:6px; }
.add-grid.three{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
.add-btn{ display:flex; align-items:center; gap:8px; background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-sm);
  color:var(--ink); font:inherit; font-size:12.5px; font-weight:600; padding:8px 10px; cursor:pointer; text-align:left; line-height:1.25; min-height:40px;
  transition:border-color .15s, box-shadow .15s, transform .15s; }
.add-btn:hover{ border-color:var(--line-strong); box-shadow:var(--shadow-sm); transform:translateY(-1px); }
.add-btn svg{ flex:none; width:18px; height:18px; color:var(--accent); }
.add-btn > span{ min-width:0; overflow-wrap:break-word; hyphens:auto; }
.add-btn.wide{ grid-column:1 / -1; }
.add-btn .v{ font-size:10.5px; font-weight:500; color:var(--muted); display:block; }
.shape-btn{ flex-direction:column; justify-content:center; gap:4px; padding:8px 4px; text-align:center; font-size:11.5px; }
.shape-btn svg{ width:26px; height:26px; color:var(--ink-2); }
.icon-grid{ display:grid; grid-template-columns:repeat(6, 1fr); gap:4px; max-height:300px; overflow:auto; padding-right:2px; }
.icon-grid button{ aspect-ratio:1; display:grid; place-items:center; background:var(--bg); border:1px solid var(--line);
  border-radius:var(--radius-xs); cursor:pointer; color:var(--ink-2); padding:0; }
.icon-grid button:hover, .icon-grid button[aria-pressed="true"]{ border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.icon-grid svg{ width:22px; height:22px; }

/* layers */
.layers{ list-style:none; margin:0; padding:0; }
.layer{ display:flex; align-items:center; gap:6px; padding:5px 6px; border-radius:var(--radius-xs); border:1px solid transparent;
  cursor:pointer; user-select:none; position:relative; }
.layer:hover{ background:var(--fill); }
.layer[aria-selected="true"]{ background:var(--accent-soft); border-color:var(--accent-ring); }
.layer.drop-before{ box-shadow:0 -2px 0 var(--ed-sel); }
.layer.drop-after{ box-shadow:0 2px 0 var(--ed-sel); }
.layer .ty{ width:18px; text-align:center; color:var(--muted); flex:none; font-size:12px; }
.layer .nm{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.layer .nm small{ color:var(--muted); margin-left:5px; }
.layer.off .nm{ opacity:.45; }
.layer .grp{ width:3px; align-self:stretch; flex:none; }
.layer .ic{ display:inline-grid; place-items:center; background:none; border:0; color:var(--muted); cursor:pointer; width:24px; height:24px;
  padding:0; font-size:12px; flex:none; }
.layer .ic svg{ width:15px; height:15px; pointer-events:none; }
.layer .ic:hover{ color:var(--ink); background:var(--bg); }
.layer .ic.on{ color:var(--accent); }
.layer input{ font-size:12px; padding:2px 5px; min-height:0; }

/* colours */
.swatches{ display:flex; flex-wrap:wrap; gap:5px; }
.sw{ width:24px; height:24px; border:2px solid var(--bg); box-shadow:0 0 0 1px var(--line-strong);
  cursor:pointer; padding:0; position:relative; flex:none; }
.sw[aria-pressed="true"]{ box-shadow:0 0 0 2px var(--accent-2); }
.sw.none{ background:repeating-linear-gradient(45deg, #fff 0 4px, #e45 4px 6px) !important; }
.sw.more{ background:conic-gradient(red, yellow, lime, cyan, blue, magenta, red) !important; }
.color-row{ display:flex; align-items:center; gap:8px; padding:4px 0; }
.color-row input[type=color]{ width:34px; height:30px; border:1px solid var(--line-strong); border-radius:var(--radius-xs); background:none; padding:2px; cursor:pointer; flex:none; }
.color-row .cn{ flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
.color-row .cn b{ font-weight:600; font-size:13px; }
.color-row .cn small{ font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.color-row input.hex{ width:86px; flex:none; font-family:ui-monospace, Menlo, Consolas, monospace; font-size:11.5px; }
.font-card{ border:1px solid var(--line); border-radius:var(--radius-sm); padding:10px 12px; margin-bottom:8px; background:var(--fill); }
.font-card .fc-h{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom:6px; }
.font-card .fc-h b{ font-size:12.5px; font-weight:700; }
.font-card .fc-h small{ font-size:11px; color:var(--muted); }
.font-card .sample{ font-size:22px; line-height:1.2; margin:6px 0 2px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.font-card .wts{ font-size:11px; color:var(--muted); }

/* toast, menu, dialog */
.toast{ position:fixed; left:50%; bottom:22px; transform:translateX(-50%); background:var(--ink); color:var(--canvas);
  border-radius:var(--radius-pill); padding:10px 18px; font-size:13px; font-weight:600; z-index:50; box-shadow:var(--shadow); max-width:min(640px, 90vw); }
.toast.err{ background:var(--danger); color:var(--on-grad); }
.menu{ position:fixed; z-index:40; background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-md); padding:6px;
  min-width:230px; box-shadow:var(--shadow); }
.menu button{ display:block; width:100%; text-align:left; background:none; border:0; color:var(--ink); font:inherit; font-size:13px; font-weight:500;
  padding:8px 10px; border-radius:var(--radius-xs); cursor:pointer; }
.menu button:hover{ background:var(--fill); }
.menu button:disabled{ opacity:.4; cursor:default; }
.menu hr{ border:0; border-top:1px solid var(--line); margin:4px 0; }
.dlg{ background:var(--bg); color:var(--ink); border:1px solid var(--line-strong); border-radius:var(--radius); padding:0;
  width:min(760px, 94vw); max-height:86vh; box-shadow:var(--shadow); }
.dlg::backdrop{ background:var(--scrim); }
.dlg-h{ display:flex; justify-content:space-between; align-items:center; padding:16px 20px; border-bottom:1px solid var(--line); }
.dlg-h h2{ margin:0; font-size:17px; font-weight:800; letter-spacing:-.02em; }
.dlg-b{ padding:16px 20px; overflow:auto; max-height:calc(86vh - 130px); font-size:13.5px; }
.dlg-f{ display:flex; justify-content:flex-end; gap:8px; padding:12px 20px; border-top:1px solid var(--line); background:var(--canvas); }
.dlg .x{ background:none; border:0; color:var(--muted); font-size:22px; cursor:pointer; width:34px; height:34px; border-radius:var(--radius-pill); }
.dlg .x:hover{ background:var(--fill); color:var(--ink); }
.cards{ display:grid; grid-template-columns:repeat(auto-fill, minmax(160px, 1fr)); gap:12px; }
.cards > p{ grid-column:1 / -1; margin:0; }
.card{ border:1px solid var(--line); border-radius:var(--radius-md); overflow:hidden; background:var(--bg); display:flex; flex-direction:column;
  transition:border-color .15s, box-shadow .15s, transform .15s; }
.card .th{ aspect-ratio:4/5; background:var(--fill) center/cover no-repeat; display:grid; place-items:center; color:var(--muted); font-size:11px; }
.card .th.sw-th{ display:flex; aspect-ratio:auto; height:70px; }
.card .th.sw-th span{ flex:1; }
.card .cb{ padding:9px 10px; display:flex; flex-direction:column; gap:3px; flex:1; }
.card .cb b{ font-size:13px; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.card .cb small{ font-size:11px; color:var(--muted); }
.card .ca{ display:flex; flex-wrap:wrap; gap:4px; padding:0 10px 10px; }
.card .ca button{ font-size:11.5px; padding:3px 9px; min-height:26px; }
.card.pick{ cursor:pointer; }
.card.pick:hover, .card.pick:focus-visible{ border-color:var(--line-strong); box-shadow:var(--shadow-sm); transform:translateY(-2px); outline:none; }
.pill{ display:inline-block; font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--on-grad);
  background:var(--grad); border-radius:var(--radius-pill); padding:2px 8px; }

/* inspector */
.insp-head{ display:flex; align-items:center; gap:8px; padding:12px 14px 10px; border-bottom:1px solid var(--line); position:sticky; top:0;
  background:var(--bg); z-index:2; }
.insp-head b{ font-size:14px; font-weight:800; }
.insp-head small{ color:var(--muted); font-size:11.5px; margin-left:auto; }
.insp-name{ flex:1; }
.grp-tag{ color:var(--muted); font-size:12px; }
.act-grid{ display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.btn-s.on{ border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.fill-ed{ display:flex; flex-direction:column; gap:0; }
.row.stop .num{ max-width:76px; }
.checklist{ list-style:none; margin:0; padding:0; font-size:12.5px; line-height:1.9; }
.checklist .ok{ color:var(--ink); }
.checklist .miss{ color:var(--muted); }
.copy-list{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px; }
.segb svg{ width:16px; height:16px; vertical-align:middle; }
.ed-right .segb.grow button{ padding:0 4px; }
.fld .segb{ width:100%; }
.fld .row > .segb{ width:auto; }

/* colour button + popover */
.cbtn{ display:flex; align-items:center; gap:7px; background:var(--bg); border:1px solid var(--line-strong); border-radius:var(--radius-xs); color:var(--ink);
  font:inherit; font-size:12.5px; height:var(--ed-ctl); padding:0 9px; cursor:pointer; min-width:0; flex:1; }
.cbtn:hover{ border-color:var(--ink-2); }
.cdot{ width:16px; height:16px; flex:none; box-shadow:0 0 0 1px var(--line-strong); }
.cdot.none{ background:repeating-linear-gradient(45deg, #fff 0 3px, #e45 3px 5px) !important; }
.cname{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pop{ position:fixed; z-index:60; width:264px; background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-md);
  padding:10px 12px 12px; box-shadow:var(--shadow); font-size:12.5px; color:var(--ink); }
.pop-h{ font-size:12px; color:var(--ink-2); margin:6px 0 7px; font-weight:650; }
.pop .swatches{ gap:6px; }
.pop input[type=text]{ background:var(--canvas); color:var(--ink); border:1px solid var(--line-strong); border-radius:var(--radius-xs); font:inherit; font-size:12.5px; padding:6px 9px; }
.pop input[type=text]:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.pop .btn-s{ margin-top:6px; }
.ic-s{ background:none; border:0; color:var(--muted); cursor:pointer; font-size:13px; width:24px; height:24px; padding:0; flex:none; }
.ic-s:hover{ color:var(--ink); background:var(--fill); }

/* variables */
.vchips{ display:flex; flex-wrap:wrap; gap:4px; align-items:center; margin-bottom:6px; }
.vchips .vg{ font-size:11px; font-weight:600; color:var(--muted); width:100%; margin-top:4px; }
.vchip{ background:var(--bg); border:1px solid var(--line); color:var(--ink); border-radius:var(--radius-pill); font:inherit; font-size:12px; font-weight:600;
  padding:4px 10px; cursor:pointer; }
.vchip:hover{ border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.vchip.add{ border-style:dashed; border-color:var(--line-strong); color:var(--muted); }
.vchips.small .vchip{ font-size:11px; padding:2px 8px; }
.var-card{ border:1px solid var(--line); border-radius:var(--radius-sm); padding:9px 10px 3px; margin-bottom:8px; background:var(--fill); }
.var-card code{ font-size:11.5px; color:var(--accent); }
.var-card .spacer{ flex:1; }

/* fonts dialog */
.font-list{ display:grid; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); gap:6px; margin-top:10px; max-height:46vh; overflow:auto; padding-right:2px; }
.font-opt{ display:flex; flex-direction:column; align-items:flex-start; gap:2px; background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-sm);
  color:var(--ink); padding:9px 11px; cursor:pointer; text-align:left; }
.font-opt span{ font-size:21px; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.font-opt small{ font-size:10.5px; color:var(--muted); }
.font-opt:hover{ border-color:var(--line-strong); }
.font-opt[aria-pressed="true"]{ border-color:var(--accent); background:var(--accent-soft); }
.dlg input[type=text]{ flex:1; }
.dlg .lbl{ margin:0 0 8px; }
.keys{ border-collapse:collapse; width:100%; font-size:13px; }
.keys td{ padding:6px 8px; border-bottom:1px solid var(--line); }
.keys kbd{ font:inherit; font-size:11.5px; font-weight:600; background:var(--fill); border:1px solid var(--line); padding:1px 6px; white-space:nowrap; }

@media (max-width: 1100px){
  .ed{ grid-template-columns:250px minmax(0,1fr) 270px; }
  .range input[type=range]{ min-width:36px; }
  .range input[type=number]{ width:60px; padding-right:4px; }
}
/* narrow screens: panels stacked, the whole editor scrolls */
@media (max-width: 860px){
  .ed{ display:flex; flex-direction:column; overflow:auto; }
  .ed-left, .ed-right{ flex:none; overflow:visible; border:0; max-height:none; }
  .ed-center{ flex:none; height:min(64vh, 560px); border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
  .ed-right{ border-top:1px solid var(--line); }
  .tb-sub, .tb-sep{ display:none; }
  .tb-doc{ width:100%; order:1; }
  .tb-name{ width:100%; }
  .tb-state{ white-space:normal; }
  .tb-actions{ flex-wrap:wrap; order:2; }
  .ed-stage{ padding:20px; }
}
