/*
 * Videogen dashboard — design system (docs/UI.md).
 * System fonts only, no external resources (CSP: style-src 'self'). Light and dark themes: the
 * system setting by default, or <html data-theme="light|dark"> from the header's toggle.
 */

/* ---- 1. tokens ------------------------------------------------------------------------------ */

:root {
    color-scheme: light dark;
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f2f4f8;
    --surface-3: #e8ebf2;
    --border: #e3e6ee;
    --border-strong: #c9cfdd;
    --text: #141827;
    --text-2: #3b4257;
    --muted: #5f6880;
    --accent: #5257d9;
    --accent-strong: #3f44c2;
    --accent-soft: #ebecfc;
    --on-accent: #ffffff;
    --success: #15803d;
    --success-soft: #dcf5e6;
    --warning: #9a5600;
    --warning-soft: #fdf0d5;
    --danger: #b42318;
    --danger-soft: #fde4e1;
    --info: #1d5fb4;
    --info-soft: #e1ecfb;
    --attention: #6b3fc9;
    --attention-soft: #efe7fd;
    --muted-soft: #eaedf3;
    --media-bg: #0b0d12;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px -2px rgba(16, 24, 40, 0.1);
    --shadow-lg: 0 20px 48px -20px rgba(16, 24, 40, 0.35);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-8: 3rem;
    --fs-xs: 0.74rem;
    --fs-sm: 0.82rem;
    --fs-md: 0.94rem;
    --fs-lg: 1.05rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.6rem;
    --fs-3xl: 2.1rem;
    --header-h: 56px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    /* semantic status colours: running / done / waiting (for you) / failed / paused / cancelled */
    --st-running: var(--accent);
    --st-running-soft: var(--accent-soft);
    --st-done: var(--success);
    --st-done-soft: var(--success-soft);
    --st-waiting: var(--attention);
    --st-waiting-soft: var(--attention-soft);
    --st-failed: var(--danger);
    --st-failed-soft: var(--danger-soft);
    --st-paused: var(--warning);
    --st-paused-soft: var(--warning-soft);
    --st-cancelled: var(--muted);
    --st-cancelled-soft: var(--muted-soft);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1016;
        --surface: #161923;
        --surface-2: #1c2030;
        --surface-3: #262b3b;
        --border: #272c3b;
        --border-strong: #3a4155;
        --text: #e9ebf2;
        --text-2: #c5cad8;
        --muted: #949cb2;
        --accent: #8b8ffb;
        --accent-strong: #a7aaff;
        --accent-soft: #252850;
        --on-accent: #0e1016;
        --success: #45c984;
        --success-soft: #123320;
        --warning: #f1b55c;
        --warning-soft: #352810;
        --danger: #ff8178;
        --danger-soft: #3b1a17;
        --info: #74adff;
        --info-soft: #14294a;
        --attention: #b69bff;
        --attention-soft: #2a2049;
        --muted-soft: #232838;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px -2px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 48px -20px rgba(0, 0, 0, 0.8);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1016;
    --surface: #161923;
    --surface-2: #1c2030;
    --surface-3: #262b3b;
    --border: #272c3b;
    --border-strong: #3a4155;
    --text: #e9ebf2;
    --text-2: #c5cad8;
    --muted: #949cb2;
    --accent: #8b8ffb;
    --accent-strong: #a7aaff;
    --accent-soft: #252850;
    --on-accent: #0e1016;
    --success: #45c984;
    --success-soft: #123320;
    --warning: #f1b55c;
    --warning-soft: #352810;
    --danger: #ff8178;
    --danger-soft: #3b1a17;
    --info: #74adff;
    --info-soft: #14294a;
    --attention: #b69bff;
    --attention-soft: #2a2049;
    --muted-soft: #232838;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 48px -20px rgba(0, 0, 0, 0.8);
}

:root[data-theme="light"] {
    color-scheme: light;
}

/* ---- 2. base -------------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 15px/1.55 var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3 {
    line-height: 1.25;
    margin: 0 0 0.5rem;
    letter-spacing: -0.012em;
    overflow-wrap: anywhere;
}

h1 {
    font-size: var(--fs-2xl);
    font-weight: 750;
}

h2 {
    font-size: var(--fs-lg);
    font-weight: 700;
}

h3 {
    font-size: var(--fs-md);
    font-weight: 650;
}

p {
    margin: 0 0 0.75rem;
}

img,
video {
    display: block;
    max-width: 100%;
}

code {
    font-family: var(--mono);
    font-size: 0.86em;
    padding: 0.1em 0.35em;
    border-radius: 5px;
    background: var(--surface-2);
    overflow-wrap: anywhere;
}

blockquote {
    margin: 0;
}

time,
.num,
.money,
.tabular {
    font-variant-numeric: tabular-nums;
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 2px;
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    flex: none;
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.14em;
}

.icon--lg {
    width: 1.35em;
    height: 1.35em;
}

/* utilities */

.muted {
    color: var(--muted);
}

.small {
    font-size: var(--fs-sm);
}

.nowrap {
    white-space: nowrap;
}

.num {
    text-align: right !important;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0.5rem;
    z-index: 100;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    left: 0.5rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stack > .field {
    margin: 0;
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.row--center {
    justify-content: center;
}

.row--between {
    justify-content: space-between;
}

.row--end {
    align-items: flex-end;
}

.row--end > .field {
    flex: 1 1 320px;
    margin: 0;
}

.inline-form {
    display: inline;
    margin: 0;
}

.plain-list {
    margin: 0.3rem 0 0;
    padding-left: 1.1rem;
}

.lead {
    font-size: var(--fs-lg);
    color: var(--text-2);
}

.subhead {
    margin: 1.2rem 0 0.6rem;
    font-size: var(--fs-md);
}

/* ---- 3. app shell --------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
}

.topbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    max-width: 1200px;
    min-height: var(--header-h);
    margin: 0 auto;
    padding: 0.4rem 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    font-weight: 750;
    font-size: var(--fs-lg);
    letter-spacing: -0.01em;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
}

.brand__logo {
    flex: none;
    width: 30px;
    height: 30px;
}

.brand__logo--lg {
    width: 56px;
    height: 56px;
}

.nav {
    display: flex;
    flex: 1;
    gap: 0.15rem;
    min-width: 0;
}

.nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 560;
    white-space: nowrap;
}

.nav__link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav__link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.nav-toggle__input,
.nav-toggle {
    display: none;
}

.topbar__status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}

.topbar__tools {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 34px;
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font-size: var(--fs-sm);
    white-space: nowrap;
}

.chip:hover {
    text-decoration: none;
    border-color: var(--border-strong);
    color: var(--text);
}

.chip strong {
    font-variant-numeric: tabular-nums;
}

.dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.chip.is-online .dot {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.chip.is-offline .dot {
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.theme-toggle,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 1.15rem;
    cursor: pointer;
}

.theme-toggle:hover,
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.theme-toggle .icon {
    display: none;
}

html:not([data-theme]) .theme-toggle__auto,
html[data-theme="light"] .theme-toggle__light,
html[data-theme="dark"] .theme-toggle__dark {
    display: block;
}

.page {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin: 0;
}

.page-head p {
    margin: 0.3rem 0 0;
    max-width: 70ch;
}

.page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 32px;
    color: var(--muted);
    font-size: var(--fs-sm);
    font-weight: 550;
}

.back-link:hover {
    color: var(--accent);
    text-decoration: none;
}

.footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
    border-top: 1px solid var(--border);
    font-size: var(--fs-sm);
    color: var(--muted);
}

/* ---- 4. components -------------------------------------------------------------------------- */

/* buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.btn--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
}

.btn--secondary {
    background: var(--surface-2);
}

.btn--secondary:hover {
    background: var(--surface-3);
}

.btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
}

.btn--ghost:hover {
    color: var(--text);
}

.btn--danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
}

.btn--danger:hover {
    border-color: color-mix(in srgb, var(--danger) 82%, #000000);
    background: color-mix(in srgb, var(--danger) 82%, #000000);
}

.btn--danger-ghost {
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    background: transparent;
    color: var(--danger);
}

.btn--danger-ghost:hover {
    background: var(--danger-soft);
}

.btn--sm {
    min-height: 34px;
    padding: 0.3rem 0.75rem;
    border-radius: 8px;
    font-size: var(--fs-sm);
}

.btn--lg {
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    font-size: var(--fs-lg);
}

.btn--block {
    width: 100%;
}

.btn[disabled],
.btn.is-busy {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.is-busy::before {
    content: "";
    flex: none;
    width: 0.9em;
    height: 0.9em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* badges (status pills with a dot; the label, not the colour, carries the meaning) */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.14rem 0.6rem;
    border-radius: 999px;
    background: var(--muted-soft);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 650;
    line-height: 1.6;
    white-space: nowrap;
}

.badge::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge--success {
    background: var(--st-done-soft);
    color: var(--st-done);
}

.badge--warning {
    background: var(--st-paused-soft);
    color: var(--st-paused);
}

.badge--danger {
    background: var(--st-failed-soft);
    color: var(--st-failed);
}

.badge--info {
    background: var(--info-soft);
    color: var(--info);
}

.badge--attention {
    background: var(--st-waiting-soft);
    color: var(--st-waiting);
}

.badge--progress {
    background: var(--st-running-soft);
    color: var(--accent-strong);
}

.badge--progress::before {
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.35;
        transform: scale(0.7);
    }
}

/* progress bars */

.bar {
    display: block;
    width: 100%;
    max-width: 140px;
    height: 6px;
    margin-top: 0.35rem;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: var(--surface-3);
    -webkit-appearance: none;
    appearance: none;
}

.bar::-webkit-progress-bar {
    border-radius: 999px;
    background: var(--surface-3);
}

.bar::-webkit-progress-value {
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.4s;
}

.bar::-moz-progress-bar {
    border-radius: 999px;
    background: var(--accent);
}

.bar--lg {
    max-width: none;
    height: 8px;
}

.bar--warning::-webkit-progress-value {
    background: var(--warning);
}

.bar--warning::-moz-progress-bar {
    background: var(--warning);
}

/* cards & sections */

.card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    min-width: 0;
}

.card--flush {
    padding: 0;
    overflow: hidden;
}

.card__title,
.section__title {
    margin: 0 0 0.85rem;
    font-size: var(--fs-lg);
    font-weight: 700;
}

.card__head,
.section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 1rem;
    margin-bottom: 0.75rem;
}

.card__head .card__title,
.section__head .section__title {
    margin: 0;
}

.section {
    margin-bottom: 1.25rem;
}

.section__more {
    margin-top: 0.85rem;
}

.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1.25rem;
}

.columns > .section {
    margin: 0;
}

.action-card .section__title,
.danger-zone .section__title {
    margin-bottom: 0.2rem;
}

.action-card p,
.danger-zone p {
    margin: 0;
}

.danger-zone {
    border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

/* tables */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-md);
}

.table th,
.table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child > * {
    border-bottom: 0;
}

.table--compact th,
.table--compact td {
    padding: 0.5rem 0.6rem;
    vertical-align: top;
}

/* model ids stay whole: a narrow table scrolls inside .table-wrap instead of breaking them */
.table code {
    white-space: nowrap;
    overflow-wrap: normal;
}

/* many text columns: scroll inside .table-wrap rather than squeeze every column on a phone */
.table--wide {
    min-width: 640px;
}

.table--projects tbody tr:hover {
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

tr.is-unavailable {
    opacity: 0.6;
}

/* rows stack into labelled blocks on narrow screens (td[data-label]) */
@media (max-width: 640px) {
    .table--stack thead {
        display: none;
    }

    .table--stack tbody,
    .table--stack tr {
        display: block;
    }

    .table--stack tr {
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border);
    }

    .table--stack tr:last-child {
        border-bottom: 0;
    }

    .table--stack td,
    .table--stack th[scope="row"] {
        display: flex;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.3rem 1rem;
        border: 0;
        text-align: left !important;
    }

    .table--stack td:empty {
        display: none;
    }

    .table--stack td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 7rem;
        color: var(--muted);
        font-size: var(--fs-xs);
        font-weight: 650;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .table--stack td.num {
        justify-content: flex-start;
    }
}

/* alerts (flash messages) */

.flashes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid color-mix(in srgb, var(--info) 30%, var(--border));
    border-left: 4px solid var(--info);
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--text);
    font-size: var(--fs-md);
}

.flashes .flash {
    margin: 0;
}

.flash > .icon {
    margin-top: 0.2rem;
    color: var(--info);
}

.flash > span,
.flash > div {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.flash--success {
    border-color: color-mix(in srgb, var(--success) 30%, var(--border));
    border-left-color: var(--success);
    background: var(--success-soft);
}

.flash--success > .icon {
    color: var(--success);
}

.flash--warning {
    border-color: color-mix(in srgb, var(--warning) 30%, var(--border));
    border-left-color: var(--warning);
    background: var(--warning-soft);
}

.flash--warning > .icon {
    color: var(--warning);
}

.flash--error {
    border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
    border-left-color: var(--danger);
    background: var(--danger-soft);
}

.flash--error > .icon {
    color: var(--danger);
}

.flash__close {
    flex: none;
    width: 32px;
    height: 32px;
    margin: -0.3rem -0.4rem -0.3rem 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.65;
    cursor: pointer;
}

.flash__close:hover {
    background: color-mix(in srgb, var(--text) 8%, transparent);
    opacity: 1;
}

/* banners (the project page's status explanation, the worker warning) */

.banner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    border-left: 5px solid var(--muted);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.banner--success {
    border-left-color: var(--success);
    background: linear-gradient(100deg, var(--success-soft), var(--surface) 65%);
}

.banner--warning {
    border-left-color: var(--warning);
    background: linear-gradient(100deg, var(--warning-soft), var(--surface) 65%);
}

.banner--danger {
    border-left-color: var(--danger);
    background: linear-gradient(100deg, var(--danger-soft), var(--surface) 65%);
}

.banner--attention {
    border-left-color: var(--attention);
    background: linear-gradient(100deg, var(--attention-soft), var(--surface) 65%);
}

.banner--progress {
    border-left-color: var(--accent);
}

.banner--info {
    border-left-color: var(--info);
}

.banner__body {
    flex: 1 1 380px;
    min-width: 0;
}

.banner__title {
    margin: 0 0 0.3rem;
    font-size: var(--fs-lg);
}

.banner__message {
    margin: 0 0 0.4rem;
    overflow-wrap: anywhere;
}

.banner__details {
    margin: 0.4rem 0;
    padding-left: 1.1rem;
    font-size: var(--fs-md);
}

.banner__details li + li {
    margin-top: 0.2rem;
}

.banner__hint {
    margin: 0.4rem 0 0;
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.banner__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.banner__actions form {
    margin: 0;
}

.worker-banner .banner__title {
    color: var(--danger);
}

/* empty states */

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state p {
    max-width: 520px;
    margin: 0.5rem auto 1.25rem;
}

.empty-state__art {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 22px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 2rem;
}

/* dialogs */

.dialog {
    width: min(440px, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
    background: rgba(8, 10, 18, 0.55);
    backdrop-filter: blur(2px);
}

.dialog__form {
    margin: 0;
    padding: 1.4rem 1.4rem 1.2rem;
}

.dialog__title {
    margin: 0 0 0.5rem;
    font-size: var(--fs-xl);
}

.dialog__text {
    margin: 0 0 1.2rem;
    color: var(--text-2);
}

.dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* live "updated N s ago" indicator */

.live {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: var(--fs-xs);
    white-space: nowrap;
}

.live .icon {
    color: var(--success);
}

.live.is-stale .icon {
    color: var(--muted);
}

/* stepper (pipeline progress) */

.timeline {
    display: flex;
    margin: 0;
    padding: 0.25rem 0;
    overflow-x: auto;
    list-style: none;
    scrollbar-width: thin;
}

.timeline__step {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    min-width: 84px;
    color: var(--muted);
    font-size: var(--fs-xs);
    line-height: 1.25;
    text-align: center;
}

.timeline__step::before {
    content: "";
    position: absolute;
    top: 9px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border-strong);
}

.timeline__step:first-child::before {
    display: none;
}

.timeline__dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
}

.timeline__step.is-done {
    color: var(--text-2);
}

.timeline__step.is-done::before,
.timeline__step.is-current::before {
    background: var(--accent);
}

.timeline__step.is-done .timeline__dot {
    border-color: var(--accent);
    background: var(--accent);
}

.timeline__step.is-done .timeline__dot::after {
    content: "";
    width: 5px;
    height: 9px;
    margin-top: -2px;
    border: solid var(--on-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.timeline__step.is-current {
    color: var(--text);
    font-weight: 650;
}

.timeline__step.is-current .timeline__dot {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.timeline__step.is-current .timeline__dot::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline__step.is-current.tone-progress .timeline__dot {
    animation: ring 1.8s ease-out infinite;
}

.timeline__step.is-current.tone-warning .timeline__dot {
    border-color: var(--warning);
    box-shadow: 0 0 0 4px var(--warning-soft);
}

.timeline__step.is-current.tone-warning .timeline__dot::after {
    background: var(--warning);
}

.timeline__step.is-current.tone-danger .timeline__dot {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-soft);
}

.timeline__step.is-current.tone-danger .timeline__dot::after {
    width: 2px;
    height: 10px;
    border-radius: 1px;
    background: var(--danger);
    transform: rotate(45deg);
}

.timeline__step.is-current.tone-attention .timeline__dot {
    border-color: var(--attention);
    box-shadow: 0 0 0 4px var(--attention-soft);
}

.timeline__step.is-current.tone-attention .timeline__dot::after {
    background: var(--attention);
}

.timeline__step.is-current.tone-muted .timeline__dot {
    border-color: var(--muted);
    box-shadow: 0 0 0 4px var(--muted-soft);
}

.timeline__step.is-current.tone-muted .timeline__dot::after {
    background: var(--muted);
}

@keyframes ring {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
    }

    100% {
        box-shadow: 0 0 0 10px transparent;
    }
}

/* stats, facts, tags, tiles */

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin-bottom: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat__label {
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stat__value {
    font-size: 1.4rem;
    font-weight: 720;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.4rem 1.25rem;
    margin: 0 0 1rem;
    font-size: var(--fs-md);
}

.facts dt {
    color: var(--muted);
    font-weight: 600;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.tag {
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-xs);
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tile {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.tile p {
    margin: 0 0 0.35rem;
}

/* activity feed (a vertical timeline of events) */

.feed {
    position: relative;
    max-height: 560px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.feed__item {
    position: relative;
    display: flex;
    gap: 0.8rem;
    padding: 0.5rem 0 0.5rem 0.15rem;
}

.feed__item::before {
    content: "";
    position: absolute;
    top: 1.35rem;
    bottom: -0.5rem;
    left: 0.4rem;
    width: 2px;
    background: var(--border);
}

.feed__item:last-child::before {
    display: none;
}

.feed__item.is-new {
    animation: arrive 1.6s ease-out;
}

@keyframes arrive {
    from {
        background: var(--accent-soft);
    }

    to {
        background: transparent;
    }
}

.feed__dot {
    flex: none;
    z-index: 1;
    width: 10px;
    height: 10px;
    margin: 0.5rem 0 0 0.05rem;
    border-radius: 50%;
    background: var(--info);
    box-shadow: 0 0 0 3px var(--surface);
}

.feed__item--danger .feed__dot {
    background: var(--danger);
}

.feed__item--warning .feed__dot {
    background: var(--warning);
}

.feed__item--success .feed__dot {
    background: var(--success);
}

.feed__item--muted .feed__dot {
    background: var(--muted);
}

.feed__body {
    min-width: 0;
}

.feed__message {
    margin: 0;
    font-size: var(--fs-md);
    overflow-wrap: anywhere;
}

.feed__body .muted {
    margin: 0.1rem 0 0;
}

/* galleries & media */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.gallery__item {
    margin: 0;
}

.gallery__item a {
    display: block;
    border-radius: var(--radius-sm);
}

.gallery__item img {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    object-fit: cover;
    transition: transform 0.15s;
}

.gallery__item a:hover img {
    transform: scale(1.02);
}

.gallery__item figcaption {
    margin-top: 0.3rem;
    color: var(--text-2);
}

.media {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    background: var(--media-bg);
}

.media--portrait {
    aspect-ratio: 9 / 16;
    max-height: 520px;
}

.media--square {
    aspect-ratio: 1 / 1;
}

.media video,
.media img {
    width: 100%;
    height: 100%;
    background: #000;
    object-fit: contain;
}

.media > a {
    display: block;
    width: 100%;
    height: 100%;
}

.media__placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    color: #a9b0c3;
    font-size: var(--fs-sm);
    text-align: center;
    background: repeating-linear-gradient(45deg, #11141c, #11141c 12px, #161a25 12px, #161a25 24px);
}

.thumb {
    flex: none;
    width: 80px;
    height: 48px;
    border-radius: 8px;
    background: var(--surface-3);
    object-fit: cover;
}

.thumb--empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.audio {
    width: 100%;
    height: 36px;
}

/* status lists (settings), command lists, chains */

.status-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.status-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.status-list li > .badge {
    flex: none;
    min-width: 6.2rem;
    justify-content: center;
}

.status-list li > div {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.status-list p {
    margin: 0.15rem 0 0;
}

.command-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.55rem 0;
    padding: 0;
    list-style: none;
}

.command-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
}

.command {
    padding: 0.2rem 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface-2);
    font-size: var(--fs-sm);
    overflow-wrap: anywhere;
    user-select: all;
}

.chain {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    padding-left: 1.2rem;
}

.chain__item.is-unavailable code {
    color: var(--muted);
    text-decoration: line-through;
}

.code-block {
    margin: 0 0 1rem;
    padding: 0.8rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.code-block code {
    padding: 0;
    background: none;
    font-size: 0.92rem;
}

/* disclosures & popovers */

.disclosure > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.75rem;
    min-height: 40px;
    list-style: none;
    cursor: pointer;
}

.disclosure > summary::-webkit-details-marker {
    display: none;
}

.disclosure > summary::before {
    content: "";
    align-self: center;
    width: 7px;
    height: 7px;
    margin: 0 0.25rem 0 0.1rem;
    border: solid var(--muted);
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

.disclosure[open] > summary {
    margin-bottom: 1rem;
}

.disclosure[open] > summary::before {
    transform: rotate(45deg);
}

.disclosure > summary .card__title,
.disclosure > summary .section__title {
    margin: 0;
}

.popover > summary {
    list-style: none;
}

.popover > summary::-webkit-details-marker {
    display: none;
}

.popover[open] {
    flex-basis: 100%;
    order: -1;
}

.popover[open] > summary {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.popover__panel {
    margin-top: 0.5rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.pager {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.update-bar {
    position: sticky;
    top: calc(var(--header-h) + 8px);
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow-lg);
}

.update-bar .btn {
    border-color: transparent;
    background: var(--surface);
    color: var(--accent-strong);
}

/* ---- 5. forms ------------------------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0 0 1rem;
    min-width: 0;
}

.field__label {
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 650;
}

.field__hint {
    color: var(--muted);
    font-size: var(--fs-xs);
}

.field__error {
    color: var(--danger);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.field.is-invalid input,
.field.is-invalid textarea,
.field.is-invalid select {
    border-color: var(--danger);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
}

::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.code-input {
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: pre;
    tab-size: 2;
}

.json-ok {
    color: var(--success);
}

.json-error {
    color: var(--danger);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 1rem;
}

.field--wide {
    grid-column: span 2;
}

.fieldset {
    min-width: 0;
    margin: 0 0 1.1rem;
    padding: 0;
    border: 0;
}

.fieldset legend {
    margin-bottom: 0.5rem;
    padding: 0;
}

/* radio cards */

.choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
}

.choice {
    position: relative;
    cursor: pointer;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice__box {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    height: 100%;
    min-height: 44px;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.choice:hover .choice__box {
    border-color: var(--accent);
}

.choice input:checked + .choice__box {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.choice input:focus-visible + .choice__box {
    outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 2px;
}

.ratio {
    display: block;
    margin-bottom: 0.35rem;
    border: 2px solid currentColor;
    border-radius: 4px;
    color: var(--muted);
}

.ratio--16x9 {
    width: 32px;
    height: 18px;
}

.ratio--9x16 {
    width: 14px;
    height: 24px;
}

.ratio--1x1 {
    width: 20px;
    height: 20px;
}

.choice input:checked + .choice__box .ratio {
    color: var(--accent);
}

/* switches */

.switches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
    gap: 0.3rem 1rem;
}

.switch {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.switch:hover {
    background: var(--surface-2);
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch__track {
    position: relative;
    flex: none;
    width: 40px;
    height: 24px;
    margin-top: 1px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-3);
    transition: background-color 0.15s, border-color 0.15s;
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}

.switch input:checked + .switch__track {
    border-color: var(--accent);
    background: var(--accent);
}

.switch input:checked + .switch__track::after {
    transform: translateX(16px);
}

.switch input:focus-visible + .switch__track {
    outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 2px;
}

.switch.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.switch__text {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

/* affixed and password inputs */

.input-affix {
    display: inline-flex;
    align-items: center;
    padding-left: 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.input-affix:focus-within {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.input-affix input {
    width: 7.5rem;
    padding-left: 0.3rem;
    border: 0;
    background: transparent;
    box-shadow: none !important;
}

.input-affix__text {
    color: var(--muted);
    font-weight: 650;
}

.password {
    position: relative;
}

.password input {
    padding-right: 3rem;
}

.password__toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    transform: translateY(-50%);
}

.password__toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}

.password__toggle .icon--off {
    display: none;
}

.password__toggle[aria-pressed="true"] .icon--on {
    display: none;
}

.password__toggle[aria-pressed="true"] .icon--off {
    display: block;
}

/* model pickers */

.model-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.model-field {
    margin-bottom: 0.6rem;
}

.model-field .field__label code {
    padding: 0;
    background: none;
    font-weight: 400;
}

.model-select {
    text-overflow: ellipsis;
}

/* ---- 6. pages ------------------------------------------------------------------------------- */

/* projects list */

.project-cell {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 240px;
    color: inherit;
}

.project-cell:hover {
    text-decoration: none;
}

.project-cell:hover strong {
    color: var(--accent);
}

.project-cell__text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.spend {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.4rem;
    font-variant-numeric: tabular-nums;
}

.spend .bar {
    width: 120px;
    margin: 0;
}

/* project page */

.project-head {
    align-items: flex-start;
    margin-bottom: 1rem;
}

.project-head__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.85rem;
    margin: 0.3rem 0 0.6rem;
}

.project-head__title {
    margin: 0;
    font-size: var(--fs-2xl);
}

.idea {
    margin-bottom: 0.75rem;
    font-size: var(--fs-md);
}

.idea summary {
    min-height: 32px;
    color: var(--muted);
    cursor: pointer;
}

.idea p {
    margin: 0.4rem 0 0;
    white-space: pre-line;
}

.project-head__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.9rem 1.25rem;
}

.summary__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

.summary__spend {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 260px;
    max-width: 440px;
    font-size: var(--fs-sm);
}

.summary__spend .bar {
    max-width: none;
    margin: 0;
}

.summary__spend-text {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-variant-numeric: tabular-nums;
}

.summary__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.summary__actions form {
    margin: 0;
}

@media (min-width: 761px) {
    .summary {
        position: sticky;
        top: calc(var(--header-h) + 8px);
        z-index: 20;
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .summary__bottom {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem 1.5rem;
    }

    .summary__bottom .timeline {
        flex: 1 1 640px;
    }

    /* nine steps must fit beside the actions: labels wrap rather than the stepper scrolling */
    .summary__bottom .timeline__step {
        min-width: 64px;
    }
}

.budget-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.final__player {
    max-width: 960px;
    margin-bottom: 0.9rem;
}

.final__player.media--portrait {
    max-width: 400px;
}

.final__player.media--square {
    max-width: 640px;
}

.script-editor {
    margin-top: 1.25rem;
}

/* shots grid */

.shots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 1rem;
    align-items: start;
}

.shot {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.shot > .media {
    border-radius: var(--radius) var(--radius) 0 0;
}

.shot:target {
    box-shadow: 0 0 0 3px var(--accent);
}

.shot--troubled {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}

.shot--dropped {
    opacity: 0.55;
}

.shot__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem 1rem 1rem;
}

.shot__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.shot__key {
    font-family: var(--mono);
    font-size: var(--fs-md);
}

.shot__take {
    margin-left: auto;
}

.shot__error {
    margin: 0;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: var(--fs-sm);
    overflow-wrap: anywhere;
}

.shot__action {
    margin: 0;
    font-size: var(--fs-md);
}

.shot__body > p.muted {
    margin: 0;
}

.shot__narration {
    padding: 0.35rem 0.7rem;
    border-left: 3px solid var(--accent-soft);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-style: italic;
}

.end-frame {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
}

.end-frame img {
    width: 64px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
}

.qa {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    background: var(--surface-2);
}

.qa p {
    margin: 0.25rem 0 0;
}

.qa--flagged {
    background: var(--warning-soft);
}

.shot__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.shot__actions form {
    margin: 0;
}

.models-used th[scope="rowgroup"] {
    vertical-align: top;
    white-space: nowrap;
}

/* new video */

.new-project {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.25rem;
    align-items: start;
}

.new-project__main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.new-project__side {
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.estimate__total {
    margin: 0.2rem 0 0.4rem;
    font-size: var(--fs-3xl);
    font-weight: 780;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.estimate.is-loading [data-estimate-total] {
    opacity: 0.45;
}

.estimate__items {
    margin: 0.5rem 0 1rem;
}

.estimate__warning {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--warning-soft);
    color: var(--warning);
    font-size: var(--fs-sm);
}

.estimate .btn--block {
    margin: 0.25rem 0 0.75rem;
}

[data-estimate-warnings] {
    margin-top: 0.5rem;
    padding-left: 1.6rem;
}

[data-estimate-warnings] li + li {
    margin-top: 0.45rem;
}

/* models page */

.role-block + .role-block {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.role-block__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
}

.role-block__head .subhead {
    margin-top: 0;
}

.default-form {
    margin-top: 0.75rem;
}

/* sub-pages: forms, confirmations, sign-in, errors */

.form-page,
.confirm-page {
    max-width: 920px;
    margin: 0 auto;
}

.confirm-page {
    max-width: 660px;
}

.form-page__card,
.confirm-page__card {
    margin-top: 0.75rem;
}

.confirm-page__card {
    border-top: 4px solid var(--danger);
}

.confirm-page__list {
    margin: 1rem 0 1.25rem;
}

.confirm-page__list li + li {
    margin-top: 0.35rem;
}

.auth,
.error-page {
    display: grid;
    place-items: center;
    min-height: 60vh;
}

.auth__card {
    width: min(420px, 100%);
    padding: 2rem;
}

.auth__card--wide {
    width: min(580px, 100%);
}

.auth__brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--accent);
}

.auth__title,
.auth__subtitle {
    text-align: center;
}

.auth__title {
    font-size: var(--fs-xl);
}

.auth__foot {
    margin: 1.1rem 0 0;
    text-align: center;
}

.error-page__card {
    max-width: 520px;
    padding: 2.5rem 2rem;
    text-align: center;
}

.error-page__code {
    margin: 0;
    color: var(--accent);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* ---- 7. responsive -------------------------------------------------------------------------- */

@media (max-width: 760px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        order: 3;
        width: 44px;
        height: 44px;
        border-radius: var(--radius-sm);
        color: var(--text-2);
        font-size: 1.4rem;
        cursor: pointer;
    }

    .nav-toggle:hover {
        background: var(--surface-2);
    }

    .nav-toggle .icon--close {
        display: none;
    }

    .nav-toggle__input {
        display: block;
        position: absolute;
        width: 44px;
        height: 44px;
        margin: 0;
        opacity: 0;
        cursor: pointer;
        z-index: -1;
    }

    .nav-toggle__input:focus-visible + .nav-toggle {
        outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    }

    .nav-toggle__input:checked ~ .nav-toggle .icon--menu {
        display: none;
    }

    .nav-toggle__input:checked ~ .nav-toggle .icon--close {
        display: block;
    }

    .topbar__tools {
        order: 2;
        margin-left: auto;
    }

    .nav,
    .topbar__status {
        display: none;
        order: 4;
        flex-basis: 100%;
    }

    .nav-toggle__input:checked ~ .nav,
    .nav-toggle__input:checked ~ .topbar__status {
        display: flex;
    }

    .nav {
        flex-direction: column;
        gap: 0.1rem;
        padding-top: 0.25rem;
        border-top: 1px solid var(--border);
    }

    .nav__link {
        min-height: 44px;
    }

    .topbar__status {
        flex-wrap: wrap;
        margin: 0;
        padding: 0.25rem 0 0.4rem;
    }

    .chip {
        min-height: 40px;
    }

    .btn {
        min-height: 44px;
    }

    .btn--sm {
        min-height: 40px;
    }
}

@media (max-width: 980px) {
    .new-project {
        grid-template-columns: minmax(0, 1fr);
    }

    .new-project__side {
        position: static;
    }
}

@media (max-width: 560px) {
    .page {
        padding: 1rem 1rem 2.5rem;
    }

    .card {
        padding: 1rem;
    }

    .shot,
    .card--flush {
        padding: 0;
    }

    .table th,
    .table td {
        padding: 0.6rem 0.7rem;
    }

    .project-head__title {
        font-size: 1.4rem;
    }

    .field--wide {
        grid-column: auto;
    }

    .facts {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.1rem;
    }

    .facts dd {
        margin-bottom: 0.5rem;
    }

    .page-head__actions,
    .page-head__actions .btn {
        width: 100%;
    }

    .summary {
        padding: 0.85rem 1rem;
    }

    /* compact stepper: every step's dot fits, only the current label shows (the others stay for screen readers) */
    .timeline {
        overflow: visible;
        padding-bottom: 1.5rem;
    }

    .timeline__step {
        min-width: 0;
    }

    .timeline__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .timeline__step.is-current .timeline__label {
        top: 100%;
        left: 50%;
        width: auto;
        height: auto;
        margin-top: 0.3rem;
        overflow: visible;
        clip: auto;
        transform: translateX(-50%);
    }

    .timeline__step.is-current:first-child .timeline__label {
        left: 0;
        transform: none;
    }

    .timeline__step.is-current:last-child .timeline__label {
        left: auto;
        right: 0;
        transform: none;
    }

    .stat__value {
        font-size: 1.2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .topbar,
    .footer,
    .skip-link,
    .update-bar,
    .summary__actions,
    .banner__actions,
    .shot__actions,
    .flash__close,
    .theme-toggle,
    .danger-zone,
    .btn {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card,
    .banner {
        box-shadow: none;
        break-inside: avoid;
    }

    .summary {
        position: static;
    }

    .feed {
        max-height: none;
        overflow: visible;
    }
}
