/* Khuwari, smooth matte Nordic editor UI */

:root {
  --bg: #1b1f25;          /* deep slate */
  --bg-elev: #22272e;     /* elevated surface */
  --bg-elev2: #2a3038;    /* buttons / cards */
  --bg-elev3: #313844;    /* hover */
  --border: #39414d;      /* subtle border */
  --text: #e6e9ee;
  --muted: #98a1ad;
  --accent: #8aa3b9;      /* frost blue */
  --accent-2: #8fb0a2;    /* sage (ok / ready) */
  --danger: #c48181;      /* muted brick */
  --gold: #c3ab7d;        /* muted sand */
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* subtle grain over everything, a smooth matte texture */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 27, 33, 0.92);
}
.loading-box {
  width: min(420px, 88vw);
  text-align: center;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}
.loading-box .logo.big {
  display: flex;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 10px;
}
.loading-box .logo.big img { width: 40px; height: 40px; }
.loading-box .logo.big svg { width: 34px; height: 34px; }

.loading-title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.loading-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; line-height: 1.5; }
.loading-box .bar { height: 8px; }
.loading-box .bar-meta { margin-top: 6px; }
.loading-box #btnLoadingRetry { margin-top: 12px; }
.loading-box #btnExportCancelOverlay { margin-top: 12px; }

/* Start screen: full-window launch menu. The mascot (500×1000) is a banner on
   the left, scaled to the full window height (width = half the height, so the
   2:1 portrait aspect is preserved at any window size); the menu is on the
   right. */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  background: var(--bg);
}
.start-art {
  position: relative;
  flex: 0 0 auto;
  width: 50vh;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: linear-gradient(160deg, var(--bg-elev3), var(--bg-elev) 55%, #1a1f26);
  overflow: hidden;
}
.start-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
/* Fade the banner's right edge into the menu background instead of a hard
   cutoff, so the mascot blends with the rest of the start screen. */
.start-art::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(160px, 30%);
  background: linear-gradient(to right, rgba(27, 31, 37, 0), var(--bg));
  pointer-events: none;
}

.start-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px;
  min-width: 0;
}
.start-name {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text);
  animation: rise-in 0.5s ease both;
}
.start-tagline {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 26px;
  animation: rise-in 0.5s 0.06s ease both;
}
.start-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, 80vw);
}
.start-btn {
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  border-radius: 9px;
  justify-content: center;
}
/* Staggered entrance: each menu row rises in after the one above it. */
.start-menu .start-btn {
  animation: rise-in 0.45s ease both;
  animation-delay: calc(0.1s + var(--i, 0) * 0.05s);
}
.start-menu .start-btn:nth-of-type(1) { --i: 0; }
.start-menu .start-btn:nth-of-type(2) { --i: 1; }
.start-menu .start-btn:nth-of-type(3) { --i: 2; }
.start-menu .start-btn:nth-of-type(4) { --i: 4; }
.start-menu .start-btn:nth-of-type(5) { --i: 5; }
.start-menu .start-btn:nth-of-type(6) { --i: 6; }
.start-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  animation: rise-in 0.45s 0.32s ease both;
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toolbar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: rgba(34, 39, 46, 0.88);
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  border-bottom: 1px solid rgba(57, 65, 77, 0.55);
  flex-wrap: wrap;
}

.toolbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); opacity: 0.92; }
.toolbar-brand .brand-logo { width: 16px; height: 16px; }
.toolbar-brand .brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(138,163,185,0.6); }
.toolbar-brand .brand-name { font-size: 13px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn-group { display: inline-flex; align-items: center; position: relative; }
.btn-group .btn + .btn { border-left: 0; }
.vsep { width: 1px; height: 20px; background: rgba(57, 65, 77, 0.55); margin: 0 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid rgba(57, 65, 77, 0.7);
  border-radius: 8px;
  padding: 6.5px 11px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease,
              transform 0.16s cubic-bezier(0.34, 1.25, 0.64, 1), box-shadow 0.16s ease;
  will-change: transform;
}
.btn:hover {
  background: var(--bg-elev3);
  border-color: #4a5566;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.btn:active {
  filter: brightness(0.92);
  transform: translateY(0) scale(0.96);
  box-shadow: none;
  transition-duration: 0.05s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.icon { padding: 6px 9px; min-width: 32px; }
.btn svg { flex: 0 0 auto; }
/* Click pop: JS adds this class briefly on pointerdown for tactile feedback. */
.btn.pop { animation: btn-pop 0.28s ease; }
@keyframes btn-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.94); }
  70%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #161a20;
}
.btn.active:hover { background: #9ab2c6; border-color: #9ab2c6; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #161a20;
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(138, 163, 185, 0.22);
}
.btn.primary:hover {
  background: #9ab2c6;
  border-color: #9ab2c6;
  box-shadow: 0 3px 12px rgba(138, 163, 185, 0.32);
}
.btn.danger { color: var(--danger); border-color: #4d3a3a; }
.btn.danger:hover { background: #33252a; border-color: var(--danger); }
.btn.mini { padding: 2px 8px; font-size: 11px; border-radius: 5px; }

.field { display: inline-flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.field.grow { flex: 1; min-width: 0; }
.field.check { flex-direction: row; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }

.field input[type="number"],
.field input[type="text"],
.field select {
  background: #1e232a;
  color: var(--text);
  border: 1px solid rgba(57, 65, 77, 0.55);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
  min-width: 0;
  width: 100%;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.field input[type="number"]:focus,
.field input[type="text"]:focus,
.field select:focus { border-color: rgba(138,163,185,0.55); box-shadow: 0 0 0 3px rgba(138,163,185,0.14); outline: none; background: #232830; }
.field input[type="number"] { width: 64px; }

/* Switch-style checkboxes (global): every checkbox renders as a toggle switch,
   consistently across the whole app (menus, dialogs, side panel, paint editor). */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 28px; height: 16px; flex: 0 0 auto; margin: 0; border-radius: 8px;
  background: var(--border); position: relative; cursor: pointer;
  transition: background 0.15s ease;
}
input[type="checkbox"]::after { content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4); transition: transform 0.15s ease; }
input[type="checkbox"]:checked { background: var(--accent); }
input[type="checkbox"]:checked::after { transform: translateX(12px); }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"]:disabled { opacity: 0.45; cursor: not-allowed; }

/* side-by-side fields (e.g. custom width + height) */
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }
.field-row .field input { width: 100%; }

.export-wrap { position: relative; }
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: rgba(42, 48, 56, 0.96);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border: 1px solid rgba(57, 65, 77, 0.6);
  border-radius: 10px;
  padding: 8px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 210px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255,255,255,0.06) inset;
}
.menu button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.12s ease, transform 0.12s ease, color 0.12s ease;
}
.menu button svg { flex: 0 0 auto; opacity: 0.85; }
.menu button:hover {
  background: var(--bg-elev);
  color: var(--text);
  transform: translateX(2px);
}
.menu button.btn { border: 1px solid var(--border); background: var(--bg-elev2); }
.menu button.btn.primary { background: var(--accent); border-color: var(--accent); color: #161a20; }
.menu .field { width: 100%; }
.menu-row { display: flex; gap: 6px; }
.menu-row .btn { flex: 1; text-align: center; }
.menu-sep { height: 1px; background: var(--border); margin: 2px 0; }
.menu { overflow: hidden; }
.menu.hidden { display: none !important; }
.menu:not(.hidden) { animation: menu-grow 0.24s cubic-bezier(0.22,1,0.36,1); transform-origin: top center; }
.menu:not(.hidden) > * { animation: menu-item-in 0.28s cubic-bezier(0.22,1,0.36,1) both; }
.menu:not(.hidden) > *:nth-child(1) { animation-delay: 0.02s; }
.menu:not(.hidden) > *:nth-child(2) { animation-delay: 0.05s; }
.menu:not(.hidden) > *:nth-child(3) { animation-delay: 0.08s; }
.menu:not(.hidden) > *:nth-child(4) { animation-delay: 0.11s; }
.menu:not(.hidden) > *:nth-child(5) { animation-delay: 0.14s; }
.menu:not(.hidden) > *:nth-child(6) { animation-delay: 0.17s; }
.menu:not(.hidden) > *:nth-child(7) { animation-delay: 0.20s; }
.menu:not(.hidden) > *:nth-child(8) { animation-delay: 0.23s; }
.menu:not(.hidden) > *:nth-child(9) { animation-delay: 0.26s; }
.menu:not(.hidden) > *:nth-child(n+10) { animation-delay: 0.28s; }
@keyframes menu-grow {
  from { opacity: 0; transform: scaleY(0.88) translateY(-4px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}
@keyframes menu-item-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Right-click context menu: same look and feel as the dropdown menus, but
   positioned at the cursor instead of under a button. Sits above everything. */
.context-menu {
  position: fixed;
  z-index: 2000;
  background: rgba(42, 48, 56, 0.97);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border: 1px solid rgba(57, 65, 77, 0.6);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255,255,255,0.06) inset;
}
.context-menu button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.12s ease, transform 0.12s ease, color 0.12s ease;
}
.context-menu button svg { flex: 0 0 auto; opacity: 0.85; }
.context-menu button:hover { background: var(--bg-elev); transform: translateX(2px); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: #33252a; }
.context-menu button.disabled { opacity: 0.35; pointer-events: none; }
.context-menu.hidden { display: none !important; }
.context-menu:not(.hidden) { animation: menu-grow 0.22s cubic-bezier(0.22,1,0.36,1); transform-origin: top left; }
.context-menu:not(.hidden) > * { animation: menu-item-in 0.26s cubic-bezier(0.22,1,0.36,1) both; }
.context-menu:not(.hidden) > *:nth-child(1) { animation-delay: 0.02s; }
.context-menu:not(.hidden) > *:nth-child(2) { animation-delay: 0.05s; }
.context-menu:not(.hidden) > *:nth-child(3) { animation-delay: 0.08s; }
.context-menu:not(.hidden) > *:nth-child(4) { animation-delay: 0.11s; }

.side-col {
  flex: 0 0 auto;
  width: 212px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background: var(--bg-elev);
  border-right: 1px solid rgba(57, 65, 77, 0.45);
  overflow-y: auto;
  min-height: 0;
  min-width: 0;
  scrollbar-width: thin;
}
/* Keyframe panel column: mirrored to the right of the preview. */
.side-col.right {
  border-right: none;
  border-left: 1px solid var(--border);
}

/* Divider between the preview and a side panel: drag to resize the panel
   width, double-click to restore the default. */
.side-resizer {
  flex: 0 0 auto;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  transition: background 0.16s ease;
}
.side-resizer:hover, .side-resizer.dragging { background: rgba(138, 163, 185, 0.18); }
body.resizing-side { cursor: col-resize; user-select: none; }
/* Gap controls (right panel, shown when a gap is selected on the timeline). */
.gap-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: panel-in 0.2s ease;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.asset-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-bottom: 8px;
}
.asset {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid rgba(57, 65, 77, 0.55);
  border-radius: 9px;
  padding: 6px;
  background: var(--bg-elev2);
  cursor: grab;
  min-width: 0;
  touch-action: none;
  user-select: none;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s cubic-bezier(0.34,1.2,0.64,1), box-shadow 0.16s ease;
}
.asset:hover { border-color: #4e5a6b; background: var(--bg-elev3); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.22); }
.asset:active { cursor: grabbing; }
.asset-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}
.asset:hover .asset-del, .asset-del:focus-visible { display: flex; }
.asset-del:hover { background: var(--danger); color: #161a20; }
.asset-edit {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}
.asset:hover .asset-edit, .asset-edit:focus-visible { display: flex; }
.asset-edit:hover { background: var(--accent); color: #161a20; }
.asset img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  /* Same light-grey checkerboard as the paint editor canvas area, so
     transparent previews look like they do on the painting canvas. */
  background-color: #aeb4bb;
  background-image: linear-gradient(45deg, #c9cdd3 25%, transparent 25%),
    linear-gradient(-45deg, #c9cdd3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c9cdd3 75%),
    linear-gradient(-45deg, transparent 75%, #c9cdd3 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border-radius: 4px;
  display: block;
  pointer-events: none;  /* the tile is the drag source, not the img */
}
.asset-name {
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.asset-empty {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* Ghost that follows the cursor while an asset tile is dragged, plus the
   forced grabbing cursor for the whole drag (custom pointer drag, so the
   browser's no-drop X never appears). JS drives the transform (position
   spring + velocity tilt), so the card visibly swings while dragged. */
.asset-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  border: 1px solid rgba(138, 163, 185, 0.9);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(138, 163, 185, 0.12);
  background: #0f1216;
  pointer-events: none;
  z-index: 1000;
  display: flex;
  will-change: transform;
}
.asset-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 7px;
}
body.dragging-asset,
body.dragging-asset * { cursor: grabbing !important; }
.side-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  opacity: 0.9;
}
/* Collapsible right-panel categories use the global .collapsible mechanism
   (animation + chevron in the universal section below); no extra rules needed. */
.kf-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-elev2);
  border: 1px solid rgba(57, 65, 77, 0.55);
  border-radius: 10px;
  padding: 10px;
}
.kf-card-thumb {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(195, 171, 125, 0.5);
  background: #0d0f12;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.kf-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.kf-card-meta { min-width: 0; }
.kf-card-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kf-card-time { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.kf-empty { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.side-col .field input { width: 100%; }
/* Switch checkboxes stay compact even where field inputs go full width. */
.side-col .field input[type="checkbox"] { width: 28px; height: 16px; flex: 0 0 auto; }
.side-col .btn { width: 100%; text-align: center; }
.side-col .menu-row .btn { width: auto; flex: 1; }

/* Keyframe panel: consistent rhythm between the title, the preview card, the
   time field and the actions. */
#kfSection {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#kfSection .kf-card {
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
#kfSection .kf-card:hover {
  border-color: #4e5a6b;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
#kfSection .kf-card-thumb {
  width: 58px;
  height: 58px;
  border-radius: 9px;
  flex: 0 0 auto;
}
#kfSection .kf-card-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
#kfSection .kf-card-name { font-size: 13px; font-weight: 650; }
#kfSection .kf-card-time { font-size: 11px; margin-top: 0; }
#kfSection .kf-empty {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  padding: 2px 0;
}
.kf-field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--bg-elev2);
  border: 1px solid rgba(57, 65, 77, 0.5);
  border-radius: 10px;
}
#kfSection .menu-row { gap: 8px; }
#kfSection .menu-row .btn { padding: 8px 10px; }

.squash-group:not(.hidden) { display: flex; flex-direction: column; }
.squash-group { gap: 10px; }
.squash-group .field { gap: 6px; }
/* Small sub-section heading inside a collapsible panel (e.g. Camera > Effects). */
.side-subhead {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  opacity: 0.75;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(57, 65, 77, 0.35);
}
/* Camera panel while a color layer is selected: controls dim + disabled so
   the inactive camera (see cameraActive) never edits invisibly. */
#cameraPanel.camera-off .field input { opacity: 0.45; }
#cameraPanel.camera-off .menu-row .btn { opacity: 0.45; }
#cameraFillNote { margin-top: 2px; }
/* Reusable modern slider: thin rounded track, filled progress, compact thumb.
   Set --val (0..1) via JS or inline style to draw the filled portion. */
.slider {
  --val: 0.5;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  display: block;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--accent) calc(var(--val) * 100%),
    var(--border) calc(var(--val) * 100%));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev2);
  box-shadow: 0 0 0 1px var(--accent);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: ew-resize;
}
.slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}
.slider::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg-elev2);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: ew-resize;
}
.slider:hover::-webkit-slider-thumb,
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(138, 163, 185, 0.25);
  transform: scale(1.15);
}
.slider:hover::-moz-range-thumb,
.slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(138, 163, 185, 0.25);
  transform: scale(1.15);
}
.slider:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.slider:disabled::-webkit-slider-thumb,
.slider:disabled::-moz-range-thumb {
  cursor: not-allowed;
}
.squash-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.squash-row .btn { width: auto; flex: 0 0 auto; }
.squash-hint { font-size: 10px; color: var(--muted); }
#gapSquashValue { color: var(--accent); font-weight: 600; }
#gapSquashValue.is-auto { color: var(--muted); font-weight: 400; }

.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  gap: 0;
}

.preview-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Scroll container that also anchors the floating generation progress bar:
   the bar is positioned against this box, so it stays put over the preview
   even while the canvas is panned or zoomed. */
.preview-scroll {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
}

.preview-wrap {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  display: flex;
  background: radial-gradient(900px 600px at 50% -10%, rgba(138,163,185,0.10), transparent 60%), #161a20;
  overflow: auto;
}
.preview-stage {
  position: relative;
  flex: 0 0 auto;
  margin: auto;
}
.preview-stage canvas { display: block; }
/* Dot markers live on their own overlay canvas so editing never disturbs the
   composite underneath (no smears or stale marker ghosts when scrubbing). */
.preview-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#previewCanvas {
  flex: 0 0 auto;
  image-rendering: auto;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.06);
  cursor: grab;
  touch-action: none;
}
#previewCanvas.panning { cursor: grabbing; }

.empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 26, 32, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
}
.empty-box {
  max-width: 420px;
  text-align: center;
  padding: 26px 28px;
  border: 1px dashed rgba(57, 65, 77, 0.7);
  border-radius: 14px;
  background: rgba(34, 39, 46, 0.88);
  box-shadow: 0 10px 32px rgba(0,0,0,0.35);
}
.empty-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

.transport {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(34, 39, 46, 0.92);
  border-top: 1px solid rgba(57, 65, 77, 0.45);
  font-size: 12px;
}
.transport .status {
  margin: 0;
  padding: 2px 9px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

.filmstrip {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--bg-elev);
  border-top: 1px solid rgba(57, 65, 77, 0.45);
  min-height: 98px;
  scrollbar-width: thin;
}
.filmstrip .thumb {
  position: relative;
  flex: 0 0 auto;
  width: 68px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(57, 65, 77, 0.55);
  background: #0d0f12;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34,1.15,0.64,1), border-color 0.16s ease, box-shadow 0.16s ease;
}
.filmstrip .thumb:hover { transform: translateY(-1px); border-color: #4a5566; box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
.filmstrip .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.filmstrip .thumb.key { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(195, 171, 125, 0.4); }
.filmstrip .thumb.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.filmstrip .thumb .badge {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--gold);
}
.filmstrip .thumb .tlabel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  font-family: var(--mono);
  padding: 1px 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #cfd6e2;
  text-align: center;
}
.filmstrip .thumb .actions {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  background: rgba(27, 31, 37, 0.78);
}
.filmstrip .thumb:hover .actions { display: flex; }
.filmstrip .thumb .actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-elev2);
  color: var(--text);
  cursor: pointer;
}
.filmstrip .thumb .actions button:hover { background: var(--bg-elev3); }

.status {
  font-size: 12px;
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--muted);
  word-break: break-word;
}
.status.ready { color: var(--accent-2); border-color: rgba(143, 176, 162, 0.4); }
.status.error { color: var(--danger); border-color: rgba(196, 129, 129, 0.4); }
.status.downloading { color: var(--gold); border-color: rgba(195, 171, 125, 0.4); }

.genbar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 6;
  width: min(420px, calc(100% - 28px));
  padding: 10px 12px;
  background: rgba(27, 31, 37, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.bar {
  height: 6px;
  border-radius: 4px;
  background: #1e232a;
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #9ab2c6);
  transition: width 0.2s;
}
.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  font-family: var(--mono);
  word-break: break-all;
}

.note { font-size: 11px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.note.warn { color: var(--gold); }

.timeline-col {
  flex: 0 0 auto;
  height: 188px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-top: 1px solid rgba(57, 65, 77, 0.45);
  box-shadow: 0 -6px 24px rgba(0,0,0,0.18);
}

/* Divider between the stage and the timeline: drag to resize the timeline
   height, double-click to restore the default. */
.tl-resizer {
  flex: 0 0 auto;
  height: 6px;
  cursor: row-resize;
  background: transparent;
  border-top: 1px solid rgba(57, 65, 77, 0.35);
  touch-action: none;
  transition: background 0.16s ease;
}
.tl-resizer:hover, .tl-resizer.dragging { background: rgba(138, 163, 185, 0.14); }
body.resizing-timeline { cursor: row-resize; user-select: none; }

.tl-transport {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid rgba(57, 65, 77, 0.45);
}

.menu-label { font-size: 11px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; padding: 2px 10px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: #33252a; }

.timeline-scroll {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  cursor: text;
}
.track {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.ruler {
  flex: 0 0 auto;
  height: 26px;
  position: relative;
  display: flex;
  border-bottom: 1px solid rgba(57, 65, 77, 0.45);
  background: #191d23;
}
.ruler .tick { position: absolute; top: 0; bottom: 0; }
.ruler .tick .line { position: absolute; top: 0; width: 1px; background: #333b47; }
.ruler .tick.minor .line { height: 6px; }
.ruler .tick.major .line { height: 12px; background: #46505e; }
.ruler .tick .label {
  position: absolute;
  top: 12px;
  left: 3px;
  font-size: 9.5px;
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
/* The ruler gutter matches the layer gutters below it and stays pinned while
   the timeline scrolls horizontally. */
.ruler-gutter {
  position: sticky;
  left: 0;
  flex: 0 0 96px;
  width: 96px;
  z-index: 12;
  background: #191d23;
  border-right: 1px solid rgba(57, 65, 77, 0.45);
}

.lane {
  position: relative;
  flex: 1 1 auto;
}
/* One row per layer: name gutter (sticky) + the layer's own timeline band. */
.layer-row {
  position: relative;
  display: flex;
  height: 62px;
  border-bottom: 1px solid rgba(57, 65, 77, 0.35);
  transition: background 0.14s ease;
}
.layer-row:hover { background: rgba(255,255,255,0.015); }
/* Color-fill layers only hold dot chips (no keyframe previews), so their rows
   are much thinner than normal layers. */
.layer-row.thin {
  height: 34px;
}
.layer-row.active .layer-content { background: rgba(138, 163, 185, 0.06); }
.layer-gutter {
  position: sticky;
  left: 0;
  flex: 0 0 96px;
  width: 96px;
  z-index: 12;
  background: var(--bg-elev);
  border-right: 1px solid rgba(57, 65, 77, 0.45);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  color: var(--muted);
  cursor: grab;
  overflow: hidden;
  white-space: nowrap;
}
.layer-gutter:active { cursor: grabbing; }
.layer-gutter .layer-grip {
  margin-left: auto;
  color: var(--muted);
  opacity: 0.35;
  font-size: 11px;
  line-height: 1;
  letter-spacing: -0.5px;
  user-select: none;
  transition: opacity 0.14s ease;
}
.layer-gutter:hover .layer-grip { opacity: 0.85; }
.layer-row.dragging .layer-content { opacity: 0.45; }
.layer-row.dragging { outline: 1px dashed var(--accent); outline-offset: -1px; }
body.dragging-layer { cursor: grabbing; user-select: none; }
.layer-gutter.active {
  color: var(--text);
  background: var(--bg-elev2);
  box-shadow: inset 2px 0 0 var(--accent);
}
/* Layer name label + inline rename input (animation timeline). */
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-name-input { width: 100%; min-width: 0; background: var(--bg-elev3);
  color: var(--text); border: 1px solid var(--accent); border-radius: 3px;
  font-size: 11px; padding: 1px 4px; box-sizing: border-box; }
.layer-content {
  position: relative;
  flex: 1;
  min-width: 0;
}
.lane-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5262;
  font-size: 12px;
  pointer-events: none;
  border: 1px dashed #232a35;
  margin: 10px 12px;
  border-radius: 8px;
}

.gap-overlay {
  position: absolute;
  top: 32px;
  bottom: 8px;
  border-radius: 5px;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.gap-overlay.ok { background: rgba(143, 176, 162, 0.07); }
.gap-overlay.dirty {
  background: repeating-linear-gradient(
    45deg,
    rgba(195, 171, 125, 0.10) 0 8px,
    rgba(195, 171, 125, 0.03) 8px 16px
  );
  border: 1px dashed rgba(195, 171, 125, 0.4);
}
.gap-overlay.warn {
  border: 1px solid rgba(255, 107, 107, 0.55);
  background: rgba(255, 70, 70, 0.07);
  cursor: help;
}
/* Interpolation modes: squash gets a sage tint, none becomes a plain hold
   band. Dirty gaps keep their gold stripes regardless of mode. */
.gap-overlay.mode-squash:not(.dirty) { background: rgba(143, 176, 162, 0.11); }
.gap-overlay.mode-none:not(.dirty) { border: 1px dashed #3a4150; background: transparent; }
.gap-overlay.selected { outline: 1px solid var(--accent); outline-offset: 1px; }
.gap-overlay.selected::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.gap-overlay .glabel {
  position: absolute;
  top: -14px;
  left: 4px;
  font-size: 9px;
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
/* A label pushed onto a stacked row gets a solid badge so it stays readable
   over the gap stripes and keyframe chips below it. */
.gap-overlay .glabel.stacked {
  background: rgba(28, 33, 40, 0.95);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: 4px;
  color: #c3cbd6;
  z-index: 15; /* above chips (z 10) so stacked rows aren't hidden behind them */
}
.gap-overlay .gap-warn {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  font-size: 9px;
  font-family: var(--mono);
  color: #ff7b72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gap-tip {
  position: fixed;
  z-index: 500;
  max-width: 270px;
  padding: 7px 10px;
  background: #2a3038;
  border: 1px solid rgba(196, 129, 129, 0.45);
  border-radius: 6px;
  color: #e3c9c9;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.gap-tip.hidden { display: none; }

.frame-dot {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent-2);
  top: 38px;
  opacity: 0.55;
  pointer-events: none;
}

.kf {
  position: absolute;
  top: 12px;
  height: 50px;
  min-width: 12px;
  background: rgba(195, 171, 125, 0.09);
  border-radius: 9px;
  border: 1px solid rgba(195, 171, 125, 0.3);
  cursor: grab;
  user-select: none;
  touch-action: none; /* let a touch drag move the chip instead of scrolling */
}
.kf:active { cursor: grabbing; }
.kf:hover { border-color: rgba(195, 171, 125, 0.5); }
.kf .kf-thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 38px;
  height: 38px;
  max-width: calc(100% - 4px); /* clamp to the chip so narrow holds don't paint over the next cell */
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--gold);
  background: #000;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.kf .kf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf .kf-time {
  position: absolute;
  left: 3px;
  bottom: 1px;
  max-width: calc(100% - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 8.5px;
  font-family: var(--mono);
  color: #cfd6e2;
  background: rgba(0, 0, 0, 0.55);
  padding: 0 3px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}
.kf.selected { border-color: var(--accent); background: rgba(138, 163, 185, 0.14); }
.kf.selected .kf-thumb { border-color: var(--accent); }
.kf .kf-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  border-radius: 0 8px 8px 0;
}
.kf .kf-resize:hover { background: rgba(195, 171, 125, 0.22); }
.kf .kf-resize::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 20px;
  border-radius: 2px;
  background: rgba(195, 171, 125, 0.5);
}
.kf .kf-drag-tip {
  position: absolute;
  top: -22px;
  font-size: 10px;
  font-family: var(--mono);
  background: var(--accent);
  color: #14181d;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.fill-dot {
  position: absolute;
  top: 7px;
  height: 20px;
  min-width: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(79, 143, 255, 0.12);
  border: 1px solid rgba(79, 143, 255, 0.4);
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.fill-dot:hover { border-color: rgba(79, 143, 255, 0.65); background: rgba(79, 143, 255, 0.18); }
.fill-dot.selected {
  border-color: var(--accent);
  background: rgba(138, 163, 185, 0.16);
  box-shadow: 0 0 0 1px var(--accent);
}
.fill-dot-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.fill-dot-label {
  font-size: 8.5px;
  font-family: var(--mono);
  color: #c3cbd6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.fill-dot-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}
.fill-dot-edge.left { left: 0; border-radius: 8px 0 0 8px; }
.fill-dot-edge.right { right: 0; border-radius: 0 8px 8px 0; }
.fill-dot-edge:hover { background: rgba(255, 255, 255, 0.12); }
.fill-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5262;
  font-size: 11px;
  pointer-events: none;
  border: 1px dashed #232a35;
  margin: 10px 12px;
  border-radius: 8px;
  text-align: center;
  padding: 0 10px;
}
/* Color picker input in the dot panel: match the other field inputs. */
.field input[type="color"] {
  width: 100%;
  height: 30px;
  padding: 2px;
  background: #1e232a;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.field input[type="color"]:hover { border-color: #454f5e; }

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  margin-left: -3.5px; /* keep the 2px line centered on the time */
  z-index: 25;
  cursor: ew-resize;
  /* transparent grab strip; the visible line is drawn by ::before */
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3.5px;
  width: 2px;
  background: var(--danger);
}
.playhead::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 9px;
  height: 11px;
  background: var(--danger);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

/* Drop placement guide: shown while an asset drags over the timeline. */
.drop-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  z-index: 20;
  pointer-events: none;
  display: none;
}
.drop-guide.visible { display: block; }
.drop-guide-label {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 10px;
  font-family: var(--mono);
  color: #161a20;
  background: var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
}

.timeline-hint {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 12px;
  font-size: 10.5px;
  color: var(--muted);
  border-top: 1px solid rgba(57, 65, 77, 0.35);
  background: #1c2128;
}
.timeline-hint b { color: #c3cbd6; }

.toast {
  position: fixed;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(42, 48, 56, 0.97);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border: 1px solid rgba(57, 65, 77, 0.6);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  z-index: 100;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  max-width: 80vw;
  animation: toast-in 0.24s cubic-bezier(0.34,1.15,0.64,1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* General polish: subtle lift + ring on interactive cards, focus rings for
   keyboard users, and a shimmer on the progress fill. */
.asset { transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease; }
.asset:hover {
  border-color: #454f5e;
  background: var(--bg-elev3);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.kf-card { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.kf-card:hover { border-color: #454f5e; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.filmstrip .thumb img { transition: transform 0.18s ease; }
.filmstrip .thumb:hover img { transform: scale(1.07); }
.filmstrip .thumb .actions button { transition: background 0.12s ease, transform 0.12s ease; }
.filmstrip .thumb .actions button:hover { background: var(--bg-elev3); transform: translateY(-1px); }
.kf { transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease; }
.kf:hover { border-color: rgba(195, 171, 125, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.kf.selected:hover { border-color: var(--accent); }

/* Camera track (timeline row + keyframe chips)
   The camera row mirrors a layer row (gutter + content) but is NOT a
   .layer-row, so the layer-reorder index math in drag.js ignores it. */
.camera-row {
  position: relative;
  display: flex;
  height: 62px;
  border-bottom: 1px solid rgba(57, 65, 77, 0.35);
  background: rgba(0, 0, 0, 0.16);
}
.camera-row .layer-gutter {
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}
.cam-dot {
  position: absolute;
  top: 8px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: var(--accent);
  border-radius: 3px;
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.cam-dot:hover { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }


/* Reference audio lane (waveform under the timeline)
   Spans the full timeline width (like .lane) and draws the waveform with the
   same GUTTER_W time offset as the lane, so clicks map to the right time. */
#audioLane {
  position: relative;
  margin: 6px 0 10px;
  height: 48px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(57, 65, 77, 0.45);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
}
#audioLane.hidden { display: none !important; }
#audioCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Keyboard focus rings (mouse users keep the clean look). */
.btn:focus-visible,
.menu button:focus-visible,
.asset:focus-visible,
.kf:focus-visible,
.filmstrip .thumb:focus-visible,
.slider:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Respect users who prefer reduced motion: kill animations and springy
   transforms, keep functional transitions instant. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
  }
  .btn:hover, .asset:hover { transform: none; box-shadow: none; }
  .filmstrip .thumb:hover img { transform: none; }
}

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #39414d; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #454f5e; }
::-webkit-scrollbar-track { background: transparent; }

/* mobile

   Everything below only kicks in on narrow screens; desktop is untouched.
   The side panels become sliding drawers over the preview (the timeline stays
   visible below them), the start screen stacks, and touch gets its own
   hit-sizes and safe-area padding. */

.mobile-only { display: none !important; }

@media (max-width: 860px) {
  /* drawer toggle buttons in the toolbar */
  .mobile-only { display: inline-flex !important; }
  /* but a mobile-only row of panel buttons stays a full-width flex row */
  .menu-row.mobile-only { display: flex !important; }
  .toolbar { padding: 8px 10px; gap: 8px; }
  .toolbar-brand .brand-name { display: none; }
  .toolbar-group { gap: 6px; }

  /* side panels become fixed drawers; JS positions them between the toolbar
     and the timeline so the timeline stays reachable for scrubbing and drops */
  .side-resizer { display: none; }
  .side-col {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 120;
    width: min(300px, 86vw);
    box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .side-col.right {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid rgba(57, 65, 77, 0.45);
  }
  /* off-screen to the right when closed, slides in from the right edge */
  .side-col.right { transform: translateX(108%); }
  .side-col.right.open { transform: translateX(0); }
  /* default hidden, slid off the left edge */
  .side-col { transform: translateX(-108%); }
  .side-col.open { transform: translateX(0); }

  /* backdrop behind an open drawer */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(12, 14, 17, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }

  /* dropdown menus clamp to the viewport so they never go off-screen */
  .menu { max-width: min(320px, 92vw); }
  .menu-wrap { max-width: 100%; }

  /* start screen stacks: banner on top, menu below */
  .start-screen { flex-direction: column; }
  .start-art {
    width: 100%;
    height: 36vh;
    min-height: 150px;
  }
  .start-art::after {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(80px, 26%);
    background: linear-gradient(to bottom, rgba(27, 31, 37, 0), var(--bg));
  }
  .start-panel { padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
  .start-name { font-size: 38px; }

  /* timeline: touch drags scrub / move chips instead of scrolling the lane */
  .ruler, .lane { touch-action: pan-y; }
  .playhead { touch-action: pan-y; }
  .tl-transport { gap: 6px; padding: 7px 8px; }
  .timeline-hint { flex-wrap: wrap; }

  /* transport + status take less room so the preview gets more */
  .transport { padding: 7px 10px; gap: 8px; }
  .transport .status { max-width: 38vw; }

  /* safe areas for notched phones */
  .toolbar { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .timeline-col { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tl-resizer { height: 10px; }

  .filmstrip { min-height: 84px; }
  .filmstrip .thumb { width: 62px; height: 70px; }
  .filmstrip .thumb .badge { font-size: 9px; }

  /* touch-friendly affordances: things that only ever appeared on hover */
  .asset-del { display: flex !important; width: 26px; height: 26px; min-width: 26px; }
  .asset-del svg { width: 16px; height: 16px; }
  .filmstrip .thumb .actions { display: flex !important; }
  .filmstrip .thumb .actions button { padding: 6px 8px; font-size: 11px; }
  .kf .kf-resize { width: 24px; } /* wider resize edge for a finger */

  /* bigger tap targets for the small buttons */
  .btn.icon { min-height: 40px; min-width: 44px; }
  .btn.mini { min-height: 34px; padding: 6px 10px; }
  .field input[type="number"], .field input[type="text"], .field select,
  .field input[type="range"] { min-height: 40px; }
  .field input[type="number"], .field select { font-size: 14px; padding: 9px 10px; }

  /* dropdown menus: bigger, easier to tap */
  .menu button { padding: 10px 12px; font-size: 14px; }
  .menu button svg { width: 18px; height: 18px; }
  .menu .field { font-size: 13px; }
  .menu .field input, .menu .field select { padding: 9px 10px; font-size: 14px; }

  /* context menu (long-press on a chip): bigger items */
  .context-menu button { padding: 11px 14px; font-size: 14.5px; }
  .context-menu button svg { width: 18px; height: 18px; }

  /* sliders: a thumb a finger can grab */
  .slider::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }
  .slider::-moz-range-thumb { width: 22px; height: 22px; }

  /* no browser tap highlight / long-press callout, and taps are instant
     (no 300ms hover delay) */
  * { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
  .btn, .asset, .filmstrip .thumb, .menu button, .context-menu button,
  .field input, .field select, .kf, .gap-overlay, .layer-gutter,
  .layer-row, .fill-dot { touch-action: manipulation; }
  .kf .kf-resize, .tl-resizer, .side-resizer { touch-action: none; }

  .kf-drag-tip { font-size: 11px; }
  .asset-ghost { width: 54px; height: 54px; }
}

@media (max-width: 480px) {
  .toolbar-brand { display: none; }
  .btn { padding: 6px 9px; }
  .btn.icon { min-width: 34px; padding: 7px 9px; }
  .tl-transport .btn { font-size: 12px; }
  .start-name { font-size: 32px; }
  .start-art { height: 30vh; }
  .side-col { width: min(280px, 92vw); }
  .bar-meta { font-size: 9.5px; }
}

/* Built-in paint tool
   A Krita-style workspace: flat toolbar on top, tool-options docker on the
   left, the canvas in the centre, docker panels on the right and an action /
   onion-skin status bar at the bottom. Reuses the editor's design tokens. */
.paint-overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: stretch; justify-content: stretch; padding: 0; }
.paint-overlay.hidden { display: none; }
.paint-box { width: 100%; height: 100%;
  background: var(--bg-elev); border: none;
  border-radius: 0; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: none; }

/* Top toolbar: tool buttons, brush name, quick sliders, colour, close. */
.paint-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--bg-elev2); border-bottom: 1px solid var(--border); }
/* Tool buttons live in the left panel above Tool options (Krita-style). */
.paint-tools { display: grid; grid-template-columns: repeat(5, 26px); gap: 3px;
  margin-bottom: 9px; }
.paint-tool { display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  cursor: pointer; }
.paint-tool svg { width: 16px; height: 16px; }
.paint-tool:hover { background: var(--bg-elev3); color: var(--text); }
.paint-tool.active { background: var(--bg-elev3); border-color: var(--accent); color: var(--text); }
.paint-toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.paint-brush-name { font-size: 12px; font-weight: 600; color: var(--text);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paint-qfield { display: flex; flex-direction: column; gap: 2px; font-size: 11px;
  color: var(--muted); min-width: 118px; }
.paint-qfield .paint-qval { color: var(--text); }
.paint-qfield .slider { height: 14px; }
/* Krita-style slider + spinbox row. */
.paint-qrow { display: flex; align-items: center; gap: 6px; }
.paint-qrow .slider { flex: 1; min-width: 0; }
.paint-num { width: 44px; box-sizing: border-box; flex: 0 0 auto;
  background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border);
  border-radius: 5px; font-size: 11px; padding: 2px 4px; text-align: center; }
.paint-num:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Krita-style size / opacity control: a slider with the value drawn in a pill
   centred over the groove. Double-clicking the slider swaps the pill for a
   text field you can type into (see wirePaintKSlider). */
.paint-kfield { display: flex; flex-direction: column; gap: 2px; font-size: 11px;
  color: var(--muted); min-width: 132px; flex: 0 0 auto; }
.paint-kname { font-size: 11px; color: var(--muted); }
.paint-kslider { position: relative; display: block; }
.paint-kslider-range { height: 18px; }
.paint-kslider-val { position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 1;
  font-size: 10.5px; line-height: 1; padding: 3px 9px; font-weight: 600;
  color: var(--text); background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 8px; white-space: nowrap; }
.paint-kslider-text { position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); z-index: 2; width: 66px; box-sizing: border-box;
  background: var(--bg-elev2); color: var(--text); border: 1px solid var(--accent);
  border-radius: 8px; font-size: 11px; padding: 2px 6px; text-align: center; }
.paint-kslider-text[hidden] { display: none; }
.paint-kslider-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.paint-color-wrap { display: block; width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); cursor: default; }
.paint-close { margin-left: 2px; padding: 8px 18px; font-weight: 700; gap: 8px;
  font-size: 13px; box-shadow: 0 1px 8px rgba(138, 163, 185, 0.35); }
.paint-close svg { width: 17px; height: 17px; }

/* Main workspace row. */
.paint-body { display: flex; min-height: 0; flex: 1; }

/* Docker panels: title strip + body, like Krita's dockers. */
.paint-docker { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.docker-title { display: flex; align-items: center; gap: 6px; font-size: 10.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border); }
.paint-left { width: 190px; flex: 0 0 auto; border-right: 1px solid var(--border);
  overflow-y: auto; background: var(--bg-elev); }
.paint-dockers { width: 250px; flex: 0 0 auto; border-left: 1px solid var(--border);
  overflow-y: auto; background: var(--bg-elev); }

/* Universal collapsible panels (used by the paint editor docker AND the right
   panel of the main editor): a `.collapsible` container whose first child is a
   `.collapsible-title` button, with the foldable content wrapped in
   `.collapsible-body > .collapsible-inner`. Clicking the title folds/unfolds
   with a smooth grid-template-rows animation to the exact content height. */
.collapsible-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.collapsible.collapsed .collapsible-body { grid-template-rows: 0fr; }
.collapsible-inner { min-height: 0; overflow: hidden; }
.collapsible-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; margin: 0; padding: 0 0 4px; border: none; background: none;
  font: inherit; text-align: left; cursor: pointer; user-select: none;
}
.collapsible-title:hover { color: var(--text); }
.collapsible-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.collapsible-chev { flex: 0 0 auto; width: 12px; height: 12px; opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.15s ease; }
.collapsible-title:hover .collapsible-chev { opacity: 1; }
.collapsible.collapsed .collapsible-chev { transform: rotate(-90deg); }
/* Resizer handles between the paint panels (drag to resize, double-click reset). */
.paint-resizer { flex: 0 0 auto; width: 5px; cursor: col-resize; background: transparent;
  touch-action: none; transition: background 0.16s ease; }
.paint-resizer:hover, .paint-resizer.dragging { background: rgba(138, 163, 185, 0.18); }

/* Color wheel (Krita-style): SV square + hue slider, capped + centred.
   Position math in the JS reads getBoundingClientRect() at runtime, so the
   fixed display size is safe. */
.paint-colorwheel { display: flex; justify-content: center; align-items: flex-start;
  gap: 8px; margin-bottom: 8px; }
.paint-cw-sv-wrap { position: relative; flex: 0 0 auto; width: 150px;
  aspect-ratio: 1 / 1; }
.paint-cw-sv { display: block; width: 100%; height: 100%; border-radius: 6px;
  border: 1px solid var(--border); cursor: crosshair; touch-action: none; }
.paint-cw-dot { position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 1px 3px rgba(0,0,0,0.5);
  pointer-events: none; transform: translate(-50%, -50%); }
.paint-cw-hue-wrap { position: relative; width: 18px; height: 150px; flex: 0 0 auto; }
.paint-cw-hue { display: block; width: 100%; height: 100%; border-radius: 6px;
  border: 1px solid var(--border); cursor: pointer; touch-action: none; }
.paint-cw-hue-marker { position: absolute; left: -3px; right: -3px; height: 8px;
  border: 2px solid #fff; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6); pointer-events: none; }
.paint-cw-hex { display: flex; justify-content: center; }
.paint-cw-hex .paint-field { flex: 0 0 auto; width: 176px; }
.paint-cw-hex .text-input { font-family: var(--mono); text-align: center; }

/* Recent-colour swatch row (paint history, newest first). */
.paint-cw-recent { margin-top: 9px; }
.paint-cw-recent-label { font-size: 11px; color: var(--muted); margin: 0 0 5px; text-align: center; }
.paint-recent-colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.paint-recent-swatch {
  width: 18px; height: 18px; padding: 0;
  border-radius: 5px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.paint-recent-swatch:hover { transform: scale(1.18); border-color: #fff; }

/* Tool-options fields. */
.paint-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px;
  color: var(--muted); margin-bottom: 9px; }
.paint-field .mono { color: var(--text); }
.paint-field select { background: var(--bg-elev2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px;
  font-size: 12px; }
.paint-check { display: flex; align-items: center; gap: 8px; font-size: 12px;
  color: var(--text); margin-bottom: 9px; cursor: pointer; }
.paint-left .slider { height: 14px; }

/* Centre canvas. */
.paint-center { flex: 1; min-width: 0; display: flex; align-items: center;
  justify-content: center; padding: 12px; background: var(--bg); }
.paint-canvas-wrap { width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center;
  /* Light-grey checkerboard so dark paint is easy to see while whites still
     read as white (Krita/Photoshop-style). The dark tile was the app's
     --bg-elev2 (#2a3038), which swallowed dark colours. The wrap's own
     background-color is the darker of the two tiles. */
  background-color: #aeb4bb;
  background-image: linear-gradient(45deg, #c9cdd3 25%, transparent 25%),
    linear-gradient(-45deg, #c9cdd3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c9cdd3 75%),
    linear-gradient(-45deg, transparent 75%, #c9cdd3 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border-radius: 6px; overflow: hidden; }
.paint-canvas-wrap .paint-stage { border-radius: 2px; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
#paintCanvas { background: transparent; touch-action: none; border-radius: 2px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4); cursor: crosshair; }

/* Brush palette: Krita-style grid of square previews on white, no labels. */
.paint-brush-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 4px; margin-bottom: 8px; max-height: 240px; overflow-y: auto; }
.paint-brush { display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1 / 1; padding: 3px; border-radius: 5px;
  border: 1px solid transparent; background: transparent;
  color: var(--text); cursor: pointer; }
.paint-brush:hover { background: var(--bg-elev3); }
.paint-brush.active { border-color: var(--accent); background: rgba(138,163,185,0.16); }
.paint-brush-prev { width: 100%; height: 100%; border-radius: 3px;
  overflow: hidden; background: #fff; display: flex; align-items: center;
  justify-content: center; }
.paint-brush-prev canvas { display: block; max-width: 100%; max-height: 100%; }
.paint-brush-prev img { width: 100%; height: 100%; object-fit: contain; display: block; }
.paint-brush-count { margin-left: auto; font-size: 10px; font-weight: 600;
  color: var(--accent); background: rgba(138,163,185,0.12);
  border: 1px solid rgba(138,163,185,0.25); padding: 1px 6px; border-radius: 999px; }

/* Layer list (Krita-style: thumbnail + eye + name, icon toolbar, props). */
.paint-layer-list { display: flex; flex-direction: column; gap: 2px;
  max-height: 200px; overflow-y: auto; margin-bottom: 5px; }
.paint-layer { display: flex; align-items: center; gap: 6px; padding: 3px 4px;
  border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.paint-layer:hover { background: var(--bg-elev3); }
.paint-layer.active { border-color: var(--accent); background: rgba(138,163,185,0.16); }
.paint-layer-thumb { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 4px;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#b9bfc6 0% 25%, #eceff2 0% 50%) 0 0 / 8px 8px; }
.paint-layer-name { flex: 1; min-width: 0; font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paint-layer-name-input { flex: 1; min-width: 0; background: var(--bg-elev3);
  color: var(--text); border: 1px solid var(--accent); border-radius: 4px;
  font-size: 12px; padding: 1px 4px; }
.paint-layer-eye { display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: 0 0 auto; padding: 0; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; }
.paint-layer-eye:hover { background: var(--bg-elev3); color: var(--text); }
.paint-layer-eye.off { color: var(--bg-elev3); }
.paint-layer-eye.off:hover { color: var(--muted); }
/* Docker toolbar: flat icon buttons consistent with the tools column. */
.paint-layer-toolbar { display: flex; align-items: center; gap: 2px;
  padding: 5px 0 7px; border-top: 1px solid var(--border); }
.paint-icon-btn { display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; }
.paint-icon-btn:hover:not(:disabled) { background: var(--bg-elev3); color: var(--text); }
.paint-icon-btn:disabled { opacity: 0.35; cursor: default; }
.paint-icon-btn.danger:hover:not(:disabled) { color: var(--danger); }
.paint-layer-tb-sep { width: 1px; height: 18px; flex: 0 0 auto;
  background: var(--border); margin: 0 6px; }
/* Active-layer opacity + blend props (opacity is slider + percent spinbox,
   matching the top-toolbar brush controls). */
.paint-layer-props { display: flex; flex-direction: column; gap: 6px; }
.paint-layer-prop { display: flex; align-items: center; gap: 8px; font-size: 11px;
  color: var(--muted); }
.paint-layer-oprow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.paint-layer-oprow .slider { flex: 1; min-width: 0; height: 14px; }
.paint-layer-oprow .paint-num { width: 40px; }
.paint-layer-prop .paint-qval { width: 34px; text-align: right; color: var(--text); }
.paint-layer-blend { flex: 1; min-width: 0; background: var(--bg-elev2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 11px;
  padding: 3px 5px; cursor: pointer; }

/* Resize dialog inputs. */
.text-input { width: 100%; box-sizing: border-box; background: var(--bg-elev2);
  border: 1px solid var(--border); color: inherit; border-radius: 6px;
  padding: 6px 8px; font-size: 12px; }

/* Bottom status bar: actions + onion skin. */
.paint-statusbar { display: flex; align-items: center; gap: 10px; padding: 5px 10px;
  background: var(--bg-elev2); border-top: 1px solid var(--border); }
.paint-actions { display: flex; gap: 6px; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.paint-view { display: flex; align-items: center; gap: 5px; }
.paint-view .paint-qval { font-size: 12px; min-width: 40px; text-align: center; }
/* Icon-only zoom controls at the right of the status bar. */
.paint-view-btn { display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 6px; }
.paint-view-btn svg { width: 13px; height: 13px; }
/* Frame scrubber: moves the timeline playhead so onion ghosts follow it. */
.paint-frame-field { min-width: 150px; }
.paint-frame-field .paint-qrow { gap: 6px; }
.paint-frame-field .paint-qrow .slider { flex: 1 1 auto; min-width: 70px; }
.paint-frame-field .paint-qval { min-width: 46px; text-align: center; color: var(--text); }
.paint-banner { font-size: 12px; color: var(--gold); background: rgba(255,180,40,0.12);
  padding: 3px 8px; border-radius: 6px; }
.paint-banner.hidden { display: none; }

/* Extra tools: stage overlay, tool option panels, dialogs, menus. */
.paint-stage { position: relative; }
.paint-overlay-cv { position: absolute; inset: 0; pointer-events: none; }
#paintCanvas { position: relative; }
.paint-toolopts { display: block; }
.paint-toolopts.hidden { display: none; }
.paint-btnrow { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.paint-hint { font-size: 11px; color: var(--muted); line-height: 1.5;
  margin: 0 0 9px; }
.paint-dialog { position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center; background: rgba(0,0,0,0.45); }
.paint-dialog.hidden { display: none; }
.paint-dialog-box { width: 320px; background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.paint-dialog-row { display: flex; gap: 10px; }
.paint-dialog-row .paint-field { flex: 1; min-width: 0; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }
