/* Frameline studio. One theme per system preference, one accent, one radius scale:
   buttons and chips are pills, surfaces are 16px, media inside surfaces 10px. */
:root {
  --bg: #0e0e10;
  --bg-2: #141417;
  --surface: #17171b;
  --surface-2: #1d1d22;
  --line: rgb(255 255 255 / 0.08);
  --line-2: rgb(255 255 255 / 0.14);
  --text: #eeece8;
  --text-2: #a9a6a0;
  --text-3: #75726d;
  --accent: #ee7d45;
  --accent-ink: #1a0e07;
  --accent-soft: rgb(238 125 69 / 0.14);
  --ok: #8fcf9c;
  --warn: #e7b05a;
  --shadow: 0 30px 80px rgb(0 0 0 / 0.45);
  --r: 16px;
  --r-media: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --max: 1320px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f2ef;
    --bg-2: #ebe9e5;
    --surface: #fbfaf8;
    --surface-2: #f1efeb;
    --line: rgb(20 18 16 / 0.09);
    --line-2: rgb(20 18 16 / 0.16);
    --text: #17161a;
    --text-2: #56534e;
    --text-3: #7c7872;
    --accent: #c4561f;
    --accent-ink: #fff8f3;
    --accent-soft: rgb(196 86 31 / 0.1);
    --ok: #2f7d45;
    --warn: #9a6512;
    --shadow: 0 30px 70px rgb(40 30 20 / 0.14);
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 Geist, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Film grain: fixed, non-interactive, never on a scrolling layer. */
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap;
  padding: 0.8rem 1.25rem; border-radius: 999px; font-weight: 500; font-size: 0.95rem;
  border: 1px solid transparent; cursor: pointer; transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { border-color: var(--line-2); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--text-3); }
.btn-block { width: 100%; justify-content: center; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50; height: 64px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; letter-spacing: -0.01em; }
.brand i { font-size: 1.35rem; color: var(--accent); }
.nav-links { display: flex; gap: 2rem; font-size: 0.92rem; color: var(--text-2); }
.nav-links a:hover { color: var(--text); }
.nav-wallet {
  justify-self: end; display: inline-flex; align-items: center; gap: 0.45rem;
  font: 500 0.82rem/1 "Geist Mono", monospace; color: var(--text-2);
  padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: 999px;
}

/* Hero */
.hero {
  max-width: var(--max); margin: 0 auto;
  min-height: calc(100dvh - 64px);
  display: grid; grid-template-columns: 5fr 7fr; gap: clamp(24px, 4vw, 64px); align-items: center;
  padding: clamp(32px, 6vh, 72px) clamp(16px, 4vw, 40px);
}
.hero-title {
  font-size: clamp(2.6rem, 5.4vw, 4.8rem); font-weight: 600; letter-spacing: -0.035em; line-height: 1.02;
}
.hero-title em { font-style: italic; font-weight: 500; color: var(--accent); }
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.08em; }
.hero-title .line > span { display: inline-block; }
.hero-sub { margin-top: 1.4rem; max-width: 40ch; color: var(--text-2); font-size: clamp(1.02rem, 1.3vw, 1.15rem); }
.hero-ctas { margin-top: 2rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.hero-film { position: relative; }
.hero-film video {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow);
}
.hero-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.hero-strip img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-media);
  opacity: 0.55; transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.hero-strip img.on { opacity: 1; transform: translateY(-3px); }

/* Sections */
section.studio, section.money, section.films {
  max-width: var(--max); margin: 0 auto; padding: clamp(64px, 11vh, 120px) clamp(16px, 4vw, 40px);
}
.section-title { font-size: clamp(2rem, 3.6vw, 3rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.section-sub { margin-top: 0.8rem; color: var(--text-2); max-width: 58ch; }

/* Studio */
.studio-grid { margin-top: 2.5rem; display: grid; grid-template-columns: 5fr 7fr; gap: 20px; align-items: start; }

.chat {
  display: flex; flex-direction: column; height: min(720px, 80dvh);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.agent-mark {
  width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 1.2rem;
}
.chat-name { font-weight: 600; font-size: 0.95rem; }
.chat-meta { font-size: 0.8rem; color: var(--text-3); }
.chat-log { list-style: none; padding: 1.1rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 0.7rem; }
.msg { max-width: 86%; padding: 0.7rem 0.95rem; border-radius: 14px; font-size: 0.95rem; line-height: 1.5; }
.msg.agent { background: var(--surface-2); border-top-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--accent-soft); border-top-right-radius: 4px; align-self: flex-end; }
.msg.photo { padding: 4px; background: var(--surface-2); align-self: flex-end; }
.msg.photo img { width: 220px; border-radius: 10px; }
.msg.error { background: transparent; border: 1px solid var(--line-2); color: var(--warn); font-size: 0.88rem; }
.msg.typing { display: inline-flex; gap: 5px; align-items: center; }
.msg.typing span { width: 6px; height: 6px; border-radius: 99px; background: var(--text-3); animation: blink 1.2s infinite var(--ease); }
.msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-ready { padding: 0 1.1rem 0.8rem; }
.chat-form { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--line); }
.chat-form input#chat-input {
  flex: 1; min-width: 0; padding: 0.75rem 0.9rem; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line); outline: none;
}
.chat-form input#chat-input::placeholder { color: var(--text-3); }
.chat-form input#chat-input:focus { border-color: var(--accent); }
.attach, .send {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 999px;
  cursor: pointer; font-size: 1.15rem; border: 1px solid var(--line-2); background: transparent;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.attach:hover { border-color: var(--text-3); }
.send { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.attach:active, .send:active { transform: scale(0.94); }
.chat.dragging { border-color: var(--accent); }

/* Stage */
.stage {
  min-height: min(720px, 80dvh); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1.4rem; position: relative; overflow: hidden;
}
.stage-empty { height: 100%; min-height: 60dvh; display: flex; flex-direction: column; justify-content: center; gap: 1.4rem; }
.stage-empty p { color: var(--text-3); max-width: 42ch; }
.strip-skeleton { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.strip-skeleton span, .frame .media.pending {
  aspect-ratio: 16 / 9; border-radius: var(--r-media);
  background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 60%, var(--text-3)) 50%, var(--surface-2) 70%);
  background-size: 250% 100%; animation: shimmer 1.8s infinite linear;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.board-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.board-head h3 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.board-head p { color: var(--text-2); font-size: 0.95rem; margin-top: 0.2rem; }
.board-status {
  font: 500 0.78rem/1 "Geist Mono", monospace; padding: 0.45rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap;
}
.board-status.live { color: var(--accent); border-color: var(--accent); }
.board-status.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 60%, transparent); }

.frames { margin-top: 1.2rem; display: grid; grid-auto-flow: column; gap: 12px; overflow-x: auto; padding-bottom: 0.4rem; scroll-snap-type: x proximity; }
.frames .frame { scroll-snap-align: start; }
.frame { display: flex; flex-direction: column; gap: 0.5rem; }
.frame .media { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-media); overflow: hidden; background: var(--surface-2); }
.frame .media img, .frame .media video { width: 100%; height: 100%; object-fit: cover; }
.frame .media img { clip-path: inset(0 100% 0 0); transition: clip-path 0.9s var(--ease), transform 1.2s var(--ease); transform: scale(1.06); }
.frame .media img.shown { clip-path: inset(0 0 0 0); transform: none; }
.frame .label { font: 500 0.75rem/1.3 "Geist Mono", monospace; color: var(--text-3); }
.frame .prompt { font-size: 0.82rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.frame.move .media { background: var(--bg-2); display: grid; place-items: center; color: var(--text-3); font-size: 1.4rem; }
.frame.move.working .media { color: var(--accent); }
.frame.move.working .media i { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.frame .join { font: 500 0.72rem/1 "Geist Mono", monospace; color: var(--ok); }
.frame .join.bad { color: var(--warn); }

.progress { margin-top: 1.1rem; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 0.8s var(--ease); }

.quote {
  margin-top: 1.4rem; display: grid; grid-template-columns: 1fr auto; gap: 1rem 1.5rem; align-items: center;
  padding: 1.2rem; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line);
}
.quote-figures { display: flex; gap: 2.2rem; }
.fig { font-size: 1.9rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.fig.muted { color: var(--text-2); }
.fig-label { font-size: 0.8rem; color: var(--text-3); }
.quote-note { grid-column: 1 / -1; font-size: 0.82rem; color: var(--text-3); }

.ledger { margin-top: 1.2rem; }
.ledger-head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-2); margin-bottom: 0.6rem; }
.ledger ol { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; max-height: 180px; overflow-y: auto; }
.ledger li {
  display: flex; justify-content: space-between; gap: 1rem; font: 400 0.8rem/1.4 "Geist Mono", monospace; color: var(--text-2);
  animation: rowIn 0.5s var(--ease) both;
}
.ledger li .amt { color: var(--text); white-space: nowrap; }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }

.result { margin-top: 1.4rem; }
.device {
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line-2); box-shadow: var(--shadow);
  aspect-ratio: 16 / 10; background: #0d0c0b;
}
.device iframe { width: 100%; height: 100%; border: 0; }
.result-actions { margin-top: 1rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* Money flow */
.flow { margin-top: 2.6rem; display: grid; grid-template-columns: 1fr 1.1fr 1fr 1.1fr 1fr; align-items: stretch; }
.flow .link { align-self: center; }
.node {
  padding: 1.4rem; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.25rem;
}
.node i { font-size: 1.5rem; color: var(--accent); margin-bottom: 0.6rem; }
.node-name { font-size: 0.9rem; color: var(--text-2); }
.node-value { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.node-note { font-size: 0.8rem; color: var(--text-3); }
.link { position: relative; padding: 0 0.8rem; }
.link span { display: block; height: 1px; background: var(--line-2); position: relative; overflow: hidden; }
.link span::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: travel 2.6s var(--ease) infinite;
}
@keyframes travel { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.link-label { margin-top: 0.6rem; text-align: center; font: 400 0.75rem/1.3 "Geist Mono", monospace; color: var(--text-3); }
.rules { list-style: none; padding: 0; margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.rules li {
  display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; color: var(--text-2);
  padding: 0.55rem 0.9rem; border-radius: 999px; border: 1px solid var(--line);
}
.rules i { color: var(--ok); }

/* Films */
.film-row { margin-top: 2.2rem; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, 46%); gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 0.6rem; }
.film-card { scroll-snap-align: start; display: flex; flex-direction: column; gap: 0.8rem; }
.film-card .media { position: relative; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; background: var(--surface); }
.film-card .media img, .film-card .media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.film-card .media video { opacity: 0; transition: opacity 0.5s var(--ease); }
.film-card:hover .media video { opacity: 1; }
.film-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.film-card h3 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.film-card .links { display: flex; gap: 1rem; font-size: 0.88rem; color: var(--text-2); }
.film-card .links a:hover { color: var(--text); }
.films-empty { color: var(--text-3); }

.foot {
  max-width: var(--max); margin: 0 auto; padding: 2rem clamp(16px, 4vw, 40px) 3rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--text-3); font-size: 0.85rem; border-top: 1px solid var(--line);
}

/* Motion: entrances and reveals, only when the user allows motion. */
@media (prefers-reduced-motion: no-preference) {
  .hero-title .line > span { transform: translateY(105%); animation: rise 1s var(--ease) forwards; }
  .hero-title .line:nth-child(2) > span { animation-delay: 0.12s; }
  .hero-sub, .hero-ctas { opacity: 0; animation: fade 0.9s var(--ease) 0.35s forwards; }
  .hero-ctas { animation-delay: 0.5s; }
  .hero-film video { clip-path: inset(8% 8% 8% 8% round 16px); animation: open 1.4s var(--ease) 0.2s forwards; }
  .hero-strip img { opacity: 0; animation: fade 0.8s var(--ease) forwards; }
  .reveal { opacity: 0; transform: translateY(28px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
  .reveal.in { opacity: 1; transform: none; }
  @keyframes rise { to { transform: none; } }
  @keyframes fade { to { opacity: 1; } }
  @keyframes open { to { clip-path: inset(0 0 0 0 round 16px); } }
}
@media (prefers-reduced-motion: reduce) {
  .frame .media img { clip-path: none; transform: none; transition: none; }
  .link span::after, .strip-skeleton span, .frame .media.pending, .msg.typing span, .frame.move.working .media i { animation: none; }
  html { scroll-behavior: auto; }
}

/* Mobile: every multi-column layout collapses to one column. */
@media (max-width: 900px) {
  .nav { grid-template-columns: 1fr auto; }
  .nav-links { display: none; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .studio-grid { grid-template-columns: 1fr; }
  .chat { height: 70dvh; }
  .stage { min-height: 0; }
  .flow { grid-template-columns: 1fr; gap: 0.6rem; }
  .link { padding: 0.8rem 0; }
  .link span { width: 1px; height: 36px; margin: 0 auto; }
  .link span::after { width: 100%; height: 40%; background: linear-gradient(180deg, transparent, var(--accent), transparent); animation-name: travelY; }
  @keyframes travelY { from { transform: translateY(-100%); } to { transform: translateY(260%); } }
  .quote { grid-template-columns: 1fr; }
  .film-row { grid-auto-columns: 86%; }
}
