/* MemeForge — forge-console UI
   Palette is graphite + ember; type is Archivo (UI), Anton (wordmark), IBM Plex Mono (readouts).
   Fonts are bundled in /vendor/fonts so the app looks right offline. */

@font-face {
  font-family: 'Archivo';
  src: url('../vendor/fonts/archivo-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Anton';
  src: url('../vendor/fonts/anton-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('../vendor/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('../vendor/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
/* Impact is the mother tongue of memes but ships with Windows and macOS only.
   Real Impact wins where it exists; everywhere else Anton stands in. */
@font-face {
  font-family: 'Impact';
  src: local('Impact'), local('Haettenschweiler'),
       url('../vendor/fonts/anton-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #0e0f12;
  --panel: #14161d;
  --panel-2: #1a1d26;
  --panel-3: #212533;
  --edge: #272c38;
  --edge-soft: #1e222c;
  --text: #e9ebf2;
  --muted: #949cb0;
  --faint: #6a7286;
  --ember: #ff5a1f;
  --ember-dim: #c9430f;
  --spark: #ffc542;
  --danger: #ff4d4d;
  --ok: #35d07f;

  --rail-w: 74px;
  --drawer-w: 322px;
  --inspector-w: 302px;
  --top-h: 54px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --font-ui: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Anton', Impact, 'Haettenschweiler', sans-serif;
  --font-mono: 'Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --tick: color-mix(in srgb, var(--edge) 70%, transparent);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --ink: #e6e8ee;
  --panel: #f7f8fa;
  --panel-2: #eef0f5;
  --panel-3: #e4e7ee;
  --edge: #cdd2dd;
  --edge-soft: #dfe3ea;
  --text: #171a22;
  --muted: #5c6478;
  --faint: #838b9d;
  --ember: #e2450c;
  --ember-dim: #b8380a;
  --spark: #b57e00;
  --shadow: 0 10px 26px rgba(20, 24, 35, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Display rules below would otherwise beat the attribute. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: .02em; }

h1, h2, h3 { margin: 0; font-weight: 600; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
  border-radius: 3px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel-3);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--edge); background-clip: content-box; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--ember);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r-sm);
}
.skip-link:focus { left: 8px; }

/* ---------- top bar ---------- */

.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(150deg, var(--ember) 0%, var(--ember-dim) 100%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ember) 45%, transparent), 0 6px 14px -6px var(--ember);
}

.wordmark {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: .015em;
  text-transform: uppercase;
  line-height: 1;
  padding-top: 2px;
}

.project-name { flex: 1; min-width: 0; }

.project-name input[type='text'] {
  width: min(320px, 100%);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 5px 9px;
  color: var(--muted);
}
.project-name input[type='text']:hover { border-color: var(--edge); }
.project-name input[type='text']:focus { border-color: var(--edge); background: var(--panel-2); color: var(--text); outline: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-group { display: flex; gap: 2px; background: var(--panel-2); border-radius: var(--r-sm); padding: 2px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 30px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.icon-btn:disabled { opacity: .32; cursor: default; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(160deg, var(--ember) 0%, var(--ember-dim) 100%);
  border-color: color-mix(in srgb, var(--ember) 60%, transparent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(160deg, color-mix(in srgb, var(--ember) 88%, #fff) 0%, var(--ember) 100%);
  box-shadow: 0 6px 20px -8px var(--ember);
}

.btn-quiet { background: transparent; }
.btn-quiet:hover { background: var(--panel-2); }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--edge)); }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--edge);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--muted);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ember);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- menu ---------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 246px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: 40;
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

.menu-label {
  margin: 6px 0 4px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { background: var(--panel-3); }
.menu-item em { font-style: normal; font-size: 11px; color: var(--faint); font-family: var(--font-mono); }
.menu-item[disabled] { opacity: .4; cursor: default; }
.menu-item[disabled]:hover { background: transparent; }

.seg { display: flex; gap: 4px; padding: 2px 6px 6px; }
.seg-btn {
  flex: 1;
  height: 27px;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
}
.seg-btn.is-on { background: var(--panel-3); color: var(--text); border-color: var(--ember); }

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: var(--rail-w) var(--drawer-w) minmax(0, 1fr) var(--inspector-w);
  height: calc(100% - var(--top-h));
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  background: var(--panel);
  border-right: 1px solid var(--edge);
  overflow-y: auto;
}

.rail-btn {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 9px 2px 7px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: background .12s, color .12s;
}
.rail-btn span {
  font-size: 10px;
  letter-spacing: .01em;
}
.rail-btn:hover { background: var(--panel-2); color: var(--text); }
.rail-btn.is-on { color: var(--text); background: var(--panel-2); }
.rail-btn.is-on::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--ember);
}

.drawer {
  background: var(--panel);
  border-right: 1px solid var(--edge);
  overflow: hidden;
  position: relative;
}

.panel {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 14px 12px 16px;
  overflow-y: auto;
  gap: 10px;
}
.panel.is-on { display: flex; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--text);
}

.sub-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--faint);
}

.count { color: var(--faint); }

.panel-hint, .panel-note {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.5;
}
.panel-note:empty { display: none; }
.panel-note.is-warn { color: var(--spark); }

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 34px;
  background: var(--panel-2);
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-sm);
}
.search-row:focus-within { border-color: var(--ember); }
.search-icon { color: var(--faint); flex: none; }
.search-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
}
.search-row input::placeholder { color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  padding: 4px 10px;
  border: 1px solid var(--edge-soft);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { background: var(--panel-2); color: var(--text); }
.chip.is-on { background: color-mix(in srgb, var(--ember) 16%, transparent); border-color: var(--ember); color: var(--text); }

.drop-zone {
  display: grid;
  gap: 2px;
  place-items: center;
  padding: 14px 10px;
  border: 1px dashed var(--edge);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.drop-zone strong { font-size: 13px; color: var(--text); font-weight: 500; }
.drop-zone:hover, .drop-zone.is-hot { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 8%, transparent); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--panel-2);
  cursor: pointer;
  padding: 0;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.tile:hover img { transform: scale(1.05); }
.tile:hover { border-color: var(--ember); }
.tile.is-on { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember); }
.tile figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 7px 5px;
  font-size: 10.5px;
  line-height: 1.25;
  text-align: left;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile .badge {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .7);
  color: var(--spark);
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
}

.feed { display: grid; gap: 8px; }

.post {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-md);
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.post:hover { border-color: var(--ember); }
.post img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); background: var(--panel-3); }
.post-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.post-title {
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-meta { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }

.stack { display: grid; gap: 7px; }
.stack-row { display: flex; flex-wrap: wrap; gap: 6px; }
.stack-row .btn { flex: 1; min-width: 92px; }

.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.preset {
  padding: 7px 4px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.preset:hover { border-color: var(--ember); color: var(--text); }
.preset.is-on { border-color: var(--ember); color: var(--text); background: color-mix(in srgb, var(--ember) 14%, var(--panel-2)); }

.font-list {
  display: grid;
  gap: 3px;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.font-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.font-row:hover { border-color: var(--ember); }
.font-row.is-on { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 12%, var(--panel-2)); }
.font-row span { font-size: 16px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-row em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  flex: none;
}

.upload-font { cursor: pointer; }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.sticker {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 20px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--panel-2);
  cursor: pointer;
}
.sticker:hover { border-color: var(--ember); background: var(--panel-3); }

.sliders { display: grid; gap: 9px; }

.field { display: grid; gap: 5px; }
.field > label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.field .row { display: flex; align-items: center; gap: 8px; }
.field .row input[type='range'] { flex: 1; }
.field output { min-width: 40px; text-align: right; color: var(--faint); }
.field .hint { font-size: 11px; color: var(--faint); }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  background: none;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--panel-3);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--edge);
}
input[type='range']:hover::-webkit-slider-thumb { background: var(--ember); }
input[type='range']::-moz-range-track { height: 3px; border-radius: 2px; background: var(--panel-3); }
input[type='range']::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid var(--ink); border-radius: 50%; background: var(--text); }

input[type='color'] {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
}
input[type='color']::-webkit-color-swatch-wrapper { padding: 2px; }
input[type='color']::-webkit-color-swatch { border: 0; border-radius: 3px; }

input[type='text'], textarea, select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  outline: none;
  resize: vertical;
}
input[type='text']:focus, textarea:focus, select:focus { border-color: var(--ember); }

.layer-list, .gallery-list { display: grid; gap: 5px; }

.layer {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  cursor: pointer;
}
.layer:hover { border-color: var(--edge); }
.layer.is-on { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 12%, var(--panel-2)); }
.layer-grip { color: var(--faint); cursor: grab; line-height: 1; }
.layer-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-kind { font-family: var(--font-mono); font-size: 9px; color: var(--faint); text-transform: uppercase; }
.layer-tools { display: flex; gap: 2px; }
.layer-tools button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  font-size: 12px;
}
.layer-tools button:hover { background: var(--panel-3); color: var(--text); }
.sortable-ghost { opacity: .35; }

.gallery-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-md);
  background: var(--panel-2);
}
.gallery-card img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--panel-3);
  cursor: pointer;
}
.gallery-meta { min-width: 0; }
.gallery-meta b { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-meta span { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }

.empty-note {
  padding: 18px 12px;
  border: 1px dashed var(--edge);
  border-radius: var(--r-md);
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- stage ---------- */

.stage-col {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--ember) 5%, transparent) 0%, transparent 60%),
    var(--ink);
  min-width: 0;
}

.stage {
  display: grid;
  place-items: center;
  padding: 26px;
  overflow: auto;
  background-image:
    linear-gradient(var(--tick) 1px, transparent 1px),
    linear-gradient(90deg, var(--tick) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: center;
}

.bench { position: relative; display: grid; place-items: center; }

.canvas-hold {
  position: relative;
  line-height: 0;
  box-shadow: var(--shadow);
  background:
    conic-gradient(from 90deg, #ffffff10 25%, #00000010 25% 50%, #ffffff10 50% 75%, #00000010 75%) 0 0 / 18px 18px;
}
.canvas-hold canvas { display: block; }
.canvas-hold.is-empty { display: none; }

/* registration marks: the bench is a print shop, these frame the work */
.marks { position: absolute; inset: -13px; pointer-events: none; }
.marks i {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1px solid var(--edge);
  opacity: .9;
}
.marks i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.marks i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.marks i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.marks i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.bench.is-empty .marks { display: none; }

.empty-state { text-align: center; max-width: 340px; padding: 30px 10px; }
.empty-state[hidden] { display: none; }
.empty-kicker {
  text-transform: uppercase;
  letter-spacing: .28em;
  color: var(--ember);
  margin: 0 0 10px;
}
.empty-state h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.02;
  text-transform: uppercase;
  letter-spacing: .01em;
  color: var(--text);
  margin-bottom: 12px;
}
.empty-sub { margin: 0; color: var(--faint); font-size: 13px; }

.readout {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 14px;
  border-top: 1px solid var(--edge);
  background: var(--panel);
  color: var(--faint);
  white-space: nowrap;
  overflow-x: auto;
}
.readout b { color: var(--text); font-weight: 500; }
.readout-item { display: inline-flex; align-items: center; gap: 5px; }
.readout-sep { width: 1px; height: 12px; background: var(--edge); flex: none; }
.readout-sep[hidden] { display: none; }
.readout-grow { flex: 1; }
.readout-src { color: var(--faint); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; }

.play-btn {
  width: 20px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 8px;
  cursor: pointer;
}
.play-btn:hover { border-color: var(--ember); }

/* ---------- inspector ---------- */

.inspector {
  background: var(--panel);
  border-left: 1px solid var(--edge);
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspector-body { display: flex; flex-direction: column; gap: 10px; }
.inspector-body[hidden], .inspector-empty[hidden] { display: none; }

.insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--edge-soft);
}
.insp-kind {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--ember);
}

.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--edge);
  cursor: pointer;
  padding: 0;
}
.swatch:hover { transform: scale(1.12); }

.toggle-row { display: flex; gap: 5px; flex-wrap: wrap; }
.toggle {
  flex: 1;
  min-width: 40px;
  height: 28px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.toggle:hover { color: var(--text); }
.toggle.is-on { border-color: var(--ember); color: var(--text); background: color-mix(in srgb, var(--ember) 14%, var(--panel-2)); }

/* ---------- toasts, dialog, progress ---------- */

.toasts {
  position: fixed;
  right: 14px;
  bottom: 44px;
  z-index: 60;
  display: grid;
  gap: 7px;
  justify-items: end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 340px;
  padding: 9px 13px;
  border: 1px solid var(--edge);
  border-left: 3px solid var(--ember);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  animation: slide-in .18s ease-out;
}
.toast.is-bad { border-left-color: var(--danger); }
.toast.is-good { border-left-color: var(--ok); }
.toast.is-out { opacity: 0; transform: translateX(12px); transition: opacity .2s, transform .2s; }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

.dialog {
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--text);
  padding: 20px;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--faint);
  margin-bottom: 14px;
}
.keys { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 7px; }
.keys li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }

.progress {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .55);
  z-index: 70;
}
.progress[hidden] { display: none; }
.progress-card {
  width: min(320px, 86vw);
  padding: 18px;
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.progress-card p { margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.bar { height: 4px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ember); transition: width .15s linear; }

.mobile-bar { display: none; }

/* ---------- easter egg: first switch to light mode ---------- */

.fb {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
}

.fb-throw {
  position: absolute;
  left: 50%;
  top: 50%;
  animation: fb-throw 860ms linear both;
}

.fb-hop {
  animation: fb-hop 900ms both;
}

.fb-nade {
  display: block;
  margin: -44px 0 0 -32px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45));
  animation: fb-spin 900ms cubic-bezier(.15, .7, .3, 1) both, fb-gone 1ms 940ms both;
}

@keyframes fb-throw {
  from { transform: translateX(-52vw); }
  to { transform: translateX(0); }
}

/* up, down, and a couple of tired bounces on the floor */
@keyframes fb-hop {
  0% { transform: translateY(46vh); animation-timing-function: cubic-bezier(.2, .55, .4, 1); }
  44% { transform: translateY(-20vh); animation-timing-function: cubic-bezier(.6, 0, .85, .5); }
  68% { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  80% { transform: translateY(-6vh); animation-timing-function: cubic-bezier(.6, 0, .85, .5); }
  90% { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  95% { transform: translateY(-1.5vh); }
  100% { transform: translateY(0); }
}

@keyframes fb-spin {
  from { rotate: -40deg; }
  to { rotate: 760deg; }
}

@keyframes fb-gone {
  to { opacity: 0; }
}

.fb-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #fff 42%, rgba(255, 255, 255, .5) 62%, transparent 72%);
  opacity: 0;
  animation: fb-burst 420ms 920ms ease-out both;
}

@keyframes fb-burst {
  0% { opacity: 1; transform: scale(.2); }
  100% { opacity: 0; transform: scale(46); }
}

.fb-white {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  opacity: 0;
  animation: fb-white 2900ms 940ms ease-out both;
}

@keyframes fb-white {
  0% { opacity: 0; }
  3% { opacity: 1; }
  34% { opacity: .97; }
  100% { opacity: 0; }
}

.fb-caption {
  margin: 0;
  color: #11131a;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .34em;
  opacity: 0;
  animation: fb-caption 2200ms 1500ms ease-out both;
}

@keyframes fb-caption {
  0% { opacity: 0; }
  18% { opacity: .55; }
  70% { opacity: .3; }
  100% { opacity: 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  :root { --drawer-w: 280px; --inspector-w: 264px; }
}

@media (max-width: 940px) {
  body { overflow: auto; }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 1fr) auto auto;
    height: auto;
  }

  .rail {
    order: 3;
    position: sticky;
    bottom: 0;
    flex-direction: row;
    justify-content: space-between;
    overflow-x: auto;
    border-right: 0;
    border-top: 1px solid var(--edge);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 25;
  }
  .rail-btn { flex: 1; min-width: 62px; }
  .rail-btn.is-on::before { left: 50%; top: auto; bottom: -6px; transform: translateX(-50%); width: 22px; height: 3px; border-radius: 3px 3px 0 0; }

  .drawer { order: 2; border-right: 0; border-top: 1px solid var(--edge); max-height: 58vh; }
  .stage-col { order: 1; min-height: 46vh; }
  .stage { padding: 16px; }

  .inspector {
    order: 2;
    border-left: 0;
    border-top: 1px solid var(--edge);
    max-height: 58vh;
  }
  .inspector:not(.is-open) { display: none; }
  .drawer.is-hidden { display: none; }

  .project-name { display: none; }
  .toasts { bottom: calc(74px + env(safe-area-inset-bottom)); left: 14px; justify-items: stretch; }
  .topbar { padding: 0 8px 0 10px; gap: 8px; }
  .wordmark { font-size: 18px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .sticker-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 560px) {
  #save-btn span, #export-btn span { display: none; }
  .btn { padding: 0 10px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .sticker-grid { grid-template-columns: repeat(6, 1fr); }
}

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

/* Workbench and GIF timeline */
.stage-col { grid-template-rows: auto minmax(0, 1fr) auto auto; min-height: 0; }
.work-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 7px 10px; border-bottom: 1px solid var(--edge); background: var(--panel); }
.work-tools .btn { height: 29px; font-size: 11px; padding: 0 8px; }
.work-tools .icon-btn { width: 27px; height: 27px; }
.snap-toggle { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
#save-state { margin-left: auto; color: var(--muted); }
.url-import { display: flex; gap: 6px; margin: 10px 0; }
.url-import input { min-width: 0; flex: 1; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 6px; padding: 8px; font-size: 11px; }
.favorite-btn { position: absolute; top: 4px; left: 4px; border: 0; border-radius: 6px; width: 28px; height: 28px; background: #000b; color: var(--spark); font-size: 19px; cursor: pointer; }
.chips { flex-wrap: wrap; }
#templates-more { margin-top: 12px; }
.timeline { padding: 9px 12px; background: var(--panel); border-top: 1px solid var(--edge); min-width: 0; max-height: 280px; overflow-y: auto; }
.timeline-head { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.timeline-head .seg { width: auto; }
.timeline-head .seg-btn { padding: 5px 12px; }
.timeline .panel-hint { margin: 6px 0; font-size: 11px; }
#timeline-info { margin-left: auto; color: var(--muted); }
#timeline-seek { width: 100%; }
.frame-strip { position: relative; display: flex; overflow-x: auto; gap: 5px; padding: 5px 0 8px; }
.frame-thumb { flex: 0 0 68px; border: 1px solid var(--edge); border-radius: 5px; padding: 2px; background: var(--panel-2); cursor: pointer; font: 10px var(--font-mono); }
.frame-thumb canvas { display: block; width: 64px; height: 42px; }
.frame-thumb.is-on { border-color: var(--ember); color: var(--ember); }
.timeline-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.timeline-controls label { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); }
.timeline-controls input { width: 62px; padding: 4px; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 4px; }
.timeline-controls .btn { font-size: 10px; height: 27px; padding: 0 7px; }
.context-menu { position: fixed; z-index: 120; width: 218px; max-height: calc(100dvh - 8px); overflow-y: auto; padding: 5px; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 9px; box-shadow: var(--shadow); }
.context-menu button { display: block; width: 100%; text-align: left; border: 0; padding: 8px 10px; border-radius: 5px; background: transparent; font-size: 12px; cursor: pointer; }
.context-menu button:hover, .context-menu button:focus-visible { background: var(--panel-3); color: var(--ember); }
.dialog { max-height: 85dvh; overflow-y: auto; }
#editor-dialog { width: min(440px, calc(100vw - 28px)); }
#editor-dialog h2 { margin-bottom: 14px; }
.dialog-field { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 10px; margin: 10px 0; font-size: 12px; }
.dialog-field input, #editor-dialog select, #rename-input { min-width: 0; width: 100%; padding: 8px; border: 1px solid var(--edge); background: var(--panel-2); border-radius: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.mobile-sheet-close { display: none; }
.stage.is-panning { cursor: grab; touch-action: none; }
.stage .canvas-hold::before, .stage .canvas-hold::after { content: ''; position: absolute; z-index: 5; pointer-events: none; background: var(--ember); display: none; }
.stage[data-guides*='x'] .canvas-hold::before { display: block; width: 1px; height: 100%; left: 50%; }
.stage[data-guides*='y'] .canvas-hold::after { display: block; height: 1px; width: 100%; top: 50%; }
@media (max-width: 940px) {
  .workspace { grid-template-rows: auto auto auto; }
  .stage-col { min-height: 60dvh; }
  .stage { min-height: 38dvh; }
  .timeline { max-height: none; }
  .inspector.is-open { display: block; position: fixed; bottom: 62px; left: 0; right: 0; z-index: 40; height: auto; max-height: 42dvh; overflow-y: auto; background: var(--panel); box-shadow: 0 -6px 28px #0005; border-radius: 14px 14px 0 0; }
  .mobile-sheet-close { display: block; margin: 8px 12px 0 auto; }
  .canvas-hold .upper-canvas { touch-action: none; }
  .canvas-hold .upper-canvas { --touch-target: 24px; }
  .topbar-actions { gap: 4px; }
  #project-menu-btn { padding: 0 7px; font-size: 11px; }
  #save-state { flex-basis: 100%; margin-left: 0; }
}
@media (max-width: 560px) {
  .topbar .brand-mark { display: none; }
  .wordmark { font-size: 16px; }
  .topbar .btn-group .icon-btn, #theme-btn, #shortcuts-btn { width: 27px; }
  .work-tools .btn { min-height: 32px; }
  .frame-thumb { min-height: 64px; }
}

.stage.is-cropping { cursor: crosshair; touch-action: none; }
.crop-guide { position: absolute; z-index: 20; border: 1px dashed var(--spark); background: #ffc54226; pointer-events: none; }

@media (max-width: 940px) { .stage { touch-action: none; } }

.field .row input[type='number'] { flex: 1; width: 65px; min-width: 0; padding: 6px; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 5px; }

/* Creative workbench: tracks are time-proportional and scroll on small screens. */
.advanced-tools { display:flex; flex-wrap:wrap; gap:4px; padding:5px 10px; border-bottom:1px solid var(--edge); }
.advanced-tools .btn { font-size:11px; padding:5px 8px; min-height:30px; }
.layer-tracks { max-height:180px; overflow:auto; padding:6px 0; }
.track-row { display:flex; min-width:600px; height:32px; gap:8px; margin:4px 0; }
.track-label { position:sticky; left:0; z-index:3; flex:0 0 130px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; text-align:left; background:var(--panel); }
.track-lane { position:relative; flex:1; background:rgba(128,128,128,.12); border-radius:4px; }
.track-bar { position:absolute; top:3px; bottom:3px; min-width:8px; background:#8b5cf6; border-radius:4px; display:flex; align-items:center; justify-content:space-between; cursor:grab; touch-action:none; color:#fff; }
.track-caption { overflow:hidden; white-space:nowrap; font-size:10px; pointer-events:none; padding:0 3px; }
.track-handle { flex:0 0 9px; height:100%; background:rgba(255,255,255,.25); cursor:ew-resize; border-radius:3px; }
.track-playhead { position:absolute; top:0; bottom:0; width:2px; background:#ff5a1f; pointer-events:none; z-index:2; }
.frame-thumb.is-selected { outline:2px solid #8b5cf6; outline-offset:-2px; }
.onion-overlay { position:absolute; left:0; top:0; pointer-events:none; z-index:5; }
.batch-tools label { display:flex; align-items:center; gap:5px; font-size:11px; }
.batch-tools input[type=range] { width:70px; }
.output-preview, .video-preview { display:block; max-width:100%; max-height:260px; margin:8px auto; object-fit:contain; }
.output-preview[hidden], .onion-overlay[hidden] { display:none; }
#editor-dialog-body progress { width:100%; accent-color:#ff5a1f; }
#editor-dialog { max-height:90dvh; overflow:auto; }
@media(max-width:940px) { .advanced-tools { gap:3px; padding:4px; } .layer-tracks { max-height:120px; } }

.stage-col { grid-template-rows:auto auto minmax(0,1fr) auto auto; }
.batch-tools { display:flex; flex-wrap:wrap; gap:5px; align-items:center; margin-top:7px; }
.batch-tools .btn { font-size:10px; min-height:27px; padding:3px 7px; }

@media(min-width:941px) { .timeline { max-height:420px; } }

.pose-columns { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.pose-column { min-width:0; }
.pose-column h3 { margin:4px 0 8px; }
.pose-column .dialog-field { display:block; }
.pose-column input { width:100%; box-sizing:border-box; }
.arrange-list { max-height:220px; overflow:auto; border:1px solid var(--edge); padding:8px; border-radius:6px; }
.arrange-list .dialog-field { display:flex; flex-direction:row-reverse; justify-content:flex-end; gap:8px; }
.creative-guides { position:absolute; top:0; left:0; pointer-events:none; z-index:6; }
.creative-guides[hidden], .creative-shelf[hidden] { display:none; }
.creative-shelf { position:fixed; right:12px; top:110px; bottom:45px; width:300px; z-index:30; padding:12px; overflow:auto; background:var(--panel); border:1px solid var(--edge); border-radius:10px; box-shadow:0 12px 40px #0008; }
.shelf-head, .shelf-actions { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.shelf-head { justify-content:space-between; }
.shelf-head h2 { font-size:17px; margin:0; }
#part-name { margin:10px 0; width:100%; }
.shelf-actions .btn { font-size:11px; padding:6px 8px; }
.part-list { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.part-card { border:1px solid var(--edge); padding:7px; border-radius:6px; cursor:grab; overflow:hidden; }
.part-card img { width:100%; height:90px; object-fit:contain; background:repeating-conic-gradient(#8882 0% 25%,transparent 0% 50%) 0 0/12px 12px; }
.part-card strong, .part-card small { display:block; margin:4px 0; overflow-wrap:anywhere; }
.version-list { max-height:200px; overflow:auto; }
.version-card { display:flex; gap:6px; align-items:center; flex-wrap:wrap; border-bottom:1px solid var(--edge); padding:8px 0; }
.version-card strong { flex:1; min-width:100px; }
.version-card small { color:var(--muted); font-size:10px; }
.version-compare { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.version-compare figure { margin:0; min-width:0; }
.version-compare img { width:100%; max-height:300px; object-fit:contain; }
.version-compare figcaption { font-weight:700; margin:8px 0; }
@media(max-width:940px) { .creative-shelf { top:auto; left:8px; right:8px; bottom:65px; width:auto; max-height:55dvh; } .pose-columns { gap:8px; } }

/* GIF discovery keeps provider results separate. */
.gif-search { display: flex; gap: 6px; margin: 12px 0; }
.gif-search input { min-width: 0; flex: 1; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 6px; padding: 8px; color: var(--text); }
.gif-search input:focus { outline: 1px solid var(--ember); }
#gif-settings { margin: 14px 0; }
#gif-settings summary { cursor: pointer; }
#gif-key-form { margin-top: 10px; }
#gif-key-form a, #gif-external { color: var(--ember); font-size: 12px; overflow-wrap: anywhere; }
.gif-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.gif-card { min-width: 0; overflow: hidden; padding: 0; text-align: left; border: 1px solid var(--edge); border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.gif-card img { display: block; width: 100%; height: 115px; object-fit: contain; background: #111; }
.gif-card span { display: block; padding: 6px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gif-card:hover { border-color: var(--ember); }
.gif-grid.is-loading { opacity: .5; pointer-events: none; }
