/* FLUX — štýly editora. SR identita: #0a0a0c / #2dd4bf, Instrument Serif · DM Sans · DM Mono. */

@font-face { font-family: 'DM Sans'; src: url(../assets/fonts/dmsans.woff2) format('woff2'); font-weight: 100 1000; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; src: url(../assets/fonts/dmsans-ext.woff2) format('woff2'); font-weight: 100 1000; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Mono'; src: url(../assets/fonts/dmmono-400.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: 'DM Mono'; src: url(../assets/fonts/dmmono-400-ext.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: 'DM Mono'; src: url(../assets/fonts/dmmono-500.woff2) format('woff2'); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: 'Instrument Serif'; src: url(../assets/fonts/instrumentserif.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Instrument Serif'; src: url(../assets/fonts/instrumentserif-ext.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0100-02BA, U+1E00-1E9F; }

:root {
  --bg: #0a0a0c;
  --surface: #111114;
  --surface-2: #16161a;
  --surface-3: #1d1d22;
  --line: #24242b;
  --line-2: #2f2f37;
  --text: #ececef;
  --text-2: #a9a9b3;
  --muted: #8b8b96;
  --accent: #2dd4bf;
  --accent-ink: #04201c;
  --accent-soft: rgb(45 212 191 / 0.14);
  --warn: #f5b84a;
  --danger: #ff6b6b;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
  --left: 280px;
  --right: 348px;
  --timeline: 168px;
  --top: 48px;
  --r: 6px;
  --r-sm: 4px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: var(--accent-soft); }

.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; border-radius: var(--r); }
.skip-link:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ——— layout ——— */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--left) minmax(0, 1fr) var(--right);
  grid-template-rows: var(--top) minmax(0, 1fr) var(--timeline);
  grid-template-areas: "top top top" "left view right" "time time time";
}
.app.no-left { grid-template-columns: 0 minmax(0, 1fr) var(--right); }
.app.no-left .panel-left { visibility: hidden; }
.app.no-timeline { grid-template-rows: var(--top) minmax(0, 1fr) 34px; }
.topbar { grid-area: top; }
.panel-left { grid-area: left; }
.viewport { grid-area: view; }
.panel-right { grid-area: right; }
.timeline { grid-area: time; }
.mobile-tabs { display: none; }

/* ——— top bar ——— */
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.logo { font: 400 24px/1 var(--serif); letter-spacing: 0.02em; color: var(--text); padding: 0 6px 0 2px; display: flex; align-items: baseline; gap: 2px; user-select: none; }
.logo i { color: var(--accent); font-style: italic; }
.project-name {
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 4px 6px; width: 160px; min-width: 60px; color: var(--text);
}
.project-name:hover { border-color: var(--line-2); }
.project-name:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1px solid var(--line); }
.tb-spacer { flex: 1; }
.stats { font: 400 11px/1.2 var(--mono); color: var(--text-2); display: flex; gap: 10px; white-space: nowrap; overflow: hidden; }
.stats b { color: var(--text); font-weight: 500; }
.stats .warn { color: var(--warn); }
.chip { font: 500 11px/1 var(--mono); padding: 4px 6px; border-radius: 99px; background: rgb(245 184 74 / 0.12); color: var(--warn); border: 0; }

/* ——— buttons ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #3a3a44; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #4fe0cd; border-color: #4fe0cd; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn-danger { color: var(--danger); }
.icon-btn {
  width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center;
  border-radius: var(--r); border: 1px solid transparent; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"], .icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg, .btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn.sm { width: 22px; height: 22px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.speed-select { height: 26px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 0 4px; font: 400 12px var(--mono); }

/* ——— panels ——— */
.panel { position: relative; background: var(--surface); min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.panel-tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.panel-tab { background: transparent; border: 0; padding: 7px 10px 8px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.panel-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pane { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.pane-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 6px 12px; }
.pane-title { font: 500 11px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); flex: 1; }

.splitter { position: absolute; z-index: 5; background: transparent; }
.splitter:hover, .splitter:focus-visible, .splitter.dragging { background: var(--accent); outline: none; }
.splitter-v { top: 0; bottom: 0; right: -3px; width: 5px; cursor: col-resize; }
.splitter-left { left: -3px; right: auto; }
.splitter-h { left: 0; right: 0; top: -3px; height: 5px; cursor: row-resize; }

/* ——— scene tree ——— */
.tree { list-style: none; margin: 0; padding: 0 6px 8px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree-row {
  display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 4px 0 calc(6px + var(--depth, 0) * 16px);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); position: relative; user-select: none;
}
.tree-row:hover { background: var(--surface-2); color: var(--text); }
.tree-row[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.tree-row[aria-selected="true"]::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--accent); }
.tree-row.disabled .tree-name { opacity: 0.45; text-decoration: line-through; }
.tree-row.drop-into { box-shadow: inset 0 0 0 1px var(--accent); }
.tree-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tree-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.tree-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-badge { font: 400 10px/1 var(--mono); color: var(--muted); padding: 2px 4px; border: 1px solid var(--line-2); border-radius: 3px; }
.tree-count { font: 400 10px/1 var(--mono); color: var(--muted); min-width: 28px; text-align: right; }
.tree-row .icon-btn { opacity: 0; }
.tree-row:hover .icon-btn, .tree-row:focus-within .icon-btn, .tree-row .icon-btn.on { opacity: 1; }
.tree-rename { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--accent); border-radius: 3px; padding: 2px 4px; }
.tree-root-drop { margin: 4px 6px; padding: 8px; border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--muted); text-align: center; font-size: 11px; }
.tree-root-drop.drop-into { border-color: var(--accent); color: var(--accent); }
.scene-settings-btn { display: flex; width: calc(100% - 12px); margin: 0 6px 6px; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent; color: var(--text-2); }
.scene-settings-btn svg { width: 16px; height: 16px; flex: none; }
.scene-settings-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ——— presets ——— */
.preset-cat { padding: 4px 10px 10px; }
.preset-cat h3 { font: 400 20px/1.1 var(--serif); margin: 10px 2px 8px; color: var(--text); }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.preset-card {
  position: relative; display: flex; flex-direction: column; width: 100%; border-radius: var(--r); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg); padding: 0; text-align: left; color: var(--text-2);
}
.preset-card:hover, .preset-card:focus-visible { border-color: var(--accent); color: var(--text); }
.preset-thumb { aspect-ratio: 1; width: 100%; background-color: #0a0a0c; background-repeat: no-repeat; background-size: 1600% 100%; background-position: 0 0; }
.preset-thumb.loading { background-image: radial-gradient(circle at 50% 60%, rgb(45 212 191 / 0.12), transparent 60%); }
@keyframes thumb { to { background-position: 100% 0; } }
@media (prefers-reduced-motion: no-preference) {
  .preset-card .preset-thumb.ready { animation: thumb 1.6s steps(16, jump-none) infinite; }
}
.preset-card:hover .preset-thumb.ready, .preset-card:focus-visible .preset-thumb.ready { animation: thumb 1.6s steps(16, jump-none) infinite; }
.preset-name { padding: 6px 8px 7px; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-add {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line-2); background: rgb(10 10 12 / 0.75); color: var(--text); display: grid; place-items: center; opacity: 0;
}
.preset-card:hover .preset-add, .preset-card:focus-within .preset-add, .preset-add:focus-visible { opacity: 1; }
.preset-add svg { width: 14px; height: 14px; }
.preset-hint { padding: 10px 12px 0; color: var(--muted); font-size: 12px; }

/* ——— viewport ——— */
.viewport { position: relative; overflow: hidden; background: var(--bg); min-width: 0; min-height: 0; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.viewport canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.viewport.trigger canvas { cursor: crosshair; }
.viewport.picking canvas { cursor: copy; }
.viewport-toolbar {
  position: absolute; top: 8px; left: 8px; display: flex; gap: 2px; padding: 3px;
  background: rgb(17 17 20 / 0.86); border: 1px solid var(--line); border-radius: 8px; backdrop-filter: blur(8px);
}
.viewport-toolbar .sep { width: 1px; background: var(--line); margin: 3px 2px; }
.viewport-toolbar select { height: 28px; background: transparent; border: 0; color: var(--text-2); padding: 0 4px; font-size: 12px; }
.seg { display: inline-flex; background: var(--bg); border-radius: var(--r); padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); height: 24px; padding: 0 8px; border-radius: var(--r-sm); font: 500 11px var(--mono); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.viewport-hud { position: absolute; left: 10px; bottom: 8px; font: 400 11px var(--mono); color: var(--muted); pointer-events: none; text-shadow: 0 1px 2px #000; }
.viewport-hud .warn { color: var(--warn); }
.viewport-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); pointer-events: none; }
.viewport-empty h2 { font: 400 32px/1.1 var(--serif); color: var(--text); margin: 0 0 6px; }

/* ——— inspector ——— */
.inspector { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; padding-bottom: 40px; }
.insp-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.insp-head h2 { font: 400 22px/1.1 var(--serif); margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-head .sub { font: 400 11px var(--mono); color: var(--muted); }
.insp-locked { margin: 10px 12px; padding: 8px 10px; border-radius: var(--r); background: rgb(245 184 74 / 0.08); color: var(--warn); font-size: 12px; }
fieldset.insp-body { border: 0; margin: 0; padding: 0; min-width: 0; }
.section { border-bottom: 1px solid var(--line); }
.section-head { display: flex; align-items: center; gap: 4px; padding: 0 8px 0 4px; height: 36px; }
.section-toggle {
  flex: 1; display: flex; align-items: center; gap: 6px; height: 100%; background: transparent; border: 0;
  text-align: left; padding: 0 4px; color: var(--text); font-weight: 500; min-width: 0;
}
.section-toggle svg { width: 12px; height: 12px; color: var(--muted); transition: transform 0.15s; flex: none; }
.section-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.section.off .section-toggle { color: var(--muted); }
.section-body { padding: 2px 12px 12px; display: grid; gap: 6px; }
.section-body[hidden] { display: none; }

.switch { position: relative; width: 28px; height: 16px; 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: 99px; background: var(--line-2); transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 26px; }
.field-label { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.field-label.scrub { cursor: ew-resize; }
.field-label.scrub:hover { color: var(--text); }
.field-ctrl { display: flex; gap: 4px; min-width: 0; align-items: center; }
.field.stack { grid-template-columns: 1fr; gap: 4px; }
.field.stack > .field-head { display: flex; align-items: center; gap: 6px; }
.field.stack > .field-head .field-label { flex: 1; }
.num, .txt, .sel {
  height: 26px; min-width: 0; width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 6px; color: var(--text);
}
.num { font: 400 12px var(--mono); text-align: right; }
.num:hover, .txt:hover, .sel:hover { border-color: var(--line-2); }
.num:focus, .txt:focus, .sel:focus { border-color: var(--accent); outline: none; }
.sel { padding: 0 4px; font-size: 12px; }
.mode-sel { width: auto; flex: none; height: 22px; font: 400 11px var(--mono); color: var(--muted); background: transparent; border-color: transparent; }
.mode-sel:hover { border-color: var(--line-2); }
.vec { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)) auto; gap: 3px; width: 100%; }
.vec .axis { position: relative; }
.vec .axis::before { content: attr(data-axis); position: absolute; left: 5px; top: 50%; transform: translateY(-50%); font: 500 10px var(--mono); color: var(--muted); pointer-events: none; }
.vec .axis[data-axis="x"]::before { color: #ff7a7a; }
.vec .axis[data-axis="y"]::before { color: #7ae08a; }
.vec .axis[data-axis="z"]::before { color: #7aa8ff; }
.vec .num { padding-left: 14px; }
.unit { font: 400 11px var(--mono); color: var(--muted); flex: none; }
.swatch { width: 26px; height: 26px; flex: none; border-radius: var(--r-sm); border: 1px solid var(--line-2); padding: 0; background-clip: padding-box; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.35; }
.list { display: grid; gap: 6px; }
.list-item { border: 1px solid var(--line); border-radius: var(--r); padding: 8px; display: grid; gap: 6px; background: var(--surface-2); }
.list-item-head { display: flex; align-items: center; gap: 6px; font: 500 11px var(--mono); color: var(--muted); }
.list-item-head span { flex: 1; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ——— curve / gradient editor ——— */
.curve { position: relative; display: grid; gap: 4px; }
.curve-canvas { width: 100%; height: 96px; display: block; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); touch-action: none; cursor: crosshair; }
.curve-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.curve-tools { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.curve-tools .sel { width: auto; height: 22px; font-size: 11px; }
.curve-tools .num { width: 56px; height: 22px; }
.curve-table { width: 100%; border-collapse: collapse; font: 400 11px var(--mono); }
.curve-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 2px 4px; }
.curve-table td { padding: 1px 2px; }
.curve-table .num { height: 22px; }

.gradient { display: grid; gap: 4px; }
.grad-wrap { position: relative; padding: 12px 0; }
.grad-bar { height: 22px; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; width: 100%; cursor: copy; }
.grad-stops { position: absolute; left: 0; right: 0; height: 12px; }
.grad-stops.top { top: 0; }
.grad-stops.bottom { bottom: 0; }
.grad-stop {
  position: absolute; width: 12px; height: 12px; margin-left: -6px; padding: 0; border: 2px solid var(--text-2); border-radius: 3px;
  background: var(--c, #fff); touch-action: none; cursor: ew-resize;
}
.grad-stop.alpha { border-radius: 50%; }
.grad-stop[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgb(45 212 191 / 0.35); }

/* ——— color picker popover ——— */
.popover {
  position: fixed; z-index: 60; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.55); padding: 10px; width: 244px; display: grid; gap: 8px;
}
.cp-sv { width: 100%; height: 140px; border-radius: var(--r); display: block; touch-action: none; cursor: crosshair; }
.cp-hue { width: 100%; accent-color: var(--accent); }
.cp-row { display: grid; grid-template-columns: 52px 1fr; gap: 6px; align-items: center; }
.cp-row label { color: var(--muted); font-size: 11px; }
.cp-lch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.cp-preview { height: 22px; border-radius: var(--r-sm); border: 1px solid var(--line-2); }

/* ——— timeline ——— */
.timeline { position: relative; background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tl-bar { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; border-bottom: 1px solid var(--line); flex: none; }
.tl-time { font: 500 12px var(--mono); color: var(--text); min-width: 112px; }
.tl-time span { color: var(--muted); }
.tl-body { flex: 1; position: relative; min-height: 0; }
.tl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.tl-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app.no-timeline .tl-body { display: none; }
.tl-bar .num { width: 64px; height: 24px; }

/* ——— dialog ——— */
dialog {
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-shadow: 0 30px 80px rgb(0 0 0 / 0.6);
}
dialog::backdrop { background: rgb(4 4 6 / 0.7); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; padding: 14px 16px 10px; gap: 8px; }
.dlg-head h2 { font: 400 26px/1.1 var(--serif); margin: 0; flex: 1; }
.dlg-body { padding: 4px 16px 12px; display: grid; gap: 10px; overflow: auto; max-height: calc(100dvh - 160px); }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px 16px; border-top: 1px solid var(--line); align-items: center; }
.dlg-foot .grow { flex: 1; color: var(--muted); font-size: 12px; }
.fmt-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.fmt-tabs button { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: var(--r); padding: 6px 10px; color: var(--text-2); }
.fmt-tabs button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.1s; }
.warnbox { padding: 10px 12px; border-radius: var(--r); background: rgb(245 184 74 / 0.08); border: 1px solid rgb(245 184 74 / 0.25); color: #f8d394; font-size: 12px; }
.proj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.proj-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); }
.proj-list li .meta { flex: 1; min-width: 0; }
.proj-list li .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-list li .meta span { color: var(--muted); font: 400 11px var(--mono); }
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
kbd { font: 500 11px var(--mono); padding: 2px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }

.menu {
  position: fixed; z-index: 70; min-width: 220px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: 0 16px 40px rgb(0 0 0 / 0.5);
}
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-3); outline: none; }
.menu button .k { margin-left: auto; font: 400 11px var(--mono); color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ——— toasts ——— */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 9px 12px; max-width: 360px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.4); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }

/* ——— mobil / tablet (FX-UI-01) ——— */
@media (max-width: 899px) {
  .app, .app.no-left, .app.no-timeline {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top) minmax(0, 1fr) 52px;
    grid-template-areas: "top" "view" "tabs";
  }
  .mobile-tabs {
    grid-area: tabs; display: flex; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .mobile-tabs button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); color: var(--text-2); min-height: 40px; font-weight: 500; }
  .mobile-tabs button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
  .toasts { left: 10px; right: 10px; bottom: calc(52px + env(safe-area-inset-bottom) + 10px); }
  .toasts .toast { max-width: none; pointer-events: none; }
  .panel-left, .panel-right, .timeline {
    position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); z-index: 30;
    height: min(62dvh, 560px); border: 0; border-top: 1px solid var(--line-2); border-radius: 14px 14px 0 0;
    box-shadow: 0 -20px 50px rgb(0 0 0 / 0.5); transform: translateY(110%); transition: transform 0.22s ease; visibility: hidden;
  }
  .timeline { height: 220px; }
  .app[data-mobile-panel="left"] .panel-left,
  .app[data-mobile-panel="right"] .panel-right,
  .app[data-mobile-panel="timeline"] .timeline { transform: none; visibility: visible; }
  .app.no-left .panel-left { visibility: hidden; }
  .app.no-left[data-mobile-panel="left"] .panel-left { visibility: visible; }
  .splitter { display: none; }
  .stats .opt, .tb-group.opt, .project-name { display: none; }
  .topbar { gap: 2px; padding: 0 6px; overflow-x: auto; }
  .field { grid-template-columns: 96px minmax(0, 1fr); }
  .icon-btn { width: 36px; height: 36px; }
}
@media (pointer: coarse) {
  .num, .txt, .sel { height: 32px; }
  .tree-row { height: 38px; }
  .grad-stop { width: 18px; height: 18px; margin-left: -9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
