/* Shared design system, inspired by api.ahwuoc.site. Loaded after feature styles. */
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  color-scheme: light;
  --canvas: #fafafa;
  --surface: #ffffff;
  --field: #f4f4f5;
  --line: #e4e4e7;
  --ink: #09090b;
  --muted: #71717a;
  --primary: #18181b;
  --primary-hover: #303034;
  --accent: #16a36c;
  --accent-soft: #ecf9f1;
  --accent-line: #c9ead7;
  --button-bg: #18181b;
  --button-hover: #303034;
  --button-border: #18181b;
  --button-ink: #fafafa;
  --badge-bg: #f4f4f5;
  --error: #b42332;
  --error-bg: #fff1f2;
  --error-border: #fecdd3;
  --focus-ring: #18181b20;
  --surface-shadow: 0 1px 2px #09090b04;
  --surface-shadow-hover: 0 4px 16px #09090b08;
  --background-base: #ffffff;
  --background-grid: rgb(113 113 122 / 25%);
  --background-particle: 82, 82, 91;
  --background-dot-opacity: .75;
  --background-line-opacity: .5;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #09090b;
  --surface: #111216;
  --field: #1e2027;
  --line: #2b2e36;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --primary: #f4f4f5;
  --primary-hover: #d4d4d8;
  --accent: #6cdda3;
  --accent-soft: #142c23;
  --accent-line: #28503c;
  --button-bg: #f4f4f5;
  --button-hover: #d4d4d8;
  --button-border: #f4f4f5;
  --button-ink: #18181b;
  --badge-bg: #22252c;
  --error: #fda4af;
  --error-bg: #351c24;
  --error-border: #70303e;
  --focus-ring: #ffffff20;
  --surface-shadow: 0 1px 2px #00000014;
  --surface-shadow-hover: 0 4px 16px #00000020;
  --background-base: #09090b;
  --background-grid: rgb(39 39 42 / 55%);
  --background-particle: 135, 135, 146;
  --background-dot-opacity: .55;
  --background-line-opacity: .22;
}
html { scrollbar-gutter: stable; background: var(--background-base); }
body {
  position: relative;
  isolation: isolate;
  background: var(--background-base);
  color: var(--ink);
  font: 14px/1.6 Inter, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--background-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--background-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(70% 60% at 60% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(70% 60% at 60% 0%, #000 0%, transparent 75%);
}
.studio-particles {
  position: fixed;
  z-index: -1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.shell, .auth-header, .auth-layout, .auth-footer { position: relative; z-index: 1; }
::selection { color: var(--ink); background: var(--accent-line); }
button, input, textarea, select { font-family: inherit; }
button { border-radius: 6px; }
button:disabled { opacity: .45; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Header and persistent navigation. */
.shell { --shell-gutter: 0px; max-width: 1600px; margin-inline: auto; padding: 0; }
.shell > .nav-wrap { position: relative; z-index: 5; margin: 0; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface); }
.nav-wrap .nav-pill { min-height: 72px; gap: 20px; padding: 12px 0; flex-wrap: nowrap; }
.brand-group { gap: 12px; }
body .brand { gap: 10px; font-size: 18px; font-weight: 650; letter-spacing: -.65px; }
body .brand small { margin-top: 1px; color: var(--muted); font-size: 8px; font-weight: 500; letter-spacing: .17em; }
body .brand-logo { position: relative; width: 34px; height: 34px; border: 1px solid var(--button-border); border-radius: 9px; background: var(--button-bg); color: var(--button-ink); box-shadow: none; font-size: 22px; font-weight: 650; }
body .brand-logo::after { content: ''; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: #59d399; }
.brand > span:not(.brand-logo)::after { display: none; }
.nav-pill .studio-userbar { gap: 12px; flex-wrap: nowrap; width: auto; }
.studio-userbar .credit-label { min-height: 38px; gap: 9px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.studio-userbar .credit-label::before { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: var(--field); color: var(--ink); box-shadow: none; font-size: 12px; }
#studio-username { max-width: 160px; font-size: 12px; font-weight: 600; }
#studio-credit-detail { font-size: 10px; }
.studio-role { padding: 2px 6px; border-color: var(--line); border-radius: 4px; background: var(--field); color: var(--muted); }
body #server-status { min-height: 30px; padding: 5px 10px; border-color: var(--line); background: var(--surface); color: var(--muted); box-shadow: none; font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
body .nav-pill .admin-nav-actions { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
body .theme-toggle { display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; min-height: 34px; padding: 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); }
body .theme-toggle:hover { border-color: var(--line); background: var(--field); transform: none; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .theme-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
.workspace-shell { gap: 0; }
.shell .content-column, .admin-shell .content-column { padding: 30px 32px 40px; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.workspace-heading .eyebrow { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; color: var(--muted); font-size: 10px; letter-spacing: .1em; font-weight: 500; }
.workspace-heading .eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.workspace-heading h1 { margin: 0; font-size: clamp(24px, 2.3vw, 32px); line-height: 1.3; letter-spacing: -.9px; font-weight: 600; }
.workspace-heading p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.workspace-heading-tag { flex: none; display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 10px; }
.workspace-heading-tag svg { color: var(--accent); }
.sidebar { background: var(--surface); }
body .sidebar .sidebar-label { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .07em; }
body .sidebar .workspace-tabs, .sidebar-studio-links { gap: 4px; }
body .sidebar .workspace-tabs button, body .sidebar .admin-nav-link { min-height: 42px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; box-shadow: none; }
body .sidebar .workspace-tabs button:hover, body .sidebar .admin-nav-link:hover { background: var(--field); color: var(--ink); transform: none; box-shadow: none; }
body .sidebar .workspace-tabs button[aria-selected="true"], body .sidebar .admin-nav-link[aria-current="page"] { background: var(--field); color: var(--ink); border-color: var(--line); font-weight: 600; }
body .sidebar .workspace-tabs button[aria-selected="true"] .nav-icon, body .sidebar .admin-nav-link[aria-current="page"] svg { color: var(--accent); }
body .sidebar .workspace-tabs button::before { display: none; }
body .sidebar .workspace-tabs .count-badge { background: var(--surface); color: var(--muted); border-color: var(--line); }
.sidebar .account-links.admin-nav-actions { margin: 24px 0 0; padding-top: 16px; gap: 4px; width: 100%; }
.sidebar .admin-logout:hover { color: var(--error); background: var(--error-bg); }
.sidebar .sidebar-note { margin: auto 8px 0; padding: 16px 12px 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.sidebar-note .sidebar-note-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-bottom: 8px; border: 1px solid var(--accent-line); border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.sidebar-note strong { color: var(--ink); font-size: 11px; font-weight: 500; }
.sidebar-note p { margin-top: 4px; font-size: 10px; }
body #sidebar-inner-toggle { top: 22px; right: -16px; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); box-shadow: 0 2px 6px #09090b0d; }
body #sidebar-inner-toggle::before { inset: -5px; border-radius: 50%; }
body #sidebar-inner-toggle svg { width: 16px; height: 16px; stroke-width: 2; }
body #sidebar-inner-toggle:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); box-shadow: 0 2px 8px #09090b12; }
body #sidebar-inner-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body .sidebar-toggle, body #sidebar-close { border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); box-shadow: none; }
.shell > footer { display: flex; justify-content: space-between; gap: 16px; margin: 0; padding: 15px 32px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 10px; }
.shell > footer span { color: var(--muted); }

/* Shared surfaces, forms and controls. Feature layout rules stay in app.css. */
body .card, body .audio-card, body .workflow-run, body .workflow-step, body .analytics-chart, body .admin-analytics { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: var(--surface-shadow); }
.content-column .layout { grid-template-columns: minmax(290px, 350px) minmax(0, 1fr); gap: 24px; align-items: stretch; align-content: start; }
.content-column .layout > .editor-card { position: static; align-self: start; max-height: none; padding: 22px; overflow: visible; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--surface-shadow); }
.content-column .layout > .preview-panel { display: flex; flex-direction: column; align-self: stretch; min-width: 0; }
body textarea, body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), body select { border: 1px solid var(--line); border-radius: 6px; background-color: var(--surface); color: var(--ink); font-size: 12px; box-shadow: none; }
body textarea { min-height: 112px; padding: 11px 12px; line-height: 1.75; }
body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), body select { min-height: 38px; padding: 8px 10px; }
body textarea:focus, body input:not([type="checkbox"]):not([type="range"]):focus, body select:focus { outline: none; border-color: var(--muted); background-color: var(--surface); box-shadow: 0 0 0 3px var(--focus-ring); }
body textarea::placeholder, body input::placeholder { color: var(--muted); opacity: .8; }
body input[type="checkbox"], body input[type="radio"], body input[type="range"] { accent-color: var(--accent); }
body label, .input-label { color: var(--ink); }
body .stack-form { gap: 16px; }
body .stack-form > label { font-size: 12px; font-weight: 500; }
body .field-note, body .subtle-count { color: var(--muted); font-size: 11px; line-height: 1.7; }
body .eyebrow { color: var(--muted); font-weight: 500; }
.editor-card h2, .editor-card #prompt-label { margin: 0 0 16px; color: var(--ink); font-size: 14px; font-weight: 600; letter-spacing: -.2px; }
.editor-card :is(#image-form, #image-edit-form, #audio-form, #workflow-form, #prompt-form) > h2::after { background: var(--line); }
.editor-card .prompt-label-icon { width: 30px; height: 30px; flex-basis: 30px; border-color: var(--accent-line); border-radius: 7px; background: var(--accent-soft); color: var(--accent); }
.prompt-label-icon svg { animation: none; }
body .keep-shape.keep-shape, #form .mode2-analysis, #workflow-form .mode2-analysis { min-height: 40px; padding: 10px 11px; border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 450; box-shadow: none; }
body .keep-shape:has(input:checked), #form .mode2-analysis:has(input:checked), #workflow-form .mode2-analysis:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
#form .mode2-duration, .editor-card .preview-settings { border-color: var(--line); border-radius: 6px; background: var(--field); box-shadow: none; }
#mode2-duration-value, .preview-size-control output, .step-chip { border-color: var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); }
body .submit-btn, body #send-otp-btn { min-height: 40px; border: 1px solid var(--button-border); border-radius: 6px; background: var(--button-bg); color: var(--button-ink); box-shadow: 0 1px 2px #0000000a; font-size: 12px; font-weight: 500; }
body .submit-btn:hover:not(:disabled), body #send-otp-btn:hover:not(:disabled) { background: var(--button-hover); box-shadow: none; transform: none; }
.submit-btn::after, #send-otp-btn::after { display: none; }
body .secondary-button, body .text-button, body .refresh-btn, body .history-btn, body .account-pagination button, body .admin-refresh { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); box-shadow: none; font-size: 11px; font-weight: 500; }
body .secondary-button:hover:not(:disabled), body .text-button:hover:not(:disabled), body .refresh-btn:hover:not(:disabled), body .history-btn:hover, body .account-pagination button:hover:not(:disabled), body .admin-refresh:hover { border-color: var(--line); background: var(--field); color: var(--ink); transform: none; box-shadow: none; }
body .text-button { border-color: transparent; padding: 4px 7px; }
body .danger-btn, body .history-card .history-actions .danger-btn { color: var(--error); background: var(--surface); }
body .danger-btn:hover:not(:disabled) { border-color: var(--error-border); background: var(--error-bg); color: var(--error); }
body .count-badge, body .meta-pill, body .studio-tag { border-color: var(--line); border-radius: 5px; background: var(--field); color: var(--muted); font-weight: 500; }
body .workflow-upload { padding: 18px 12px; border: 1px dashed var(--line); border-radius: 7px; background: var(--canvas); box-shadow: none; }
body .workflow-upload:hover, body .workflow-upload.is-dragging, body .workflow-upload[data-selected="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
body .workflow-upload-icon { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
body .workflow-upload-icon svg { width: 18px; height: 18px; stroke: var(--muted); }
body .workflow-upload-picker, body .workflow-upload-picker:hover { background: transparent; color: var(--ink); }
body .workflow-upload-picker strong { font-size: 11px; font-weight: 500; }
body .workflow-upload-hint, body .workflow-upload-selection { color: var(--muted); font-size: 10px; }
body .ref-thumb-item, body .ref-thumb-remove { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: none; }

/* Result toolbars, illustrations and generated content. */
body .download-toolbar, body .audio-toolbar, #history-panel .history-toolbar { gap: 8px; min-height: 46px; margin: 0 0 16px; padding: 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: none; }
body .download-toolbar .secondary-button { min-height: 32px; padding: 6px 10px; border-radius: 5px; background: var(--surface); color: var(--muted); }
body .video-selection-tools > button, body .image-selection-tools > button { width: auto; }
.download-toolbar :is(#select-all-videos, #select-all-images), .download-toolbar :is(#clear-all-videos, #clear-all-images) { min-height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 5px; background: var(--field); color: var(--ink); }
.download-toolbar :is(#select-all-videos, #select-all-images)::before { width: 13px; height: 13px; border-color: var(--line); border-radius: 3px; background-color: var(--surface); }
.download-toolbar :is(#select-all-videos, #select-all-images)[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.download-toolbar :is(#download-selected, #image-download-selected), .download-toolbar button[id$="download-selected"] { min-height: 32px; border-radius: 5px; background: var(--button-bg); color: var(--button-ink); box-shadow: none; }
.download-toolbar :is(#download-selected, #image-download-selected):not(:disabled) { background: var(--button-bg); color: var(--button-ink); opacity: 1; box-shadow: none; animation: none; }
.download-toolbar :is(#download-selected, #image-download-selected)::after { display: none; }
.download-toolbar :is(#download-selected, #image-download-selected):disabled { opacity: .4; color: var(--button-ink); }
body #video-selection-summary, body #image-selection-summary { margin-left: auto; padding: 4px 6px; border-radius: 4px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 400; }
body .content-column .layout :is(#empty, #image-empty, #image-edit-empty) { min-height: 430px; align-self: stretch; padding: 38px 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: none; }
body .layout :is(#empty, #image-empty, #image-edit-empty):not([hidden]) { min-height: 430px; flex: 1 1 auto; align-self: stretch; height: 100%; gap: 18px; }
body .content-column .layout > .preview-panel { height: 100%; }
body #history-grid .job-group, body #image-history-grid .job-group, body #history-panel .job-group { background: var(--surface); }
body #history-grid .job-group-head, body #image-history-grid .job-group-head, body #history-panel .job-group > .job-group-head { background: var(--surface); }
body :is(#empty, #image-empty, #image-edit-empty)::before { display: none; }
body .empty-scene { width: min(360px, 100%); aspect-ratio: 8 / 5; background: url('studio-illustration.svg') center / contain no-repeat; }
body .empty-scene::before, body .empty-scene::after, .empty-scene > * { display: none; }
body .empty-copy { max-width: 360px; }
body :is(#empty, #image-empty, #image-edit-empty) .empty-copy h2 { margin: 6px 0 9px; color: var(--ink); font-size: clamp(18px, 1.8vw, 23px); font-weight: 600; letter-spacing: -.6px; animation: none; }
body .empty-copy .eyebrow { font-size: 9px; letter-spacing: .08em; }
body .empty-copy p { color: var(--muted); font-size: 11px; line-height: 1.8; }
body #audio-empty, body #workflow-empty, body #workflow-history-empty { min-height: 220px; display: grid; place-content: center; text-align: center; padding: 28px; background: var(--surface); }
body .preview-card, body .history-card, body .audio-card { border-color: var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); box-shadow: var(--surface-shadow); }
body .preview-card:hover, body .history-card:hover { border-color: var(--line); box-shadow: var(--surface-shadow-hover); }
body .preview-card .card-head, #jobs .card-head { border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); box-shadow: none; }
body .preview-card .card-title, #jobs .card-title { color: var(--ink); font-weight: 500; }
body .preview-card .stream-status, body .audio-card-text, body .workflow-message, body .image-chat-prompt { background: var(--field); color: var(--ink); }
body .preview-card[data-state="done"] .stream-status { background: var(--accent-soft); color: var(--accent); }
body .preview-card .downloads .cancel-job, body #image-jobs .downloads .video-select { border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); }
body .audio-voices, body .audio-voice, body #audio-voice-search, body #audio-voice-list .audio-voice-play { border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
body .audio-voice:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: inset 2px 0 var(--accent); }
body #audio-voice-list .audio-voice:has(input:checked) .audio-voice-play, body #audio-voice-list .audio-voice:hover .audio-voice-play { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body .audio-text-copy, body .audio-text-copy:hover { border-color: var(--line); background: var(--surface); color: var(--muted); }
body .video-select { border-color: var(--line); background: var(--surface); color: var(--ink); }
body .video-select:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body .history-card .history-actions .primary-link, body .downloads a { border-color: var(--button-border); background: var(--button-bg); color: var(--button-ink); }
body #history-panel, body #accounts-panel { padding: 24px; }
body #history-panel .history-heading h1, body #accounts-panel .section-head h1 { color: var(--ink); font-size: 17px; font-weight: 600; letter-spacing: -.4px; }
body .history-empty-icon { background: var(--accent-soft); color: var(--accent); border-radius: 9px; }
body .history-tabs, body .workflow-tabs { gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); box-shadow: none; }
body .history-tabs [role="tab"], body .workflow-tabs [role="tab"] { min-height: 36px; padding: 7px 10px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; }
body .history-tabs [role="tab"][aria-selected="true"], body .workflow-tabs [role="tab"][aria-selected="true"] { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #00000005; }
body .workflow-tabs [role="tab"]::after { display: none; }
body .job-group-toggle, body .job-group-close { border-color: var(--line); border-radius: 7px; background: var(--field); color: var(--ink); box-shadow: none; }
body #history-grid .job-group.is-expanded, body #image-history-grid .job-group.is-expanded, body #history-panel .job-group.is-expanded > .job-group-head { background: var(--surface); border-color: var(--line); }

/* Workflow trees and account tables. */
body .workflow-branch, body .workflow-result-branch, body .workflow-tools, body .workflow-shuffle-details, body .workflow-step-status { border-color: var(--line); border-radius: 7px; background: var(--field); color: var(--ink); }
body .workflow-run-content { border-color: var(--line); }
body .workflow-result-label, body .workflow-zoom, body .workflow-step a, body .workflow-shuffle-item, body .workflow-shuffle-audio-item { border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); box-shadow: none; }
body .workflow-toggle::before { border-color: var(--line); border-radius: 6px; background: var(--field); }
body .workflow-zoom-button:hover, body .workflow-zoom-fit[aria-pressed="true"], body .workflow-step a:hover { background: var(--accent-soft); color: var(--accent); }
body .table-wrap { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
body table { color: var(--ink); }
body th, .admin-shell .users-table th, body .analytics-summary caption { border-color: var(--line); background: var(--field); color: var(--muted); font-size: 10px; font-weight: 500; }
body td, .admin-shell .users-table td { border-color: var(--line); background: transparent; font-size: 11px; }
body tbody tr:hover, body tbody tr:nth-child(even) { background: var(--canvas); }
body .account-setup, body .account-form, body .account-stats, body .token-box, body .account-pagination { border-color: var(--line); background: var(--surface); color: var(--ink); }
body .account-plan, body .balance-panel, body .identity-avatar { border-color: var(--line); background: var(--field); color: var(--ink); }
body .account-plan-bar, body .balance-bar { background: var(--line); }
body .account-plan-bar > span, body .balance-bar > span { background: var(--accent); }
body .error-banner, body .form-feedback[data-error="true"] { border-color: var(--error-border); border-radius: 6px; background: var(--error-bg); color: var(--error); }
body .form-feedback { border-color: var(--line); border-radius: 6px; background: var(--field); color: var(--ink); }

/* Authentication and administration use the same surfaces and spacing. */
body.auth-page, body.password-page { background: var(--background-base); }
.auth-page .auth-header { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; padding: 20px 32px; }
.auth-header .auth-header-link { color: var(--muted); font-size: 12px; }
.auth-page .auth-layout { max-width: 1160px; grid-template-columns: minmax(0, 1fr) 400px; gap: 100px; padding: 52px 32px 72px; }
body .auth-orbs { display: none; }
.auth-intro .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: .05em; }
.auth-intro .eyebrow::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.auth-intro h1 { margin: 20px 0; font-size: clamp(34px, 3.3vw, 46px); font-weight: 600; line-height: 1.2; letter-spacing: -1.6px; }
.auth-intro h1 span { color: var(--ink); }
.auth-intro > p { max-width: 400px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.auth-intro .auth-art { height: auto; aspect-ratio: 8 / 5; max-width: 420px; margin-top: 25px; background: url('studio-illustration.svg') center / contain no-repeat; }
.auth-art > * { display: none; }
body .auth-card { padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--background-base) 72%, transparent); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); box-shadow: var(--surface-shadow); }
body .auth-card:focus-within { border-color: var(--line); box-shadow: var(--surface-shadow-hover); }
.auth-card > .eyebrow { font-size: 9px; letter-spacing: .1em; }
.auth-card h2 { margin: 10px 0; font-size: 23px; font-weight: 600; letter-spacing: -.6px; }
.auth-card .auth-subtitle { color: var(--muted); font-size: 12px; line-height: 1.8; }
.auth-card .auth-switch { margin-bottom: 24px; padding: 3px; border-color: var(--line); border-radius: 6px; background: var(--field); }
.auth-card .auth-switch a { padding: 7px; border: 1px solid transparent; border-radius: 4px; color: var(--muted); font-size: 12px; }
.auth-card .auth-switch a[aria-current] { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #00000004; font-weight: 500; }
.auth-card .auth-switch a:hover { transform: none; }
.auth-card .stack-form input { min-height: 40px; }
.auth-card .password-field button { top: 5px; color: var(--muted); }
body .auth-footer { max-width: none; margin: 0; padding: 18px 32px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 11px; }
.password-page .auth-card { width: min(480px, 100%); margin: 24px auto 60px; }
body .admin-shell .admin-heading { padding: 0 0 26px; }
.admin-shell .admin-heading h1 { font-size: 28px; font-weight: 600; letter-spacing: -.9px; }
body .admin-shell .admin-settings .card, body .admin-shell .users-section, body .admin-shell .admin-history { padding: 22px; border-color: var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--surface-shadow); }
body .admin-shell .admin-settings h2 { font-size: 14px; font-weight: 600; }
body .admin-shell .admin-settings .card:hover, body .admin-shell .admin-history:hover { border-color: var(--line); box-shadow: var(--surface-shadow-hover); }
body .admin-analytics { margin-bottom: 24px; padding: 22px; }
body .admin-analytics h2 { font-size: 19px; font-weight: 600; }
body .analytics-filters input, body .analytics-filters select { border-color: var(--line); background: var(--surface); color: var(--ink); }
body .analytics-charts { --chart-series: var(--accent); color-scheme: inherit; }
body .analytics-chart { padding: 18px; background: var(--surface); }
body .chart-plot { background-image: repeating-linear-gradient(to top, transparent 0, transparent 49px, var(--line) 49px, var(--line) 50px); }
body .chart-hit { border-bottom-color: var(--line); }
body .chart-hit:hover, body .chart-hit:focus-visible { background: var(--accent-soft); }
body .chart-bar { background: var(--accent); }
body .analytics-detail tbody th, body .analytics-summary caption { background: var(--surface); color: var(--ink); }
body .permission-options, body .admin-shell .user-filters { border-color: var(--line); border-radius: 6px; background: var(--field); }
body .admin-shell .user-filters input, body .admin-shell .user-filters select { background: var(--surface); }
body .user-state { border-color: var(--line); background: var(--field); color: var(--muted); }
body .user-state[data-state="active"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body .user-state[data-state="blocked"] { border-color: var(--error-border); background: var(--error-bg); color: var(--error); }
body .management-dialog { padding: 24px; border-color: var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
body .management-dialog::backdrop { background: #09090b80; backdrop-filter: blur(3px); }

/* Secondary panels and dialogs also follow the selected theme. */
body .image-edit-card, body .image-chat, body .image-chat-turn, body .image-chat-nav, body .image-edit-arrow,
body .account-import, body .account-login-log, body .error-toast, body .confirm-toast {
  border-color: var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: var(--surface-shadow);
}
body .image-chat-turn[data-role="user"], body .image-chat-placeholder { border-color: var(--line); background: var(--field); color: var(--muted); }
body #accounts-panel .account-setup > * { padding: 18px; border-color: var(--line); border-radius: 8px; background: var(--canvas); }
body .switch-label, body .index-pill, body .token-chip, body .reset-time, body .plan-badge { border-color: var(--line); background: var(--field); color: var(--ink); box-shadow: none; }
body .switch-label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body .quota-track { background: var(--line); }
body .account-state[data-kind="ready"], body .account-state[data-kind="off"] { background: var(--field); color: var(--muted); }
body .account-state[data-kind="busy"], body .account-state[data-kind="pending"] { background: var(--accent-soft); color: var(--accent); }
body .account-row:focus-within { background: var(--field); }
body .account-actions .account-delete { color: var(--error); }
body #account-stats-dialog { border-color: var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); color-scheme: inherit; }
body #account-stats-content, body #account-stats-close { border-color: var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
body #account-stats-form, body #account-stats-email, body .account-stats-table summary { border-color: var(--line); border-radius: 6px; background: var(--field); color: var(--muted); }
body .account-chart-plot { background-image: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 50px); }
body .account-chart-bars { border-color: var(--line); }
body .account-chart-hit:hover, body .account-chart-hit:focus-visible { background: var(--field); }
body .history-tabs [role="tab"]:not([aria-selected="true"]):hover, body .workflow-tabs [role="tab"]:not([aria-selected="true"]):hover { background: var(--surface); color: var(--ink); }
body .workflow-run:has(.workflow-toggle[aria-expanded="true"]), body .workflow-tree > .workflow-step { border-color: var(--line); box-shadow: var(--surface-shadow); }
body .error-toast[data-kind="success"], body #image-jobs .image-card[data-state="done"] .job-progress-label { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body #image-jobs .image-card[data-state="done"] .preview-stage { background: var(--field); }
body .history-inputs, body .history-prompt, body .image-edit-card-prompt { border-color: var(--line); background: var(--field); color: var(--ink); }
body .submit-btn[aria-busy="true"]::before, body .button-spinner { border-color: color-mix(in srgb, var(--button-ink) 30%, transparent); border-top-color: var(--button-ink); }
body .sidebar-note .sidebar-note-icon { display: grid; }

/* History sessions: one compact frame, with actions attached to each result. */
#history-panel :is(#history-grid, #image-history-grid) {
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  align-items: start;
  gap: 16px;
}
#history-panel :is(#history-grid, #image-history-grid) > .job-group {
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--surface-shadow);
}
#history-panel :is(#history-grid, #image-history-grid) .job-group > .job-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
  padding: 7px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 11px 11px 0 0;
  background: var(--surface);
}
#history-panel :is(#history-grid, #image-history-grid) > .job-group.is-single > .job-group-head {
  display: none;
}
#history-panel .job-group-select { position: relative; display: inline-flex; justify-content: center; flex: 0 0 24px; min-height: 32px; padding: 0; }
#history-panel .job-group-select input { width: 16px; height: 16px; accent-color: var(--accent); }
#history-panel .job-group-select > span { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#history-panel .job-group-label { margin-right: auto; color: var(--ink); font-size: 12px; font-weight: 600; letter-spacing: 0; }
#history-panel :is(#history-grid, #image-history-grid) .job-group-toggle {
  flex: none; width: auto; min-height: 32px; gap: 5px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
#history-panel :is(#history-grid, #image-history-grid) .job-group-toggle:hover { background: var(--field); color: var(--ink); }
#history-panel .job-group > .history-card { gap: 8px; padding: 12px; border: 0; border-radius: 0 0 11px 11px; box-shadow: none; }
#history-panel .job-group > .history-card:hover { box-shadow: none; }
#history-panel .history-card .history-stage { height: auto; max-height: 230px; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--field); }
#history-panel .history-card .history-stage video { width: 100%; height: 100%; object-fit: contain; }
#history-panel .history-card.image-card .preview-stage { max-height: 230px; aspect-ratio: 4 / 3; background: var(--field); }
#history-panel .history-card .history-inputs { min-width: 0; margin: 0; background: transparent; }
#history-panel .history-prompt-details { min-width: 0; margin: 0; padding: 0; border: 0; }
#history-panel .history-prompt-details > summary { display: block; position: relative; padding: 3px 18px 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; line-height: 1.6; list-style: none; }
#history-panel .history-prompt-details > summary::-webkit-details-marker { display: none; }
#history-panel .history-prompt-details > summary::after { content: ''; position: absolute; right: 3px; top: 9px; width: 5px; height: 5px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(45deg); }
#history-panel .history-prompt-details[open] > summary::after { top: 12px; transform: rotate(225deg); }
#history-panel .history-prompt-details .history-prompt { margin-top: 6px; max-height: 150px; font-size: 11px; }
#history-panel .history-created { font-size: 10px; color: var(--muted); }
#history-panel .history-card .history-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin: 0; padding-top: 9px; }
#history-panel .history-actions .download-selection { flex: 1; }
#history-panel .history-actions .video-select { justify-content: flex-start; gap: 7px; width: auto; min-height: 34px; padding: 4px 0; border: 0; background: transparent; font-size: 11px; font-weight: 400; color: var(--muted); }
#history-panel .history-actions .video-select > span { display: inline; }
#history-panel .history-actions .video-select input { width: 15px; height: 15px; accent-color: var(--accent); }
#history-panel .history-actions .history-btn { flex: 0 0 34px; width: 34px; min-height: 34px; padding: 7px; border-radius: 6px; }
#history-panel .history-actions .history-btn svg { width: 17px; height: 17px; }
#history-panel .history-actions .danger-btn { color: var(--muted); border-color: transparent; background: transparent; }
#history-panel .history-actions .danger-btn:hover { color: var(--error); background: var(--error-bg); border-color: var(--error-border); }
#history-panel .job-group.is-single .history-actions .download-selection { visibility: hidden; }
#history-panel :is(#history-grid, #image-history-grid) .job-group:has(.job-group-select input:checked) { border-color: var(--accent-line); }
#history-panel :is(#history-grid, #image-history-grid) .job-group:has(.job-group-select input:checked) > .job-group-head { background: var(--surface); }
#history-panel :is(#history-grid, #image-history-grid) > .job-group.is-expanded {
  width: min(var(--session-width, 872px), calc(100vw - 32px));
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 16px; padding: 16px; border-radius: 14px;
  background: var(--surface); box-shadow: 0 24px 80px #09090b33;
}
#history-panel :is(#history-grid, #image-history-grid) .job-group.is-expanded > .job-group-head {
  top: -16px; margin: -16px -16px 0; padding: 10px 16px; border-radius: 0; background: var(--surface);
}
#history-panel .job-group.is-expanded > .history-card { border: 1px solid var(--line); border-radius: 10px; }
#history-panel .job-group.is-expanded .history-stage { height: 260px; max-height: 260px; aspect-ratio: auto; }
#history-panel .job-group-close { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 6px; background: var(--field); }
#history-panel .job-group-close svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#history-panel .job-group-close:hover { color: var(--ink); background: var(--line); }
@media (pointer: coarse) {
  #history-panel .history-actions .history-btn { flex-basis: 40px; width: 40px; min-height: 40px; }
  #history-panel .history-actions .video-select, #history-panel .job-group-select { min-height: 40px; }
}

@media (min-width: 901px) {
  .workspace-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar-expanded .workspace-shell { grid-template-columns: 224px minmax(0, 1fr); }
  body .sidebar { position: sticky; top: 0; align-self: start; display: flex; min-height: calc(100dvh - 72px); padding: 28px 12px 24px; border: 0; border-right: 1px solid var(--line); border-image: none; border-radius: 0; background: var(--surface); }
  .sidebar-expanded .sidebar .sidebar-label { height: auto; margin: 0 12px 15px; }
  .sidebar-expanded .sidebar .workspace-tabs button, .sidebar-expanded .sidebar .admin-nav-link { padding-inline: 12px; gap: 10px; }
  .sidebar .sidebar-note { display: none; }
  .sidebar-expanded .sidebar .sidebar-note { display: block; margin-top: 36px; }
  .sidebar-expanded .sidebar .workspace-tabs .count-badge { background: var(--surface); color: var(--muted); }
}
@media (max-width: 1200px) {
  .shell .content-column, .admin-shell .content-column { padding: 26px 24px 32px; }
  .content-column .layout { grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); gap: 18px; }
  .content-column .layout > .editor-card { padding: 18px; }
  .workspace-heading-tag { display: none; }
  .auth-page .auth-layout { gap: 50px; }
}
@media (max-width: 1080px) {
  .content-column .layout { grid-template-columns: minmax(0, 1fr); }
  .content-column .layout > .editor-card { max-width: none; }
}
@media (max-width: 900px) {
  .workspace-shell { display: block; }
  .shell > .nav-wrap { padding: 0 20px; }
  .nav-wrap .nav-pill { gap: 12px; }
  .workspace-heading { margin-bottom: 22px; padding-bottom: 22px; }
  body .sidebar { padding: 20px 12px; border-right: 1px solid var(--line); border-radius: 0; background: var(--surface); }
  body .sidebar-note { margin-top: 24px; }
  body .sidebar-backdrop { background: #09090b66; backdrop-filter: blur(2px); }
  body .sidebar .workspace-tabs button, body .sidebar .admin-nav-link { justify-content: flex-start; padding: 10px 12px; font-size: 13px; }
  .sidebar .account-links.admin-nav-actions { justify-content: flex-start; }
  .auth-page .auth-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; }
}
@media (max-width: 760px) {
  .auth-page .auth-layout { display: block; max-width: 430px; padding: 28px 20px 52px; }
  .auth-page .auth-header { padding: 20px; }
  .auth-page .auth-intro { display: none; }
  .auth-header-link { display: none; }
}
@media (max-width: 600px) {
  .shell > .nav-wrap { padding: 0 16px; }
  .nav-wrap .nav-pill { min-height: 64px; flex-wrap: wrap; gap: 10px; padding: 12px 0; }
  body .brand { gap: 8px; font-size: 16px; }
  body .brand-logo { width: 30px; height: 30px; border-radius: 7px; font-size: 19px; }
  body .brand small { font-size: 7px; }
  .nav-pill .studio-userbar { flex: 1 0 100%; justify-content: space-between; gap: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
  .studio-userbar .credit-label { flex: 0 1 auto; }
  body #server-status { min-height: 26px; padding: 4px 8px; font-size: 10px; }
  .header-actions { gap: 7px; margin-left: auto; }
  .studio-role { display: none; }
  .shell .content-column, .admin-shell .content-column { padding: 24px 16px 30px; }
  .workspace-heading { gap: 12px; margin-bottom: 20px; padding-bottom: 20px; }
  .workspace-heading h1 { font-size: 24px; letter-spacing: -.7px; }
  .workspace-heading p { font-size: 12px; line-height: 1.8; }
  .workspace-heading .eyebrow { font-size: 9px; }
  .content-column .layout { gap: 18px; }
  .content-column .layout > .editor-card, body #history-panel, body #accounts-panel { padding: 18px; }
  body .download-toolbar { gap: 5px; }
  body #video-selection-summary, body #image-selection-summary { flex: 1 0 100%; margin-left: 0; padding: 3px 5px; }
  body .layout :is(#empty, #image-empty, #image-edit-empty):not([hidden]) { min-height: 340px; padding: 26px 18px; }
  body .empty-scene { width: min(300px, 100%); }
  body .content-column .layout :is(#empty, #image-empty, #image-edit-empty) { min-height: 340px; padding: 26px 18px; }
  body .empty-copy h2 { font-size: 20px; }
  .shell > footer { padding: 15px 16px; }
  body .auth-card { padding: 24px; }
  .admin-shell .nav-pill .admin-nav-actions { flex: 1 0 100%; flex-wrap: wrap; justify-content: space-between; gap: 4px; padding-top: 9px; border-top: 1px solid var(--line); }
  .admin-shell .nav-pill .admin-nav-link { padding: 5px; font-size: 10px; }
  .admin-shell .nav-pill .admin-nav-divider { display: none; }
  body .admin-shell .admin-heading h1 { max-width: none; font-size: 24px; }
  body .admin-shell .admin-heading h1 > span { display: inline; }
  body .admin-analytics, body .admin-shell .admin-settings .card, body .admin-shell .users-section, body .admin-shell .admin-history { padding: 18px; }
  body .history-tabs [role="tab"], body .workflow-tabs [role="tab"] { padding: 7px 5px; font-size: 10px; }
  .auth-page .auth-footer { padding: 18px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

body .video-backgrounds { background: var(--field); border-color: var(--line); }
body .video-background-item { background: var(--surface); color: var(--ink); border-color: var(--line); }
body .video-background-item:hover { border-color: var(--accent-line); }
body .video-background-item:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }

/* Video variant cards use the same light surfaces as the rest of the studio. */
body #jobs .preview-card { background: var(--surface); }
body #jobs .card-head { border-color: var(--line); background: var(--field); box-shadow: none; }
body #jobs .card-title { color: var(--ink); }
body #jobs .card-account { color: var(--muted); }
body #jobs .card-title::before { box-shadow: none; }
body #jobs .preview-stage, body #jobs .preview-stage video { background: var(--field); color: var(--muted); }
body #jobs .preview-stage .loading::before { background: radial-gradient(ellipse, var(--accent-line) 0%, transparent 65%); }
body #jobs .preview-stage .spinner { border-color: var(--line); background: transparent; box-shadow: none; }
body #jobs .preview-stage .spinner::before { border-top-color: var(--accent); border-right-color: var(--accent-line); }
body #jobs .preview-stage .spinner::after { border-bottom-color: var(--accent); border-left-color: var(--accent-line); }
body #jobs .preview-stage .elapsed { border-color: var(--line); background: var(--surface); color: var(--ink); }
body #jobs .preview-stage .stage-message, body #jobs .preview-stage .loading small { color: var(--muted); }
body #jobs .preview-card[data-state="error"] .loading::before { background: radial-gradient(ellipse, var(--error-border) 0%, transparent 65%); }
body #jobs .preview-card[data-state="error"] .elapsed { border-color: var(--error-border); background: var(--error-bg); color: var(--error); }
body #jobs .job-progress-label { color: var(--muted); }

body #jobs .preview-card .job-progress{ display:none; }
body #jobs .preview-card[data-state="done"] .job-progress, body #jobs .preview-card[data-state="error"] .job-progress{ display:block; margin:8px 0 0; }
body #jobs .preview-card[data-state="done"] .job-progress-label, body #jobs .preview-card[data-state="error"] .job-progress-label{ color:var(--muted); }
body #jobs .preview-card[data-state="done"] .elapsed{ border-color:var(--accent-line); background:var(--accent-soft); color:var(--accent); }
