/* Storyloom · design language carried over from the InterSpace Distribution site.
   Warm paper surface, charcoal ink, Inter for reading and Geist Mono for labels, dark pill buttons,
   soft 24px cards, InterSpace red used sparingly. One easing family, motion under 260ms. */

:root {
  --paper: #fafaf7;
  --paper-2: #f3f2ec;
  --panel-a: #f1f0eb;
  --panel-b: #eae8e2;
  --panel-c: #eceae4;
  --ink: #2a2a27;
  --ink-2: #66645d;
  --muted: #8a8880;
  --muted-2: #b1aea5;
  --line: rgba(42, 42, 39, 0.08);
  --line-2: rgba(42, 42, 39, 0.12);
  --white: #ffffff;
  --accent: #de0a26;
  --accent-soft: rgba(222, 10, 38, 0.1);
  --live: #3aa676;
  --live-soft: rgba(58, 166, 118, 0.14);
  --live-ink: #23764f;
  --wait: #d69a2a;
  --wait-soft: rgba(214, 154, 42, 0.16);
  --wait-ink: #9a6a12;
  --violet: #7466e8;

  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --mono: var(--font-mono);

  --r-pill: 999px;
  --r-xl: 34px;
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 10px;

  --shadow-card: 0 0 0 1px rgba(42, 42, 39, 0.06), 0 4px 14px rgba(42, 42, 39, 0.08);
  --shadow-float: 0 1px 2px rgba(42, 42, 39, 0.05), 0 14px 36px rgba(42, 42, 39, 0.1), 0 40px 90px rgba(42, 42, 39, 0.1), 0 0 0 1px rgba(42, 42, 39, 0.06);
  --shadow-btn: 0 14px 30px rgba(42, 42, 39, 0.14), 0 2px 6px rgba(42, 42, 39, 0.08);
  --card-grad: linear-gradient(#f1f0eb 0%, #eae8e2 58%, #eceae4 100%);

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-quick: 140ms;
  --t-std: 260ms;
  --t-slow: 520ms;

  --container: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 .95  0 0 0 0 .93  0 0 0 0 .88  0 0 0 .9 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-display); font-size: 15px; line-height: 1.55; letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden;
}
::selection { background: rgba(222, 10, 38, 0.16); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, .display { text-wrap: balance; }
p, li { text-wrap: pretty; }
.mono, .est, .est b, .status, .num, .kv, .lbl b, .gcard .mono, .steps li, #yttxt { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.container { width: min(var(--container), 100% - var(--gutter) * 2); margin-inline: auto; }
.nav {
  position: sticky; top: 0; z-index: 50; height: 68px; display: flex; align-items: center;
  background: rgba(250, 250, 247, 0);
  transition: background-color var(--t-std) var(--ease), box-shadow var(--t-std) var(--ease);
}
.nav.is-stuck { background: rgba(250, 250, 247, 0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 1px 0 var(--line); }
.nav .container { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 28px; height: 28px; border-radius: 8px; outline: 1px solid rgba(0, 0, 0, 0.08); outline-offset: -1px; }
.brand span { font-family: var(--font-mono); font-size: 14px; letter-spacing: -0.01em; text-transform: lowercase; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  color: var(--ink-2); font-size: 14px; font-weight: 450; text-decoration: none;
  transition: color var(--t-quick) var(--ease), background-color var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease), transform var(--t-quick) var(--ease);
}
.nav-links a:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .nav-links a:hover { color: var(--ink); background: rgba(42, 42, 39, 0.05); } }
.nav-links a[aria-current='page'] { color: var(--ink); background: var(--white); box-shadow: var(--shadow-card); }
.nav-links em { font: 400 11px var(--font-mono); font-style: normal; color: var(--muted); }
.nav-links em:empty { display: none; }
.nav-right { display: flex; align-items: center; gap: 10px; }

main#main { width: min(var(--container), 100% - var(--gutter) * 2); margin: 0 auto; padding: clamp(24px, 5vw, 56px) 0 clamp(72px, 9vw, 112px); min-height: calc(100vh - 68px - 96px); }
.footer { border-top: 1px solid var(--line); padding: 26px 0 34px; }
.footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font: 400 12px var(--font-mono); color: var(--muted); letter-spacing: 0.02em; }
.footer a { color: var(--ink-2); text-underline-offset: 3px; }

/* ---------- type ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font: 400 12px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
main > .eyebrow { display: flex; justify-content: center; }
h1.display { font-size: clamp(38px, 6vw, 68px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 500; text-align: center; max-width: 18ch; margin: 0 auto 16px; }
h1.display em { font-style: normal; background: linear-gradient(transparent 55%, rgba(222, 10, 38, 0.18) 55%); padding: 0 0.06em; border-radius: 2px; }
.lede { text-align: center; color: var(--ink-2); font-size: clamp(15px, 1.6vw, 17px); max-width: 52ch; margin: 0 auto 30px; }
h2.sec { font-size: 19px; font-weight: 500; letter-spacing: -0.02em; margin: 0 0 14px; }
.hint { font: 400 12px var(--font-mono); color: var(--muted); }
.inline-code, code { font: 400 12px var(--font-mono); background: var(--paper-2); border-radius: 6px; padding: 2px 7px; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill);
  font: 500 14.5px/1 var(--font-display); letter-spacing: -0.008em; white-space: nowrap; cursor: pointer; text-decoration: none; color: var(--ink);
  background: rgba(255, 255, 255, 0.7); box-shadow: inset 0 0 0 1px var(--line-2);
  transition-property: transform, box-shadow, background-color, color; transition-duration: var(--t-quick); transition-timing-function: var(--ease);
}
.btn:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--white); box-shadow: inset 0 0 0 1px rgba(42, 42, 39, 0.2); }
  .btn.primary:hover { background: #000; box-shadow: 0 18px 34px rgba(42, 42, 39, 0.2), 0 2px 6px rgba(42, 42, 39, 0.1); transform: translateY(-1px); }
  .btn.primary:active { transform: scale(0.96); }
}
.btn.primary { background: var(--ink); color: var(--white); box-shadow: var(--shadow-btn); }
.btn.danger { color: var(--accent); }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; position: relative; }
.btn.small::after { content: ''; position: absolute; inset: -4px 0; }
.btn.big { height: 52px; padding: 0 28px; font-size: 15.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > .btn, .row > .status { flex: none; }

/* ---------- forms ---------- */
label.field { display: block; }
.field { margin-bottom: 18px; }
.lbl, label.field > span { display: flex; justify-content: space-between; align-items: baseline; font: 400 12px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.lbl b, label.field > span b { font: 500 13px var(--font-display); letter-spacing: -0.005em; text-transform: none; color: var(--ink); }
input[type='text'], input[type='password'], input[type='datetime-local'], select, textarea {
  width: 100%; height: 46px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--white); color: var(--ink);
  font-size: 15px; box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow var(--t-quick) var(--ease);
}
textarea { height: auto; min-height: 84px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
input[type='datetime-local'] { width: auto; }
select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%2366645d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input[type='range'] { width: 100%; height: 24px; accent-color: var(--ink); background: transparent; box-shadow: none; padding: 0; }
input[type='file'] { display: none; }
.prompt-box { position: relative; }
.prompt-box textarea { min-height: 150px; padding: 22px 24px 58px; border-radius: var(--r-lg); font-size: 18px; line-height: 1.45; box-shadow: var(--shadow-card); background: var(--white); }
.prompt-box textarea:focus-visible { box-shadow: 0 0 0 1.5px var(--ink), var(--shadow-card); }
.prompt-box .tools { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.prompt-box .tools .row { flex: none; }

/* toggle switches */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); cursor: pointer; font-weight: 500; font-size: 14.5px; }
.switch:first-of-type { border-top: 0; }
.switch small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 1px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 26px; border-radius: 999px; background: rgba(42, 42, 39, 0.14); position: relative; cursor: pointer; flex: none; padding: 0; box-shadow: none; transition: background-color var(--t-std) var(--ease); }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(42, 42, 39, 0.3); transition: transform var(--t-std) var(--ease-out); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(16px); }
.switch.small { padding: 4px 0; border-top: 0; font-size: 13px; font-weight: 400; color: var(--ink-2); }
.switch.small input { width: 36px; height: 22px; }
.switch.small input::after { width: 16px; height: 16px; }
.switch.small input:checked::after { transform: translateX(14px); }

/* ---------- cards ---------- */
.panel { background: var(--white); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-card); }
.panel + .panel { margin-top: 16px; }
.subpanel { background: var(--paper-2); border-radius: var(--r-md); padding: 16px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.est { font: 400 12px var(--font-mono); color: var(--muted); display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 10px; }
.est b { color: var(--ink); font-weight: 500; }
.est .warn, .warn { color: var(--accent); }
.finalp { font: 400 12px/1.6 var(--font-mono); color: var(--ink-2); background: var(--card-grad); border-radius: var(--r-md); padding: 14px 16px; margin-top: 14px; overflow-wrap: anywhere; max-height: 140px; overflow: auto; }
.finalp b { display: block; font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- selectors ---------- */
.seg { position: relative; isolation: isolate; display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: rgba(42, 42, 39, 0.06); }
.seg button { border: 0; background: transparent; height: 34px; padding: 0 15px; border-radius: var(--r-pill); font: 500 13.5px var(--font-display); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: color var(--t-quick) var(--ease), background-color var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease), transform var(--t-quick) var(--ease); }
.seg button:active { transform: scale(0.96); }
.seg button[aria-pressed='true'] { color: var(--ink); background: var(--white); box-shadow: 0 0 0 1px rgba(42, 42, 39, 0.05), 0 2px 6px rgba(42, 42, 39, 0.1); }
.seg.js button[aria-pressed='true'] { background: transparent; box-shadow: none; }
.seg .pill { position: absolute; left: 0; top: 0; z-index: -1; border-radius: var(--r-pill); background: var(--white); box-shadow: 0 0 0 1px rgba(42, 42, 39, 0.05), 0 2px 6px rgba(42, 42, 39, 0.1); pointer-events: none;
  transition: transform var(--t-std) var(--ease-out), width var(--t-std) var(--ease-out), height var(--t-std) var(--ease-out), opacity var(--t-quick); }
.seg .pill.no-anim { transition: none; }
.seg .ar { border: 1.5px solid currentColor; border-radius: 2px; display: inline-block; }
.seg .ar.v { width: 9px; height: 15px; }
.seg .ar.l { width: 16px; height: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 15px; border: 0; border-radius: var(--r-pill); background: var(--white); box-shadow: inset 0 0 0 1px var(--line-2); font: 500 13.5px var(--font-display); color: var(--ink-2); cursor: pointer;
  transition: background-color var(--t-quick) var(--ease), color var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease), transform var(--t-quick) var(--ease); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--white); box-shadow: none; }
.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style-card { border: 0; padding: 0; background: var(--white); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-card); text-align: left; cursor: pointer;
  transition: transform var(--t-std) var(--ease), box-shadow var(--t-std) var(--ease); }
.style-card:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .style-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(42, 42, 39, 0.06), 0 12px 30px rgba(42, 42, 39, 0.1); } }
.style-card[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ink); }
.style-card .sw { height: 54px; }
.style-card span { display: block; padding: 9px 12px 11px; font-size: 13px; font-weight: 500; }

/* ---------- status ---------- */
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.run { animation: pulse 2.2s ease-in-out infinite; }
.status, .chip-note { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: var(--r-pill); font: 400 11px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; background: rgba(42, 42, 39, 0.06); color: var(--ink-2); white-space: nowrap; }
.status:has(.dot.run) { background: var(--wait-soft); color: var(--wait-ink); }
.status:has(.dot.ok) { background: var(--live-soft); color: var(--live-ink); }
.status:has(.dot.bad) { background: var(--accent-soft); color: var(--accent); }
.engine { height: 30px; }

/* ---------- project ---------- */
.p-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 26px; flex-wrap: wrap; }
.p-head h1 { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.06; letter-spacing: -0.03em; font-weight: 500; max-width: 26ch; }
.p-head .row { flex: none; gap: 8px; }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tabs button { background: none; border: 0; padding: 12px 0; font: 500 14.5px var(--font-display); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t-quick) var(--ease), border-color var(--t-quick) var(--ease); }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--ink); }
.steps { display: flex; margin: 0 0 24px; padding: 0; list-style: none; }
.steps li { flex: 1; position: relative; padding-top: 16px; font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); }
.steps li::before { content: ''; position: absolute; top: 3px; left: 0; right: 6px; height: 3px; border-radius: 3px; background: rgba(42, 42, 39, 0.1); }
.steps li.done { color: var(--ink-2); }
.steps li.done::before { background: var(--live); }
.steps li.on { color: var(--ink); }
.steps li.on::before { background: linear-gradient(90deg, var(--ink) var(--p, 40%), rgba(42, 42, 39, 0.1) var(--p, 40%)); }

/* the film strip: frames develop as images land */
.strip { background: var(--ink); border-radius: var(--r-lg); padding: 28px 16px; display: flex; gap: 12px; overflow-x: auto; position: relative; box-shadow: var(--shadow-btn); scrollbar-width: thin; scrollbar-color: rgba(250, 250, 247, 0.3) transparent;
  background-image: radial-gradient(circle, rgba(250, 250, 247, 0.16) 45%, transparent 47%), radial-gradient(circle, rgba(250, 250, 247, 0.16) 45%, transparent 47%);
  background-size: 22px 10px, 22px 10px; background-position: 6px 9px, 6px calc(100% - 9px); background-repeat: repeat-x, repeat-x; }
.frame { flex: none; width: 150px; aspect-ratio: var(--ar, 9/16); border-radius: 4px; position: relative; overflow: hidden; background: #3b3b37; border: 1px solid rgba(250, 250, 247, 0.16); }
.frame.land { width: 240px; --ar: 16/9; }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 1.6s ease, opacity 1.2s ease; }
.frame.wait img { opacity: 0; }
.frame.wait::before, .gimg.wait::before { content: ''; position: absolute; inset: 0; opacity: 0.5; background-image: var(--grain); }
.frame.now::after, .gimg.now::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, rgba(222, 10, 38, 0.32), transparent); background-size: 100% 60%; background-repeat: no-repeat; animation: scan 2.2s linear infinite; }
.frame.fresh img, .gimg.fresh img { animation: develop 1.8s ease-out; }
.frame .n { position: absolute; left: 7px; bottom: 6px; font: 400 10px var(--font-mono); color: rgba(255, 255, 255, 0.8); text-shadow: 0 1px 3px #000; }
.big-status { display: flex; align-items: baseline; gap: 14px; margin: 22px 0 8px; flex-wrap: wrap; }
.big-status .num { font-size: 56px; font-weight: 500; letter-spacing: -0.035em; line-height: 1; }
.big-status .what { color: var(--ink-2); }
.log { font: 400 11.5px/1.6 var(--font-mono); color: var(--ink-2); background: var(--paper-2); border-radius: var(--r-md); padding: 14px 16px; max-height: 190px; overflow: auto; white-space: pre-wrap; margin-top: 14px; }
.notice { border-radius: var(--r-md); padding: 14px 18px; margin-bottom: 18px; background: var(--wait-soft); }
.notice b { display: block; font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 3px; color: var(--wait-ink); }
.notice.bad { background: var(--accent-soft); }
.notice.bad b { color: var(--accent); }
.bar { height: 6px; background: rgba(42, 42, 39, 0.08); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--ink); border-radius: 6px; transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 400ms var(--ease); }

/* ---------- script editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.scene { background: var(--white); border-radius: 20px; padding: 16px; box-shadow: var(--shadow-card); display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; margin-bottom: 12px; }
.scene .pic { width: 96px; aspect-ratio: var(--ar, 9/16); background: var(--paper-2) center/cover; border-radius: 10px; position: relative; }
.scene .pic.land { --ar: 16/9; }
.scene .pic small { position: absolute; left: 6px; top: 5px; font: 400 10px var(--font-mono); color: #fff; text-shadow: 0 1px 3px #000; }
.scene .body > * + * { margin-top: 10px; }
.scene textarea { min-height: 60px; font-size: 14px; }
.scene .lbl { margin-bottom: 5px; }
.scene .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font: 400 11.5px var(--font-mono); color: var(--muted); }
.scene .meta .acts { display: flex; gap: 6px; }
.side { position: sticky; top: 88px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 18px 0 16px; background: linear-gradient(rgba(250, 250, 247, 0), var(--paper) 34%); }

/* ---------- gallery + library ---------- */
.gal, .lib-grid { display: grid; gap: 16px; align-items: start; }
.gal { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.gcard, .lib-card { background: var(--white); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-card); }
.gimg { position: relative; aspect-ratio: var(--ar, 1/1); background: var(--paper-2); cursor: zoom-in; overflow: hidden; }
.gimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gimg.wait { cursor: progress; }
.gimg .st { position: absolute; left: 12px; bottom: 10px; z-index: 1; font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.gimg.bad { cursor: default; display: grid; place-items: center; padding: 16px; text-align: center; color: var(--accent); font-size: 13px; }
.gcard .cap { padding: 12px 14px 14px; }
.gcard .cap p { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard .cap .mono { font: 400 11px var(--font-mono); color: var(--muted); }
.gcard .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.lib-card { display: block; text-decoration: none; color: inherit; transition: transform var(--t-std) var(--ease), box-shadow var(--t-std) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .lib-card:hover, .gcard:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(42, 42, 39, 0.06), 0 12px 30px rgba(42, 42, 39, 0.1); }
}
.lib-card:active { transform: scale(0.985); }
.lib-thumb { aspect-ratio: 16 / 10; background: var(--card-grad) center / cover; position: relative; }
.lib-thumb .status { position: absolute; left: 12px; top: 12px; background: rgba(250, 250, 247, 0.92); backdrop-filter: blur(6px); }
.lib-thumb .status:has(.dot.run) { background: rgba(255, 244, 222, 0.94); }
.lib-thumb .status:has(.dot.ok) { background: rgba(229, 245, 237, 0.94); }
.lib-thumb .status:has(.dot.bad) { background: rgba(253, 228, 231, 0.94); }
.lib-cap { padding: 14px 16px 16px; }
.lib-cap h3 { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-cap .mono { display: block; margin-top: 8px; font: 400 11px var(--font-mono); letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.empty { text-align: center; color: var(--ink-2); max-width: 44ch; margin: 40px auto; }
.empty .btn { margin-top: 18px; }
.refs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.ref { width: 68px; height: 68px; border-radius: 12px; background: var(--paper-2) center/cover; position: relative; }
.ref button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.gimg img, .frame img, .scene .pic, .ref, .player video, .style-card .sw, .lib-thumb { outline: 1px solid rgba(0, 0, 0, 0.08); outline-offset: -1px; }

/* ---------- result ---------- */
.player { background: #000; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-float); }
.kv { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px 12px; align-items: start; }
.kv dt { font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 7px; }
.kv dd { margin: 0; padding: 4px 0; overflow-wrap: anywhere; }
.tag { display: inline-block; font: 400 11.5px var(--font-mono); background: var(--paper-2); border-radius: var(--r-pill); padding: 3px 10px; margin: 0 4px 4px 0; color: var(--ink-2); }
.chan-list { display: flex; flex-direction: column; gap: 8px; }
.chan { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: var(--paper-2); border-radius: var(--r-md); }
.chan-name { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.chan-name b { font-weight: 500; overflow-wrap: anywhere; }
.steps-list { margin: 0 0 18px; padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.steps-list li { margin: 0 0 7px; padding-left: 4px; }
.steps-list b { color: var(--ink); font-weight: 500; }
.steps-list a { color: var(--accent); text-underline-offset: 3px; }
.runs dt { font: 400 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 14px; }
.runs dd { margin: 3px 0 0; }

/* ---------- overlays ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; z-index: 60; padding: 12px 20px; border-radius: var(--r-pill); background: var(--ink); color: var(--white); font-weight: 500; font-size: 14px; box-shadow: var(--shadow-btn);
  opacity: 0; transform: translate(-50%, 10px) scale(0.98); filter: blur(2px);
  transition: opacity var(--t-std) var(--ease-out), transform var(--t-std) var(--ease-out), filter var(--t-std) var(--ease-out); }
.toast.bad { background: var(--accent); }
.toast.in { opacity: 1; transform: translate(-50%, 0); filter: none; }
.toast.out { opacity: 0; transform: translate(-50%, 6px); transition-duration: var(--t-quick); }
dialog.lightbox { border: 0; border-radius: var(--r-lg); background: var(--paper); color: var(--ink); padding: 0; width: min(1100px, 94vw); max-height: 92vh; box-shadow: var(--shadow-float); overflow: hidden;
  opacity: 0; transform: scale(0.96) translateY(6px); transition: opacity var(--t-std) var(--ease-out), transform var(--t-std) var(--ease-out), overlay var(--t-std) allow-discrete, display var(--t-std) allow-discrete; }
dialog.lightbox[open] { opacity: 1; transform: none; }
@starting-style { dialog.lightbox[open] { opacity: 0; transform: scale(0.96) translateY(6px); } }
dialog.lightbox::backdrop { background: rgba(42, 42, 39, 0); transition: background var(--t-std) var(--ease-out), overlay var(--t-std) allow-discrete, display var(--t-std) allow-discrete; }
dialog.lightbox[open]::backdrop { background: rgba(42, 42, 39, 0.55); }
@starting-style { dialog.lightbox[open]::backdrop { background: rgba(42, 42, 39, 0); } }
.lb { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); }
.lb .pic { background: #141412; display: grid; place-items: center; max-height: 88vh; }
.lb .pic img { max-width: 100%; max-height: 88vh; display: block; }
.lb .info { padding: 24px; overflow: auto; max-height: 88vh; }
.lb .info p { font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.lb .info p.eyebrow { margin-top: 14px; }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; text-align: center; padding: 8px 12px; font: 400 12px var(--font-mono); letter-spacing: 0.06em; background: var(--accent); color: #fff; transform: translateY(-100%); transition: transform var(--t-std) var(--ease-out); }
.offline:not([hidden]) { transform: none; }
@starting-style { .offline:not([hidden]) { transform: translateY(-100%); } }
.skel, .shimmer { border-radius: 12px; background: linear-gradient(90deg, var(--paper-2), var(--white), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin: 10px 0; height: 14px; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes scan { from { background-position: 0 -60%; } to { background-position: 0 160%; } }
@keyframes develop { 0% { filter: sepia(1) saturate(0) brightness(1.5) contrast(0.7) blur(8px); } 45% { filter: sepia(0.8) saturate(0.6) brightness(1.15) blur(2px); } 100% { filter: none; } }
main.enter > * { animation: rise 380ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.gcard, .lib-card { animation: rise 320ms var(--ease-out) both; animation-delay: calc(var(--k, 0) * 40ms); }
.player { animation: rise 420ms var(--ease-out) both; }

/* ---------- narrow screens ---------- */
@media (max-width: 1000px) {
  .grid2, .editor { grid-template-columns: 1fr; }
  .styles { grid-template-columns: repeat(2, 1fr); }
  .side { position: static; }
  .lb { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .nav { height: auto; min-height: 60px; padding: 8px 0 6px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .nav .container { flex-wrap: wrap; gap: 8px 12px; }
  .nav-links { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 2px 4px; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex: none; }
  .nav-right { margin-left: auto; }
  main#main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .sticky-actions { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .frame { width: 112px; } .frame.land { width: 190px; }
  .kv { grid-template-columns: 1fr auto; } .kv dt { grid-column: 1 / -1; padding-top: 10px; }
  .scene { grid-template-columns: 72px minmax(0, 1fr); } .scene .pic { width: 72px; }
  .prompt-box textarea { font-size: 17px; }
  h1.display { max-width: 12ch; }
  .steps li { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- result page layout ---------- */
.result { display: grid; gap: 24px; align-items: start; }
.result.tall { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
.result.land { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); }
.result-media { min-width: 0; }
.result.tall .result-media { position: sticky; top: 88px; }
.result-side { display: grid; gap: 16px; min-width: 0; }
.result-side > .panel + .panel { margin-top: 0; }
.player video { display: block; width: 100%; height: auto; background: #000; }
.result.tall .player video { max-height: 78vh; object-fit: contain; }
.result.land .player video { aspect-ratio: 16 / 9; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.fact { font: 400 11.5px var(--font-mono); letter-spacing: 0.04em; color: var(--ink-2); background: var(--paper-2); border-radius: var(--r-pill); padding: 4px 11px; font-variant-numeric: tabular-nums; }
.details-panel { margin-top: 24px; }
.note { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }
@media (max-width: 1000px) {
  .result.tall, .result.land { grid-template-columns: 1fr; }
  .result.tall .result-media { position: static; }
  .result.tall .player { max-width: 380px; }
}
