:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--base);
  --base: #191a1f;
  --panel: #24252b;
  --bar: #202126;
  --strip: #28292f;
  --raised: #303138;
  --field: #1c1d23;
  --line: #383940;
  --divider: #191a1e;
  --control-border: #50515a;
  --control-border-hover: #676771;
  --low: #a9aab5;
  --label: #c5c5cf;
  --text: #e8e8ed;
  --hover: #36373e;
  --hover-text: #ffffff;
  --accent: #b3a3ff;
  --accent-bg: #3c3457;
  --accent-text: #e1dbff;
  --accent-line: #675886;
  --brand-shadow: #9383da;
  --primary: #b6a6ff;
  --primary-hover: #c7bbff;
  --on-primary: #211937;
  --preview-active: #ffb09e;
  --on-preview-active: #331b13;
  --preview-label: #ffc1ac;
  --danger: #ff9fa6;
  --danger-bg: #35262d;
  --danger-border: #795159;
  --pasteboard: #36373d;
  --pasteboard-dot: #505159;
  --track: #222329;
  --track-grid: #85869233;
  --exposure: #41414d;
  --tween: #60537c;
  --tween-hover: #817196;
  --hold: #45464f;
  --key: #d4cdea;
  --key-edge: #ece9f8;
  --event: #594881;
  --event-text: #e3ddff;
  --playhead: #ff907c;
  --dialog-backdrop: #101015b8;
  --dock-height: clamp(192px, 30vh, 330px);
  --track-label: clamp(192px, 18vw, 242px);
  font-synthesis: none;
}
:root[data-theme="light"] {
  color-scheme: light;
  --base: #eff0f4;
  --panel: #f8f9fb;
  --bar: #ebedf2;
  --strip: #f0f1f5;
  --raised: #ffffff;
  --field: #ffffff;
  --line: #cbd0db;
  --divider: #bfc4d0;
  --control-border: #a6acba;
  --control-border-hover: #727b8d;
  --low: #555d6e;
  --label: #41485a;
  --text: #222735;
  --hover: #dee1e9;
  --hover-text: #171b25;
  --accent: #59429d;
  --accent-bg: #e7e0f8;
  --accent-text: #49327d;
  --accent-line: #9580bf;
  --brand-shadow: #806ab9;
  --primary: #61479f;
  --primary-hover: #503a87;
  --on-primary: #ffffff;
  --preview-active: #873b2d;
  --on-preview-active: #ffffff;
  --preview-label: #903f2f;
  --danger: #9a293f;
  --danger-bg: #ffebee;
  --danger-border: #c78794;
  --pasteboard: #d9dce4;
  --pasteboard-dot: #afb5c3;
  --track: #f4f5f8;
  --track-grid: #4750692e;
  --exposure: #d1d6e1;
  --tween: #bcacd6;
  --tween-hover: #a693c3;
  --hold: #bfc5d0;
  --key: #504364;
  --key-edge: #403351;
  --event: #634c8f;
  --event-text: #ffffff;
  --playhead: #a23222;
  --dialog-backdrop: #252b3c66;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  overflow: hidden;
}
button, input, select, textarea, summary { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, select, input, textarea { min-width: 0; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { border: 0; background: transparent; }
button:not(:disabled):hover, summary:hover { color: var(--hover-text); background-color: var(--hover); }
button:disabled, select:disabled, input:disabled, textarea:disabled { opacity: .43; cursor: default; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
h2, h3, h4, p { margin: 0; }
h2 { font-size: 13px; font-weight: 650; }
h3, h4 { font-size: 12px; font-weight: 600; }
h4 { color: var(--text); }
button, select, summary { border-radius: 4px; }
.topbar, .brand, .file-actions, .history-actions, .stage-toolbar, .stage-context, .stage-meta, .stage-footer, .path-actions,
.timeline-heading, .timeline-title, .timeline-controls, .transport, .section-heading, .object-arrange, .dock-tabs, .project-io-header, .project-io-actions {
  display: flex;
  align-items: center;
}
.topbar {
  padding: 0 14px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  background: var(--bar);
}
.brand {
  flex: none;
  gap: 9px;
  font-size: 16px;
  font-weight: 690;
  letter-spacing: -.045em;
}
.brand strong { font-weight: 450; color: var(--label); }
.brand-mark {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 27px;
  transform: skewY(-8deg);
  color: var(--accent);
}
.brand-mark::before, .brand-mark::after, .brand-mark i {
  content: "";
  position: absolute;
  top: 5px;
  left: 2px;
  width: 17px;
  height: 8px;
  background: currentColor;
  transform: skewX(-26deg);
  border-radius: 1px;
}
.brand-mark i {
  top: 11px;
  left: 8px;
  background: var(--brand-shadow);
}
.brand-mark::after { top: 17px; left: 3px; }
.file-actions, .history-actions {
  border-left: 1px solid var(--line);
  padding-left: 10px;
  gap: 2px;
}
.file-actions button, #toggle-dock {
  padding: 6px 9px;
  color: var(--label);
  font-size: 12px;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 28px;
  padding: 0;
  font-size: 16px;
}
.history-actions .icon-button { font-size: 22px; }
.theme-control {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}
.theme-icon {
  position: absolute;
  left: 8px;
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  color: var(--label);
  pointer-events: none;
}
#editor-theme {
  height: 30px;
  padding-left: 27px;
  font-size: 12px;
}
#preview-button {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 650;
}
#preview-button::before, #play-button::before {
  content: "";
  width: 8px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(0 0,100% 50%,0 100%);
}
#preview-button:hover { background: var(--primary-hover); color: var(--on-primary); }
#preview-button.is-active { background: var(--preview-active); color: var(--on-preview-active); }
#preview-button.is-active::before { clip-path: none; height: 8px; }
#toggle-dock { display: none; }
.editor-shell {
  display: grid;
  grid-template-columns: 60px minmax(0,1fr) clamp(255px, 20.5vw, 325px);
  min-height: 0;
}
.tool-rail {
  z-index: 4;
  min-height: 0;
  border-right: 1px solid var(--divider);
  background: var(--panel);
}
.toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 8px 2px;
}
.tool-group {
  display: grid;
  gap: 2px;
  width: 100%;
  justify-items: center;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.tool-mode {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 48px;
  height: 44px;
  padding: 2px;
  color: var(--label);
  font-size: 9px;
  line-height: 1;
  font-weight: 500;
}
.tool-mode.is-active, .tool-mode[aria-pressed=true], .more-tools:has([aria-pressed=true]) summary {
  background: var(--accent-bg);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.rail-glyph {
  width: 18px;
  height: 18px;
  display: inline-block;
  position: relative;
  color: currentColor;
}
.glyph-select {
  background: currentColor;
  clip-path: polygon(13% 0,88% 61%,54% 62%,70% 93%,55% 100%,38% 68%,13% 90%);
}
.glyph-scale::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1.5px dashed currentColor;
}
.glyph-scale::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  left: 1px;
  top: 1px;
  background: currentColor;
  box-shadow: 12px 0, 0 12px, 12px 12px;
}
.glyph-rotate::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.7px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  transform: rotate(18deg);
}
.glyph-rotate::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 8px;
  height: 8px;
  background: currentColor;
  clip-path: polygon(100% 0,100% 100%,0 75%);
}
.glyph-polygon { background:currentColor;clip-path:polygon(50% 0,100% 36%,82% 94%,18% 94%,0 36%); }
.glyph-polygon::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--panel);
  clip-path: inherit;
}
.shape-tools:has([aria-pressed=true]) .glyph-polygon::after { background:var(--accent-bg); }
.glyph-pen { background:currentColor;clip-path:polygon(5% 98%,18% 37%,67% 7%,90% 30%,61% 80%); }
.glyph-pen::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: 3px;
  height: 10px;
  border-radius: 100%;
  background: var(--panel);
  transform: rotate(46deg);
}
.glyph-text::before { content:"T";font:600 21px/18px Georgia,serif; }
.more-tools-menu, .scene-menu {
  z-index: 9;
  padding: 5px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--strip);
  box-shadow: 0 8px 22px #0006;
}
.more-tools-menu {
  position: fixed;
  min-width: 158px;
  max-height: calc(100dvh - 12px);
  overflow-y: auto;
}
.more-tools-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  font-size: 12px;
}
.glyph-controls { font-size: 20px; line-height: 18px; }
.control-tools-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(105px, 1fr));
}
.more-tools-menu button:focus-visible { outline-offset: -2px; }
.more-tools-menu button.is-active { color:var(--accent); }
.center-panel {
  display: grid;
  grid-template-rows: 37px minmax(0,1fr) 28px 6px minmax(0,var(--dock-height));
  min-width: 0;
  min-height: 0;
}
.stage-toolbar {
  position: relative;
  z-index: 3;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--divider);
  background: var(--panel);
}
.stage-context { min-width:0;gap:8px; }
#scene-switcher { position:relative;min-width:0; }
#scene-switcher > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  font-size: 12px;
}
#stage-scene-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.scene-symbol {
  width: 15px;
  height: 11px;
  border: 1px solid var(--low);
  border-radius: 2px;
  box-shadow: 2px -2px 0 -1px var(--panel),2px -2px 0 var(--low);
  flex: none;
}
.chevron {
  width: 5px;
  height: 5px;
  border: solid var(--low);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
  margin: -2px 2px 0;
  flex: none;
}
.scene-menu {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  width: 224px;
  max-height: min(60vh,400px);
  overflow: auto;
}
.scene-menu .section-heading { padding:4px 6px 7px; }
.scene-list, .element-list { display:grid;gap:2px; }
.scene-entry, .element-entry, .group-entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 4px 8px;
  text-align: left;
  font-size: 12px;
}
.scene-entry.is-active, .element-entry.is-active, .group-entry[aria-pressed=true] {
  background: var(--accent-bg);
  color: var(--accent-text);
}
.scene-index { font:10px ui-monospace, monospace;color:var(--low); }
.entry-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.entry-kind, .entry-badge {
  color: var(--low);
  font-size: 10px;
  white-space: nowrap;
}
.entry-kind { margin-left:auto; }
.entry-badge { color:var(--accent); }
.entry-badge.is-invalid { color:var(--danger); }
.group-member { padding-left:20px; }
.text-button {
  font-size: 11px;
  color: var(--low);
  padding: 6px 8px;
}
.stage-meta {
  flex: none;
  gap: 11px;
  color: var(--low);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
select {
  border: 1px solid var(--control-border);
  background: var(--raised);
  padding: 3px 4px;
}
#stage-zoom {
  min-width: 65px;
  height: 24px;
  font-size: 11px;
}
.preview-badge {
  font-size: 9px;
  letter-spacing: .06em;
  color: var(--preview-label);
}
.stage-workarea {
  position:relative; min-height:0; min-width:0; display:grid;
  grid-template:18px minmax(0,1fr) / 18px minmax(0,1fr);
  background:var(--bar);
}
.stage-workarea > canvas {
  display:block; width:100%; height:100%; min-width:0; min-height:0; color:var(--low);
}
.ruler-unit { text-align:center; font:9px/18px ui-monospace,monospace; color:var(--low); }
#stage-grid {
  display:grid; place-items:center; width:27px; height:24px; border:1px solid var(--control-border);
  color:var(--label); background:var(--raised);
}
#stage-grid[aria-pressed=true] { color:var(--accent); background:var(--accent-bg); border-color:var(--accent-line); }
#stage-grid span {
  width:13px; height:13px; border:1px solid currentColor;
  background:linear-gradient(90deg,transparent 40%,currentColor 40% 52%,transparent 52%),
    linear-gradient(transparent 40%,currentColor 40% 52%,transparent 52%);
}
.stage-mat.show-grid::after {
  content:""; position:absolute; inset:0; pointer-events:none; z-index:1;
  background-image:linear-gradient(to right, #8593ad70 1px,transparent 1px),
    linear-gradient(to bottom,#8593ad70 1px,transparent 1px);
  background-size:var(--grid-x) var(--grid-y);
}
@media (max-width:570px), (max-height:420px) {
  .stage-workarea { grid-template: minmax(0,1fr) / minmax(0,1fr); }
  .stage-workarea > canvas, .ruler-unit { display:none; }
}
.stage-viewport {
  overflow-anchor: none;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
  background-color: var(--pasteboard);
  background-image: radial-gradient(var(--pasteboard-dot) 0.75px,transparent 0.85px);
  background-size: 12px 12px;
  scrollbar-width: thin;
}
.stage-pasteboard {
  min-width: 100%;
  min-height: 100%;
  width: max-content;
  height: max-content;
  padding: 22px;
  display: grid;
  place-items: center;
}
.stage-mat {
  position: relative;
  isolation: isolate;
  width: min(75vw, 700px);
  aspect-ratio: 16 / 9;
  flex: none;
  overflow: hidden;
  background: #101820;
  outline: 1px solid var(--divider);
  box-shadow: 0 5px 18px #17171a6b;
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#stage:not([data-tool=select]):not([data-tool=rotate]):not([data-tool=scale]) { cursor:crosshair; }
.empty-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
  text-align: center;
  color: #a4acba;
  font-size: 12px;
}
.empty-stage strong {
  font-weight: 550;
  font-size: 15px;
  color: #d7dce5;
}
.empty-stage-icon {
  width: 22px;
  height: 18px;
  margin-bottom: 4px;
  border: 1.5px dashed #8591a5;
  border-radius: 2px;
}
body:has(#preview-badge:not([hidden])) .empty-stage { display:none; }
/* The outgoing preview is a single frozen composition, including native fields. */
.scene-transition { position:absolute; inset:0; z-index:4; overflow:hidden; pointer-events:none; }
.scene-transition-frame { position:absolute; top:0; left:0; transform-origin:top left; }
.preview-surface {
  position: absolute;
  inset: 0 auto auto 0;
  transform-origin: top left;
  pointer-events: none;
}
.preview-surface canvas { position:absolute;inset:0; }
.preview-text-field {
  position: absolute;
  resize: none;
  overflow: hidden;
  padding: 2px;
  border: 1px solid currentColor;
  background: transparent;
  pointer-events: auto;
}
.preview-button-target {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
}
.preview-button-target:focus-visible {
  outline: 2px solid white;
  outline-offset: -3px;
  box-shadow: inset 0 0 0 4px #252035;
}
.preview-text-field:focus { outline:2px solid var(--accent); }
.text-edit-layer {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}
#text-edit-input {
  position: absolute;
  min-width: 30px;
  min-height: 24px;
  padding: 3px;
  border: 1px dashed var(--accent);
  background: #19191eed;
  color: white;
  overflow: hidden;
  resize: none;
  transform-origin: center;
  pointer-events: auto;
}
.text-edit-actions {
  position: absolute;
  top: 7px;
  right: 7px;
  display: flex;
  gap: 5px;
  pointer-events: auto;
}
.text-edit-actions button, .small-button, .tool-button, .keyframe-button, .project-io-actions button {
  min-height:25px;padding:3px 8px;border:1px solid var(--control-border);background:var(--raised);font-size:11px;font-weight:500;
}
.stage-footer {
  gap: 12px;
  padding: 0 12px;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid var(--divider);
  background: var(--strip);
  font-size: 11px;
  color: var(--low);
}
#tool-status { flex:none; }
.path-actions { gap:4px; }
.path-actions .small-button {
  min-height: 21px;
  height: 21px;
  font-size: 10px;
}
.path-actions button:disabled { display:none; }
.status-message {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.status-message:not(.is-visible) { visibility:hidden; }
.status-message.is-error { color:var(--danger); }
.dock-divider {
  position: relative;
  background: var(--divider);
  cursor: ns-resize;
  touch-action: none;
}
.dock-divider::after {
  content: "";
  position: absolute;
  left: calc(50% - 14px);
  top: 2px;
  width: 28px;
  height: 2px;
  border-radius: 2px;
  background: var(--control-border-hover);
}
.dock-divider:hover, .dock-divider:focus-visible { background:var(--accent-bg); }
.timeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-height: 0;
  min-width: 0;
  background: var(--track);
}
.timeline-heading {
  gap: 12px;
  min-width: 0;
  min-height: 39px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--divider);
  background: var(--panel);
}
.timeline-title { gap:7px; }
.timeline-title h2 { font-size:12px; }
.timeline-icon {
  width: 15px;
  height: 12px;
  border: 1px solid var(--low);
  border-radius: 2px;
  background: linear-gradient(to bottom,transparent 30%,var(--low) 30% 40%,transparent 40% 66%,var(--low) 66% 77%,transparent 77%);
}
.transport {
  gap: 1px;
  border-left: 1px solid var(--line);
  padding-left: 9px;
}
.transport .icon-button {
  width: 23px;
  height: 24px;
  font-size: 11px;
  color: var(--label);
}
#play-button {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 24px;
  padding: 3px 7px;
  font-size: 11px;
}
#play-button.is-playing::before {
  clip-path: polygon(0 0,36% 0,36% 100%,0 100%,0 0,65% 0,100% 0,100% 100%,65% 100%,65% 0);
}
.frame-readout {
  display:flex; align-items:center; gap:4px;
  font: 11px ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--text);
  white-space: nowrap;
}
#frame-number {
  appearance:textfield; width:4ch; min-width:30px; height:24px; border:1px solid var(--control-border);
  border-radius:3px; padding:1px 2px; background:var(--field); color:var(--accent-text);
  font:inherit; text-align:center;
}
#frame-number::-webkit-inner-spin-button { appearance:none; }
#frame-readout { color:var(--low); }
.timeline-controls { margin-left:auto;gap:5px; }
#timeline-scale, #frame-edit {
  max-width: 100px;
  height: 25px;
  font-size: 11px;
  background: var(--raised);
}
.timeline-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  min-height: 0;
}
.section-heading { justify-content:space-between;gap:6px; }
.ruler-row {
  height: 28px;
  min-height: 28px;
  background: var(--strip);
  border-bottom: 1px solid var(--divider);
}
.layer-entry {
  --layer-color: var(--accent);
  display: grid;
  grid-template-columns: var(--track-label) minmax(0,1fr);
}
.layer-entry:nth-child(3n + 2) { --layer-color: light-dark(#287468, #82c9b8); }
.layer-entry:nth-child(3n) { --layer-color: light-dark(#95632e, #dfb37a); }
.layer-controls, .layer-overview {
  height: 29px;
  border-bottom: 1px solid var(--divider);
}
.layer-controls {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  padding-inline: 3px;
  gap: 2px;
  border-left: 3px solid var(--layer-color);
  border-right: 1px solid var(--divider);
  background: var(--panel);
}
.layer-entry.is-active .layer-controls { background: var(--accent-bg); }
.layer-entry.is-hidden-layer .layer-select-btn,
.layer-entry.is-hidden-layer .timeline-lane-label { color:var(--low); font-style:italic; }
.layer-fold { display:grid; place-items:center; width:17px; height:24px; flex:none; padding:0; color:var(--label); }
.layer-fold::before {
  content:""; width:5px; height:5px; border:solid currentColor; border-width:0 1.5px 1.5px 0;
  transform:rotate(-45deg);
}
.layer-fold[aria-expanded=true]::before { transform:translateY(-2px) rotate(45deg); }
.layer-overview {
  position:relative;
  cursor:ew-resize;
  touch-action:none;
  background:color-mix(in srgb, var(--layer-color) 7%, var(--track));
}
.layer-overview i {
  pointer-events:none; position:absolute; top:50%; width:5px; height:5px;
  transform:translate(-50%,-50%) rotate(45deg); background:var(--layer-color);
}
.layer-overview-ticks {
  position:absolute; inset:0; width:100%; height:100%; pointer-events:none;
  stroke:var(--layer-color); stroke-width:3px;
}
.layer-tracks { grid-column:1 / -1; min-width:0; }
.layer-controls .layer-select-btn { padding:3px 0; font-weight:600; }
.layer-entry-main {
  flex: 1;
  display: flex;
  min-width: 0;
}
.layer-select-btn,.layer-rename-input {
  width: 100%;
  min-width: 0;
  text-align: left;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-rename-input {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--accent);
}
.layer-actions {
  display: flex;
  align-items: center;
  gap: 0;
}
.layer-action-btn {
  min-width: 17px;
  height: 22px;
  padding: 0 1px;
  color: var(--low);
  font-size: 10px;
}
.layer-action-btn.is-on { color:var(--accent); }
.layer-delete-prompt {
  border-radius:4px; box-shadow:0 4px 12px #0003;
  position: absolute; inset: 4px auto auto 4px; z-index: 5;
  width: min(285px, calc(100% - 8px)); max-height:calc(100% - 8px); overflow:auto;
  padding: 7px;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
}
.layer-delete-message,.action-warning {
  font-size: 11px;
  line-height: 1.4;
  color: var(--danger);
  margin-bottom: 7px;
}
.layer-delete-actions,.object-arrange {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.timeline-track-wrap {
  min-width: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.timeline-content {
  width: max(100%,var(--timeline-content-width,100%));
  min-height: 100%;
  position: relative;
  background: linear-gradient(to right,var(--strip) 0 var(--track-label), transparent var(--track-label)),
    repeating-linear-gradient(0deg,transparent 0 23px,var(--line) 23px 24px);
}
.ruler-row {
  display: grid;
  grid-template-columns: var(--track-label) minmax(0,1fr);
  position: sticky;
  top: 0;
  z-index: 3;
}
.ruler-label {
  justify-content:space-between; color:var(--label); font-weight:600; font-size:11px;
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid var(--divider);
  background: var(--strip);
}
.timeline-ruler, .timeline-lane-track { position:relative;min-width:0; }
.timeline-ruler {
  margin-right: 1px;
  touch-action: none;
  cursor: ew-resize;
}
.timeline-ruler span {
  position: absolute;
  bottom: 5px;
  transform: translateX(-50%);
  color: var(--low);
  font: 10px ui-monospace,monospace;
  pointer-events: none;
}
.timeline-ruler span:first-child { transform:none;padding-left:3px; }
.timeline-ruler span:last-child { transform:translateX(-100%);padding-right:3px; }
.timeline-track {
  position: absolute;
  left: var(--track-label);
  right: 0;
  top: 0;
  height: 28px;
  pointer-events: none;
}
#playhead {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.timeline-content:has(#playhead:focus-visible) .timeline-ruler { box-shadow:inset 0 0 0 2px var(--accent); }
.timeline-cursor {
  position:absolute; z-index:1; inset:28px 1px 0 var(--track-label); pointer-events:none;
}
.timeline-ruler::after,.timeline-cursor::after {
  content: "";
  position: absolute;
  left: var(--playhead-position,0%);
  inset-block: 0;
  width: 1px;
  background: var(--playhead);
  pointer-events: none;
  z-index: 2;
}
.timeline-ruler::before {
  content: "";
  position: absolute;
  left: var(--playhead-position,0%);
  bottom: 0;
  width: 8px;
  height: 7px;
  transform: translateX(-40%);
  background: var(--playhead);
  clip-path: polygon(0 0,100% 0,100% 45%,50% 100%,0 45%);
  z-index: 2;
  pointer-events: none;
}
.timeline-lane {
  display: grid;
  grid-template-columns: var(--track-label) minmax(0,1fr);
  min-height: 24px;
  border-bottom: 1px solid var(--divider);
}
/* Imported movies can have thousands of lanes; the browser skips style, layout and paint for
   lanes outside the visible timeline. "auto" remembers each lane's real height once shown. */
.timeline-panel.is-large .timeline-lane {
  content-visibility: auto;
  contain-intrinsic-size: auto 25px;
}
.timeline-lane-label {
  position: sticky;
  left: 0;
  z-index: 2;
  overflow: hidden;
  padding: 0 8px;
  border-right: 1px solid var(--divider);
  border-radius: 0;
  background: var(--strip);
  color: var(--label);
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-tracks .timeline-lane-label { padding-left:28px; }
.layer-tracks .timeline-lane-label::before {
  content:""; position:absolute; left:14px; top:0; height:50%; width:8px;
  border:solid var(--control-border); border-width:0 0 1px 1px;
}
.timeline-lane.is-active .timeline-lane-label { color:var(--accent-text);background:var(--accent-bg); }
.timeline-lane-track { background:var(--track); }
.timeline-lane-track::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right,var(--track-grid) 1px,transparent 1px);
  background-size: var(--frame-step,4%) 100%;
  pointer-events: none;
  z-index: 1;
}
.tween-span,.exposure-span,.keyframe-marker { position:absolute; }
.exposure-span {
  inset-block: 3px;
  background: var(--exposure);
  pointer-events: none;
}
.tween-span {
  top: 5px;
  bottom: 5px;
  min-width: 1px;
  border-radius: 0;
  padding: 0;
  background: var(--tween);
}
.tween-span:hover:not(:disabled) { background:var(--tween-hover); }
.tween-hold { background:var(--hold); }
.keyframe-marker {
  z-index: 2;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 1px;
  padding: 0;
  border: 1px solid var(--key-edge);
  background: var(--key);
  transform: translate(-50%,-50%) rotate(45deg);
}
.keyframe-marker.blank-key { background:var(--track); }
.empty-note {
  color: var(--low);
  font-size: 11px;
  line-height: 1.5;
}
.side-dock {
  z-index: 4;
  min-height: 0;
  min-width: 0;
  border-left: 1px solid var(--divider);
  background: var(--panel);
  display: grid;
  grid-template-rows: 37px minmax(0,1fr);
}
.dock-tabs {
  gap: 3px;
  padding: 0 9px;
  border-bottom: 1px solid var(--divider);
  background: var(--bar);
}
.dock-tabs button {
  align-self: stretch;
  padding: 0 8px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--low);
  font-size: 12px;
}
.dock-tabs button[aria-selected=true] {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.dock-panel {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 12px;
}
.dock-panel > .section-heading { margin-bottom:12px; }
.property-group {
  border: 0;
  margin: 0;
  padding: 0;
}
.property-group h3,.property-group h4 { margin:4px 0 11px; }
.property-group h4, #vector-style-fields h4, #text-style-fields h4 {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.property-group h3 { font-size:13px; }
.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 9px;
  color: var(--label);
  font-size: 11px;
  line-height: 1.3;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
}
.text-input,.color-input {
  width: 100%;
  height: 28px;
  padding: 4px 7px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--field);
  font-size: 12px;
  line-height: 1.35;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.color-input { padding:3px;cursor:pointer; }
.text-input:hover,.color-input:hover { border-color:var(--control-border-hover); }
.text-input:focus,.color-input:focus { border-color:var(--accent); }
.text-area { height:auto;resize:vertical; }
.checkbox-label {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 25px;
}
input[type=checkbox] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}
.type-pill,.count-badge {
  color: var(--accent-text);
  font-size: 11px;
  text-transform: capitalize;
}
.inspector-heading {
  display:flex; align-items:center; justify-content:space-between; margin-bottom:10px;
}
.inspector-heading h3 { margin:0; font-size:14px; }
.inspector-section { border-top:1px solid var(--line); }
.inspector-section > summary {
  display:flex; align-items:center; gap:7px; padding:9px 1px;
  font-size:12px; font-weight:600;
}
.inspector-section > summary::before { content:"▸"; color:var(--low); font-size:10px; }
.inspector-section[open] > summary::before { content:"▾"; }
.inspector-section .button-section { border:0; padding-top:0; }
.transform-fields .field-label {
  display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:4px;
  background:var(--field); border:1px solid var(--control-border); border-radius:4px;
  padding-left:7px; margin-bottom:5px;
}
.transform-fields .field-label:focus-within { border-color:var(--accent); }
.transform-fields .text-input { border:0; background:transparent; height:26px; text-align:right; padding-left:0; }
.transform-fields { padding-bottom:4px; }
.selection-empty { margin-bottom:13px;color:var(--low); }
.selection-empty strong {
  font-weight: 550;
  font-size: 12px;
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}
.selection-empty span:last-child,.inspector-hint {
  font-size: 11px;
  color: var(--low);
  line-height: 1.45;
}
#document-properties > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding: 8px 0;
  font-size: 12px;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
#document-properties > summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--low);
}
#document-properties[open] > summary::before { content:"▾"; }
#document-properties .property-group { margin-top:8px; }
#document-properties .property-group + .property-group { padding-top:12px;border-top:1px solid var(--line); }
#document-properties .property-group h3 { color:var(--text);font-size:12px; }
.element-properties { margin-bottom:15px; }
.button-section { padding-top:9px;border-top:1px solid var(--line); }
.empty-note { margin:8px 0; }
#symbol-library { margin-bottom:9px; }
.project-io-dialog {
  width: min(600px,calc(100vw - 20px));
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 62px #0009;
}
.project-io-dialog::backdrop { background:var(--dialog-backdrop); }
.project-io-card {
  display: grid;
  gap: 15px;
  padding: 18px;
}
.project-io-header { justify-content:space-between; }
.project-io-header h2 { font-size:17px; }
.project-io-description,.project-io-error {
  color: var(--low);
  font-size: 12px;
  line-height: 1.5;
}
.project-io-error { color:var(--danger); }
.project-io-examples h3 { margin-bottom:7px; }
.project-io-example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.project-io-textarea {
  height: clamp(120px,28dvh,330px);
  resize: vertical;
  font: 11px/1.5 ui-monospace,SFMono-Regular,monospace;
}
.project-io-actions { justify-content:flex-end;flex-wrap:wrap;gap:6px; }
#project-io-submit {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}
@media(max-width:1070px) {
  .editor-shell { grid-template-columns:53px minmax(0,1fr) 245px; }
  .timeline-heading {
    gap: 6px;
    padding-inline: 6px;
    flex-wrap: wrap;
  }
  :root { --track-label:184px; }
  .timeline-title .timeline-icon { display:none; }
  .transport { padding-left:5px; }
}
@media(max-width:800px) {
  .editor-shell { grid-template-columns:53px minmax(0,1fr); }
  #toggle-dock {
    display: block;
    margin-left: auto;
    border: 1px solid var(--line);
  }
  #toggle-dock[aria-expanded=true] { color:var(--accent);background:var(--accent-bg); }
  .theme-control { margin-left:0; }
  .side-dock {
    display: none;
    position: fixed;
    z-index: 7;
    top: 48px;
    right: 0;
    bottom: 0;
    width: min(296px,calc(100vw - 58px));
    box-shadow: -8px 0 24px #0005;
  }
  body.dock-open .side-dock { display:grid; }
}
/* The compact top bar starts at 840px so Projects and Save fit beside the panel toggle. */
@media(max-width:840px) {
  .topbar { gap:4px;padding-inline:6px; }
  .theme-control { width: 28px; height: 28px; flex: none; }
  .theme-control .theme-icon { left: 7px; }
  #editor-theme {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    padding: 0;
  }
  .theme-control:focus-within { outline: 2px solid var(--accent); border-radius: 4px; }
  .brand { gap:0; }
  .brand > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .file-actions,.history-actions { padding-left:4px;gap:0; }
  .file-actions button,#toggle-dock,#preview-button { font-size:11px;padding-inline:6px; }
  .history-actions .icon-button { width:22px; }
}
@media(max-width:420px) {
  #preview-button {
    justify-content: center;
    width: 30px;
    padding: 0;
    gap: 0;
    font-size: 0;
    flex: none;
  }
}
@media(max-width:370px) {
  .topbar { gap: 2px; padding-inline: 4px; }
  .topbar .brand { display: none; }
  .file-actions button { padding-inline: 4px; }
}
@media(max-width:570px) {
  :root { --track-label:142px;--dock-height:clamp(160px,31vh,210px); }
  .editor-shell { grid-template-columns:44px minmax(0,1fr); }
  .tool-mode {
    width: 39px;
    height: 40px;
    font-size: 8px;
  }
  .stage-toolbar,.stage-footer { padding-inline:6px;gap:5px; }
  .stage-meta { gap:5px; }
  #stage-size-label { font-size:10px; }
  #stage-zoom { min-width:48px; }
  .layer-controls { height:auto;min-height:39px;flex-wrap:wrap; }
  .layer-entry-main { flex-basis:calc(100% - 24px); }
  .layer-actions { margin-left:17px; }
  .layer-actions button { height:21px; min-width:23px; }
  .layer-overview { height:100%; }
  #frame-edit,#timeline-scale { max-width:76px; }
  .timeline-heading { gap:3px 5px; }
  .transport { border:0;padding:0; }
  .timeline-controls { margin-left:0; }
  .stage-footer:has(.status-message.is-visible) #tool-status { display:none; }
}
@media(max-height:650px) and (min-width:571px) {
  :root { --dock-height:158px; }
  .tool-mode { height:34px;gap:1px; }
}
.layer-action-btn svg {
  display: block;
  width: 13px;
  height: 13px;
}
.stage-viewport.is-panning,.stage-viewport.is-panning #stage { cursor:grabbing; }
.stage-footer {
  position: relative;
  overflow: visible;
  z-index: 2;
}
#tool-hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-footer:has(.status-message.is-visible) #tool-hint { display:none; }
.status-message:not(.is-visible) { display:none; }
.status-message.is-visible.is-error {
  position:absolute;
  left:8px;
  bottom:calc(100% + 5px);
  max-width:min(100% - 16px,500px);
  border:1px solid var(--danger-border);
  border-radius:4px;
  padding:7px 9px;
  background:var(--danger-bg);
  white-space:normal;
}
@media (max-width:570px) {
  .stage-meta #stage-fps-label { display:none; }
  .stage-footer:has(.path-actions button:not(:disabled):not([hidden])) #tool-hint { display:none; }
}

/* Project exchange */
#project-io-notice:empty { position:absolute; }
.project-file-field, .paste-label {
  display: none;
  gap: 7px;
  font-size: 12px;
  font-weight: 550;
}
#project-file {
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--control-border-hover);
  border-radius: 5px;
  color: var(--low);
}
#project-file::file-selector-button {
  margin-right: 8px;
  padding: 5px 9px;
  border: 1px solid var(--control-border);
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}
.project-io-dialog[data-mode="import"] .project-file-field,
.project-io-dialog[data-mode="import"] .paste-label { display: grid; }
.paste-label { margin-bottom: -9px; }
.project-io-dialog:not([data-mode="export"]) #download-project { display: none; }
#download-project { border-color: transparent; background: var(--primary); color: var(--on-primary); }
#download-project:hover { background: var(--primary-hover); color: var(--on-primary); }
.project-io-dialog[data-mode="examples"] { width: min(440px,calc(100vw - 20px)); }
.project-io-dialog[data-mode="examples"] .project-io-textarea,
.project-io-dialog[data-mode="examples"] .project-io-actions,
.project-io-dialog[data-mode="examples"] .project-io-examples h3 { display: none; }
.project-io-dialog[data-mode="examples"] .project-io-example-list {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 6px;
}
.project-io-dialog[data-mode="examples"] [data-example] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 7px 11px;
  font-size: 12px;
  text-align: left;
}
.project-io-dialog[data-mode="examples"] [data-example]::after { content: "›"; color: var(--accent); font-size: 16px; }
#previous-frame, #next-frame { position: relative; font-size: 0; }
#previous-frame::before, #next-frame::before {
  content: "";
  width: 11px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(0 0,16% 0,16% 100%,0 100%,0 0,100% 0,100% 100%,25% 50%,100% 0);
}
#next-frame::before { transform: rotate(180deg); }
@media(max-width:570px) {
  #frame-edit { max-width: 99px; }
}
.field-label[for="element-name"], .field-label[for="scene-name"] { margin-bottom: 5px; }
#element-name, #scene-name { margin-bottom: 9px; }

#event-actions { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#event-actions:empty, #event-editor [role="alert"]:empty { display: none; }
.event-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.event-row .text-input { flex: 1 1 118px; min-width: 0; }
.event-row-tools { display: flex; gap: 3px; margin-left: auto; }
#event-add { justify-self: start; }
.event-track { position: relative; min-width: 0; background: var(--track); }
.event-track .event-marker { position: absolute; top: 50%; transform: translate(-50%, -50%); min-width: 12px; height: 15px; padding: 0 2px; font: bold 11px monospace; color: var(--event-text); background: var(--event); border: 0; border-radius: 3px; }

#media-library, #timeline-audio { margin-bottom: 8px; }
#media-thumbnail { display: block; width: 100%; height: 68px; object-fit: contain; margin-bottom: 8px; background: var(--field); }
#audio-section, #library-panel .section-heading:not(:first-child) { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
#audio-section h3 { margin-bottom: 8px; }
.audio-track { position: relative; background: var(--track); }
.audio-span { position: absolute; inset-block: 4px; min-width: 3px; border: 1px solid var(--accent-line); background: var(--accent-bg); }

/* Server projects */
#save-project[data-dirty="true"]::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
#save-project[data-failed="true"]::after { background: var(--danger); }
#projects-dialog { width: min(520px,calc(100vw - 20px)); }
#projects-notice:empty { position:absolute; }
.projects-section { display: grid; gap: 7px; }
.projects-row { display: flex; gap: 6px; }
.projects-row .text-input { flex: 1; min-width: 0; }
#projects-dialog .project-file-field { display: grid; }
#swf-file {
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--control-border-hover);
  border-radius: 5px;
  color: var(--low);
}
.project-list {
  display: grid;
  gap: 4px;
  max-height: min(260px,32dvh);
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.project-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.project-list li[aria-current="true"] { border-color: var(--accent); }
.project-list .project-entry { flex: 1; min-width: 0; display: grid; gap: 2px; }
.project-list .project-entry strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.project-list .project-entry span { color: var(--low); font-size: 11px; }
.swf-report { display: grid; gap: 12px; max-height: min(420px,55dvh); overflow: auto; font-size: 12px; }
.swf-report h3 { margin-bottom: 4px; }
.swf-report ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.swf-report .report-where { color: var(--low); }
.is-drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; }
@media(max-width:570px) {
  #save-project { display: none; }
  #projects-button, #browse-examples { width: 28px; padding: 0; font-size: 0; flex: none; }
  #projects-button::before, #browse-examples::before { font-size: 15px; line-height: 1; }
  #projects-button::before { content: "\25A4"; }
}
@media(min-width:421px) and (max-width:570px) {
  #browse-examples { width: auto; padding-inline: 6px; font-size: 11px; }
  #browse-examples::before { content: none; }
}
@media(max-width:420px) {
  #browse-examples::before { content: "\25C7"; }
}

/* ActionScript projects preview on the swf2js player, over the whole work area. */
.swf-player { position:absolute; inset:0; width:100%; height:100%; border:0; background:#111; z-index:20; }
.swf-player[hidden] { display:none; }
.event-script { font:12px/1.4 ui-monospace,monospace; color:var(--text, inherit); align-self:center; }
.script-editor-card { width: min(860px, calc(100vw - 32px)); }
.script-code { width: 100%; min-height: 360px; resize: vertical; font: 12px/1.5 ui-monospace, monospace; tab-size: 2; white-space: pre; }
.script-code[readonly] { opacity: 0.8; }
.script-check { min-height: 1.4em; margin: 4px 0 0; font-size: 12px; }
.script-check.has-error { color: var(--danger, #e5484d); }

/* Busy indicator (busy.js). The spinner animates a transform only, so the browser keeps it turning
   on the compositor while the main thread works. */
.busy-indicator {
  position:absolute; z-index:30; top:12px; left:50%; transform:translateX(-50%);
  display:flex; align-items:center; gap:10px; padding:8px 14px; border-radius:999px;
  background:var(--panel, #fff); color:var(--label, #222); box-shadow:0 2px 12px rgb(0 0 0 / .25);
  font-size:13px; pointer-events:none;
}
.busy-indicator[hidden] { display:none; }
.busy-spinner {
  width:16px; height:16px; border-radius:50%;
  border:2px solid color-mix(in srgb, var(--accent, #6b4fd8) 25%, transparent); border-top-color:var(--accent, #6b4fd8);
  animation:busy-turn .8s linear infinite; will-change:transform;
}
@keyframes busy-turn { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy-spinner { animation-duration:2.4s; } }

#paint-options { display:flex; align-items:center; gap:6px; }
#paint-options label { display:flex; align-items:center; gap:3px; }
#paint-options input[type=color] { width:25px; height:23px; padding:1px; }
#paint-options input[type=number] { width:45px; }

#media-transfers:empty { display: none; }
#media-transfers label { display: grid; gap: .2rem; overflow-wrap: anywhere; }
#media-transfers progress { width: 100%; }
