/* Animation Forge — "Aurora" palette */
:root {
  --bg: #070B14;
  --surface: #0F1626;
  --surface-2: #151E33;
  --surface-3: #1B2640;
  --border: #22304d;
  --border-2: #2c3d61;
  --primary: #22E3C4;
  --secondary: #FF5C8A;
  --text: #EEF4F2;
  --muted: #8A96AD;
  --ok: #22E3C4;
  --warn: #FFC15C;
  --err: #FF5C6E;
  --grad: linear-gradient(120deg, #22E3C4 0%, #5fb6d6 45%, #FF5C8A 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar: 236px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 750; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
::selection { background: rgba(34, 227, 196, .3); }

/* Inputs */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 60px; }
textarea.big { min-height: 180px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(34, 227, 196, .15); }
input:disabled, select:disabled, textarea:disabled { opacity: .5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; cursor: pointer; }
input[type=file] { width: 100%; padding: 10px; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); background: var(--bg); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field-hint { font-size: 12px; color: var(--muted); }
.inline-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.inline-field input { width: 70px !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.center { justify-content: center; margin-top: 10px; }
.push { margin-left: auto; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none !important; transition: transform .08s, background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: #3a4f7a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--grad); border: 0; color: #061016; box-shadow: 0 6px 20px rgba(34, 227, 196, .18); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 26px rgba(255, 92, 138, .22); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--err); border: 0; color: #fff; }
.btn.danger-text { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { color: var(--primary); cursor: pointer; background: none; border: 0; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.icon { flex: none; }

/* Shell */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 18px 12px; background: linear-gradient(180deg, #0b1120, #080d18); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; text-decoration: none !important; }
.wordmark { font-weight: 800; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.wm-a { color: var(--text); }
.wm-b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 3px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; text-decoration: none !important; position: relative; }
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link.active { background: var(--surface-2); color: var(--text); }
.side-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.side-link.active .icon { color: var(--primary); }
.side-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #061016; display: grid; place-items: center; font-weight: 800; }
.user-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.version { font-size: 11px; color: var(--muted); padding: 6px 8px 0; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { padding: 28px 32px 60px; max-width: 1280px; width: 100%; margin: 0 auto; outline: none; }
.mobile-top, .tabbar { display: none; }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { word-break: break-word; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back-link { display: inline-block; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.section-title { margin: 26px 0 12px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card.feature { background: radial-gradient(120% 140% at 0% 0%, rgba(34, 227, 196, .12), transparent 55%), radial-gradient(120% 140% at 100% 100%, rgba(255, 92, 138, .12), transparent 55%), var(--surface); border-color: #2a4166; }

/* Segmented */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }

/* Notes, pills, badges */
.note { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); margin: 6px 0; font-size: 13px; }
.note.warn { border-color: rgba(255, 193, 92, .35); background: rgba(255, 193, 92, .07); color: #f3d9a8; }
.note.error { border-color: rgba(255, 92, 110, .4); background: rgba(255, 92, 110, .08); color: #ffc2c9; white-space: pre-wrap; word-break: break-word; }
.note.ok { border-color: rgba(34, 227, 196, .4); background: rgba(34, 227, 196, .07); color: #b9f5ea; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-done { background: rgba(34, 227, 196, .12); color: var(--ok); }
.st-running, .st-authoring, .st-verifying, .st-fixing, .st-rendering { background: rgba(95, 182, 214, .14); color: #7fd3f0; }
.st-running::before, .st-authoring::before, .st-verifying::before, .st-fixing::before, .st-rendering::before { animation: pulse 1.2s infinite; }
.st-queued, .st-pending { background: rgba(138, 150, 173, .14); color: var(--muted); }
.st-failed { background: rgba(255, 92, 110, .14); color: var(--err); }
.st-cancelled { background: rgba(255, 193, 92, .12); color: var(--warn); }
@keyframes pulse { 50% { opacity: .3; } }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.badge.ok { background: rgba(34, 227, 196, .14); color: var(--ok); }
.badge.warn { background: rgba(255, 193, 92, .12); color: var(--warn); }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 5px; background: rgba(255, 92, 138, .15); color: var(--secondary); margin-left: 6px; vertical-align: middle; }
.score { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 1px 7px; border-radius: 6px; }
.score.good { background: rgba(34, 227, 196, .14); color: var(--ok); }
.score.mid { background: rgba(255, 193, 92, .12); color: var(--warn); }
.score.bad { background: rgba(255, 92, 110, .14); color: var(--err); }

/* Progress */
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); flex: 1; }
.progress-fill { height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s ease; }
.progress.live .progress-fill { background-size: 200% 100%; animation: shimmer 1.6s linear infinite; background-image: linear-gradient(90deg, #22E3C4, #FF5C8A, #22E3C4); }
.progress.bad .progress-fill { background: var(--err); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Skeletons / empty */
.sk-wrap { display: grid; gap: 12px; }
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--border); }
.sk-card { height: 120px; } .sk-row { height: 76px; } .sk-style { height: 150px; } .sk-tile { height: 210px; } .sk-hero { height: 220px; }
.style-grid > .sk-wrap, .lib-grid > .sk-wrap, .card-grid > .sk-wrap { grid-column: 1 / -1; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--border-2); border-radius: var(--radius); grid-column: 1 / -1; }
.empty-art { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); }
.empty h3 { margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--primary); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { min-height: 100vh; display: flex; flex-direction: column; gap: 18px; align-items: center; justify-content: center; }

/* Login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-glow { position: absolute; inset: -20%; background: radial-gradient(40% 40% at 30% 30%, rgba(34, 227, 196, .16), transparent 70%), radial-gradient(40% 40% at 70% 70%, rgba(255, 92, 138, .14), transparent 70%); pointer-events: none; }
.login-card { position: relative; width: 100%; max-width: 380px; background: rgba(15, 22, 38, .92); border: 1px solid var(--border); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-wm .wordmark { font-size: 26px; }
.login-card .note { margin-bottom: 12px; }

/* Create */
.create-form { max-width: 980px; }
.tab-pane { margin-bottom: 4px; }
.len-out { color: var(--primary); font-weight: 700; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.style-card { text-align: left; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.style-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.style-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(34, 227, 196, .35), 0 10px 30px rgba(34, 227, 196, .12); }
.style-thumb { aspect-ratio: 16 / 9; background: var(--bg); overflow: hidden; border-bottom: 1px solid var(--border); }
.style-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.style-fallback span { font-size: 34px; font-weight: 800; }
.style-fallback i { position: absolute; bottom: 14%; left: 30%; right: 30%; height: 4px; border-radius: 4px; }
.style-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.style-name { font-weight: 700; }
.style-desc { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.swatches { display: flex; gap: 4px; }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .12); }
.adjust { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.adjust summary, details summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
.adjust summary { padding: 10px 12px; color: var(--muted); }
.adjust summary::-webkit-details-marker, details summary::-webkit-details-marker { display: none; }
details > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
details[open] > summary::after { transform: rotate(180deg); }
.adjust-body { padding: 4px 12px 12px; }
.palette-edit { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.pal-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; }
.chip.on { border-color: var(--primary); background: rgba(34, 227, 196, .12); }
.chip-img { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); object-fit: contain; }
.aspect-row { display: flex; gap: 8px; }
.aspect-btn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.aspect-btn.active { border-color: var(--primary); background: rgba(34, 227, 196, .1); }
.aspect-box { display: inline-block; border: 2px solid currentColor; border-radius: 3px; opacity: .8; }
.verifier-row { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; transition: background .15s; flex: none; }
.switch .slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: rgba(34, 227, 196, .25); border-color: var(--primary); }
.switch input:checked + .slider::after { transform: translateX(16px); background: var(--primary); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(34, 227, 196, .25); }
.switch input:disabled + .slider { opacity: .4; }
.submit-bar { position: sticky; bottom: 0; padding: 14px 0; display: flex; justify-content: flex-end; background: linear-gradient(0deg, var(--bg) 60%, transparent); z-index: 5; }

/* Jobs */
.job-list { display: flex; flex-direction: column; gap: 10px; }
.job-row { display: flex; gap: 14px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none !important; transition: border-color .15s, background .15s; }
.job-row:hover { border-color: var(--border-2); background: #111a2d; }
.job-thumb { width: 96px; flex: none; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph, .img-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--border-2); background: var(--bg); min-height: 40px; }
.job-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-top { display: flex; align-items: center; gap: 10px; }
.job-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.job-sub { font-size: 12px; }
.job-progress { display: flex; align-items: center; gap: 10px; }
.pct { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 38px; text-align: right; }
.step-detail { font-size: 12px; color: var(--muted); }
.step-detail b { color: var(--text); text-transform: capitalize; font-weight: 600; }
.job-error { font-size: 12px; color: #ffb3bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; flex: none; }

/* Job detail */
.big-progress { display: flex; flex-direction: column; gap: 10px; }
.bp-head { display: flex; justify-content: space-between; align-items: baseline; }
.bp-step { font-weight: 700; font-size: 16px; }
.bp-pct { font-family: var(--mono); font-size: 22px; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.big-progress .progress { height: 10px; flex: none; }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.step { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.step.done { color: var(--ok); border-color: rgba(34, 227, 196, .3); }
.step.cur { color: #061016; background: var(--grad); border-color: transparent; }
.player-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.player-wrap { background: #000; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; max-height: 72vh; }
.player-wrap video { width: 100%; max-height: 72vh; display: block; background: #000; aspect-ratio: 16 / 9; }
.player-wrap.ar-9x16 video { width: auto; max-width: 100%; aspect-ratio: 9 / 16; }
.player-wrap.ar-1x1 video { width: auto; max-width: 100%; aspect-ratio: 1; }
.player-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.scenes { display: flex; flex-direction: column; gap: 12px; }
.scene-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.scene-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.scene-idx { font-family: var(--mono); font-weight: 700; color: var(--primary); }
.narration { font-size: 14px; margin-bottom: 6px; }
.brief { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.brief b { color: var(--text); font-weight: 600; }
details.verify { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
details.verify summary { font-size: 13px; color: var(--muted); padding: 4px 0; }
.verify-body { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.iteration { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.iter-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.frame-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.frame { flex: none; width: 112px; aspect-ratio: 16 / 9; padding: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #000; cursor: zoom-in; }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame:hover { border-color: var(--primary); }
.frame-big { width: 100%; max-height: 70vh; object-fit: contain; background: #000; border-radius: 8px; display: block; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid rgba(34, 48, 77, .5); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.sev { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.sev.err { background: rgba(255, 92, 110, .16); color: var(--err); }
.sev.warn { background: rgba(255, 193, 92, .14); color: var(--warn); }
details.events { margin-top: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.events summary { padding: 12px 16px; }
.event-list { max-height: 360px; overflow-y: auto; padding: 0 16px 12px; font-family: var(--mono); font-size: 12px; }
.event { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid rgba(34, 48, 77, .35); }
.ev-ts { color: var(--muted); flex: none; }
.ev-lv { flex: none; width: 44px; text-transform: uppercase; font-size: 10px; padding-top: 2px; color: var(--muted); }
.ev-msg { word-break: break-word; white-space: pre-wrap; }
.lv-warn .ev-lv { color: var(--warn); }
.lv-error .ev-lv { color: var(--err); }
.lv-error .ev-msg { color: #ffc2c9; }

/* Library */
.search-wrap { position: relative; display: flex; align-items: center; min-width: 260px; }
.search-wrap .icon { position: absolute; left: 11px; color: var(--muted); }
.search-wrap input.search { padding-left: 34px !important; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.lib-tile { text-align: left; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; overflow: hidden; transition: transform .15s, border-color .15s, box-shadow .15s; color: var(--text); }
.lib-tile:hover { transform: translateY(-3px); border-color: var(--border-2); box-shadow: var(--shadow); }
.lib-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--bg); overflow: hidden; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb.ar-9x16 img, .lib-thumb.ar-1x1 img { object-fit: contain; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(7, 11, 20, .85); padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; font-family: var(--mono); }
.play-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; opacity: 0; background: rgba(7, 11, 20, .35); transition: opacity .15s; }
.lib-tile:hover .play-overlay { opacity: 1; }
.lib-meta { padding: 10px 12px 12px; }
.lib-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }

/* Generic card grid (styles, characters) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.item-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item-actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.char-art { aspect-ratio: 1; background: radial-gradient(circle at 50% 40%, #1a2540, var(--bg)); display: grid; place-items: center; border-bottom: 1px solid var(--border); position: relative; }
.char-art img { width: 80%; height: 80%; object-fit: contain; }
.char-art .spinner { position: absolute; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.analysis-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 10px 0; }
.analysis-frames img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.big-swatches .swatch { width: 34px; height: 34px; border-radius: 8px; }

/* Settings */
.provider { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.provider.disabled { opacity: .6; }
.provider-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.prov-order { font-family: var(--mono); font-weight: 700; color: var(--primary); width: 24px; }
.prov-title { font-weight: 700; flex: 1; min-width: 100px; }
.test-result { font-size: 12px; }
.test-result.ok { color: var(--ok); }
.test-result.bad { color: var(--err); }
.save-bar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(0deg, var(--bg) 60%, transparent); display: flex; justify-content: flex-end; gap: 10px; z-index: 5; }

/* API docs */
pre.code { background: #050810; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: #cfe9e3; margin: 6px 0 14px; white-space: pre; }
.code-wrap { position: relative; }
.code-wrap .copy-btn { position: absolute; top: 6px; right: 6px; }
.secret-box { display: flex; gap: 8px; align-items: center; background: #050810; border: 1px solid var(--primary); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--mono); word-break: break-all; margin: 10px 0; }
.secret-box code { flex: 1; }
.changelog-entry { border-left: 2px solid var(--border-2); padding: 0 0 18px 18px; position: relative; }
.changelog-entry::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--grad); }
.changelog-entry ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.changelog-entry h3 { display: flex; gap: 10px; align-items: baseline; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(3, 6, 12, .72); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--primary); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--err); }

/* Responsive */
@media (max-width: 1000px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 14px 10px; border-bottom: 1px solid var(--border); background: rgba(7, 11, 20, .92); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
  .mobile-top .brand { padding: 0; }
  .mobile-top-actions { display: flex; gap: 2px; }
  main { padding: 18px 14px calc(90px + var(--safe-b)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(11, 17, 32, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + var(--safe-b)); }
  .tab-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 600; color: var(--muted); padding: 4px 0; text-decoration: none !important; }
  .tab-link.active { color: var(--primary); }
  h1 { font-size: 20px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .search-wrap { min-width: 0; width: 100%; }
  .job-thumb { width: 64px; }
  .hide-sm { display: none; }
  .submit-bar, .save-bar { bottom: calc(60px + var(--safe-b)); }
  .submit-bar .btn { width: 100%; }
  #toasts { left: 12px; right: 12px; bottom: calc(76px + var(--safe-b)); }
  .toast { max-width: none; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .card { padding: 14px; }
  textarea.big { min-height: 140px; }
  .style-grid, .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .page-head p.muted { font-size: 13px; }
  .modal-overlay { padding: 8px; align-items: end; }
  .modal { max-height: calc(100dvh - 16px - var(--safe-t)); }
}

.input-body { padding: 0 16px 14px; }
pre.script-pre { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 320px; overflow-y: auto; margin: 6px 0 0; }
details.input-box { margin-top: 22px; }
details.input-box + details.events { margin-top: 12px; }

.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--grad); color: #061016; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; }
.tab-link { position: relative; }
.tab-link .nav-badge { position: absolute; top: 0; left: calc(50% + 6px); margin: 0; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }

input[readonly] { color: var(--muted); background: var(--surface) !important; cursor: default; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--muted); }
.submit-bar { gap: 12px; align-items: center; }

.card > h3 { margin: 18px 0 4px; }
.card > h3:first-of-type { margin-top: 4px; }

/* GPT-image app mark (dark tile) */
img.logo-mark, .login-brand img, .boot img { border-radius: 22%; }
