/* Spline — professional workspace theme (see design-system/spline/MASTER.md).
   Dark by default, like Photoshop / AutoCAD; light theme via [data-theme="light"]. */
:root,
:root[data-theme="dark"] {
  --bg-app: #1E1E1E;          /* behind everything */
  --bg-panel: #2B2B2B;        /* panels, bars */
  --bg-panel-2: #323232;      /* panel headers, inputs */
  --bg-raised: #3A3A3A;       /* hover, buttons */
  --bg-active: #474747;
  --bg-input: #1F1F1F;
  --line: #151515;            /* hard separators between panels */
  --line-soft: #3D3D3D;
  --text: #E3E3E3;
  --text-2: #A8A8A8;          /* secondary, 7.0:1 on panel */
  --text-3: #8A8A8A;          /* hints, 4.6:1 on panel */
  --accent: #3B8EEA;
  --accent-strong: #2F7BD4;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(59, 142, 234, 0.22);
  --danger: #F26B6B;
  --ok: #4CC38A;
  --focus: #6AB0FF;

  --tile-bg: #2A2A2A;
  --tile-glyph: #E8E8E8;
  --tile-ghost: #4A4A4A;

  --canvas-pasteboard: #1B1B1B;
  --canvas-bg: #232323;       /* em box */
  --canvas-grid: #282828;
  --canvas-grid-major: #333333;
  --canvas-user-guide: #22D3EE;
  --ruler-bg: #2B2B2B;
  --ruler-line: #6A6A6A;
  --ruler-text: #A8A8A8;
  --canvas-line: #3A3A3A;
  --canvas-metric: #4E7FB8;
  --canvas-ink: #E6E6E6;
  --canvas-guide: rgba(59, 142, 234, 0.13);
  --canvas-handle: #8C8C8C;
  --canvas-node-fill: #1B1B1B;
  --canvas-text: #8A8A8A;

  --label-red: #6B2E2E; --label-orange: #6E4422; --label-yellow: #6A5A1E;
  --label-green: #27553A; --label-blue: #23466E; --label-purple: #4B3168;
  --dot-red: #E5534B; --dot-orange: #E08A3C; --dot-yellow: #D9B62B;
  --dot-green: #3FB46F; --dot-blue: #3B8EEA; --dot-purple: #9B6BDF;

  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-app: #D6D6D6;
  --bg-panel: #F0F0F0;
  --bg-panel-2: #E4E4E4;
  --bg-raised: #DADADA;
  --bg-active: #C8C8C8;
  --bg-input: #FFFFFF;
  --line: #B4B4B4;
  --line-soft: #D0D0D0;
  --text: #1C1C1C;
  --text-2: #4A4A4A;
  --text-3: #626262;
  --accent: #1F6FD1;
  --accent-strong: #185DB2;
  --accent-soft: rgba(31, 111, 209, 0.16);
  --danger: #C62828;
  --ok: #1E8A55;
  --focus: #1F6FD1;
  --tile-bg: #FFFFFF;
  --tile-glyph: #1C1C1C;
  --tile-ghost: #D2D2D2;
  --canvas-pasteboard: #E2E2E2;
  --canvas-bg: #FFFFFF;
  --canvas-grid: #F2F2F2;
  --canvas-grid-major: #E2E2E2;
  --canvas-user-guide: #0891B2;
  --ruler-bg: #F0F0F0;
  --ruler-line: #9A9A9A;
  --ruler-text: #4A4A4A;
  --canvas-line: #DADADA;
  --canvas-metric: #6C9AD4;
  --canvas-ink: #1C1C1C;
  --canvas-guide: rgba(31, 111, 209, 0.12);
  --canvas-handle: #7A7A7A;
  --canvas-node-fill: #FFFFFF;
  --canvas-text: #6E6E6E;
  --label-red: #F6CFCF; --label-orange: #F8DDC3; --label-yellow: #F4EAB8;
  --label-green: #CBEBD6; --label-blue: #CFE0F6; --label-purple: #E2D3F3;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

:root {
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace;
  --font-guide: Arial, Helvetica, sans-serif;
  --fs: 13px;
  --fs-s: 12px;
  --ctl-h: 28px;
  --radius: 4px;
  --t-fast: 120ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: grid;
  grid-template-rows: 32px 38px 1fr auto 24px;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
  font: 400 var(--fs)/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { flex: none; display: block; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--bg-active) transparent; }

/* ------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl-h); padding: 0 10px;
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--text);
  white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: var(--bg-active); }
.btn:active { background: var(--bg-panel-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--danger); }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-block { width: 100%; justify-content: flex-start; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

input[type="text"], input[type="number"], input[type="search"], input:not([type]), select {
  height: var(--ctl-h); padding: 0 8px; min-width: 0;
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--bg-input); color: var(--text);
  transition: border-color var(--t-fast);
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input[type="number"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
input[readonly] { color: var(--text-2); }
input[type="range"] { accent-color: var(--accent); height: 16px; }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }

/* ------------------------------------------------------------- menu bar */
.menubar {
  display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: var(--bg-panel); border-bottom: 1px solid var(--line);
  user-select: none;
}
.app-logo { margin: 0 4px; }
.menus { display: flex; height: 100%; }
.menu-root { position: relative; height: 100%; }
.menu-root > button {
  height: 100%; padding: 0 10px; border: 0; background: transparent; color: var(--text);
}
.menu-root > button:hover, .menu-root > button[aria-expanded="true"] { background: var(--bg-raised); }
.menu {
  position: absolute; left: 0; top: 100%; z-index: 40; min-width: 260px; padding: 4px 0;
  background: var(--bg-panel-2); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-pop);
}
.menu[hidden] { display: none; }
.menu [role^="menuitem"] {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px;
  width: 100%; height: 28px; padding: 0 14px 0 8px; border: 0; background: transparent; text-align: left; color: var(--text);
}
.menu [role^="menuitem"]:hover, .menu [role^="menuitem"]:focus-visible { background: var(--accent); color: var(--on-accent); outline: none; }
.menu [role^="menuitem"]:disabled { color: var(--text-3); background: transparent; cursor: default; }
.menu kbd { font: var(--fs-s) var(--font-ui); color: inherit; opacity: 0.7; }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 0; }
.doc-title {
  display: flex; align-items: center; gap: 6px; margin: 0 auto; max-width: 40vw; height: 24px; padding: 0 10px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2);
}
.doc-title:hover { background: var(--bg-raised); color: var(--text); }
.doc-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); flex: none; }
.menubar-right { display: flex; align-items: center; gap: 6px; }
.view-switch { display: flex; border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.view-switch button { height: 22px; padding: 0 12px; border: 0; background: transparent; color: var(--text-2); font-size: var(--fs-s); }
.view-switch button:hover { background: var(--bg-raised); color: var(--text); }
.view-switch button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.view-kern { grid-template-columns: minmax(0, 1fr) 270px; }
.pair-big { display: flex; justify-content: center; gap: 4px; font: 400 40px/1.1 var(--font-guide); padding: 6px 0; }
.pair-big span { min-width: 40px; text-align: center; background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.step-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.kern-list { display: flex; flex-direction: column; max-height: 360px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.kern-list .row { display: grid; grid-template-columns: 1fr auto 26px; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; border-bottom: 1px solid var(--line-soft); }
.kern-list .row:last-child { border-bottom: 0; }
.kern-list .row:hover { background: var(--bg-raised); }
.kern-list .row button.pick { border: 0; background: transparent; text-align: left; padding: 3px 0; color: var(--text); }
.kern-list .val { font-family: var(--font-mono); font-size: var(--fs-s); }
.kern-list .val.neg { color: var(--danger); }
.kern-list .val.pos { color: var(--ok); }
.kern-list .btn-icon { width: 24px; height: 24px; }
.kern-list .row button.pick { display: flex; align-items: baseline; gap: 6px; }
.kgroup { color: var(--accent); font-family: var(--font-mono); font-size: var(--fs-s); }
.kside { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.field-inline { display: grid; grid-template-columns: minmax(0, 1fr) 90px; align-items: center; gap: 8px; color: var(--text-2); font-size: var(--fs-s); }
.optionsbar input.kern-text { width: min(520px, 40vw); }
.preview-out { font-kerning: normal; }
.menubar .btn { height: 24px; }

/* ------------------------------------------------------------- app window frame */
/* Inside the Spline window the menu bar is also the title bar. */
.native .menubar { padding-right: 0; }
.win-controls { display: flex; align-self: stretch; margin-left: 6px; }
.win-controls[hidden] { display: none; }
.win-btn {
  width: 46px; height: 100%; display: grid; place-items: center; border: 0; border-radius: 0;
  background: transparent; color: var(--text); transition: background-color var(--t-fast);
}
.win-btn:hover { background: var(--bg-raised); }
.win-btn:active { background: var(--bg-active); }
.win-close:hover { background: #C42B1C; color: #FFFFFF; }
.win-close:active { background: #A1261A; color: #FFFFFF; }
.win-btn .i-restore, .maximized .win-btn .i-max { display: none; }
.maximized .win-btn .i-restore { display: block; }
.resize-edges { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.resize-edges[hidden] { display: none; }
.resize-edges div { pointer-events: auto; }
.resize-edges div { position: fixed; z-index: 90; }
.resize-edges [data-edge="n"] { top: 0; left: 8px; right: 8px; height: 4px; cursor: ns-resize; }
.resize-edges [data-edge="s"] { bottom: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
.resize-edges [data-edge="w"] { left: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
.resize-edges [data-edge="e"] { right: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
.resize-edges [data-edge="nw"] { left: 0; top: 0; width: 8px; height: 8px; cursor: nwse-resize; }
.resize-edges [data-edge="se"] { right: 0; bottom: 0; width: 8px; height: 8px; cursor: nwse-resize; }
.resize-edges [data-edge="ne"] { right: 0; top: 0; width: 8px; height: 8px; cursor: nesw-resize; }
.resize-edges [data-edge="sw"] { left: 0; bottom: 0; width: 8px; height: 8px; cursor: nesw-resize; }
.maximized .resize-edges { display: none; }

/* ------------------------------------------------------------- options bar */
.optionsbar {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; min-width: 0; overflow-x: auto;
  background: var(--bg-panel); border-bottom: 1px solid var(--line);
}
.optionsbar .group { display: flex; align-items: center; gap: 6px; flex: none; }
.optionsbar .sep { width: 1px; height: 20px; background: var(--line-soft); flex: none; }
.optionsbar label { display: flex; align-items: center; gap: 6px; color: var(--text-2); flex: none; }
.optionsbar input[type="number"] { width: 64px; }
.optionsbar input[type="range"] { width: 120px; }
.optionsbar input[type="search"] { width: 220px; }
.opt-tool { display: flex; align-items: center; gap: 6px; font-weight: 600; flex: none; }
.glyph-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.glyph-nav .cur { min-width: 120px; text-align: center; }
.glyph-nav .cur b { font-size: 16px; margin-right: 6px; }
.glyph-nav .cur small { color: var(--text-3); }

/* ------------------------------------------------------------- workspace */
.workspace { min-height: 0; background: var(--line); }
.view { height: 100%; display: grid; gap: 1px; min-height: 0; }
.view[hidden] { display: none; }
.view-grid { grid-template-columns: 220px minmax(0, 1fr) 270px; }
.view-editor { grid-template-columns: 42px minmax(0, 1fr) 270px; }

.panel, .dock { background: var(--bg-panel); min-height: 0; overflow: auto; }
.panel.side { display: flex; flex-direction: column; overflow: hidden; }
/* The upper part scrolls; metrics and the site slot stay pinned below it. */
.panel.side > .panel-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.side-metrics { flex: none; padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.side-metrics:empty { display: none; }
.side-slot {
  flex: none; padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: center;
  overflow: hidden; contain: layout paint; /* whatever a site puts here cannot spill over the editor */
}
.side-slot:empty { display: none; }
.metrics-widget { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.metrics-widget label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-3); text-align: center; }
.metrics-widget input { text-align: center; padding: 0 4px; }
.with-unit { display: flex; align-items: center; gap: 4px; }
.with-unit input { flex: 1; width: 0; }
.with-unit em { font-style: normal; color: var(--text-3); width: 14px; }
.with-unit .btn-icon { width: 26px; height: 26px; flex: none; }
.optionsbar .check { color: var(--text); }
.opt-label { color: var(--text-3); }
.optionsbar output { width: 18px; font-size: var(--fs-s); color: var(--text-2); }
.op-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.op-row .btn-icon { width: 100%; height: 32px; }
.xy-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.xy-grid label { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: center; gap: 4px; color: var(--text-3); font-size: var(--fs-s); }
.xy-grid input { width: 100%; }
.panel-head, .dock summary {
  display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  background: var(--bg-panel-2); border-bottom: 1px solid var(--line);
  font-size: var(--fs-s); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2);
  user-select: none;
}
.panel-body, .dock .section { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.sub-head { font-size: var(--fs-s); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; }

.dock details { border-bottom: 1px solid var(--line); }
.dock summary { cursor: pointer; list-style: none; }
.dock summary::-webkit-details-marker { display: none; }
.dock summary::before {
  content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor; transition: transform var(--t-fast);
}
.dock details:not([open]) summary::before { transform: rotate(-90deg); }

.cat-list { display: flex; flex-direction: column; }
.cat-list button {
  display: flex; justify-content: space-between; align-items: center; height: 26px; padding: 0 8px;
  border: 0; border-radius: var(--radius); background: transparent; text-align: left; color: var(--text);
}
.cat-list button:hover { background: var(--bg-raised); }
.cat-list button[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.cat-list .count { color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-s); }

.color-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%; padding: 0;
  border: 2px solid var(--bg-panel); box-shadow: 0 0 0 1px var(--line-soft);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.swatch.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%), var(--bg-input); }

.progress-bar { height: 4px; border-radius: 2px; background: var(--bg-input); overflow: hidden; }
.progress-bar div { height: 100%; width: 0; background: var(--accent); transition: width 300ms ease-out; }
.progress-label { font-size: var(--fs-s); color: var(--text-2); }

/* ------------------------------------------------------------- glyph grid */
.grid-wrap { overflow: auto; min-height: 0; background: var(--bg-app); padding: 10px; }
.glyph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 96px), 1fr)); gap: 4px; outline: none; }
.tile {
  position: relative; display: flex; flex-direction: column; aspect-ratio: 0.86; padding: 4px;
  border: 1px solid transparent; border-radius: 3px; background: var(--tile-bg); color: var(--tile-glyph);
  transition: border-color var(--t-fast);
}
.tile:hover { border-color: var(--line-soft); }
.tile[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile[data-color="red"] { background: var(--label-red); }
.tile[data-color="orange"] { background: var(--label-orange); }
.tile[data-color="yellow"] { background: var(--label-yellow); }
.tile[data-color="green"] { background: var(--label-green); }
.tile[data-color="blue"] { background: var(--label-blue); }
.tile[data-color="purple"] { background: var(--label-purple); }
.tile svg.glyph { flex: 1; width: 100%; min-height: 0; }
.tile .ghost { flex: 1; display: grid; place-items: center; font: 400 calc(var(--tile, 96px) * 0.42)/1 var(--font-guide); color: var(--tile-ghost); }
.tile .label { display: flex; justify-content: space-between; gap: 4px; font-size: 11px; color: var(--text-2); }
.tile .label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: center; }
.tile .label .code { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); }
.tile[data-color] .label, .tile[data-color] .label .code { color: var(--text); opacity: 0.85; }
.grid-section { grid-column: 1 / -1; margin: 10px 0 4px; font-size: 18px; font-weight: 400; color: var(--text); }
.grid-section:first-child { margin-top: 0; }
.tile .mark { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.grid-empty { padding: 40px; text-align: center; color: var(--text-3); }

/* ------------------------------------------------------------- dock content */
.big-glyph { aspect-ratio: 1.3; display: grid; place-items: center; background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: var(--radius); color: var(--tile-glyph); }
.big-glyph svg { width: 80%; height: 85%; }
.big-glyph .ghost { font: 400 96px/1 var(--font-guide); color: var(--tile-ghost); }
.prop { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px; }
.prop > span { color: var(--text-2); }
.prop-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.prop-pair label { display: flex; flex-direction: column; gap: 3px; color: var(--text-2); font-size: var(--fs-s); }
.title-row { display: flex; align-items: baseline; gap: 8px; }
.title-row b { font-size: 18px; }
.title-row small { color: var(--text-3); }
.hint { color: var(--text-3); margin: 0; }
.btn-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.btn-row .btn, .btn-block { overflow: hidden; }
.btn span { overflow: hidden; text-overflow: ellipsis; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); }

/* ------------------------------------------------------------- editor */
.toolstrip { background: var(--bg-panel); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; overflow: auto; }
#toolButtons { display: flex; flex-direction: column; gap: 2px; }
.tool {
  position: relative; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.tool:hover { background: var(--bg-raised); color: var(--text); }
.tool[aria-checked="true"] { background: var(--bg-active); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.tool-sep { width: 24px; height: 1px; background: var(--line-soft); margin: 4px 0; }
.canvas-wrap { position: relative; overflow: hidden; min-height: 0; min-width: 0; background: var(--canvas-pasteboard); touch-action: none; }
#canvas { position: absolute; inset: 0; display: block; outline: none; }
#canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }

/* ------------------------------------------------------------- preview */
.preview { background: var(--bg-panel); border-top: 1px solid var(--line); min-height: 0; }
.preview-head { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; }
.collapse { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px; border: 0; border-radius: var(--radius); background: transparent; font-weight: 600; flex: none; }
.collapse:hover { background: var(--bg-raised); }
.collapse[aria-expanded="false"] .icon { transform: rotate(-90deg); }
#previewInput { flex: 1; }
.preview-size { display: flex; align-items: center; gap: 6px; color: var(--text-2); flex: none; }
.preview-size output { width: 28px; font-family: var(--font-mono); font-size: var(--fs-s); }
.preview-body { padding: 0 12px 10px; max-height: 26vh; overflow: auto; }
.preview-body[hidden] { display: none; }
.preview-out { white-space: pre-wrap; word-break: break-word; line-height: 1.25; color: var(--text); }
.preview-out[hidden] { display: none; }
.preview-out .mine { font-family: var(--preview-font), var(--font-guide); }
.preview-out .missing { font-family: var(--font-guide); color: var(--text-3); }
.preview-msg { margin: 0; color: var(--text-3); }
.preview-msg:empty { display: none; }

/* ------------------------------------------------------------- status bar */
.statusbar {
  display: flex; align-items: center; gap: 12px; padding: 0 10px; min-width: 0;
  background: var(--bg-panel-2); border-top: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-s);
}
#statusTip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-right { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.update-badge {
  height: 18px; padding: 0 8px; border: 0; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 600; transition: background-color var(--t-fast);
}
.update-badge:hover { background: var(--accent-strong); }
.update-badge[hidden] { display: none; }

/* ------------------------------------------------------------- dialogs, toasts, tooltip */
.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-panel); color: var(--text); box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h2 { margin: 0; padding: 0 14px; height: 34px; display: flex; align-items: center; font-size: var(--fs); font-weight: 600; background: var(--bg-panel-2); border-bottom: 1px solid var(--line); }
.dialog form { display: flex; flex-direction: column; }
.dialog .body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.dialog .field { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
.dialog .field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.dialog h3 { margin: 6px 0 0; font-size: var(--fs-s); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.dialog .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-soft); }
.dialog .keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.dialog kbd { font: var(--fs-s) var(--font-mono); padding: 1px 6px; border-radius: 3px; background: var(--bg-input); border: 1px solid var(--line-soft); white-space: nowrap; }
.dialog dd { margin: 0; }
.dialog p { margin: 0; }

.toasts { position: fixed; right: 12px; bottom: 34px; display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 420px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--bg-panel-2); box-shadow: var(--shadow-pop); border-left: 3px solid var(--ok);
}
.toast.error { border-left-color: var(--danger); }
.toast .icon { color: var(--ok); }
.toast.error .icon { color: var(--danger); }
.toast.leaving { opacity: 0; transition: opacity 150ms ease-in; }

.tooltip {
  position: fixed; z-index: 70; padding: 4px 8px; border-radius: 3px; pointer-events: none;
  background: #111; color: #EEE; font-size: var(--fs-s); box-shadow: var(--shadow-pop); white-space: nowrap;
}
.tooltip[hidden] { display: none; }
.tooltip kbd { font: inherit; color: #9CC6FF; margin-left: 6px; }

.drop-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); }
.drop-overlay[hidden] { display: none; }
.drop-overlay div { text-align: center; padding: 28px 44px; border: 2px dashed var(--accent); border-radius: 8px; background: var(--bg-panel); color: var(--text); }
.drop-overlay .icon { margin: 0 auto 8px; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .view-grid { grid-template-columns: 190px minmax(0, 1fr); }
  .view-grid .dock { display: none; }
  .view-editor { grid-template-columns: 42px minmax(0, 1fr) 230px; }
}
@media (max-width: 760px) {
  body { grid-template-rows: auto auto 1fr auto 24px; overflow: auto; }
  .menubar { flex-wrap: wrap; }
  .doc-title { display: none; }
  .view-grid { grid-template-columns: 1fr; }
  .view-grid .side { display: none; }
  .view-editor { grid-template-columns: 42px minmax(0, 1fr); grid-template-rows: minmax(360px, 1fr) auto; }
  .view-editor .dock { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
