:root {
  --bg: #090b0f;
  --panel: #101319;
  --panel-2: #151920;
  --line: rgba(255,255,255,.11);
  --line-strong: rgba(255,255,255,.2);
  --text: #f4f5f7;
  --muted: #9299a7;
  --muted-2: #666e7d;
  --accent: #a6ffcb;
  --accent-2: #65eaa3;
  --danger: #ff7c7c;
  --radius: 18px;
  --ratio: 1.727;
  font-family: Pretendard, "Noto Sans KR", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; z-index: -1; width: 42vw; height: 42vw; border-radius: 50%; filter: blur(100px); opacity: .09; pointer-events: none; }
.ambient-a { top: -25vw; right: -10vw; background: #46ee9d; }
.ambient-b { bottom: -32vw; left: -18vw; background: #5b7cff; }

.boot-view { display: grid; place-items: center; align-content: center; min-height: 100vh; gap: 20px; color: var(--muted); letter-spacing: .05em; }
.boot-view p { margin: 0; font-size: 13px; }
.boot-line { width: 120px; height: 1px; overflow: hidden; background: var(--line); }
.boot-line::after { content: ""; display: block; width: 50%; height: 100%; background: var(--accent); animation: boot 1.2s ease-in-out infinite; }
@keyframes boot { from { transform: translateX(-110%); } to { transform: translateX(220%); } }

.wordmark { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 11px; font-weight: 700; letter-spacing: .18em; }
.brand-mark { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--accent); font-family: Georgia, serif; font-size: 15px; font-style: italic; letter-spacing: 0; }
.brand-mark-large { width: 54px; height: 54px; border-radius: 15px; font-size: 27px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .18em; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; }
.login-card { width: min(100%, 440px); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(155deg, rgba(23,27,34,.96), rgba(12,15,20,.96)); box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.login-copy { margin: 64px 0 34px; }
.login-copy h1 { margin: 10px 0 10px; font-size: clamp(28px, 7vw, 39px); line-height: 1.15; letter-spacing: -.045em; }
.login-copy p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.field-label { display: block; margin: 0 0 8px; color: #c7cbd3; font-size: 12px; font-weight: 650; }
input[type="text"], input[type="password"], input[type="number"], textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--text); background: rgba(5,7,10,.55); transition: border-color .2s, box-shadow .2s; }
input[type="text"], input[type="password"], input[type="number"] { height: 48px; padding: 0 14px; }
textarea { min-height: 112px; padding: 14px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(166,255,203,.65); box-shadow: 0 0 0 3px rgba(166,255,203,.08); }
.login-card input { margin-bottom: 19px; }
.password-field { position: relative; }
.password-field input { padding-right: 62px; }
.password-field .text-button { position: absolute; top: 12px; right: 13px; }
.text-button { min-height: 28px; padding: 3px 5px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.text-button:hover { color: var(--text); }
.text-button.danger:hover { color: var(--danger); }
.primary-button { min-height: 50px; border: 0; border-radius: 12px; color: #06130c; background: var(--accent); font-weight: 750; cursor: pointer; transition: transform .18s ease, background .18s ease, opacity .18s ease; }
.primary-button:hover:not(:disabled) { transform: translateY(-1px); background: #bdffd7; }
.primary-button:disabled { cursor: not-allowed; opacity: .35; }
.login-button { display: flex; width: 100%; align-items: center; justify-content: space-between; margin-top: 10px; padding: 0 17px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 22px 0 0; color: var(--muted-2); font-size: 10px; letter-spacing: .05em; }
.secure-note span { color: var(--accent); font-size: 6px; }
.form-error { margin: 8px 0 0; color: var(--danger); font-size: 12px; line-height: 1.5; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 66px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(9,11,15,.82); backdrop-filter: blur(18px); }
.topbar-center { display: flex; align-items: center; gap: 12px; }
.model-name { font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.model-separator { width: 1px; height: 14px; background: var(--line-strong); }
.status-chip { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.status-chip i { width: 6px; height: 6px; border-radius: 50%; background: #dfb95e; box-shadow: 0 0 10px currentColor; }
.status-chip.ready i { background: var(--accent-2); }
.status-chip.error i { background: var(--danger); }
.topbar-actions { display: flex; justify-self: end; align-items: center; gap: 15px; }
.queue-status { color: var(--muted); font-size: 11px; }
.ghost-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; color: #c8ccd4; background: transparent; cursor: pointer; font-size: 11px; }
.ghost-button:hover { border-color: var(--line-strong); color: var(--text); }

.studio { display: grid; grid-template-columns: minmax(380px, 470px) minmax(480px, 1fr); gap: 42px; width: min(1440px, 100%); margin: 0 auto; padding: 52px 44px 70px; }
.control-column { min-width: 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 38px; }
.section-heading h1 { margin: 8px 0 0; max-width: 390px; font-size: clamp(30px, 3vw, 44px); line-height: 1.08; letter-spacing: -.052em; }
.step-count { padding-bottom: 5px; color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.control-section { padding: 25px 0; border-top: 1px solid var(--line); }
.control-title { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.control-title span { color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.control-title h2, .result-heading h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }

.dropzone { display: grid; position: relative; place-items: center; min-height: 205px; overflow: hidden; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255,255,255,.018); cursor: pointer; transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.dragging { border-color: rgba(166,255,203,.58); background: rgba(166,255,203,.035); }
.dropzone:focus-within { box-shadow: 0 0 0 3px rgba(166,255,203,.09); }
.upload-empty { display: grid; place-items: center; gap: 7px; padding: 30px; text-align: center; }
.upload-empty strong { font-size: 13px; }
.upload-empty small { color: var(--muted-2); font-size: 10px; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 7px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); }
.upload-preview { width: 100%; aspect-ratio: var(--ratio); background: #050608; }
.upload-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.crop-badge { position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 6px; color: rgba(255,255,255,.75); background: rgba(0,0,0,.58); backdrop-filter: blur(7px); font-size: 9px; }
.file-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 11px; }
.file-meta > div:first-child { display: grid; min-width: 0; gap: 3px; }
.file-meta strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { color: var(--muted-2); font-size: 9px; }
.file-actions { display: flex; gap: 5px; flex: none; }
.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-bottom: 34px; }
.char-count { position: absolute; right: 12px; bottom: 11px; color: var(--muted-2); font-size: 9px; }
.field-help { margin: 8px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.55; }

fieldset { margin: 0 0 19px; padding: 0; border: 0; }
legend { margin-bottom: 9px; color: var(--muted); font-size: 10px; }
.segmented { display: grid; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4,6,9,.45); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented button { display: flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.segmented button[aria-pressed="true"] { color: var(--text); background: var(--panel-2); box-shadow: 0 2px 12px rgba(0,0,0,.24); }
.ratio-icon { display: inline-block; border: 1px solid currentColor; border-radius: 2px; opacity: .8; }
.ratio-icon.landscape { width: 14px; height: 8px; }
.ratio-icon.portrait { width: 7px; height: 12px; }
.ratio-icon.square { width: 10px; height: 10px; }
.audio-note { display: flex; align-items: center; gap: 8px; color: var(--muted-2); font-size: 10px; }
.audio-note > span:first-child { color: var(--accent); font-size: 8px; }

.advanced-settings { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-settings summary { display: flex; min-height: 62px; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; font-size: 13px; }
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary b { margin-right: 11px; color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; font-weight: 400; }
.summary-icon { color: var(--muted); transition: transform .2s; }
.advanced-settings[open] .summary-icon { transform: rotate(45deg); }
.advanced-body { padding: 5px 0 24px; }
.range-label { display: flex; justify-content: space-between; margin-bottom: 9px; color: #c7cbd3; font-size: 11px; }
.range-label output { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-ends { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted-2); font-size: 9px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin: 24px 0; cursor: pointer; }
.switch-row > span:first-child { display: grid; gap: 3px; }
.switch-row strong { font-size: 11px; }
.switch-row small { color: var(--muted-2); font-size: 9px; }
.switch { position: relative; width: 40px; height: 23px; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border: 1px solid var(--line-strong); border-radius: 20px; background: #1b2028; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + i { border-color: rgba(166,255,203,.4); background: rgba(166,255,203,.13); }
.switch input:checked + i::after { transform: translateX(17px); background: var(--accent); }
.seed-field { margin-bottom: 22px; }
.advanced-body .field-label em { color: var(--muted-2); font-style: normal; font-weight: 400; }
.advanced-body textarea { min-height: 78px; }

.generation-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 25px; }
.generation-summary { display: grid; gap: 4px; }
.generation-summary span { font-size: 10px; font-weight: 650; }
.generation-summary small { color: var(--muted-2); font-size: 9px; line-height: 1.4; }
.generate-button { display: flex; min-width: 190px; align-items: center; justify-content: space-between; padding: 0 15px 0 18px; }
.button-arrow { font-size: 17px; font-weight: 400; }

.result-column { min-width: 0; }
.result-heading { display: flex; align-items: flex-end; justify-content: space-between; min-height: 48px; margin-bottom: 18px; }
.result-heading h2 { margin-top: 7px; font-size: 20px; }
.result-meta { color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.result-stage { display: grid; position: sticky; top: 88px; min-height: min(66vh, 720px); overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #07090c; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.empty-state, .working-state, .error-state { display: grid; place-items: center; align-content: center; padding: 35px; text-align: center; }
.empty-state h3, .working-state h3, .error-state h3 { margin: 20px 0 7px; font-size: 15px; }
.empty-state p, .working-state p, .error-state p { max-width: 380px; margin: 0; color: var(--muted-2); font-size: 11px; line-height: 1.6; }
.frame-lines { position: absolute; inset: 18px; pointer-events: none; }
.frame-lines i { position: absolute; width: 20px; height: 20px; border-color: rgba(255,255,255,.12); border-style: solid; }
.frame-lines i:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.frame-lines i:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.frame-lines i:nth-child(3) { right: 0; bottom: 0; border-width: 0 1px 1px 0; }
.frame-lines i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.empty-orbit { width: 74px; height: 74px; border: 1px solid var(--line); border-radius: 50%; box-shadow: inset 0 0 30px rgba(166,255,203,.035); }
.empty-orbit::after { content: ""; display: block; width: 6px; height: 6px; margin: 6px auto 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 15px var(--accent); }
.working-state { width: min(100%, 500px); justify-self: center; }
.working-visual { display: flex; height: 82px; align-items: end; gap: 7px; margin-bottom: 23px; }
.working-visual span { width: 2px; height: 35%; background: var(--accent); opacity: .55; animation: pulse 1.2s ease-in-out infinite; }
.working-visual span:nth-child(2) { height: 100%; animation-delay: -.35s; }
.working-visual span:nth-child(3) { height: 58%; animation-delay: -.7s; }
@keyframes pulse { 0%,100% { transform: scaleY(.35); opacity: .25; } 50% { transform: scaleY(1); opacity: .95; } }
.working-state h3 { margin-top: 9px; font-size: 20px; }
.progress-track { width: 100%; height: 2px; margin-top: 34px; overflow: hidden; background: rgba(255,255,255,.1); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .5s ease; }
.progress-meta { display: flex; width: 100%; justify-content: space-between; margin-top: 9px; color: var(--muted-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.cancel-button { margin-top: 28px; }
.video-state { display: grid; grid-template-rows: 1fr auto; min-height: 100%; }
.video-state video { width: 100%; height: 100%; min-height: 420px; object-fit: contain; background: #000; }
.video-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 18px; border-top: 1px solid var(--line); background: var(--panel); }
.video-actions > div { display: grid; gap: 4px; }
.video-actions strong { font-size: 11px; }
.video-actions span { color: var(--muted-2); font-size: 9px; }
.download-button { display: inline-flex; min-height: 40px; align-items: center; gap: 12px; padding: 0 13px; text-decoration: none; font-size: 10px; }
.error-symbol { display: grid; place-items: center; width: 50px; height: 50px; border: 1px solid rgba(255,124,124,.45); border-radius: 50%; color: var(--danger); }
.error-state .primary-button { margin-top: 24px; padding: 0 22px; }

.history { margin-top: 30px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.history-heading h3 { margin: 0; font-size: 12px; }
.history-list { display: grid; gap: 7px; }
.history-empty { margin: 0; padding: 18px 0; color: var(--muted-2); font-size: 10px; }
.history-item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 11px; color: inherit; text-align: left; background: rgba(255,255,255,.015); cursor: pointer; }
.history-item:hover { border-color: var(--line-strong); }
.history-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.history-item[data-status="succeeded"] .history-dot { background: var(--accent); }
.history-item[data-status="failed"] .history-dot { background: var(--danger); }
.history-copy { display: grid; min-width: 0; gap: 3px; }
.history-copy strong { overflow: hidden; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.history-copy small, .history-state { color: var(--muted-2); font-size: 9px; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(390px, calc(100vw - 44px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 11px; color: #d8dbe1; background: rgba(22,26,33,.96); box-shadow: 0 14px 45px rgba(0,0,0,.35); font-size: 11px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 980px) {
  .studio { grid-template-columns: 1fr; width: min(720px, 100%); padding: 38px 24px 70px; }
  .result-stage { position: relative; top: auto; min-height: 540px; }
}

@media (max-width: 620px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 60px; padding: 0 16px; }
  .topbar-center { grid-row: 2; grid-column: 1 / -1; justify-content: center; padding: 0 0 10px; }
  .topbar-actions { gap: 8px; }
  .queue-status, .wordmark-full { display: none; }
  .studio { gap: 34px; padding: 30px 16px calc(45px + env(safe-area-inset-bottom)); }
  .section-heading h1 { font-size: 34px; }
  .step-count { display: none; }
  .dropzone { min-height: 180px; }
  .generation-footer { position: sticky; z-index: 10; bottom: 0; margin: 0 -16px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(9,11,15,.94); backdrop-filter: blur(18px); }
  .generation-summary { display: none; }
  .generate-button { width: 100%; }
  .result-stage { min-height: 470px; }
  .video-state video { min-height: 360px; }
  .video-actions { align-items: stretch; flex-direction: column; }
  .download-button { justify-content: space-between; }
  .login-card { padding: 26px 22px; }
  .login-copy { margin-top: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
