/* ===========================================================================
   SEEGEN — design system
   =========================================================================== */
:root {
  --bg:        #08080c;
  --bg-2:      #0d0d14;
  --panel:     #101019;
  --panel-2:   #16161f;
  --line:      #22222e;
  --line-2:    #2c2c3a;
  --text:      #ececf2;
  --muted:     #8b8b9e;
  --muted-2:   #5f5f72;
  --brand:     #7c5cff;
  --brand-2:   #a48bff;
  --accent:    #00e0c6;
  --danger:    #ff5c72;
  --warn:      #ffb648;
  --radius:    14px;
  --radius-lg: 20px;
  --shadow:    0 18px 50px rgba(0,0,0,.55);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(124,92,255,.16), transparent 60%),
    radial-gradient(760px 480px at 92% 4%, rgba(0,224,198,.10), transparent 62%);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(124,92,255,.35); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #23232f; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #32323f; }

/* boot spinner */
.boot { display: grid; place-items: center; height: 100vh; }
.boot-ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(124,92,255,.25); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ layout ============================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 60px;
  background: rgba(8,8,12,.82);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.02em; font-size: 16px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(140deg, var(--brand), var(--accent));
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}
.brand-mark::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #0a0a10; }
.brand small { color: var(--muted-2); font-weight: 500; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

.topbar-spacer { flex: 1; }

.credit-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 600;
}
.credit-pill b { color: var(--accent); font-variant-numeric: tabular-nums; }
.credit-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ============================ buttons ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-2);
  font-size: 14px; font-weight: 550; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #1d1d29; border-color: #3a3a4a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(140deg, var(--brand), #6a49f2);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 20px rgba(124,92,255,.32);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(140deg, var(--brand-2), var(--brand)); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }

/* ============================ landing ============================ */
.landing { flex: 1; }
.hero { max-width: 1080px; margin: 0 auto; padding: 88px 24px 56px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; margin-bottom: 26px;
  background: rgba(124,92,255,.10); border: 1px solid rgba(124,92,255,.28);
  font-size: 12.5px; color: var(--brand-2); font-weight: 550;
}
.hero h1 {
  margin: 0 0 18px; font-size: clamp(38px, 6.4vw, 68px); line-height: 1.04;
  letter-spacing: -.035em; font-weight: 680;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand-2) 10%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { margin: 0 auto 34px; max-width: 620px; color: var(--muted); font-size: 17.5px; line-height: 1.65; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 18px; color: var(--muted-2); font-size: 13px; }

.strip { max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }
.strip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; }
.strip-card {
  padding: 22px; border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); text-align: left;
}
.strip-card .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(124,92,255,.12); color: var(--brand-2); margin-bottom: 14px; }
.strip-card h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 620; letter-spacing: -.01em; }
.strip-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.6; }

/* ============================ auth ============================ */
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 48px 20px 80px; }
.auth-card {
  width: 100%; max-width: 410px; padding: 34px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.02em; font-weight: 640; }
.auth-card .sub { margin: 0 0 26px; color: var(--muted); font-size: 14px; }
.auth-switch { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-switch button { background: none; border: none; color: var(--brand-2); cursor: pointer; font-weight: 550; padding: 0; }
.auth-switch button:hover { text-decoration: underline; }

/* ============================ forms ============================ */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field .hint { margin-top: 6px; font-size: 12px; color: var(--muted-2); }
.input, .textarea, .select {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  transition: border-color .15s, box-shadow .15s; font-size: 14.5px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124,92,255,.16);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.select { appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%238b8b9e' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.check span { font-size: 14px; color: var(--text); }

.alert {
  padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.5;
  background: rgba(255,92,114,.10); border: 1px solid rgba(255,92,114,.32); color: #ffa8b5;
}
.alert-warn { background: rgba(255,182,72,.10); border-color: rgba(255,182,72,.32); color: #ffd08a; }

/* ============================ studio ============================ */
.studio { flex: 1; display: grid; grid-template-columns: 232px 372px 1fr; min-height: 0; }
@media (max-width: 1180px) { .studio { grid-template-columns: 200px 340px 1fr; } }

.rail {
  border-right: 1px solid var(--line); padding: 18px 12px;
  background: var(--bg-2); overflow-y: auto;
}
.rail-title { padding: 0 10px; margin: 0 0 12px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.rail-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 11px; margin-bottom: 3px; border-radius: 10px;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--muted); font-size: 14px; font-weight: 520;
  transition: background .13s, color .13s;
}
.rail-item:hover { background: var(--panel); color: var(--text); }
.rail-item.active { background: rgba(124,92,255,.13); color: #fff; }
.rail-item.active .rail-ico { color: var(--brand-2); }
.rail-ico { display: grid; place-items: center; width: 18px; flex: none; color: var(--muted-2); }
.rail-count { margin-left: auto; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.rail-sep { height: 1px; background: var(--line); margin: 16px 6px; }

.config { border-right: 1px solid var(--line); padding: 20px; overflow-y: auto; background: var(--bg); }
.canvas { padding: 24px; overflow-y: auto; background: var(--bg); min-width: 0; }

/* model picker */
.model-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.model-card {
  padding: 13px 14px; border-radius: 12px; cursor: pointer; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color .14s, background .14s;
}
.model-card:hover { border-color: var(--line-2); background: var(--panel-2); }
.model-card.active { border-color: var(--brand); background: rgba(124,92,255,.09); }
.model-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.model-name { font-weight: 620; font-size: 14.5px; letter-spacing: -.01em; }
.model-blurb { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.model-meta { display: flex; align-items: center; gap: 10px; margin-top: 9px; font-size: 11.5px; color: var(--muted-2); }
.model-price { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 640; font-variant-numeric: tabular-nums; }

.tag {
  padding: 2px 7px; border-radius: 5px; font-size: 9.5px; font-weight: 720;
  letter-spacing: .07em; text-transform: uppercase;
}
.tag-ultra { background: rgba(124,92,255,.18); color: var(--brand-2); }
.tag-pro   { background: rgba(0,224,198,.14); color: var(--accent); }
.tag-fast  { background: rgba(255,182,72,.14); color: var(--warn); }

.section-label {
  margin: 0 0 11px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2);
}

/* dropzone */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 20px;
  text-align: center; cursor: pointer; background: var(--bg-2);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: rgba(124,92,255,.06); }
.drop p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.drop small { color: var(--muted-2); font-size: 11.5px; }
.drop-preview { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); }
.drop-preview img { display: block; width: 100%; max-height: 190px; object-fit: contain; background: #000; }
.drop-clear {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 7px;
  background: rgba(0,0,0,.72); border: 1px solid rgba(255,255,255,.14); color: #fff;
  cursor: pointer; display: grid; place-items: center; backdrop-filter: blur(4px);
}
.drop-clear:hover { background: rgba(0,0,0,.9); }

/* run bar */
.run-bar { position: sticky; bottom: 0; padding-top: 16px; margin-top: 20px; background: linear-gradient(180deg, transparent, var(--bg) 22%); }
.run-cost { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; font-size: 13px; color: var(--muted); }
.run-cost b { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ============================ canvas ============================ */
.canvas-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.canvas-head h2 { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -.015em; }
.canvas-head .sp { flex: 1; }

.empty { display: grid; place-items: center; min-height: 60vh; text-align: center; padding: 24px; }
.empty-ico {
  width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted-2);
}
.empty h3 { margin: 0 0 7px; font-size: 17px; font-weight: 620; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; max-width: 380px; }

.results { display: flex; flex-direction: column; gap: 18px; }
.result {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden;
}
.result-top {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.result-model { font-weight: 620; }
.result-prompt {
  color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0; font-size: 12.5px;
}
.result-body { padding: 16px; }
.result-actions { display: flex; gap: 8px; padding: 0 16px 16px; }

.media-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.media { border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.media img, .media video { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.media audio { display: block; width: 100%; padding: 14px; background: var(--panel-2); }

/* progress */
.progress { display: flex; align-items: center; gap: 13px; padding: 20px 16px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 2.5px solid rgba(124,92,255,.22); border-top-color: var(--brand);
  animation: spin .75s linear infinite;
}
.progress-text { font-size: 13.5px; color: var(--muted); }
.progress-text b { color: var(--text); font-weight: 580; display: block; margin-bottom: 2px; font-size: 14px; }
.bar { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 9px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 3px; transition: width .5s ease; }

.status-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 620;
}
.chip-done { background: rgba(0,224,198,.13); color: var(--accent); }
.chip-failed { background: rgba(255,92,114,.13); color: var(--danger); }
.chip-pending { background: rgba(124,92,255,.13); color: var(--brand-2); }

/* history */
.hist-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); }
.hist-item {
  position: relative; border-radius: 12px; overflow: hidden; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); aspect-ratio: 1;
}
.hist-item img, .hist-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.hist-item .ph { display: grid; place-items: center; height: 100%; color: var(--muted-2); }
.hist-cap {
  position: absolute; inset: auto 0 0 0; padding: 18px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.88));
  font-size: 11px; color: #d8d8e4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* toast */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  padding: 12px 16px; border-radius: 11px; max-width: 340px; font-size: 13.5px;
  background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: slideIn .22s cubic-bezier(.2,.9,.3,1);
}
.toast.err { border-color: rgba(255,92,114,.42); color: #ffa8b5; }
.toast.ok { border-color: rgba(0,224,198,.42); color: #7ff0e2; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(0,0,0,.90); padding: 32px; backdrop-filter: blur(6px);
}
.lightbox img, .lightbox video { max-width: 100%; max-height: 88vh; border-radius: 12px; display: block; }
.lightbox-close {
  position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}

/* mobile */
.mob-tabs { display: none; }
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .rail, .config, .canvas { border-right: none; }
  .rail { display: none; }
  .studio[data-mob="create"] .canvas { display: none; }
  .studio[data-mob="results"] .config { display: none; }
  .mob-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px;
    position: sticky; top: 60px; z-index: 40;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .mob-tab { padding: 9px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; font-size: 13.5px; font-weight: 560; color: var(--muted); }
  .mob-tab.active { background: rgba(124,92,255,.14); color: #fff; border-color: rgba(124,92,255,.4); }
  .hero { padding: 56px 20px 40px; }
}

/* ===================== admin (rendered inside the studio) ================= */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 22px; }
.kpi { padding: 13px 15px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.kpi b { display: block; font-size: 23px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

.canvas table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.canvas th { text-align: left; padding: 9px 11px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap; }
.canvas td { padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.canvas tbody tr:hover td { background: rgba(255,255,255,.02); }
.canvas .num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-2); }
.ok { color: var(--accent); }
.bad { color: var(--danger); }

.price-in { width: 76px; padding: 6px 9px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--accent); font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.price-in:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }

.sw { position: relative; width: 38px; height: 21px; border-radius: 999px; background: var(--line-2); cursor: pointer; transition: background .16s; flex: none; border: none; }
.sw::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s; }
.sw.on { background: var(--brand); }
.sw.on::after { transform: translateX(17px); }
