:root {
  --bg: #0b0b12;
  --bg2: #12121c;
  --panel: #171724;
  --panel2: #1e1e2e;
  --line: #2a2a3d;
  --text: #ececf4;
  --muted: #9a9ab3;
  --accent: #7c5cff;
  --accent2: #ff3b7f;
  --ok: #2ecc71;
  --warn: #f5a623;
  --err: #ff4d4f;
  --radius: 14px;
  --grad: linear-gradient(135deg, #7c5cff 0%, #ff3b7f 100%);
  font-family: Inter, "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 14px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--line); background: var(--panel2);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; transition: .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #44445f; background: #25253a; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 24px -8px #7c5cff99; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { padding: 14px 26px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #7c5cff33; }
textarea { resize: vertical; min-height: 90px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 40px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: none; padding: 2px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span, .label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 6px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: #2ecc7144; background: #2ecc7114; }
.pill.warn { color: var(--warn); border-color: #f5a62344; background: #f5a62314; }
.pill.err { color: var(--err); border-color: #ff4d4f44; background: #ff4d4f14; }
.pill.hot { color: #fff; background: var(--grad); border: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }

/* ---------- top nav ---------- */
.topnav { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 10px 20px;
  background: #0b0b12e6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; margin-right: 18px; text-decoration: none; }
.logo b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topnav .nav a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.topnav .nav a.active, .topnav .nav a:hover { color: var(--text); background: var(--panel2); }
.topnav .spacer { flex: 1; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .hero { background: radial-gradient(circle at 20% 20%, #7c5cff55, transparent 50%), radial-gradient(circle at 80% 70%, #ff3b7f44, transparent 50%), var(--bg2);
  padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.auth .hero h1 { font-size: 44px; }
.auth .hero ul { color: var(--muted); padding-left: 18px; font-size: 15px; }
.auth .hero li { margin: 6px 0; }
.auth form { align-self: center; justify-self: center; width: min(400px, 90vw); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth .hero { padding: 30px 20px; } .auth .hero h1 { font-size: 30px; } }

/* ---------- dashboard ---------- */
.grid-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-top: 18px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: .15s; }
.pcard:hover { transform: translateY(-2px); border-color: #44445f; }
.pcard .thumb { aspect-ratio: 9/14; background: var(--grad); background-size: cover; background-position: center; position: relative; }
.pcard .thumb .pill { position: absolute; top: 8px; left: 8px; }
.pcard .meta { padding: 10px 12px; }
.pcard .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .acts { display: flex; gap: 4px; padding: 0 8px 10px; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .big { font-size: 54px; }

/* ---------- wizard ---------- */
.wizard { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .wizard { grid-template-columns: 1fr; } }
.section { margin-bottom: 22px; }
.section .label .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--grad); color: #fff; font-size: 11px; margin-right: 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice { border: 1.5px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px; cursor: pointer; transition: .15s; position: relative; }
.choice:hover { border-color: #4a4a68; }
.choice.on { border-color: var(--accent); background: #7c5cff18; box-shadow: 0 0 0 3px #7c5cff22; }
.choice .t { font-weight: 700; }
.choice .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.choice .flag { font-size: 26px; }
.market { grid-template-columns: 1fr 1fr; }
.market .choice { padding: 18px; display: flex; gap: 12px; align-items: center; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: 0 1px 0 #ffffff10 inset; }
.styles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.style-card .sample { height: 86px; border-radius: 8px; margin-bottom: 10px; display: grid; place-items: center; text-align: center; padding: 8px;
  background: linear-gradient(160deg, #2b2b44, #0e0e18); overflow: hidden; font-size: 22px; line-height: 1.1; }
.style-card .hot { position: absolute; top: 8px; right: 8px; }
.side-sticky { position: sticky; top: 74px; }
.summary dt { color: var(--muted); font-size: 12px; }
.summary dd { margin: 0 0 10px; font-weight: 600; }
details.adv { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); }
details.adv summary { cursor: pointer; font-weight: 700; }
.prov-list { display: flex; flex-wrap: wrap; gap: 6px; }
.prov { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-size: 13px; user-select: none; }
.prov.on { border-color: var(--accent); background: #7c5cff22; }
.prov.off { opacity: .45; cursor: not-allowed; }

/* ---------- progress ---------- */
.progress-wrap { max-width: 860px; margin: 0 auto; }
.bar { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); width: 0; transition: width .5s; }
.lanes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 18px 0; }
.lane { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; }
.lane .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.lane.running .dot { background: var(--warn); animation: pulse 1s infinite; }
.lane.done .dot { background: var(--ok); }
.lane.error .dot { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }
.log { background: #07070c; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; max-height: 280px; overflow: auto; }
.log div { padding: 2px 0; }
.log .warn { color: var(--warn); }
.log .error { color: var(--err); }

/* ---------- studio ---------- */
.studio { display: grid; grid-template-columns: 340px 1fr 340px; height: calc(100vh - 57px); }
.studio > * { min-height: 0; }
.studio .col { overflow: auto; padding: 14px; border-right: 1px solid var(--line); }
.studio .col:last-child { border-right: 0; border-left: 1px solid var(--line); }
.studio .center { display: flex; flex-direction: column; align-items: center; padding: 14px; gap: 10px; overflow: hidden; background: radial-gradient(circle at 50% 30%, #1a1a2a, var(--bg)); }
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.stage canvas { height: 100%; max-height: 100%; aspect-ratio: 9/16; max-width: 100%; border-radius: 14px; box-shadow: 0 20px 60px -20px #000; background: #000; }
.transport { display: flex; align-items: center; gap: 10px; width: min(520px, 100%); }
.transport input[type=range] { flex: 1; }
.timecode { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); min-width: 90px; text-align: right; }
.studio-head { display: flex; align-items: center; gap: 8px; width: 100%; }
.studio-head input { font-weight: 700; font-size: 15px; background: transparent; border-color: transparent; }
.studio-head input:hover { border-color: var(--line); }
.scene { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; transition: .15s; }
.scene.active { border-color: var(--accent); box-shadow: 0 0 0 2px #7c5cff33; }
.scene .head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.scene .head b { color: var(--text); }
.scene textarea { min-height: 54px; font-size: 13.5px; padding: 8px; }
.scene .vis { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.scene .vis .thumb { width: 44px; height: 70px; border-radius: 6px; background: var(--grad); background-size: cover; background-position: center; flex: none; display: grid; place-items: center; font-size: 10px; }
.scene .tools { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -14px -14px 14px; padding: 0 8px; position: sticky; top: -14px; background: var(--bg); z-index: 2; }
.tabs button { border: 0; background: none; padding: 12px 10px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; align-items: center; margin-bottom: 14px; }
.kv > span { font-size: 12.5px; color: var(--muted); }
.copybox { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 13px; white-space: pre-wrap; position: relative; margin-bottom: 8px; }
.copybox .btn { position: absolute; top: 6px; right: 6px; }
@media (max-width: 1100px) { .studio { grid-template-columns: 1fr; height: auto; } .studio .center { height: 80vh; } .studio .col { border: 0; } }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 26px; font-weight: 800; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid #22223a; vertical-align: middle; }
.tbl select, .tbl input { padding: 5px 8px; font-size: 12.5px; width: auto; }
.provider-row { display: grid; grid-template-columns: 220px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.provider-row:last-child { border-bottom: 0; }
.provider-row .models { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 8px; }
@media (max-width: 800px) { .provider-row { grid-template-columns: 1fr; } }

/* ---------- modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(460px, 100%); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(820px, 100%); }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 10px; max-width: 380px; box-shadow: 0 10px 30px #0008; transition: .3s; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateX(20px); }
.spinner { width: 16px; height: 16px; border: 2px solid #fff4; border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.export-overlay { position: fixed; inset: 0; background: #000c; z-index: 90; display: grid; place-items: center; }
.export-overlay .card { width: min(440px, 90vw); text-align: center; }
