:root {
  --bg: #16161c;
  --panel: #1f1f28;
  --panel-edge: #2c2c38;
  --text: #d8d8e0;
  --text-dim: #8a8a98;
  --accent: #41a6f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, sans-serif;
  user-select: none;
  overflow: hidden;
  /* Touch screens: buttons respond instantly, double-tap can't zoom the
     page. The canvas opts out of ALL browser gestures separately (#view
     touch-action:none) — pinch/pan there is handled by the app itself. */
  touch-action: manipulation;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-edge);
}

#topbar h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-right: 8px;
}

/* "For now" brand mark: the Enkava wave, shown as a small rounded tile. */
.brand-logo {
  height: 24px;
  width: auto;
  border-radius: 5px;
  display: block;
}

.group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* pushes this group (and everything after it) to the right edge */
.group.push { margin-left: auto; }

/* ---------- topbar dropdown menus (File, Toggles) ---------- */
#file-wrap, #toggles-wrap { position: relative; }

#file-menu, #toggles-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

#file-menu[hidden], #toggles-menu[hidden] { display: none; }

#file-menu hr, #toggles-menu hr {
  border: none;
  border-top: 1px solid var(--panel-edge);
}

/* Toggles menu: one checkbox row per hideable panel / canvas guide. */
#toggles-menu label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#file-menu .menu-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#file-menu .menu-item, #toggles-menu .menu-item { text-align: left; }

/* New-project mode picker: two radio labels side by side */
#mode-row { justify-content: space-between; }
#mode-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

#file-menu select {
  padding: 5px 6px;
  background: var(--bg);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
}

.group label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}

input[type="number"] {
  width: 52px;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
}

button {
  padding: 5px 10px;
  background: #2a2a35;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #343442; }
button:disabled { opacity: 0.4; cursor: default; }

#zoom-label {
  min-width: 44px;
  text-align: center;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- main layout ---------- */
main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Panels hidden from the Toggles menu. Their display:flex rules would beat
   the [hidden] attribute's default styling, so spell it out. */
#toolbar[hidden], #layers-panel[hidden], #framebar[hidden] { display: none; }

#toolbar {
  width: 150px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border-right: 1px solid var(--panel-edge);
  overflow-y: auto;
}

#toolbar hr {
  border: none;
  border-top: 1px solid var(--panel-edge);
  margin: 6px 0;
}

.tool {
  text-align: left;
  padding: 7px 10px;
}

.tool .icon { display: inline-block; width: 18px; }

.tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0c12;
  font-weight: 600;
}

/* Brush size + tip shape (shared by the brush and eraser tools) */
#brush-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

#brush-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#brush-shapes { display: flex; gap: 4px; }

.shape {
  padding: 2px 8px;
  line-height: 1.4;
}

.shape.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0c12;
}

#inp-brush-size {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

/* Freeform-only stroke settings; pixel mode hides them (and freeform hides
   the square/circle tip toggle — freeform tips are always round). */
.brush-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
}
body.mode-free .brush-sub { display: flex; }
body.mode-free #brush-shapes { display: none; }

.brush-sub input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

#color-well input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 0;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

#palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.swatch {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- floating preview popup (playback happens in the main canvas;
              this optional panel is a small always-visible loop monitor) ---------- */
#preview-panel {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 200px;
  display: flex;
  flex-direction: column;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 6;
  overflow: hidden;
}

#preview-panel[hidden] { display: none; }

#preview-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--panel-edge);
  cursor: grab;        /* the header doubles as the panel's drag handle */
  touch-action: none;
}

#preview-head:active { cursor: grabbing; }

#preview-head span {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#preview-head button {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.2;
}

#preview {
  width: 100%;
  /* canvas keeps its own aspect ratio; upscale stays crisp */
  image-rendering: pixelated;
  background: repeating-conic-gradient(#4a4a52 0% 25%, #5a5a63 0% 50%) 0 0 / 12px 12px;
}

/* Freeform projects interpolate the preview instead of showing fat pixels. */
#preview.smooth { image-rendering: auto; }

/* ---------- selection action bar ---------- */
#select-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 5;
  white-space: nowrap;
}

#select-bar[hidden] { display: none; }

#select-bar button {
  padding: 4px 8px;
  font-size: 13px;
}

/* W / H / angle readout + manual entry — freeform only (typing a size would
   resample pixel art, which that mode deliberately never does). */
#sel-dims {
  display: none;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  color: var(--text-dim);
}

body.mode-free #sel-dims { display: flex; }

#sel-dims label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ---------- slider number boxes (exact-value entry on every slider) ---------- */
input.num {
  width: 44px;
  padding: 1px 3px;
  font: inherit;
  font-size: 12px;
  text-align: right;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
}

input.num:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- brush library panel (floating overlay, Procreate-style) ---------- */
#brush-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 208px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 6; /* above the layers panel when they overlap */
  overflow: hidden;
}

#brush-panel[hidden] { display: none; }

#brush-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-edge);
  cursor: grab;        /* the header doubles as the panel's drag handle */
  touch-action: none;
}

#brush-head:active { cursor: grabbing; }

#brush-head span {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#brush-head button {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.2;
}

/* Bitmap / Vector engine tabs (Phase 8a) — segmented control under the
   header; the active side gets the accent card treatment like brush rows. */
#brush-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
}

#brush-tabs button {
  flex: 1;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  background: #26262f;
  border: 1px solid transparent;
  border-radius: 6px;
}

#brush-tabs button:hover { background: #2a2a35; }

#brush-tabs button.active {
  background: rgba(65, 166, 246, 0.28);
  border-color: var(--accent);
}

#brush-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
}

#brush-list .brush {
  position: relative;
  padding: 4px 6px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #26262f; /* dark card so the white stroke swatch reads */
  cursor: pointer;
}

#brush-list .brush:hover { background: #2a2a35; }

#brush-list .brush.active {
  background: rgba(65, 166, 246, 0.28); /* the Procreate-blue selected card */
  border-color: var(--accent);
}

#brush-list .brush span {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
}

#brush-list .brush-swatch {
  display: block;
  width: 100%;
}

#brush-list .brush-del {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1.6;
}

/* The library opener lives in the brush box, freeform only. */
#btn-brush-lib {
  display: none;
  width: 100%;
  margin-bottom: 6px;
  text-align: left;
}

body.mode-free #btn-brush-lib { display: block; }

/* Rasterize-layer is a vector-layer command — freeform projects only. */
#btn-layer-raster { display: none; }
body.mode-free #btn-layer-raster { display: inline-block; }

/* ---------- palette library panel (to-do #8) — the brush library's twin ---------- */

/* The strip ends in an explicit "+ add current color" cell: named palettes
   are curated (painting no longer appends — see addUsedColor), so adding
   a color has to be a deliberate act. */
.swatch-add {
  background: none;
  font-size: 14px;
  line-height: 1;
  border-style: dashed;
}

/* Drop-slot highlight while a swatch is being drag-reordered. */
.swatch.drop {
  outline: 2px dashed var(--accent);
  outline-offset: 1px;
}

/* The in-place swatch editor: invisible but NOT display:none — some
   browsers refuse to open a picker for an element that has no box. */
#inp-swatch-edit {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

#btn-palette-lib {
  width: 100%;
  margin-top: 6px;
  text-align: left;
}

#palette-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 208px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 6; /* same layer as the brush panel — last opened wins by DOM order */
  overflow: hidden;
}

#palette-panel[hidden] { display: none; }

#palette-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-edge);
  cursor: grab;        /* the header doubles as the panel's drag handle */
  touch-action: none;
}

#palette-head:active { cursor: grabbing; }

#palette-head span {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#palette-head button {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.2;
}

#palette-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
}

#palette-list .pal {
  position: relative;
  padding: 4px 6px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #26262f;
  cursor: pointer;
}

#palette-list .pal:hover { background: #2a2a35; }

#palette-list .pal.active {
  background: rgba(65, 166, 246, 0.28); /* the Procreate-blue selected card */
  border-color: var(--accent);
}

#palette-list .pal > span {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 600;
}

#palette-list .pal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 11px;
  color: #888;
}

#palette-list .pal-chips i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#palette-list .pal-del {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1.6;
}

#palette-foot {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid var(--panel-edge);
}

#palette-foot button {
  flex: 1;
  padding: 4px 0;
  font-size: 11px;
}

/* ---- Start screen: modal project chooser shown on boot ---- */

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 50;               /* above every floating panel */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, 0.78);
}

#start-screen[hidden] { display: none; }

#start-card {
  width: min(560px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 26px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}

#start-card h1 { font-size: 18px; letter-spacing: 0.4px; }

#start-sub {
  margin: 2px 0 14px;
  color: var(--text-dim);
}

#start-tabs {
  display: flex;
  gap: 6px;
  max-width: 300px;
  margin: 0 auto 10px;
}

#start-tabs button {
  flex: 1;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  background: #26262f;
  border: 1px solid transparent;
  border-radius: 8px;
}

#start-tabs button:hover { background: #2a2a35; }

#start-tabs button.active {
  background: rgba(65, 166, 246, 0.28);
  border-color: var(--accent);
}

#start-blurb {
  min-height: 2.6em;
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

#start-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

#start-presets .start-preset {
  width: 148px;
  padding: 8px 8px 6px;
  background: #26262f;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

#start-presets .start-preset:hover {
  background: #2a2a35;
  border-color: var(--accent);
}

#start-presets .start-preset canvas {
  display: block;
  margin: 0 auto 6px;
}

#start-presets .start-preset b {
  display: block;
  font-size: 12px;
}

#start-presets .start-preset span {
  color: var(--text-dim);
  font-size: 11px;
}

#start-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--panel-edge);
  padding-top: 14px;
}

#start-custom input {
  width: 64px;
  padding: 3px 5px;
}

#start-print-opts {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

#start-print-opts[hidden] { display: none; }

/* CMYK ink readout under the color well — print projects only. */
#cmyk-readout {
  display: none;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

body.intent-print #cmyk-readout { display: block; }

/* The soft-proof toggle only means something on print projects. (Extra
   specificity: the generic #toggles-menu label rule would win otherwise.) */
#toggles-menu #proof-row { display: none; }
body.intent-print #toggles-menu #proof-row { display: flex; }

/* ---- Ruler unit buttons: one per enabled ruler, at that ruler's corner
   (each ruler owns a different corner so all four can coexist). ---- */
.ruler-unit {
  position: absolute;
  z-index: 6;
  width: 24px;
  height: 22px;
  padding: 0;
  font-size: 10px;
  color: var(--text-dim);
  background: #26262f;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
}

.ruler-unit:hover { color: var(--text); border-color: var(--accent); }

#ruler-unit-left   { left: 0; top: 0; }         /* left ruler → top-left */
#ruler-unit-top    { right: 0; top: 0; }        /* top ruler → top-right */
#ruler-unit-right  { right: 0; bottom: 0; }     /* right ruler → bottom-right */
#ruler-unit-bottom { left: 0; bottom: 0; }      /* bottom ruler → bottom-left */

/* Playback hides editing chrome — the drawn rulers pause, buttons too. */
#canvas-wrap.playing .ruler-unit { display: none; }

#btn-start-create {
  background: rgba(65, 166, 246, 0.28);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 14px;
  font-weight: 600;
}

#btn-start-load { margin-left: 10px; }

/* The smudge tool only exists in freeform mode. */
body:not(.mode-free) .tool[data-tool="smudge"] { display: none; }

/* JS hides the hardness slider for texture brushes; without this the
   body.mode-free display rule would win over the hidden attribute. */
body.mode-free .brush-sub[hidden] { display: none; }

/* ---------- layers panel (floating overlay, Procreate-style) ---------- */
#layers-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 210px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 5;
  overflow: hidden;
}

#layers-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-edge);
  cursor: grab;        /* the header doubles as the panel's drag handle */
  touch-action: none;  /* let pointer events drive the drag on touch too */
}

#layers-head:active { cursor: grabbing; }

#layers-head span {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#layers-head button {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.2;
}

#layers-panel.collapsed #layers,
#layers-panel.collapsed #layer-adjust,
#layers-panel.collapsed .layer-controls { display: none; }
#layers-panel.collapsed #layers-head { border-bottom: none; }

#layers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
}

#layers .layer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

#layers .layer:hover { background: #2a2a35; }

#layers .layer.active {
  background: rgba(65, 166, 246, 0.22);
  border-color: var(--accent);
}

#layers .layer-thumb {
  image-rendering: pixelated;
  /* mini transparency checker behind the layer's content */
  background: repeating-conic-gradient(#4a4a52 0% 25%, #5a5a63 0% 50%) 0 0 / 8px 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  flex-shrink: 0;
}

#layers .layer span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Compact non-default markers on a row: "50% M 🔒". The name span flexes;
   badges must not, or long names would squeeze them out entirely. */
#layers .layer .layer-badges {
  flex: none;
  font-size: 10px;
  color: var(--text-dim);
}

/* Appearance controls for the SELECTED layer (opacity / blend / alpha lock) */
#layer-adjust {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px 8px;
  border-top: 1px solid var(--panel-edge);
  font-size: 12px;
}

#layer-adjust label {
  display: flex;
  align-items: center;
  gap: 6px;
}

#layer-adjust input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

#layer-adjust b {
  width: 34px;
  text-align: right;
  font-weight: 600;
}

#layer-adjust-row {
  display: flex;
  gap: 6px;
}

#sel-layer-blend { flex: 1; }

#btn-layer-lock.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0c12;
}

.layer-controls {
  display: flex;
  gap: 4px;
  padding: 6px 8px 8px;
  border-top: 1px solid var(--panel-edge);
}

.layer-controls button {
  flex: 1;
  padding: 3px 0;
}

/* ---------- canvas ---------- */
#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#view {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#canvas-wrap.panning #view,
#canvas-wrap.pan-tool #view { cursor: grab; }
#canvas-wrap.panning-active #view { cursor: grabbing; }

/* ---------- onion-skin settings popover ---------- */
/* Anchored bottom-right of the canvas area, right above the framebar's
   Onion… button that opens it. */
#onion-panel {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(31, 31, 40, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 6;
}

#onion-panel[hidden] { display: none; }

.onion-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-dim);
}

.onion-row input[type="range"] { width: 100%; }

#onion-colors {
  display: flex;
  gap: 14px;
  color: var(--text-dim);
}

#onion-colors label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#onion-colors input[type="color"] {
  width: 34px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

/* ---------- frame strip ---------- */
#framebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--panel);
  border-top: 1px solid var(--panel-edge);
}

#frames {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  padding: 3px;
}

.frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  /* mini transparency checker behind each thumbnail */
  background: repeating-conic-gradient(#4a4a52 0% 25%, #5a5a63 0% 50%) 0 0 / 12px 12px;
  border: 1px solid var(--panel-edge);
  padding: 0;
}

.frame canvas { image-rendering: pixelated; }

.frame.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The frame the player is currently showing — gold, so it can't be confused
   with the blue "being edited" outline while the loop runs. */
.frame.playing {
  outline: 2px solid #ffc83c;
  outline-offset: 1px;
}

.frame span {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 10px;
  color: var(--text);
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
}

/* Transport controls (playback lives in the main canvas). */
#framebar .fps {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}

#framebar .fps input { width: 46px; }

/* ---------- status bar ---------- */
#statusbar {
  display: flex;
  gap: 24px;
  padding: 5px 14px;
  background: var(--panel);
  border-top: 1px solid var(--panel-edge);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

#st-coords { min-width: 70px; }
#st-hint { margin-left: auto; }
