:root {
  --bg: #0d0e13; --surface: #16181f; --surface-2: #1e212c; --line: #292d3b; --line-strong: #3b4055;
  --ink: #f2f3f7; --sub: #a9aec2; --weak: #767c94;
  --accent: #ff7a59; --accent-2: #b46bff; --accent-ink: #1a0d08; --accent-soft: rgba(255, 122, 89, .14);
  --ok: #5fd0a0; --ok-soft: rgba(95, 208, 160, .14); --warn: #f0c060; --warn-soft: rgba(240, 192, 96, .14); --danger: #ff6b7a; --danger-soft: rgba(255, 107, 122, .14);
  --radius: 14px; --radius-sm: 9px;
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --line: #e2dfd6; --line-strong: #c9c5b9;
    --ink: #1b1c22; --sub: #575b6b; --weak: #858999;
    --accent: #dc4f2a; --accent-2: #7c3aed; --accent-ink: #ffffff; --accent-soft: rgba(220, 79, 42, .1);
    --ok: #1f8a5c; --ok-soft: rgba(31, 138, 92, .1); --warn: #946500; --warn-soft: rgba(148, 101, 0, .1); --danger: #c8324a; --danger-soft: rgba(200, 50, 74, .1);
    color-scheme: light;
  }
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding-top: 28px; padding-bottom: 80px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.03em; text-wrap: balance; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
ol, ul { list-style: none; padding: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--sub); font-size: 14px; }
.eyebrow { font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.lead { color: var(--sub); font-size: 17px; max-width: 40em; }

/* Header and footer */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; height: 60px; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.03em; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 999px; font-size: 14.5px; font-weight: 600; color: var(--sub); text-decoration: none; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current] { color: var(--ink); background: var(--surface-2); }
.header-side { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.system { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--sub); white-space: nowrap; }
.system::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--weak); }
.system[data-state=ok]::before { background: var(--ok); }
.system[data-state=busy]::before { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.system[data-state=off]::before { background: var(--danger); }
.key-toggle { border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 5px 13px; font-size: 13px; font-weight: 600; color: var(--sub); cursor: pointer; white-space: nowrap; }
.key-toggle:hover { background: var(--surface-2); color: var(--ink); }
.key-toggle.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.site-footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--weak); font-size: 13px; }
@keyframes pulse { 50% { opacity: .35; } }

/* Controls */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s, border-color .15s, opacity .15s; }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }
.button-secondary { background: transparent; border-color: var(--line-strong); }
.button-secondary:hover:not(:disabled) { background: var(--surface-2); }
.button-quiet { background: transparent; color: var(--sub); padding: 0 12px; }
.button-quiet:hover { background: var(--surface-2); color: var(--ink); }
.button-wide { width: 100%; }
.danger, .button-quiet.danger:hover { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label, legend { display: block; font-size: 13.5px; font-weight: 700; color: var(--sub); padding: 0; }
.legend-note { font-weight: 400; color: var(--weak); margin-left: 6px; }
input, textarea, select { width: 100%; display: block; margin-top: 6px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 15.5px; font-weight: 400; color: var(--ink); }
textarea { resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--weak); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
fieldset { border: 0; padding: 0; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.notice { margin-bottom: 18px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14.5px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.key-form { display: grid; grid-template-columns: auto minmax(0, 320px) auto; align-items: center; gap: 8px 12px; margin-bottom: 24px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.key-form input { margin: 0; }
.key-form .muted { grid-column: 1 / -1; font-size: 13px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.more { font-size: 14px; color: var(--sub); text-decoration: none; }
.more:hover { color: var(--ink); }

/* Studio: hero + pipeline */
.hero { padding: 32px 0 26px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin-bottom: 14px; }
.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.pipeline li { display: flex; align-items: center; gap: 12px; padding: 14px 18px; position: relative; min-width: 0; }
.pipeline li + li { border-left: 1px solid var(--line); }
.pipeline li + li::before { content: '→'; position: absolute; left: -8px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; display: grid; place-items: center; font-size: 11px; line-height: 1; color: var(--weak); background: var(--surface); border-radius: 50%; }
.step-no { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; font-family: var(--mono); background: var(--surface-2); color: var(--sub); }
.pipeline li[data-state=ok] .step-no { background: var(--ok-soft); color: var(--ok); }
.pipeline li[data-state=basic] .step-no { background: var(--warn-soft); color: var(--warn); }
.pipeline li[data-state=off] .step-no { background: var(--danger-soft); color: var(--danger); }
.pipeline strong { display: block; font-size: 14.5px; line-height: 1.3; }
.pipeline small { display: block; font-size: 12.5px; color: var(--weak); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline li[data-state=off] small { color: var(--danger); }
.pipeline li[data-state=basic] small { color: var(--warn); }
.pipeline li > div { min-width: 0; }

/* Studio: composer */
.composer { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head label { font-size: 16px; color: var(--ink); }
.counter { font-size: 12.5px; color: var(--weak); font-variant-numeric: tabular-nums; }
.story-card textarea { min-height: 300px; margin-top: 10px; font-size: 16px; line-height: 1.75; }
.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
.example-list { display: flex; flex-wrap: wrap; gap: 8px; }
.example { border: 1px dashed var(--line-strong); background: transparent; border-radius: 999px; padding: 4px 13px; font-size: 13.5px; color: var(--sub); cursor: pointer; }
.example:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }
.direction-card { display: grid; gap: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips label { position: relative; margin: 0; cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.chips span { display: block; padding: 7px 15px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 14.5px; font-weight: 600; color: var(--sub); transition: background .15s, color .15s, border-color .15s; }
.chips input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.mood-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.mood-chips span { border-radius: var(--radius-sm); padding: 8px 12px; line-height: 1.35; }
.mood-chips small { display: block; font-size: 11.5px; font-weight: 500; font-family: var(--mono); color: var(--weak); }
.mood-chips input:checked + span small { color: inherit; opacity: .8; }
.option-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.estimate { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.estimate div { display: flex; justify-content: space-between; gap: 12px; }
.estimate dt { color: var(--sub); }
.estimate dd { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.direction-card > .muted { font-size: 13px; margin-top: -8px; }

/* Project cards */
.recent { margin-top: 56px; }
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.project-list a { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.project-list a:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.cover { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2) repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--line) 55%, transparent) 10px 11px); display: grid; place-items: center; color: var(--weak); font-size: 13px; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-list .cover .status { position: absolute; top: 10px; left: 10px; }
.project-list .info { padding: 12px 14px 14px; display: grid; gap: 4px; }
.project-list strong { font-size: 15.5px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list small { color: var(--weak); font-size: 12.5px; }

/* Status badge */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--sub); }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cover .status { background: rgba(10, 10, 14, .72); color: #e6e7ee; backdrop-filter: blur(6px); }
.status[data-status=done] { color: var(--ok); }
.status[data-status=queued], .status[data-status=rendering] { color: var(--warn); }
.status[data-status=failed] { color: var(--danger); }
.cover .status[data-status=done] { color: #7be0b4; }
.cover .status[data-status=queued], .cover .status[data-status=rendering] { color: #f5cf7a; }
.cover .status[data-status=failed] { color: #ff8c98; }

/* Library */
.library-head { align-items: flex-end; flex-wrap: wrap; margin: 12px 0 22px; }
.library-head h1 { font-size: clamp(26px, 4vw, 34px); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; color: var(--sub); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed=true] { background: var(--surface-2); color: var(--ink); }
.empty { display: grid; justify-items: center; gap: 16px; padding: 64px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--sub); text-align: center; }

/* Project head */
.back { display: inline-block; color: var(--sub); font-size: 14px; text-decoration: none; margin-bottom: 16px; }
.back:hover { color: var(--ink); }
.project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.project-head h1 { font-size: clamp(26px, 4vw, 36px); margin-bottom: 8px; }
.project-meta { margin-top: 8px; font-size: 13px; color: var(--weak); }
.stepper { flex: none; display: flex; align-items: center; gap: 0; margin-top: 8px; }
.stepper li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: var(--weak); white-space: nowrap; }
.stepper li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); }
.stepper li + li { margin-left: 8px; padding-left: 34px; background: linear-gradient(var(--line-strong), var(--line-strong)) left center / 26px 2px no-repeat; }
.stepper li[data-state=done] { color: var(--sub); }
.stepper li[data-state=done]::before { background: var(--ok); border-color: var(--ok); }
.stepper li[data-state=now] { color: var(--ink); }
.stepper li[data-state=now]::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper li[data-state=failed] { color: var(--danger); }
.stepper li[data-state=failed]::before { background: var(--danger); border-color: var(--danger); }

/* Stage: player, progress, pending */
.stage { margin-bottom: 32px; }
.result { padding: 0; overflow: hidden; }
.result video { display: block; width: 100%; max-height: 72vh; aspect-ratio: 16 / 9; background: #000; }
.result-actions { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.progress { display: grid; gap: 14px; }
.progress-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.progress-top p { font-weight: 700; font-size: 17px; }
.progress-top .muted { font-family: var(--mono); font-size: 13px; }
progress { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .4s; }
progress::-moz-progress-bar { background: var(--accent); }
.progress-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.progress-steps li { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--weak); }
.progress-steps li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.progress-steps li[data-state=done] { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.progress-steps li[data-state=done]::before { background: var(--ok); }
.progress-steps li[data-state=now] { color: var(--accent); border-color: var(--accent); }
.progress-steps li[data-state=now]::before { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.pending { display: grid; gap: 4px; border-style: dashed; border-color: var(--line-strong); background: transparent; }
.pending.failed { border-style: solid; border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.pending.failed strong { color: var(--danger); }

/* Workspace: storyboard + side panel */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.scenes { display: grid; gap: 12px; counter-reset: scene; }
.scene { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; counter-increment: scene; position: relative; }
.scene-media { align-self: start; }
.scene .cover { border-radius: var(--radius-sm); overflow: hidden; }
.scene .cover::after { content: counter(scene); position: absolute; top: 8px; left: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 12.5px; font-weight: 700; font-family: var(--mono); display: grid; place-items: center; }
.scene .stale { position: absolute; left: 8px; bottom: 8px; padding: 2px 9px; border-radius: 999px; background: rgba(0, 0, 0, .72); color: #ffd58a; font-size: 12px; font-weight: 600; }
.timecode { margin-top: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--weak); text-align: center; }
.scene .fields { display: grid; gap: 12px; align-content: start; padding-right: 44px; }
.remove-scene { position: absolute; top: 12px; right: 12px; border: 0; background: transparent; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; color: var(--weak); cursor: pointer; }
.remove-scene:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.remove-scene:disabled { opacity: 0; pointer-events: none; }
.add-scene { width: 100%; margin-top: 12px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: transparent; color: var(--sub); font-weight: 600; cursor: pointer; }
.add-scene:hover { border-color: var(--accent); color: var(--accent); }
.side { position: sticky; top: 84px; display: grid; gap: 14px; }
.side-card { display: grid; gap: 14px; padding: 20px; }
.side-card .button + .button { margin-top: -4px; }
.story-source { padding: 0; }
.story-source summary { padding: 14px 20px; font-size: 14px; font-weight: 700; color: var(--sub); cursor: pointer; }
.story-source p { padding: 0 20px 18px; font-size: 14px; color: var(--sub); white-space: pre-wrap; max-height: 280px; overflow: auto; }
.side > .button-quiet { justify-self: start; font-size: 13.5px; min-height: 36px; }

@media (max-width: 960px) {
  .composer, .workspace { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .pipeline li:nth-child(3) { border-left: 0; }
  .pipeline li:nth-child(3)::before { display: none; }
  .pipeline li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .project-head { flex-direction: column-reverse; gap: 14px; }
  .stepper { margin-top: 0; }
}
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .header-inner { gap: 12px; }
  .system { display: none; }
  .nav a { padding: 6px 9px; }
  .hero { padding: 18px 0 20px; }
  .hero h1 br { display: none; }
  .card { padding: 18px; }
  .result { padding: 0; }
  .story-source { padding: 0; }
  .story-card textarea { min-height: 220px; }
  .pipeline li { padding: 12px; gap: 10px; }
  .key-form { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .library-head { align-items: flex-start; gap: 14px; }
  .scene { grid-template-columns: 1fr; }
  .scene .fields { padding-right: 0; }
  .remove-scene { background: rgba(0, 0, 0, .62); color: #fff; }
  .result-actions { flex-direction: column; align-items: stretch; text-align: center; }
  .project-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
