:root {
  --bg: #0b0b0e;
  --panel: #141418;
  --panel-2: #1b1b20;
  --panel-3: #232329;
  --border: #2a2a31;
  --text: #ececf1;
  --muted: #8d8d98;
  --faint: #5d5d68;
  --accent: #7c5cff;
  --accent-2: #6a48ff;
  --think: #f0a35e;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app { display: flex; height: 100dvh; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 236px; flex: none; display: flex; flex-direction: column; gap: 6px;
  padding: 14px 10px; background: var(--bg); border-right: 1px solid #17171c;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; padding: 4px 8px 10px; }
.brand span { letter-spacing: -0.01em; }
.new-chat {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 13.5px; text-align: left;
}
.new-chat .plus { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; font-size: 14px; line-height: 1; }
.nav { display: flex; flex-direction: column; margin-top: 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: #cfcfd6; text-decoration: none; font-size: 13.5px; }
.nav a:hover, .nav a.active { background: var(--panel-2); color: var(--text); }
.ni { width: 16px; text-align: center; color: var(--muted); }
.recents-head { display: flex; justify-content: space-between; padding: 14px 10px 4px; font-size: 12px; color: var(--muted); }
.recents { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.recents li { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; font-size: 13px; color: #c9c9d1; cursor: pointer; }
.recents li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recents li:hover, .recents li.active { background: var(--panel-2); color: var(--text); }
.recents li .del { visibility: hidden; background: none; border: 0; color: var(--muted); padding: 0 2px; }
.recents li:hover .del { visibility: visible; }
.side-foot { padding-top: 6px; }
.credit-card { padding: 9px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.credit-card span { color: var(--text); font-weight: 600; }

/* ---------- main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: #0f0f13; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 18px; }
.session-title { font-weight: 600; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.pill { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); font-size: 12.5px; white-space: nowrap; }
.pill-accent { background: var(--accent); border-color: var(--accent); font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 15px; line-height: 1; }
.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.only-mobile { display: none; }

/* ---------- home ---------- */
.home { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 9vh 20px 40px; }
.hero { font-weight: 500; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.02em; margin: 0 0 34px; text-align: center; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.hero-thumb {
  display: inline-block; width: 1.5em; height: 1.08em; border-radius: 10px; border: 2px solid #2b2b33;
  background: linear-gradient(120deg, #ff7a3d, #ff3d8b 35%, #7c5cff 65%, #2fd3c6);
  background-size: 300% 300%; animation: drift 6s ease-in-out infinite;
  box-shadow: 0 8px 30px #7c5cff33; transform: rotate(-3deg);
}
@keyframes drift { 50% { background-position: 100% 50%; } }
.home-composer-wrap { width: min(760px, 100%); }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 6px -12px; padding-bottom: 22px;
  background: linear-gradient(90deg, #191927, #1a1a22); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; font-size: 13px; color: #c9c9d3;
}
.banner span:nth-child(2) { flex: 1; }
.banner-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; max-width: 760px; }
.quick button { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; font-size: 12.5px; color: #d4d4dc; }
.quick button:hover { background: var(--panel-3); }

/* ---------- composer ---------- */
.composer {
  position: relative; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 40px #0007;
}
.composer:focus-within { border-color: #3a3a44; }
.composer-top { display: flex; justify-content: space-between; align-items: flex-start; }
.ref-chips { display: flex; gap: 8px; }
.ref-chip {
  width: 74px; height: 62px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11.5px; color: var(--muted);
}
.ref-chip:hover { color: var(--text); border-color: #3a3a44; }
.ref-chip span { font-size: 15px; }
.composer.in-session .home-only { display: none; }
textarea#input {
  resize: none; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 14.5px;
  line-height: 1.5; min-height: 26px; max-height: 220px; padding: 2px 4px;
}
textarea#input::placeholder { color: var(--faint); }
.composer:not(.in-session) textarea#input { min-height: 48px; }
.composer-bar { display: flex; align-items: center; gap: 6px; }
.composer-bar .grow { flex: 1; }
.menu-btn { background: none; border: 0; padding: 5px 8px; border-radius: 7px; font-size: 13px; color: #d9d9e0; }
.menu-btn:hover { background: var(--panel-3); }
.menu-btn i { font-style: normal; color: var(--faint); }
.menu-btn em { font-style: normal; color: var(--muted); }
.chev { color: var(--muted); font-size: 11px; }
.send {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: #f2f2f5; color: #111;
  display: grid; place-items: center; font-weight: 700; transition: opacity .15s;
}
.send:disabled { opacity: .35; cursor: default; }
.send-stop { display: none; width: 10px; height: 10px; background: #111; border-radius: 2px; }
.composer.running .send-arrow { display: none; }
.composer.running .send-stop { display: block; }
.composer.running .send:disabled { opacity: 1; cursor: pointer; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; }
.attachments:empty { display: none; }
.att { position: relative; width: 56px; height: 56px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #000b; font-size: 10px; padding: 0; }

.bottom-slot { padding: 0 20px 18px; display: flex; justify-content: center; }
.bottom-slot .composer { width: min(720px, 100%); }

/* ---------- thread ---------- */
.thread { flex: 1; overflow-y: auto; padding: 8px 20px 24px; scroll-behavior: smooth; }
.messages { width: min(720px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg-user { align-self: flex-end; max-width: 75%; background: var(--panel-2); border: 1px solid #222228; padding: 11px 15px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg-user .u-atts { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.msg-user .u-atts img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.msg-assistant { display: flex; flex-direction: column; gap: 14px; max-width: 100%; }

.pending { display: flex; align-items: center; gap: 8px; color: var(--think); font-size: 13.5px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #f0a35e44; border-top-color: var(--think); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.thinking { font-size: 13.5px; }
.think-head { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; color: var(--think); }
.thinking.done .think-head { color: var(--muted); }
.thinking.done .spinner { display: none; }
.think-chev { transition: transform .15s; font-size: 12px; opacity: .8; }
.thinking.open .think-chev { transform: rotate(90deg); }
.think-body { max-width: 520px; margin: 8px 0 0 6px; padding-left: 14px; border-left: 2px solid #26262c; color: #a5a5af; line-height: 1.55; white-space: pre-wrap; }
.thinking.live .think-body {
  max-height: 7.8em; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%); mask-image: linear-gradient(to bottom, transparent, #000 40%);
}
.thinking.done:not(.open) .think-body { display: none; }

/* cards */
.card { width: min(460px, 100%); background: var(--panel); border: 1px solid #24242a; border-radius: 14px; padding: 18px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head b { flex: 1; font-weight: 600; font-size: 15px; }
.card-prompt { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 6px 0 14px; text-align: left; color: var(--muted); font-size: 13.5px; }
.card-prompt span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.prompt-open .card-prompt span:first-child { white-space: normal; color: #c8c8d0; line-height: 1.5; }
.card.prompt-open .card-prompt .chev-r { transform: rotate(90deg); }
.chev-r { transition: transform .15s; }
.card-rows { display: grid; grid-template-columns: 140px 1fr; row-gap: 12px; font-size: 13.5px; margin: 4px 0 18px; }
.card-rows dt { color: var(--muted); }
.card-rows dd { margin: 0; }
.card textarea, .card select { width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 13px; padding: 8px; }
.card textarea { min-height: 110px; resize: vertical; margin-bottom: 14px; }
.card-actions { display: flex; gap: 10px; }
.btn { flex: 1; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); font-weight: 600; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #1e1e24 25%, #2a2a31 50%, #1e1e24 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 60px; margin: 18px 0 20px; }
.progress { height: 6px; border-radius: 4px; background: var(--panel-3); overflow: hidden; margin: 6px 0 8px; }
.progress div { height: 100%; background: var(--accent); transition: width .6s ease; }
.card-status { font-size: 13px; color: var(--muted); }
.card-status.err { color: #ff8a8a; }
.card.dismissed { opacity: .5; }
.card-media { margin-top: 4px; border-radius: 10px; overflow: hidden; background: #000; }
.card-media img, .card-media video { width: 100%; display: block; }
.media-actions { display: flex; gap: 12px; margin-top: 10px; font-size: 13px; }
.media-actions a { color: var(--muted); text-decoration: none; }
.media-actions a:hover { color: var(--text); }

/* markdown */
.md { font-size: 14.5px; line-height: 1.6; color: #e4e4ea; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { background: var(--panel-3); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.md h3, .md h4 { margin: 12px 0 6px; font-size: 15px; }
.md a { color: #a99bff; }
.error-line { color: #ff8a8a; font-size: 13.5px; }

/* popover menus */
.popover { position: fixed; z-index: 50; min-width: 220px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 16px 50px #000a; }
.pop-label { font-size: 11px; color: var(--faint); padding: 6px 10px 4px; text-transform: uppercase; letter-spacing: .06em; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 13.5px; }
.pop-item:hover { background: var(--panel-3); }
.pop-item small { display: block; color: var(--muted); font-size: 12px; }
.pop-item .check { margin-left: auto; color: var(--accent); }

/* modals */
.modal { position: fixed; inset: 0; z-index: 60; background: #000b; display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#sketchCanvas { width: 100%; height: auto; background: #fff; border-radius: 10px; touch-action: none; cursor: crosshair; }
.sketch-tools { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.sketch-tools .btn { flex: none; }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; }
.swatches button.on { border-color: #fff; }
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login input { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 11px; color: var(--text); font: inherit; }
.login-err { color: #ff8a8a; font-size: 13px; margin: 0; min-height: 1em; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-3); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; z-index: 70; }

/* ---------- pages (Script to Film list, Gallery) ---------- */
.page { flex: 1; overflow-y: auto; padding: 8px 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 auto 20px; max-width: 1100px; }
.page-head h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 620px; line-height: 1.5; }
.btn.fit { flex: none; width: auto; white-space: nowrap; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: none; border-style: dashed; color: var(--muted); font-weight: 500; }
.btn .spinner { display: inline-block; vertical-align: -2px; margin-right: 4px; border-color: #fff4; border-top-color: #fff; }
.empty { color: var(--muted); font-size: 13.5px; padding: 26px 12px; text-align: center; border: 1px dashed var(--border); border-radius: 12px; grid-column: 1 / -1; }
.film-grid, .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; max-width: 1100px; margin: 0 auto; }
.film-card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer; }
.film-card:hover { border-color: #3a3a44; }
.film-poster { aspect-ratio: 16 / 9; background: #08080a; display: grid; place-items: center; color: var(--faint); font-size: 12.5px; }
.film-poster video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.film-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.film-meta span { color: var(--muted); font-size: 12.5px; }
.film-del { position: absolute; top: 8px; right: 8px; background: #000a; opacity: 0; }
.film-card:hover .film-del, .film-del:focus-visible { opacity: 1; }
.g-item { margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.g-item img, .g-item video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #08080a; }
.g-item figcaption { display: flex; gap: 10px; justify-content: space-between; padding: 9px 12px; font-size: 12.5px; }
.g-item figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-item a { color: var(--muted); text-decoration: none; flex: none; }
.g-item a:hover { color: var(--text); }
.quick .quick-accent { border-color: var(--accent); color: #fff; background: #7c5cff22; }

/* ---------- studio (one film) ---------- */
.studio { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.studio-bar { display: flex; align-items: center; gap: 12px; padding: 0 18px 12px; flex-wrap: wrap; }
.title-input { flex: 1 1 180px; min-width: 120px; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--text); font: inherit; font-size: 18px; font-weight: 600; padding: 6px 8px; }
.title-input:hover, .title-input:focus { border-color: var(--border); background: var(--panel); outline: 0; }
.field { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.field.grow { flex: 2 1 220px; }
.field input, .field select, .shot select { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 13px; padding: 7px 9px; min-width: 0; }
.field.grow input { flex: 1; }
.field input:focus, .field select:focus, .studio textarea:focus, .shot input:focus { outline: 0; border-color: #4a4a58; }
.studio-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; padding: 0 18px; }
.studio-left, .studio-right { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; }
.panel { background: var(--panel); border: 1px solid #24242a; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
details.panel { display: block; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: '›'; margin-left: auto; color: var(--muted); transition: transform .15s; }
details.panel[open] > summary::after { transform: rotate(90deg); }
details.panel[open] > summary { margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel b { font-size: 14px; font-weight: 600; }
.hint { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.grow { flex: 1; }
.studio textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.5; padding: 10px; resize: vertical; }
#pScript { min-height: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #d4d4dc; cursor: pointer; }
.check.off { color: var(--faint); cursor: help; }
.check input { accent-color: var(--accent); }

.shots { display: flex; flex-direction: column; gap: 10px; }
.shot { display: grid; grid-template-columns: 26px minmax(0, 1fr) 128px; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #17171c; }
.shot.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.shot-n { width: 26px; height: 26px; border-radius: 8px; background: var(--panel-3); display: grid; place-items: center; font-size: 12.5px; font-weight: 600; color: #cfcfd6; }
.shot-main { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.shot-heading { background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; padding: 3px 5px; margin: 0 -5px; }
.shot-heading:hover { border-color: var(--border); }
.shot-script { color: var(--faint); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; }
.shot-prompt { min-height: 62px; }
.shot-bar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.shot select { padding: 5px 7px; font-size: 12.5px; }
.shot-thumb { position: relative; align-self: start; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: #0b0b0e; border: 1px dashed var(--border); }
.shot-thumb:not(:empty) { border-style: solid; }
.shot-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-thumb .dl { position: absolute; right: 5px; bottom: 5px; width: 24px; height: 24px; border-radius: 7px; background: #000b; color: #fff; display: grid; place-items: center; text-decoration: none; font-size: 13px; }
.st { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.st.ok { color: #58c98a; }
.st.run { color: var(--think); }
.st.wait { color: #a99bff; }
.st.err { color: #ff8a8a; }

.player { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; max-height: 46vh; margin: 0 auto; width: 100%; }
.player video { width: 100%; height: 100%; display: none; background: #000; }
.player.has-film video { display: block; }
.player.has-film .player-empty { display: none; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--faint); font-size: 13px; }
.export-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.exports { display: flex; flex-direction: column; gap: 8px; }
.exports:empty { display: none; }
.export { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 12.5px; color: #cfcfd6; }
.export > div { flex: 1; min-width: 0; }
.export .progress { margin: 6px 0 0; }

/* timeline */
.timeline-wrap { flex: none; border-top: 1px solid #1d1d23; background: #0c0c10; padding: 10px 18px 14px; }
.timeline-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.timeline { position: relative; overflow-x: auto; padding-bottom: 6px; }
.track { display: flex; gap: 3px; min-height: 68px; width: max-content; min-width: 100%; }
.tl-empty { color: var(--faint); font-size: 12.5px; align-self: center; padding: 0 6px; }
.tl-clip { position: relative; flex: none; height: 68px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); overflow: hidden; padding: 0; text-align: left; color: #fff; }
.tl-clip video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.tl-clip::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, #000c, #0000 60%); pointer-events: none; }
.tl-clip.empty { border-style: dashed; background: none; color: var(--faint); }
.tl-clip.empty::after, .tl-clip.failed::after { display: none; }
.tl-clip.queued { background: #7c5cff1c; border-color: #7c5cff66; }
.tl-clip.running { background: #f0a35e1c; border-color: #f0a35e88; }
.tl-clip.failed { border-color: #ff8a8a88; background: #ff8a8a14; color: #ff8a8a; }
.tl-clip.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.tl-n { position: absolute; z-index: 1; top: 5px; left: 6px; font-size: 11px; font-weight: 700; background: #000a; border-radius: 5px; padding: 1px 5px; color: #fff; }
.tl-name { position: absolute; z-index: 1; left: 6px; right: 6px; bottom: 5px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-state { position: absolute; z-index: 1; top: 6px; right: 6px; font-size: 10.5px; opacity: .85; }
.tl-prog { position: absolute; z-index: 1; left: 0; bottom: 0; height: 3px; background: var(--think); transition: width .6s; }
.playhead { position: absolute; top: 0; bottom: 6px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px #fff8; pointer-events: none; z-index: 2; }

@media (max-width: 980px) {
  .studio { overflow-y: auto; display: block; }
  .studio-body { display: flex; flex-direction: column; }
  .studio-left, .studio-right { overflow: visible; }
  .timeline-wrap { position: sticky; bottom: 0; }
  .page { padding: 8px 16px 32px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .shot { grid-template-columns: 26px minmax(0, 1fr); }
  .shot-thumb { grid-column: 2; width: 160px; }
  .shot-thumb:empty { display: none; }
}

/* sound + engine */
.shot-sound { display: flex; align-items: center; gap: 7px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 9px; }
.shot-sound span { color: var(--muted); font-size: 13px; }
.shot-sound input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 12.5px; padding: 7px 0; }
.shots.no-sound .shot-sound { display: none; }
.card .card-rows input { width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 13px; padding: 7px 8px; }
.card-source { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.card-source img { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.pill.engine::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--faint); vertical-align: 1px; }
.pill.engine.ok::before { background: #58c98a; }
.pill.engine.off::before { background: #f0a35e; }
.pill.engine.bad { border-color: #ff8a8a88; color: #ff8a8a; }
.pill.engine.bad::before { background: #ff6b6b; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 60px #000a; }
  .sidebar.open { transform: none; }
  .brand .only-mobile { margin-left: auto; }
  .top-actions .pill-accent, #mockPill { display: none; }
  .home { padding-top: 5vh; }
  .msg-user { max-width: 88%; }
  .card-rows { grid-template-columns: 110px 1fr; }
  .bottom-slot { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
}
