:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #111;
  --surface-2: #202020;
  --line: #1a1a1a;
  --muted: #b4b4b4;
  --text: #fff;
  --accent: #c6f24e;
  --danger: #e5566f;
  --warn: #e5a93b;
  --ok: #c6f24e;
  --radius: 20px;
  font-family: Geist, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
svg { display: block; width: 18px; height: 18px; }
.muted { color: var(--muted); }
.boot { display: grid; min-height: 100vh; place-items: center; }
.eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

.login-stage { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); min-height: 100vh; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.login-brand:after { position: absolute; border-radius: 50%; content: ""; animation: orbit 20s linear infinite; }
.brand-mark { position: relative; z-index: 1; display: grid; place-items: center; }
.login-brand h1, .login-brand > p { position: relative; z-index: 1; margin: 0; }
.login-form { display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.login-form h2 { margin: 0; }
.login-form label, .editor label, .profile-form label, .plain-section label, .admin-create label {
  display: grid; gap: 8px; color: #d0d0d0; font-size: 13px; font-weight: 550;
}
input, textarea, select { width: 100%; border: 1px solid #303030; border-radius: 10px; outline: none; color: var(--text); }
input, select { height: 42px; padding: 0 12px; }
textarea { padding: 14px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #777; }
.form-error, .inline-error { margin: 0; color: #ff899d; font-size: 13px; }
.primary, .secondary, .text-button, .icon-button { border: 0; transition: transform .15s ease, background .15s ease, color .15s ease; }
.primary { display: inline-flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 24px; padding: 0 18px; }
.secondary { min-height: 38px; padding: 0 14px; }
.text-button { padding: 0 8px; background: transparent; color: var(--muted); }
.icon-button { display: grid; place-items: center; color: #ddd; }

.shell { min-height: 100vh; }
.topbar {
  position: sticky; z-index: 30; top: 0; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; min-height: 64px; border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.wordmark span { display: grid; width: 30px; height: 30px; place-items: center; font-size: 10px; }
.topbar nav { display: flex; align-items: center; gap: 2px; }
.topbar nav button { height: 36px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); }
.account { display: flex; justify-content: flex-end; align-items: center; gap: 12px; font-size: 13px; }
.account strong { color: var(--accent); }
.role { padding: 5px 9px; font-size: 11px; }
.workspace { margin: 0 auto; animation: rise .28s ease both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.page-head h1 { margin: 0; }
.page-head > p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.55; }
.notice { margin-bottom: 20px; padding: 14px 18px; border-radius: 12px; background: #2b2414; }
.notice.danger { background: #2c1a20; }
.metric-line { display: grid; grid-template-columns: repeat(4, 1fr); }
.metric-line > div { display: grid; gap: 7px; border-right: 1px solid var(--line); }
.metric-line > div:last-child { border: 0; }
.metric-line span { color: #888; font-size: 11px; }

.studio-layout { display: grid; align-items: start; }
.source-rail { position: sticky; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.segmented button { height: 38px; border: 0; background: transparent; color: var(--muted); }
.drop-zone {
  position: relative; display: grid; place-items: center; align-content: center; gap: 9px; overflow: hidden;
  border: 1px dashed #383838; text-align: center;
}
.drop-zone > span { font-size: 38px; font-weight: 200; }
.drop-zone small { color: #888; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone img { position: absolute; width: 100%; height: 100%; }
.privacy-note { color: #888; font-size: 12px; line-height: 1.5; }
.editor { display: grid; }
.prompt-field textarea { line-height: 1.5; }
.field-title, .prompt-field > span { color: #d0d0d0; font-size: 13px; font-weight: 550; }
.field-grid { display: grid; gap: 14px; }
.toggle-field { display: flex !important; min-height: 42px; align-items: center !important; align-self: end; padding: 0 12px; border: 1px solid #303030; border-radius: 10px; }
.toggle-field input { width: 18px; height: 18px; margin: 0 10px 0 0; }
.lora-section { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.lora-section p { margin: 4px 0 0; }
.selected-loras { grid-column: 1 / -1; display: grid; gap: 8px; }
.empty-inline { margin: 8px 0; color: #888; }
.selected-lora { display: grid; gap: 12px; align-items: center; }
.selected-lora > div { display: grid; gap: 3px; min-width: 0; }
.selected-lora strong, .selected-lora small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-lora small { color: #888; }
.selected-lora label { gap: 3px; font-size: 10px; }
.selected-lora input { height: 32px; }
.submit-line { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title h2, .plain-section h2 { margin: 0; }

.generation-list { display: grid; }
.generation { display: grid; overflow: hidden; }
.generation-media { position: relative; overflow: hidden; }
.generation-media img, .generation-media video { display: block; }
.status { position: absolute; top: 12px; left: 12px; padding: 6px 9px; border-radius: 999px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.generation-body { display: flex; flex-direction: column; }
.generation-title { display: flex; justify-content: space-between; gap: 24px; }
.generation-title span { color: #888; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.generation-title h3 { display: -webkit-box; overflow: hidden; margin: 6px 0 0; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.generation-title time { flex: none; color: #888; font-size: 11px; }
.generation-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.generation-meta span { padding: 5px 8px; font-size: 10px; }
.review-line { display: flex; align-items: center; margin-top: auto; }
.review { margin-right: auto; color: #888; font-size: 11px; }
.review.approved { color: var(--ok); }
.review.submitted { color: var(--warn); }
.review.rejected { color: var(--danger); }
.empty-state { display: grid; min-height: 280px; place-items: center; align-content: center; border-block: 1px solid var(--line); text-align: center; }
.empty-state h3 { margin: 14px 0 6px; }
.empty-state p { margin: 0; color: #888; }

.balance-hero { margin-bottom: 42px; padding: 36px 0; border-block: 1px solid var(--line); }
.balance-hero strong { display: block; margin: 8px 0; color: var(--accent); font-size: clamp(54px, 8vw, 110px); line-height: .9; letter-spacing: -.07em; }
.balance-hero p { margin: 0; color: var(--muted); }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 54px; }
.plain-section { display: grid; align-content: start; gap: 18px; }
.rows { display: grid; }
.rows > div { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); }
.profile-form { display: grid; max-width: 650px; gap: 20px; }
.profile-form .primary { justify-self: start; }
.admin-create { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; margin: -8px 0 24px; padding: 20px; }
.admin-table { border-top: 1px solid var(--line); }
.table-head, .creator-row, .payout-row { display: grid; align-items: center; gap: 18px; padding: 14px 10px; border-bottom: 1px solid var(--line); }
.table-head { color: #888; font-size: 10px; text-transform: uppercase; }
.creator-row, .creator-table .table-head { grid-template-columns: 1.2fr 1.1fr 1fr .65fr 1.1fr; }
.creator-row > div:first-child, .creator-row > div:nth-child(4) { display: grid; gap: 4px; }
.creator-row small { color: #888; }
.compact-inputs { display: flex !important; gap: 6px !important; }
.compact-inputs label { display: grid; grid-template-columns: auto 58px; align-items: center; gap: 4px; color: #888; font-size: 10px; }
.compact-inputs input { height: 32px; padding: 0 6px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.switch { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.switch input { width: 16px; height: 16px; }
.review-queue { display: grid; gap: 28px; }
.review-queue article { display: grid; grid-template-columns: minmax(360px, 1.2fr) 1fr; gap: 32px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.review-preview img, .review-preview video { display: block; width: 100%; max-height: 560px; object-fit: contain; background: #050505; }
.review-queue article > div:last-child { display: grid; align-content: center; gap: 15px; }
.review-queue h2 { margin: 0; line-height: 1.3; }
.review-actions { display: flex; gap: 10px; }
.payout-row, .payout-table .table-head { grid-template-columns: 1fr .5fr 1.4fr .6fr 1.3fr; }
.payout-row code { overflow: hidden; text-overflow: ellipsis; }
.audit-list { border-top: 1px solid var(--line); }
.audit-list > div { display: grid; grid-template-columns: 180px 1fr 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.audit-list time, .audit-list span { color: #888; font-size: 12px; }

dialog::backdrop { background: #000d; }
.catalog-shell { display: grid; height: 100%; }
.catalog-shell header { display: flex; align-items: center; justify-content: space-between; }
.catalog-shell h2 { margin: 0; }
.catalog-list { display: grid; align-content: start; overflow: auto; }
.detail-dialog[open], .catalog-dialog[open], .media-lightbox[open] { animation: dialog-in .2s ease both; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: 420px; padding: 13px 17px; opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: none; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { filter: brightness(1.35); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; padding: 10px 18px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; }
  .account > span:not(.role) { display: none; }
  .workspace { padding: 28px 20px 70px; }
  .generation-facts { grid-template-columns: 1fr 1fr; }
  .catalog-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .studio-layout { grid-template-columns: 1fr; }
  .source-rail { position: static; }
  .metric-line { grid-template-columns: 1fr 1fr; }
  .generation { grid-template-columns: 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .review-queue article { grid-template-columns: 1fr; }
  .lora-detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .login-stage { grid-template-columns: 1fr; }
  .login-brand { min-height: 34vh; padding: 24px; }
  .login-brand > p { display: none; }
  .login-form { padding: 32px 22px; }
  .wordmark { font-size: 0; }
  .wordmark span { font-size: 10px; }
  .account { gap: 6px; }
  .account .role { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .field-grid.two { grid-template-columns: 1fr; }
  .catalog-list { grid-template-columns: 1fr; }
  .two-column { gap: 42px; }
  .admin-create { grid-template-columns: 1fr; }
  .creator-row, .payout-row { grid-template-columns: 1fr; }
  .table-head { display: none; }
  .audit-list > div { grid-template-columns: 1fr; }
}
/* Quota counters remain readable on narrow creator and admin screens. */
.quota-panel { margin-bottom: 24px; padding: 20px; border: 1px solid #303030; border-radius: 16px; display: grid; gap: 16px; }
.quota-panel p { margin: 6px 0 0; }
.quota-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.quota-values > div { display: grid; gap: 6px; }
.quota-values strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.quota-values small, .quota-panel > small { color: #aaa; }
@media (max-width: 540px) { .quota-values { grid-template-columns: 1fr; } .quota-values > div { grid-template-columns: 1fr auto; } .quota-values small { grid-column: 1 / -1; } }
