/* Studio: warm near-black tool UI, one amber accent, hairline borders. */
:root {
  --bg: #12110f;
  --surface: #191714;
  --raised: #211e1a;
  --raised-2: #2a2621;
  --line: rgba(255, 238, 214, 0.08);
  --line-strong: rgba(255, 238, 214, 0.16);
  --text: #efe9e1;
  --muted: #9b938a;
  --faint: #6c655d;
  --accent: #f0a64a;
  --accent-strong: #ffb965;
  --accent-ink: #1a1206;
  --accent-soft: rgba(240, 166, 74, 0.12);
  --ok: #8fd0a4;
  --ok-soft: rgba(143, 208, 164, 0.12);
  --bad: #f08a7a;
  --bad-soft: rgba(240, 138, 122, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Geist", ui-sans-serif, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 var(--font);
  letter-spacing: -0.005em;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(240, 166, 74, 0.06), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
p, li { text-wrap: pretty; }
.mono { font-family: var(--mono); letter-spacing: 0; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; padding: 0 28px;
  background: rgba(18, 17, 15, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform: scale(0.8);
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub {
  font-size: 11px; color: var(--muted); padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 999px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar form { margin: 0; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  gap: 28px; padding: 28px; max-width: 1480px; margin: 0 auto; align-items: start;
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
  .topbar { padding: 0 16px; }
  .brand-sub { display: none; }
}

/* ---------- Composer ---------- */
.composer {
  position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 24px; max-height: calc(100vh - 116px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--raised-2) transparent;
}
@media (max-width: 1000px) { .composer { position: static; max-height: none; padding: 18px; } }
.composer-head { display: grid; gap: 6px; margin-bottom: 22px; }
.composer-head p { font-size: 14px; }
.block { display: grid; gap: 8px; margin-bottom: 22px; }
.label {
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.09em; color: var(--faint);
}
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.hint:empty { display: none; }

/* Segmented mode control */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.segment {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.25;
  padding: 9px 8px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.segment:hover { color: var(--text); background: var(--raised); }
.segment[aria-selected="true"] { color: var(--text); background: var(--raised-2); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* Inputs */
.prompt-wrap { position: relative; }
textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
textarea { min-height: 132px; padding: 14px 14px 30px; resize: vertical; line-height: 1.55; }
textarea::placeholder { color: var(--faint); }
textarea:hover, select:hover { border-color: rgba(255, 238, 214, 0.24); }
textarea:focus, select:focus { outline: none; border-color: var(--accent); background: #15130f; }
.prompt-counter { position: absolute; right: 12px; bottom: 9px; font-size: 11px; color: var(--faint); pointer-events: none; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding: 10px 34px 10px 12px; font-size: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239b938a' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
select:disabled { cursor: not-allowed; color: var(--muted); opacity: 0.8; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }

/* Buttons */
button, .button-like, .link-button {
  font: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.08s var(--ease), color 0.15s var(--ease);
}
button:active, .button-like:active { transform: translateY(1px) scale(0.99); }
.primary {
  min-height: 46px; padding: 0 22px; border-radius: var(--radius); border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 24px -10px rgba(240, 166, 74, 0.55);
}
.primary:hover { background: var(--accent-strong); }
.primary:disabled { background: var(--raised-2); color: var(--faint); box-shadow: none; cursor: not-allowed; transform: none; }
.ghost, .button-like {
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); border: 1px solid var(--line-strong); font-size: 14px;
}
.ghost:hover, .button-like:hover { background: var(--raised); border-color: rgba(255, 238, 214, 0.26); }
.small { min-height: 32px; font-size: 13px; }
.link-button { color: var(--accent); font-size: 13px; font-weight: 500; background: none; border: 0; padding: 2px 4px; }
.link-button:hover { color: var(--accent-strong); }

/* Frames */
.frame-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frame-slot { display: grid; gap: 8px; }
.slot-top { display: flex; align-items: center; justify-content: space-between; }
.slot-title { font-size: 13px; color: var(--muted); }
.empty-slot {
  width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; font: inherit; font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer;
}
.empty-slot:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Dropzone */
.dropzone {
  display: grid; justify-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 22px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.dropzone strong { font-size: 14px; font-weight: 500; }
.dropzone .mono { font-size: 11.5px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  width: 28px; height: 28px; margin-bottom: 4px; border-radius: 8px; background: var(--raised-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m0 0l-4 4m4-4l4 4M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2'/%3E%3C/svg%3E") center / 20px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m0 0l-4 4m4-4l4 4M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2'/%3E%3C/svg%3E") center / 20px no-repeat;
  background-color: var(--muted);
}

/* File cards */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.file-grid:empty { display: none; }
.file-card {
  position: relative; display: grid; overflow: hidden;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
  animation: rise 0.25s var(--ease);
}
.file-card img, .file-card video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #000; }
.file-card audio { width: calc(100% - 16px); margin: 12px 8px 4px; height: 36px; }
.no-preview { aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 12px; color: var(--faint); }
.file-info { display: grid; padding: 8px 10px 9px; font-size: 11.5px; gap: 1px; }
.file-info .muted { font-family: var(--mono); font-size: 10.5px; }
.file-name { color: var(--text); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remove {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%; font-size: 11px; color: #fff;
  background: rgba(10, 9, 8, 0.7); backdrop-filter: blur(6px); opacity: 0.85;
}
.remove:hover { background: var(--bad); opacity: 1; }

.counters {
  margin: -8px 0 22px; padding: 8px 12px; font-size: 12px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.errors { margin: 0 0 16px; padding: 10px 14px 10px 30px; font-size: 13px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); }
.errors:empty { display: none; }
.errors li + li { margin-top: 3px; }

/* Footer */
.composer-footer {
  position: sticky; bottom: -24px; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 -24px -24px; padding: 16px 24px 24px;
  background: linear-gradient(to bottom, rgba(25, 23, 20, 0.92), var(--surface) 30%);
  border-top: 1px solid var(--line);
}
@media (max-width: 1000px) { .composer-footer { position: static; margin: 0; padding: 18px 0 0; background: none; } }
.estimate { display: grid; gap: 2px; }
.estimate strong { font-size: 22px; font-weight: 500; }
.progress { position: relative; margin-top: 14px; height: 30px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); border-right: 1px solid var(--accent); transition: width 0.2s linear; }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 28px; color: var(--muted); }
#submit-error { margin-top: 12px; }

/* ---------- Reel ---------- */
.reel { min-width: 0; }
.reel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 2px 18px; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 20px; }

.job {
  display: grid; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  animation: rise 0.35s var(--ease);
}
.job-media { position: relative; background: #0b0a09; aspect-ratio: 16 / 9; }
.job-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.job-info { display: grid; gap: 10px; padding: 16px 18px 18px; }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 999px;
  color: var(--accent); background: var(--accent-soft);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.job.queued .badge::before, .job.running .badge::before { animation: pulse 1.4s ease-in-out infinite; }
.job.succeeded .badge { color: var(--ok); background: var(--ok-soft); }
.job.failed .badge, .job.cancelled .badge { color: var(--bad); background: var(--bad-soft); }
.job.expired .badge { color: var(--muted); background: var(--raised); }
.job-cost { font-size: 13px; color: var(--muted); }
.job-prompt { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.job-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.job-time { font-size: 12px; color: var(--faint); }
.download { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }
.download:hover { background: var(--accent-strong); border-color: transparent; }

/* Pending frame */
.pending {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center;
  background:
    repeating-linear-gradient(90deg, rgba(255, 238, 214, 0.025) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, rgba(255, 238, 214, 0.025) 0 1px, transparent 1px 48px),
    #0d0c0a;
  overflow: hidden;
}
.pending::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(240, 166, 74, 0.08) 50%, transparent 70%);
  transform: translateX(-100%); animation: sweep 2.4s var(--ease) infinite;
}
.pending-title { font-size: 15px; font-weight: 500; }
.pending-sub { font-size: 12px; color: var(--muted); }
.elapsed { font-size: 28px; font-weight: 500; color: var(--text); }
.media-note { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; font-size: 14px; color: var(--muted); }
.media-note.error { color: var(--bad); }

/* Expiry */
.expiry {
  display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.4;
  padding: 8px 11px; border-radius: var(--radius-sm); color: var(--accent); background: var(--accent-soft);
}
.expiry::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.expiry.urgent { color: var(--bad); background: var(--bad-soft); }

/* Empty state */
.empty { display: grid; justify-items: center; gap: 6px; padding: 72px 20px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.empty-frame {
  width: min(260px, 70%); aspect-ratio: 16 / 9; margin-bottom: 14px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--faint); font-size: 12px;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 238, 214, 0.03) 10px 11px);
}

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.login-card .brand { margin-bottom: 10px; }
.login-card input {
  font: inherit; color: var(--text); padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line-strong);
}
.login-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
