:root, [data-theme="dark"] {
    --bg-0: #08090c;
    --bg-1: #0e1015;
    --bg-2: #14171e;
    --bg-3: #1a1e28;
    --bg-4: #222736;
    --border: #1e2330;
    --border-hi: #2a3142;
    --t1: #e4e9f0;
    --t2: #828da2;
    --t3: #4a5368;
    --blue: #4e8eff;
    --blue-dim: rgba(78,142,255,.1);
    --green: #2dd4a0;
    --green-dim: rgba(45,212,160,.08);
    --red: #f06060;
    --red-dim: rgba(240,96,96,.08);
    --amber: #f0b040;
    --amber-dim: rgba(240,176,64,.08);
    --sidebar-w: 220px;
    --topbar-h: 52px;
    --r: 6px;
    --r-lg: 10px;
    --sans: 'Instrument Sans', system-ui, sans-serif;
    --mono: 'Geist Mono', monospace;
}
[data-theme="midnight"] {
    --bg-0: #020208;
    --bg-1: #08081a;
    --bg-2: #0e0e24;
    --bg-3: #15152e;
    --bg-4: #1c1c3a;
    --border: #1a1a35;
    --border-hi: #28284a;
    --blue: #6e8eff;
    --blue-dim: rgba(110,142,255,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg-0); color: var(--t1); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; height: 100vh; }

.dash { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w); background: var(--bg-1); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; flex-shrink: 0; z-index: 10;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; }
.sb-logo { font-size: 20px; color: var(--blue); filter: drop-shadow(0 0 10px rgba(78,142,255,.4)); line-height: 1; }
.sb-name { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }

.sb-nav { flex: 1; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }

.sb-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--r); border: none;
    background: none; color: var(--t2); font-family: var(--sans);
    font-size: 13px; font-weight: 500; cursor: pointer; transition: .12s;
    text-align: left; width: 100%;
}
.sb-link:hover { background: var(--bg-3); color: var(--t1); }
.sb-link.active { background: var(--blue-dim); color: var(--blue); }
.sb-link svg { flex-shrink: 0; opacity: .7; }
.sb-link.active svg { opacity: 1; }

.sb-footer { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.sb-user { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.sb-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--bg-4); border: 1px solid var(--border-hi);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--t2); flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-username { display: block; font-size: 12px; color: var(--t2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-email { display: block; font-size: 10px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout {
    background: none; border: none; color: var(--t3); cursor: pointer;
    padding: 4px; border-radius: 3px; display: flex; align-items: center; flex-shrink: 0; transition: .12s;
}
.sb-logout:hover { color: var(--red); }

/* ===== Workspace ===== */
.workspace { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-h); flex-shrink: 0;
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px; background: var(--bg-1); border-bottom: 1px solid var(--border);
}
.tb-left { display: flex; align-items: center; gap: 14px; }
.live-pill {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    background: var(--bg-3); border: 1px solid var(--border);
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t3); transition: .3s; }
.live-pill.on { background: var(--green-dim); border-color: rgba(45,212,160,.3); }
.live-pill.on .live-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.live-pill.on #liveLabel { color: var(--green); }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.35} }

.tb-scene { display: flex; flex-direction: column; line-height: 1.2; }
.tb-scene-k { font-size: 9px; text-transform: uppercase; letter-spacing: .6px; color: var(--t3); }
.tb-scene-v { font-size: 13px; font-weight: 600; color: var(--blue); }

.tb-metrics { display: flex; gap: 20px; margin-left: auto; }
.tb-m { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.tb-mk { font-size: 9px; text-transform: uppercase; letter-spacing: .6px; color: var(--t3); }
.tb-mv { font-family: var(--mono); font-size: 12px; font-weight: 600; }

.tb-right { margin-left: 20px; }
.tb-golive {
    padding: 6px 18px; border-radius: var(--r); border: none;
    font-family: var(--sans); font-size: 12px; font-weight: 700;
    cursor: pointer; transition: .15s; text-transform: uppercase; letter-spacing: .5px;
    background: var(--blue); color: #fff;
}
.tb-golive:hover:not(:disabled) { filter: brightness(1.15); }
.tb-golive.on { background: var(--red); }
.tb-golive:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* ===== Panels ===== */
.panel { display: none; flex-direction: column; padding: 28px 28px 20px; overflow-y: auto; flex: 1; }
.panel.active { display: flex; }

.panel-title { margin-bottom: 20px; }
.panel-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.panel-title .panel-sub { font-size: 13px; color: var(--t3); margin-top: 4px; }
.panel-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }

.panel-toolbar { display: flex; gap: 8px; margin-bottom: 16px; }

/* ===== Scene grid ===== */
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }

.scene-card {
    background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 16px; cursor: pointer; transition: .15s; position: relative; overflow: hidden;
}
.scene-card:hover { border-color: var(--border-hi); background: var(--bg-3); }
.scene-card.active { border-color: var(--green); background: var(--green-dim); }
.scene-card.active::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--green);
}
/* Fallback card always has amber accent when active */
.scene-card.fallback-card.active { border-color: var(--amber); background: var(--amber-dim); }
.scene-card.fallback-card.active::before { background: var(--amber); }

.sc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sc-name { font-size: 15px; font-weight: 700; }
.sc-badge {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    padding: 2px 8px; border-radius: 3px;
}
.sc-badge.filling { background: var(--amber-dim); color: var(--amber); }
.sc-badge.live { background: var(--green-dim); color: var(--green); }
.sc-badge.idle { background: var(--bg-4); color: var(--t3); }
.sc-badge.fallback-active { background: var(--amber-dim); color: var(--amber); }

.sc-stats { display: flex; gap: 16px; position: relative; }
.sc-stat { display: flex; flex-direction: column; }
.sc-stat-k { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--t3); }
.sc-stat-v { font-family: var(--mono); font-size: 13px; font-weight: 600; }

.sc-meta { margin-top: 8px; font-family: var(--mono); font-size: 10px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sc-delay { margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.sc-delay input {
    width: 50px; padding: 3px 6px; background: var(--bg-0); border: 1px solid var(--border);
    border-radius: 3px; color: var(--t1); font-family: var(--mono); font-size: 11px;
    text-align: center; outline: none;
}
.sc-delay input:focus { border-color: var(--blue); }
.sc-delay-label { font-size: 10px; color: var(--t3); }
.sc-delay-fill { font-size: 9px; color: var(--amber); font-family: var(--mono); }

.scene-empty { grid-column: 1 / -1; text-align: center; color: var(--t3); padding: 40px 0; font-size: 14px; }

.btn-fallback-big {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px; border: 1px dashed var(--border);
    border-radius: var(--r-lg); background: none; color: var(--t3);
    font-family: var(--sans); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: .15s;
}
.btn-fallback-big:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }

/* ===== Preview in scene cards ===== */
.sc-preview {
    width: 100%; aspect-ratio: 16/9; background: #000;
    border-radius: var(--r); overflow: hidden;
    margin-bottom: 12px; position: relative;
}
.sc-preview video {
    width: 100%; height: 100%; object-fit: contain; display: block; background: #000;
}
.sc-preview-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: #000; z-index: 1;
}
.sc-spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fallback card — no video, just a placeholder icon */
.sc-preview-fallback {
    width: 100%; aspect-ratio: 16/9; background: var(--bg-0);
    border-radius: var(--r); overflow: hidden; margin-bottom: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; color: var(--amber); opacity: .6;
}
.sc-preview-fallback svg { opacity: .7; }
.sc-preview-fallback span { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ===== Cogwheel ===== */
.sc-cog {
    margin-left: auto; padding: 4px; background: none; border: none;
    color: var(--t3); cursor: pointer; transition: .15s;
    display: flex; align-items: center; border-radius: 3px;
}
.sc-cog:hover { color: var(--t1); background: var(--bg-4); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 8px 12px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--t3); border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-2); }
.tbl-empty { text-align: center; color: var(--t3); padding: 30px 12px !important; }

.tbl .key-cell {
    font-family: var(--mono); font-size: 11px; color: var(--t2);
    cursor: pointer; padding: 3px 8px; border-radius: 3px;
    background: var(--bg-0); border: 1px solid var(--border); display: inline-block;
    transition: .12s;
}
.tbl .key-cell:hover { border-color: var(--blue); color: var(--blue); }
.tbl .url-cell { font-family: var(--mono); font-size: 11px; color: var(--t3); }

/* ===== Output cards ===== */
.output-cards { display: flex; flex-direction: column; gap: 10px; }
.output-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; background: var(--bg-2); border: 1px solid var(--border);
    border-radius: var(--r-lg); transition: .12s;
}
.output-card:hover { border-color: var(--border-hi); }
.oc-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--t3); }
.oc-status.pub { background: var(--green); box-shadow: 0 0 6px var(--green); }
.oc-status.conn { background: var(--amber); }
.oc-info { flex: 1; min-width: 0; }
.oc-name { font-size: 14px; font-weight: 600; }
.oc-url { font-family: var(--mono); font-size: 10px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-state {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    padding: 3px 10px; border-radius: 3px; flex-shrink: 0;
}
.oc-state.live { background: var(--green-dim); color: var(--green); }
.oc-state.off { background: var(--bg-4); color: var(--t3); }
.oc-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== Fallback ===== */
.fb-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }

/* Status banner */
.fb-status-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--r);
    margin-bottom: 16px; font-size: 12px; font-weight: 600;
}
.fb-status-banner.encoding {
    background: var(--amber-dim); border: 1px solid rgba(240,176,64,.3);
    color: var(--amber);
}
.fb-status-banner.ready {
    background: var(--green-dim); border: 1px solid rgba(45,212,160,.25);
    color: var(--green);
}
.fb-status-banner.error {
    background: var(--red-dim); border: 1px solid rgba(240,96,96,.25);
    color: var(--red);
}
.fb-status-banner.none {
    background: var(--bg-3); border: 1px solid var(--border);
    color: var(--t3);
}

/* Progress bar */
.fb-progress-wrap { margin-bottom: 16px; }
.fb-progress-label {
    display: flex; justify-content: space-between;
    font-size: 10px; color: var(--t3); margin-bottom: 5px;
}
.fb-progress-bar {
    width: 100%; height: 4px; background: var(--bg-4); border-radius: 2px; overflow: hidden;
}
.fb-progress-fill {
    height: 100%; background: var(--blue); border-radius: 2px;
    transition: width .3s ease;
}
.fb-progress-fill.indeterminate {
    width: 40% !important;
    animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
    0%   { transform: translateX(-150%); }
    100% { transform: translateX(350%); }
}

/* Upload zone */
.fb-info { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.fb-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--t3); }
.fb-path { font-size: 12px; color: var(--t2); flex: 1; }
.fb-exists { font-size: 10px; font-weight: 700; }
.fb-exists.yes { color: var(--green); }
.fb-exists.no  { color: var(--t3); }

.fb-upload {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 30px; border: 1px dashed var(--border); border-radius: var(--r);
    color: var(--t3); font-size: 13px; cursor: pointer; transition: .15s;
}
.fb-upload:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
.fb-upload.dragging { border-color: var(--blue); background: var(--blue-dim); }
.fb-upload svg { opacity: .5; }
.fb-upload-hint { font-size: 10px; color: var(--t3); margin-top: 2px; }

/* Upload XHR progress */
.fb-upload-progress { margin-top: 12px; }
.fb-upload-progress-bar {
    width: 100%; height: 3px; background: var(--bg-4); border-radius: 2px; overflow: hidden;
}
.fb-upload-progress-fill {
    height: 100%; background: var(--blue); border-radius: 2px;
    transition: width .15s ease;
}

/* ===== Log ===== */
.log-wrap {
    flex: 1; min-height: 300px; max-height: 600px; overflow-y: auto;
    padding: 12px 0; font-family: var(--mono); font-size: 11px; line-height: 1.9; color: var(--t3);
}
.log-entry { white-space: nowrap; padding: 0 4px; }
.log-entry:hover { background: var(--bg-2); }
.log-t { color: var(--t3); margin-right: 10px; opacity: .5; }
.log-l { font-weight: 600; margin-right: 8px; }
.log-l.info { color: var(--blue); }
.log-l.live { color: var(--green); }
.log-l.warn { color: var(--amber); }
.log-l.error { color: var(--red); }

/* ===== Settings ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-section { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.settings-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.settings-section--account { grid-column: 1 / -1; }
.settings-hint { font-size: 11px; color: var(--t3); margin-bottom: 12px; line-height: 1.6; }
.settings-hint code { font-family: var(--mono); background: var(--bg-0); padding: 1px 4px; border-radius: 2px; }
.settings-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 14px; }
@media (max-width: 700px) { .settings-two-col { grid-template-columns: 1fr; } }
.settings-subsection h4 { font-size: 12px; font-weight: 600; color: var(--t2); margin-bottom: 10px; }
.account-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Forms ===== */
.fg { margin-bottom: 10px; }
.fg label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--t3); margin-bottom: 3px; }
.fg input, .fg select {
    width: 100%; padding: 7px 10px; background: var(--bg-3); border: 1px solid var(--border);
    border-radius: var(--r); color: var(--t1); font-family: var(--mono); font-size: 12px; outline: none; transition: .12s;
}
.fg input:focus, .fg select:focus { border-color: var(--blue); }
.fg input:disabled { opacity: .5; cursor: not-allowed; }
.fg-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }

.key-row { display: flex; gap: 4px; align-items: center; }
.key-row input { flex: 1; }
.mono { font-family: var(--mono); }

/* ===== Buttons ===== */
.btn-action {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; border-radius: var(--r); border: none;
    background: var(--blue); color: #fff; font-family: var(--sans);
    font-size: 12px; font-weight: 600; cursor: pointer; transition: .12s;
}
.btn-action:hover { filter: brightness(1.15); }

.btn-ghost {
    padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--border);
    background: none; color: var(--t2); font-family: var(--sans);
    font-size: 12px; font-weight: 600; cursor: pointer; transition: .12s;
}
.btn-ghost:hover { background: var(--bg-3); color: var(--t1); border-color: var(--border-hi); }

.btn-danger {
    padding: 7px 16px; border-radius: var(--r); border: 1px solid rgba(240,96,96,.25);
    background: var(--red-dim); color: var(--red); font-family: var(--sans);
    font-size: 12px; font-weight: 600; cursor: pointer; transition: .12s;
}
.btn-danger:hover { background: rgba(240,96,96,.15); border-color: var(--red); }

.btn-sm {
    padding: 4px 10px; border-radius: 4px; border: 1px solid var(--border);
    background: var(--bg-3); color: var(--t2); font-family: var(--sans);
    font-size: 10px; font-weight: 600; cursor: pointer; transition: .12s;
}
.btn-sm:hover { background: var(--bg-4); color: var(--t1); }
.btn-sm.go   { background: var(--green-dim); color: var(--green); border-color: rgba(45,212,160,.2); }
.btn-sm.stop { background: var(--red-dim); color: var(--red); border-color: rgba(240,96,96,.2); }
.btn-sm.del  { color: var(--red); }
.btn-sm.del:hover { background: var(--red-dim); }

.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; color: var(--t3); transition: .12s; }
.btn-icon:hover { color: var(--t1); }
.btn-icon.sm { font-size: 13px; }

/* ===== Modal ===== */
.modal-bg {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
    z-index: 100; align-items: center; justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
    background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-lg);
    width: 440px; max-width: 92vw; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ===== Source detail modal ===== */
.sm-grid { display: flex; flex-direction: column; gap: 10px; }
.sm-row { display: flex; align-items: center; gap: 12px; }
.sm-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--t3); min-width: 80px; flex-shrink: 0; }
.sm-val { font-size: 13px; color: var(--t1); min-width: 0; word-break: break-all; }
.sm-val.mono { font-family: var(--mono); font-size: 12px; }
.sm-copyable { cursor: pointer; padding: 2px 8px; border-radius: 3px; background: var(--bg-0); border: 1px solid var(--border); transition: .12s; }
.sm-copyable:hover { border-color: var(--blue); color: var(--blue); }
.sm-divider { height: 1px; background: var(--border); margin: 4px 0; }
.sm-delay { display: flex; align-items: center; gap: 8px; }
.sm-delay input {
    width: 60px; padding: 5px 8px; background: var(--bg-3); border: 1px solid var(--border);
    border-radius: var(--r); color: var(--t1); font-family: var(--mono); font-size: 12px;
    text-align: center; outline: none;
}
.sm-delay input:focus { border-color: var(--blue); }
.sm-delay-unit { font-size: 11px; color: var(--t3); }
.sm-filling { font-size: 11px; color: var(--amber); font-family: var(--mono); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { width: 56px; }
    .sb-name, .sb-user-info, .sb-logout { display: none; }
    .sb-link { justify-content: center; padding: 10px; }
    .sb-link span { display: none; }
    .sb-brand { justify-content: center; }
    .sb-user { justify-content: center; }
    .tb-metrics { display: none; }
    .scene-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-two-col { grid-template-columns: 1fr; }
}

/* ===== Auth / Login page ===== */
.auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-0);
    font-family: var(--sans);
}

.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.auth-grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
            linear-gradient(var(--border) 1px, transparent 1px),
            linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.4;
}

.auth-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-logo {
    font-size: 22px;
    color: var(--blue);
}

.auth-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -.2px;
}

.auth-card {
    width: 100%;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--t3);
    cursor: pointer;
    transition: .15s;
}

.auth-tab:hover { color: var(--t1); background: var(--bg-2); }
.auth-tab.active { color: var(--t1); border-bottom: 2px solid var(--blue); margin-bottom: -1px; }

.auth-card-body {
    padding: 24px;
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.3px;
    margin: 0 0 4px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--t3);
    margin: 0 0 20px;
}

.auth-error {
    display: none;
    padding: 10px 12px;
    background: var(--red-dim);
    border: 1px solid rgba(240,96,96,.25);
    border-radius: var(--r);
    color: var(--red);
    font-size: 12px;
    margin-bottom: 14px;
}

.auth-error:not(:empty) { display: block; }

.btn-auth {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    border-radius: var(--r);
    border: none;
    background: var(--blue);
    color: #fff;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-auth:hover:not(:disabled) { filter: brightness(1.15); }
.btn-auth:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.btn-auth-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

.btn-auth.loading .btn-auth-spinner { display: block; }
.btn-auth.loading .btn-auth-label { opacity: .7; }

@keyframes spin { to { transform: rotate(360deg); } }

.auth-switch {
    text-align: center;
    font-size: 12px;
    color: var(--t3);
    margin: 16px 0 0;
}

.auth-switch a { color: var(--blue); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.auth-advanced summary {
    font-size: 11px;
    color: var(--t3);
    cursor: pointer;
    user-select: none;
    margin-bottom: 2px;
}

.auth-advanced summary:hover { color: var(--t1); }

.fg-hint {
    display: block;
    font-size: 10px;
    color: var(--t3);
    margin-top: 3px;
}