/* ═══════════════════════════════════════════════════════════════════════
   Dynamo.sh — dark studio chrome around warm paper artefacts.
   ═══════════════════════════════════════════════════════════════════════ */
@font-face {
  font-family: 'Caveat';
  src: url('/assets/fonts/Caveat-700.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg:        #0b0c0f;
  --bg-raised: #121419;
  --bg-input:  #0e1015;
  --panel:     #14171d;
  --line:      rgba(255,255,255,.075);
  --line-str:  rgba(255,255,255,.14);

  --text:      #e9eaee;
  --text-dim:  #9ba1ad;
  --text-mute: #6b7280;

  --accent:    #e5644d;
  --accent-dim:#c04a36;
  --paper:     #f7f5ef;

  --ok:   #3fbf7f;
  --warn: #e0a33e;
  --err:  #ef5a5a;
  --info: #5b8def;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.34);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

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

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 600px at 82% -12%, rgba(229,100,77,.10), transparent 62%),
    radial-gradient(900px 520px at 5% 0%, rgba(91,141,239,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
}

/* ─────────────────────────── top bar ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,12,15,.78);
  backdrop-filter: blur(14px) saturate(140%);
}

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

.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--paper), #ded9cc);
  color: #1b1b1b;
  font-family: 'Caveat', 'Bradley Hand', cursive;
  font-size: 27px; font-weight: 700; line-height: 1;
  padding-bottom: 4px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.10), var(--shadow);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-mute); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-raised);
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap;
}
.pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-mute);
}
.pill.ok::before  { background: var(--ok);  box-shadow: 0 0 8px rgba(63,191,127,.55); }
.pill.bad::before { background: var(--err); box-shadow: 0 0 8px rgba(239,90,90,.55); }

/* ─────────────────────────── layout ─────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 26px 44px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, var(--panel), #111319);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.composer { padding: 20px; position: sticky; top: 84px; }
@media (max-width: 1080px) { .composer { position: static; } }

.panel-title {
  font-size: 12px; font-weight: 650; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-mute);
  margin-bottom: 14px;
}

.workspace { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ─────────────────────────── form ─────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.label { font-size: 12px; font-weight: 600; color: var(--text-dim); display: flex; justify-content: space-between; }
.label b { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 650; }
.hint { font-size: 11.5px; color: var(--text-mute); }

textarea, input[type=text], input[type=password], input[type=email],
input[type=number], input[type=search], input[type=date], select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-input);
  border: 1px solid var(--line-str);
  border-radius: var(--r);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
textarea { resize: vertical; min-height: 96px; }

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229,100,77,.16);
  background: #101318;
}
textarea::placeholder { color: #565c68; }

/* Chrome paints its own pale yellow over a filled field, which on a dark page
   is a white box with invisible text in it. There is no way to override the
   background directly; a very long inset shadow is the way through. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
  caret-color: var(--text);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5 10 4.5' stroke='%239ba1ad' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 34px;
}

input[type=color] {
  width: 100%; height: 40px; padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--line-str);
  border-radius: var(--r);
  cursor: pointer;
}

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 25%), rgba(255,255,255,.12) var(--pct, 25%));
  cursor: pointer; margin: 9px 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}

.row { display: block; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.advanced {
  border-top: 1px solid var(--line);
  padding-top: 13px; margin-bottom: 16px;
}
.advanced summary {
  cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--text-dim); list-style: none; user-select: none;
  padding-bottom: 12px;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: '▸ '; color: var(--text-mute); }
.advanced[open] summary::before { content: '▾ '; }

/* ─────────────────────────── dropzone ─────────────────────────── */
.dropzone {
  display: flex; align-items: center; gap: 13px;
  padding: 15px;
  border: 1.5px dashed var(--line-str);
  border-radius: var(--r);
  background: rgba(255,255,255,.014);
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(229,100,77,.06);
}
.dropzone div { display: flex; flex-direction: column; min-width: 0; }
.dropzone strong { font-size: 13px; }
.dropzone span { font-size: 11.5px; color: var(--text-mute); }
.dropzone .icon { flex: none; color: var(--text-mute); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  margin-left: auto; padding: 4px 6px 4px 11px;
  background: rgba(229,100,77,.14);
  border: 1px solid rgba(229,100,77,.34);
  border-radius: 999px;
  font-size: 11.5px; color: #f0a595;
  max-width: 46%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 3px;
}

/* ─────────────────────────── buttons ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 6px 18px rgba(229,100,77,.24);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn-secondary {
  background: var(--bg-raised); color: var(--text); border-color: var(--line-str);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--text-mute); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-str); background: var(--bg-raised); }

.btn-lg { width: 100%; padding: 13px; font-size: 14px; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-danger { background: rgba(239,90,90,.13); color: #ef8080; border-color: rgba(239,90,90,.3); }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon.lg { width: 24px; height: 24px; }
.icon.xl { width: 40px; height: 40px; stroke-width: 1.2; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.28);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────── jobs ─────────────────────────── */
.jobs { padding: 18px 20px 20px; }
.jobs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.jobs-head .panel-title { margin: 0; }

.job-list { display: flex; flex-direction: column; gap: 9px; }

.job {
  display: grid;
  grid-template-columns: 74px minmax(0,1fr) auto;
  gap: 14px; align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255,255,255,.017);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.job:hover { border-color: var(--line-str); background: rgba(255,255,255,.035); }
.job.active { border-color: var(--accent); background: rgba(229,100,77,.07); }

.job-thumb {
  width: 74px; height: 42px; border-radius: 6px;
  background: #1b1e25 center/cover no-repeat;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--text-mute); font-size: 10px;
  overflow: hidden; flex: none;
}

.job-main { min-width: 0; }
.job-title {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job-meta { font-size: 11.5px; color: var(--text-mute); display: flex; gap: 9px; flex-wrap: wrap; }

.bar { height: 3px; border-radius: 3px; background: rgba(255,255,255,.09); overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f0a595); transition: width .35s ease; }

.status {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.status.done      { background: rgba(63,191,127,.14);  color: var(--ok); }
.status.failed    { background: rgba(239,90,90,.14);   color: var(--err); }
.status.cancelled { background: rgba(255,255,255,.07); color: var(--text-mute); }
.status.running   { background: rgba(91,141,239,.14);  color: var(--info); }
.status.queued    { background: rgba(224,163,62,.14);  color: var(--warn); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 46px 20px; text-align: center; color: var(--text-mute);
}
.empty strong { color: var(--text-dim); font-size: 14px; }
.empty span { font-size: 12.5px; max-width: 320px; }
.empty .icon { color: #2f3540; margin-bottom: 4px; }

/* ─────────────────────────── detail ─────────────────────────── */
.detail { padding: 20px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.detail-title { font-size: 19px; font-weight: 680; letter-spacing: -.015em; line-height: 1.3; }
.detail-sub { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.detail-actions { display: flex; gap: 8px; flex: none; }

.player {
  width: 100%; aspect-ratio: 16/9;
  background: #000; border-radius: var(--r);
  border: 1px solid var(--line); overflow: hidden; display: block;
}

.progress-card {
  padding: 18px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg-input);
}
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; }
.progress-stage { font-size: 13px; color: var(--text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-pct { font-size: 21px; font-weight: 680; font-variant-numeric: tabular-nums; }
.bar.tall { height: 7px; margin-top: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 9px; margin-top: 15px; }
.stat { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(255,255,255,.028); border: 1px solid var(--line); }
.stat b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }

.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin-top: 15px; scrollbar-width: thin; }
.strip img {
  height: 82px; border-radius: 7px; border: 1px solid var(--line);
  flex: none; background: var(--paper); cursor: zoom-in;
}

.log {
  margin-top: 15px; padding: 12px 14px;
  background: #08090c; border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  max-height: 230px; overflow-y: auto;
}
.log div { display: flex; gap: 9px; }
.log time { color: #4a5160; flex: none; }
.log .warn  { color: var(--warn); }
.log .error { color: var(--err); }
.log .info  { color: #97a0b0; }

.error {
  padding: 11px 13px; border-radius: var(--r);
  background: rgba(239,90,90,.10); border: 1px solid rgba(239,90,90,.28);
  color: #f79999; font-size: 12.5px; margin-top: 12px;
  white-space: pre-wrap; word-break: break-word;
}
.warn-box {
  padding: 10px 13px; border-radius: var(--r);
  background: rgba(224,163,62,.09); border: 1px solid rgba(224,163,62,.26);
  color: #e2bd7c; font-size: 12px; margin-top: 12px;
}

/* ─────────────────────────── modal ─────────────────────────── */
.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5,6,8,.72);
  backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-str);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 70px rgba(0,0,0,.62);
}
.modal-head {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--line);
  background: var(--panel); z-index: 1;
}
.modal-head h2 { font-size: 15.5px; font-weight: 650; }
.modal-body { padding: 20px; }

.section-title {
  font-size: 11.5px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-mute); margin: 22px 0 5px;
}
.section-title:first-child { margin-top: 0; }
.section-note { font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; font-family: var(--mono); font-size: 12.5px; }
.key-state { font-weight: 500; color: var(--text-mute); font-family: var(--mono); font-size: 11px; }

.modal-actions { display: flex; gap: 9px; margin-top: 16px; }

.test-result { margin-top: 12px; padding: 11px 13px; border-radius: var(--r); font-size: 12.5px; }
.test-result.ok  { background: rgba(63,191,127,.10); border: 1px solid rgba(63,191,127,.28); color: #7ad6a6; }
.test-result.bad { background: rgba(239,90,90,.10);  border: 1px solid rgba(239,90,90,.28);  color: #f79999; }

.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 9px; }
.sys {
  padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(255,255,255,.02);
}
.sys b { display: block; font-size: 12px; margin-bottom: 3px; }
.sys span { font-size: 11px; color: var(--text-mute); word-break: break-all; }
.sys.ok b::before  { content: '● '; color: var(--ok); }
.sys.bad b::before { content: '● '; color: var(--err); }

.mono { font-family: var(--mono); font-size: .93em; color: var(--text-dim); }
.hidden { display: none !important; }

/* ─────────────────────────── toasts ─────────────────────────── */
.toasts {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  display: flex; flex-direction: column-reverse; gap: 9px;
}
.toast {
  min-width: 250px; max-width: 380px;
  padding: 12px 15px; border-radius: var(--r);
  background: var(--bg-raised); border: 1px solid var(--line-str);
  box-shadow: var(--shadow); font-size: 13px;
  animation: rise .22s ease;
}
.toast.ok  { border-left: 3px solid var(--ok); }
.toast.bad { border-left: 3px solid var(--err); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ═══════════════════════ tabs ═══════════════════════ */
.modal.wide { width: min(760px, 100%); }

.tabs {
  position: sticky; top: 57px; z-index: 1;
  display: flex; gap: 2px; padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 11px 14px 10px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-mute); font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══════════════════════ switch ═══════════════════════ */
.switch {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; margin-bottom: 15px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255,255,255,.017);
  cursor: pointer; user-select: none;
}
.switch.compact { padding: 9px 12px; margin: 12px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  flex: none; width: 38px; height: 22px; border-radius: 999px;
  background: rgba(255,255,255,.13); position: relative;
  transition: background .16s;
}
.switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .16s;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(16px); }
.switch input:disabled + .switch-track { opacity: .4; }

.switch-text { display: flex; flex-direction: column; min-width: 0; }
.switch-text strong { font-size: 13px; }
.switch-text span { font-size: 11.5px; color: var(--text-mute); }

/* ═══════════════════════ asset grid ═══════════════════════ */
.asset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 11px; margin-top: 14px;
}
.asset {
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255,255,255,.02); overflow: hidden;
}
.asset.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(229,100,77,.18); }

.asset-canvas {
  position: relative; height: 132px;
  background:
    linear-gradient(45deg, #1a1d23 25%, transparent 25%, transparent 75%, #1a1d23 75%),
    linear-gradient(45deg, #1a1d23 25%, #15181d 25%, #15181d 75%, #1a1d23 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
  display: grid; place-items: center; cursor: crosshair; overflow: hidden;
}
.asset-canvas img { max-width: 100%; max-height: 100%; display: block; }
.asset-canvas.plain { cursor: default; background: #15181d; }

.tip-marker {
  position: absolute; width: 18px; height: 18px;
  margin: -9px 0 0 -9px; pointer-events: none;
}
.tip-marker::before, .tip-marker::after {
  content: ''; position: absolute; background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,.55);
}
.tip-marker::before { left: 8px; top: 0; width: 2px; height: 18px; }
.tip-marker::after  { top: 8px; left: 0; height: 2px; width: 18px; }

.asset-body { padding: 9px 11px; }
.asset-name {
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.asset-meta { font-size: 11px; color: var(--text-mute); }
.asset-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.asset-actions .btn { padding: 4px 9px; font-size: 11.5px; }
.asset input[type=range] { margin: 8px 0 2px; }

.test-preview { margin-top: 11px; }
.test-preview img {
  max-width: 100%; max-height: 220px; border-radius: var(--r);
  border: 1px solid var(--line);
}

.code {
  margin-top: 14px; padding: 14px;
  background: #08090c; border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: #9fb0c4; max-height: 52vh; overflow: auto; white-space: pre;
}


/* ═══════════════════════ screen formats ═══════════════════════ */
.formats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.fmt {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line-str); border-radius: var(--r-sm);
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.fmt:hover { border-color: var(--text-mute); }
.fmt.active {
  border-color: var(--accent);
  background: rgba(229,100,77,.09);
  box-shadow: 0 0 0 2px rgba(229,100,77,.14);
}

/* the swatch is drawn at the format's true proportions inside a fixed box */
.fmt-swatch {
  width: 100%; height: 30px;
  display: grid; place-items: center;
}
.fmt-swatch i {
  display: block;
  border: 1.6px solid var(--text-mute);
  border-radius: 2px;
  background: rgba(255,255,255,.05);
}
.fmt.active .fmt-swatch i { border-color: var(--accent); background: rgba(229,100,77,.16); }

.fmt-label {
  font-size: 10px; font-weight: 650; color: var(--text-mute);
  letter-spacing: .02em; text-align: center; line-height: 1.2;
}
.fmt.active .fmt-label { color: var(--text); }

/* ═══════════════════════ style picker ═══════════════════════ */
.style-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px;
}
.style-chip {
  display: flex; flex-direction: column; gap: 6px;
  padding: 7px; border-radius: var(--r-sm);
  border: 1px solid var(--line-str); background: var(--bg-input);
  cursor: pointer; text-align: left;
  transition: border-color .14s, box-shadow .14s;
}
.style-chip:hover { border-color: var(--text-mute); }
.style-chip.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(229,100,77,.16); }

/* a miniature of the actual board: paper colour with three ink strokes */
.style-swatch {
  height: 30px; border-radius: 4px; position: relative; overflow: hidden;
  border: 1px solid rgba(0,0,0,.25);
}
.style-swatch i {
  position: absolute; height: 2.5px; border-radius: 2px; left: 12%;
}
.style-swatch i:nth-child(1) { top: 22%; width: 58%; }
.style-swatch i:nth-child(2) { top: 47%; width: 40%; }
.style-swatch i:nth-child(3) { top: 70%; width: 68%; }

.style-name {
  font-size: 10.5px; font-weight: 600; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.style-chip.active .style-name { color: var(--text); }

/* ═══════════════════════ left pane ═══════════════════════ */
/* The composer is taller than most viewports. Give it its own scroll so the
   page does not have to move for the panel to be reachable. */
.left-pane {
  position: sticky; top: 84px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 4px;
}
.left-pane::-webkit-scrollbar { width: 8px; }
.left-pane::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12); border-radius: 4px;
}
.left-pane::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

@media (max-width: 1080px) {
  .left-pane { position: static; max-height: none; overflow: visible; }
}
.composer { position: static; }

.pane-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; border-radius: var(--r);
  background: var(--bg-raised); border: 1px solid var(--line);
}
.pane-tab {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 10px; border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--text-mute);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .14s, color .14s;
}
.pane-tab:hover { color: var(--text-dim); }
.pane-tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* ═══════════════════════ chat ═══════════════════════ */
.chat-pane { display: flex; flex-direction: column; padding: 16px 18px 18px; max-height: calc(100vh - 130px); }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.chat-log {
  flex: 1; min-height: 180px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 2px 10px;
}
.chat-empty { color: var(--text-mute); font-size: 12.5px; padding: 20px 4px; text-align: center; }

.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.55; }
.msg.user {
  align-self: flex-end; background: rgba(229,100,77,.14);
  border: 1px solid rgba(229,100,77,.3); color: #f3c8bd;
}
.msg.assistant {
  align-self: flex-start; background: rgba(255,255,255,.04);
  border: 1px solid var(--line-str); color: var(--text-dim);
}
.msg.assistant.error { background: rgba(239,90,90,.10); border-color: rgba(239,90,90,.3); color: #f79999; }
.msg img { max-width: 100%; border-radius: 7px; margin-top: 6px; display: block; }

.msg-ops { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; }
.msg-ops span { font-size: 11px; font-family: var(--mono); }
.msg-ops .ok  { color: #7ad6a6; }
.msg-ops .bad { color: #e08a8a; }

.chat-composer { border-top: 1px solid var(--line); padding-top: 12px; }
.chat-composer textarea { min-height: 62px; }
.chat-actions { display: flex; gap: 7px; margin: 8px 0 7px; align-items: center; }
.chat-scene {
  flex: 1; padding: 6px 9px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--line-str);
  border-radius: var(--r-sm); color: var(--text);
}
.chat-composer.drag { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: var(--r); }

/* ═══════════════════════ editor ═══════════════════════ */
.editor { overflow: hidden; }
.editor .tabs { position: static; padding: 0 16px; align-items: center; }
.editor-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.editor-body { padding: 16px 18px 18px; max-height: 70vh; overflow-y: auto; }

/* --- scenes --- */
.scene-list { display: flex; flex-direction: column; gap: 9px; }

.scene-card { border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,.017); }
.scene-card.open { border-color: var(--line-str); background: rgba(255,255,255,.033); }

.scene-head {
  display: grid; grid-template-columns: 92px minmax(0,1fr) auto;
  gap: 13px; align-items: center; padding: 10px 12px; cursor: pointer;
}
.scene-head img {
  width: 92px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--paper); display: block;
}
.scene-title { font-size: 13.5px; font-weight: 600; }
.scene-sub { font-size: 11.5px; color: var(--text-mute); }
.scene-badge {
  font-size: 10.5px; font-family: var(--mono); color: var(--text-mute);
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.05);
}

.scene-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.scene-body .field { margin: 12px 0 10px; }

.el-row {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto;
  gap: 10px; align-items: center;
  padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255,255,255,.02);
}
.el-row.selected { border-color: var(--accent); }
.el-kind {
  font-size: 10px; font-family: var(--mono); text-transform: uppercase;
  color: var(--text-mute); width: 62px; letter-spacing: .04em;
}
.el-row input[type=text] { padding: 6px 9px; font-size: 12.5px; }
.el-toggle { background: none; border: none; color: var(--text-mute); cursor: pointer; font-size: 15px; padding: 0 4px; }

.el-detail {
  grid-column: 1 / -1; margin-top: 8px; padding-top: 10px;
  border-top: 1px dashed var(--line-str);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px;
}
.el-field { display: flex; flex-direction: column; gap: 3px; }
.el-field label { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.el-field input, .el-field select {
  padding: 5px 7px; font-size: 12px; font-family: var(--mono);
  background: var(--bg-input); border: 1px solid var(--line-str);
  border-radius: 5px; color: var(--text); width: 100%;
}
.el-actions { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 4px; }

/* --- timeline --- */
.scrubber { margin-bottom: 16px; }
.scrub-frame {
  width: 100%; max-height: 340px; object-fit: contain;
  border-radius: var(--r); border: 1px solid var(--line);
  background: #0c0d10; display: block;
}
.scrub-controls { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.scrub-controls input { flex: 1; }
.scrub-controls span { font-size: 12px; color: var(--text-dim); min-width: 92px; text-align: right; }

.track-list { display: flex; flex-direction: column; gap: 7px; }
.track {
  display: grid; grid-template-columns: 108px minmax(0,1fr); gap: 10px; align-items: center;
}
.track-name { font-size: 11.5px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-lane {
  position: relative; height: 30px; border-radius: 6px;
  background: rgba(255,255,255,.035); border: 1px solid var(--line);
  overflow: hidden;
}
.track-scene { position: absolute; top: 0; bottom: 0; background: rgba(255,255,255,.03); border-left: 1px solid var(--line-str); }
.bar {
  position: absolute; top: 5px; height: 20px; border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  cursor: grab; display: flex; align-items: center; padding: 0 6px;
  font-size: 10px; color: #fff; white-space: nowrap; overflow: hidden;
  border: 1px solid rgba(0,0,0,.3);
}
.bar.svg    { background: linear-gradient(180deg, #4f8ef7, #2f6feb); }
.bar.shape  { background: linear-gradient(180deg, #6b7280, #4b5563); }
.bar.image  { background: linear-gradient(180deg, #3fbf7f, #2f9c66); }
.bar.arrow  { background: linear-gradient(180deg, #a78bfa, #7c5cf0); }
.bar.locked { outline: 1px dashed rgba(255,255,255,.55); outline-offset: -3px; }
.bar:active { cursor: grabbing; }
.bar .grip { position: absolute; right: 0; top: 0; bottom: 0; width: 7px; cursor: ew-resize; background: rgba(255,255,255,.28); }

.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; box-shadow: 0 0 5px rgba(0,0,0,.6); }

.sound-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

/* ═══════════════════════ recorder ═══════════════════════ */
.recorder { display: flex; flex-direction: column; gap: 12px; }
.recorder-stage {
  position: relative; width: 260px; height: 260px;
  border-radius: var(--r); overflow: hidden;
  background: #0a0b0e; border: 1px solid var(--line);
  display: grid; place-items: center;
}
.cam-preview { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-shape {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(10,11,14,.82);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
}
.cam-shape.rounded { border-radius: 14%; }
.cam-shape.square  { border-radius: 0; }

.rec-dot {
  position: absolute; top: 10px; left: 10px;
  width: 10px; height: 10px; border-radius: 50%; background: #ef4444;
  box-shadow: 0 0 10px rgba(239,68,68,.85);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
.rec-time {
  position: absolute; top: 8px; right: 10px;
  font-family: var(--mono); font-size: 12px; color: #fff;
  background: rgba(0,0,0,.55); padding: 2px 7px; border-radius: 5px;
}
.recorder-controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════ site nav ═══════════════════════ */
a.brand-mark { text-decoration: none; }

.mainnav { display: flex; gap: 3px; margin-left: 22px; }
.mainnav a {
  padding: 7px 13px; border-radius: var(--r-sm);
  color: var(--text-mute); text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: color .14s, background .14s;
}
.mainnav a:hover { color: var(--text); background: var(--bg-raised); }
.mainnav a.current { color: var(--text); background: var(--bg-raised); }
@media (max-width: 720px) { .mainnav { display: none; } }

/* ═══════════════════════ narration source ═══════════════════════ */
.voice-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.voice-opt {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 11px; text-align: left;
  border: 1px solid var(--line-str); border-radius: var(--r-sm);
  background: var(--bg-input); color: var(--text-dim);
  font: inherit; cursor: pointer;
  transition: border-color .14s, background .14s;
}
.voice-opt:hover { border-color: var(--text-mute); }
.voice-opt.active {
  border-color: var(--accent); background: rgba(229,100,77,.08);
  box-shadow: 0 0 0 2px rgba(229,100,77,.14);
}
.voice-opt .vicon { font-size: 16px; }
.voice-opt b { font-size: 12.5px; color: var(--text); font-weight: 620; }
.voice-opt span:not(.vicon) { font-size: 10.5px; color: var(--text-mute); line-height: 1.35; }

.sub-panel {
  margin: -6px 0 15px; padding: 13px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255,255,255,.017);
}
.sub-panel .recorder-stage { width: 190px; height: 190px; }
.sub-panel .field:last-child { margin-bottom: 0; }

/* ═══════════════════════ voice browser ═══════════════════════ */
.voice-search { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; }
.voice-search input, .voice-search select { padding: 8px 11px; font-size: 13px; }
.voice-filters { display: flex; gap: 16px; margin: 9px 0 8px; }

.voice-results {
  max-height: 250px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-input);
  display: flex; flex-direction: column;
}
.voice-item {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto;
  gap: 10px; align-items: center;
  padding: 9px 11px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .12s;
}
.voice-item:last-child { border-bottom: none; }
.voice-item:hover { background: rgba(255,255,255,.035); }
.voice-item.selected { background: rgba(229,100,77,.12); box-shadow: inset 2px 0 0 var(--accent); }

.voice-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.voice-name small {
  font-weight: 500; font-size: 10px; color: var(--text-mute);
  border: 1px solid var(--line-str); border-radius: 3px; padding: 1px 5px;
}
.voice-name small.lic { color: #7ad6a6; border-color: rgba(63,191,127,.4); }
.voice-desc {
  font-size: 11px; color: var(--text-mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voice-uses { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.voice-play {
  background: none; border: 1px solid var(--line-str); border-radius: 50%;
  width: 26px; height: 26px; color: var(--text-dim); cursor: pointer;
  display: grid; place-items: center; font-size: 10px;
}
.voice-play:hover { color: var(--text); border-color: var(--accent); }
.voice-empty { padding: 22px; text-align: center; color: var(--text-mute); font-size: 12.5px; }
