/* =============================================================================
   Anim8or — dark technical admin theme
   ============================================================================= */

:root {
    --bg-app: #0f172a;
    --bg-panel: #111827;
    --bg-card: #1e293b;
    --bg-card-hover: #24344d;
    --border: #334155;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #22d3ee;
    --accent-hover: #06b6d4;
    --accent-ink: #04222b;

    --status-pending: #f59e0b;
    --status-processing: #22d3ee;
    --status-completed: #10b981;
    --status-failed: #f43f5e;
    --status-canceled: #94a3b8;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 12px;

    --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --shadow-float: 0 6px 20px rgba(2, 6, 23, 0.55);

    --sidebar-right-width: 340px;
}

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

html,
body {
    margin: 0;
    padding: 0;
}

/* Class-based display rules would otherwise beat the [hidden] attribute, which
   drives every panel/view toggle in the app shell. */
[hidden] {
    display: none !important;
}

body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
}

h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0; }

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

a:hover { color: var(--accent-hover); }

code,
.mono,
.job-id,
.timestamp,
.progress-value,
.coordinates {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

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

.icon-sprite {
    display: none;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; stroke-width: 1.3; }

.meta-line {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

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

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

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

.btn-secondary {
    background: transparent;
}

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

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-danger {
    border-color: rgba(244, 63, 94, 0.45);
    color: #fda4af;
    background: transparent;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(244, 63, 94, 0.14);
    border-color: var(--status-failed);
    color: #fecdd3;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 6px;
    min-width: 32px;
    line-height: 1;
}

/* ── App shell ─────────────────────────────────────────────────────────── */

.app-body {
    overflow: hidden;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) var(--sidebar-right-width);
    height: 100vh;
    height: 100dvh;
}

/* Dragging the sidebar handle disables transitions/selection so the resize
   tracks the pointer exactly, with no lag from animated properties. */
body.is-resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

body.is-resizing-sidebar .workspace-scroll,
body.is-resizing-sidebar .preview-stage {
    transition: none;
}

.mobile-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.mobile-bar-title {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    z-index: 40;
}

.sidebar-close {
    display: none;
}

/* ── Left sidebar: track library ───────────────────────────────────────── */

.sidebar-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
}

.sidebar-left-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.app-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.app-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 7px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
}

.brand-mark {
    display: block;
    width: auto;
    height: 15px;
}

.track-filters {
    display: grid;
    gap: 8px;
    padding: 12px 16px;
}

.sidebar-note {
    margin: 0 16px 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--status-pending);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
}

.track-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 0 10px 8px;
    list-style: none;
}

.track-list-message {
    padding: 16px 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.track-list-message.is-error {
    color: #fda4af;
}

.track-item {
    position: relative;
    margin-bottom: 4px;
}

/* Sits on top of the track button, revealed on hover/focus so the list stays
   calm. Always visible on touch, where there is no hover. */
.track-item-delete {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
}

.track-item:hover .track-item-delete,
.track-item-delete:focus-visible {
    opacity: 1;
}

.track-item-delete:hover {
    border-color: var(--status-failed);
    background: rgba(244, 63, 94, 0.14);
    color: #fda4af;
}

.track-item-delete .icon {
    width: 15px;
    height: 15px;
}

@media (hover: none) {
    .track-item-delete { opacity: 1; }
}

.track-item-button {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.track-item:has(.track-item-delete) .track-item-button {
    padding-right: 34px;
}

.track-item-button:hover {
    background: var(--bg-card);
}

.track-item.is-selected .track-item-button {
    background: var(--bg-card-hover);
    border-color: var(--border);
    border-left-color: var(--accent);
}

.track-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--accent);
}

.track-item.is-selected .track-item-icon {
    background: rgba(34, 211, 238, 0.14);
}

.track-item-body {
    min-width: 0;
}

.track-item-name {
    display: block;
    overflow: hidden;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.track-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.track-item-date {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.render-badge {
    flex: none;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
}

.render-badge.has-renders {
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--status-completed);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
}

.pagination:not(:empty) {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
}

.page-info {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
}

.sidebar-left-foot {
    position: sticky;
    bottom: 0;
    display: grid;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: underline;
    text-decoration-color: transparent;
}

.site-footer a:hover {
    color: var(--text-secondary);
    text-decoration-color: currentColor;
}

.footer-sep {
    opacity: 0.5;
}

.add-track-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.add-track-button:hover {
    border-color: var(--accent);
    border-style: solid;
    color: var(--accent);
}

/* ── Workspace ─────────────────────────────────────────────────────────── */

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg-app);
}

.workspace-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.view {
    padding: 24px;
}

.view-track {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Empty state */

.view-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.empty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 420px;
    padding: 40px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    color: var(--text-secondary);
    text-align: center;
}

.empty-card .icon-xl { color: var(--text-muted); }
.empty-card h1 { color: var(--text-primary); font-size: 18px; }
.empty-card .btn { margin-top: 8px; }

/* ── Import screen ─────────────────────────────────────────────────────── */

.import-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 8px 0 32px;
}

.import-head {
    margin-bottom: 20px;
}

.import-head p {
    color: var(--text-secondary);
    margin-top: 4px;
}

.banner {
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
}

.banner-info { border-left-color: var(--status-pending); }
.banner-ok { border-left-color: var(--status-completed); }
.banner-error {
    border-left-color: var(--status-failed);
    color: #fecdd3;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.source-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.source-card:hover {
    background: var(--bg-card-hover);
}

.source-card.is-active {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.08);
}

.source-card .icon-lg { color: var(--accent); }

.source-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.source-card-desc {
    color: var(--text-secondary);
    font-size: 12px;
}

.badge {
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-accent {
    border-color: rgba(34, 211, 238, 0.5);
    color: var(--accent);
}

.source-forms {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.source-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 640px;
}

.source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.source-message {
    min-height: 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.source-message.is-error { color: #fda4af; }
.source-message.is-ok { color: var(--status-completed); }

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    color: var(--text-secondary);
    text-align: center;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.06);
    color: var(--text-primary);
}

.dropzone .icon-lg { color: var(--accent); }
.dropzone strong { color: var(--text-primary); }

.dropzone-file {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Track header ──────────────────────────────────────────────────────── */

.track-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
}

.track-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.track-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: rgba(34, 211, 238, 0.12);
    color: var(--accent);
}

.track-header-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-header-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12px;
}

.track-header-meta .sep { color: var(--text-muted); }

.track-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Preview panel ─────────────────────────────────────────────────────── */

.preview-stage {
    position: relative;
    height: clamp(320px, 46vh, 560px);
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: #0b1220;
}

#preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.preview-overlay {
    position: absolute;
    z-index: 2;
}

.preview-telemetry {
    left: 12px;
    bottom: 68px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.82);
    box-shadow: var(--shadow-float);
    color: var(--text-primary);
    font-size: 11px;
}

.preview-telemetry:empty { display: none; }
.preview-telemetry span { white-space: nowrap; }
.preview-telemetry .label { color: var(--text-muted); }

.preview-topright {
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* flex: none is load-bearing. This group sits in the .preview-topright flex
   row next to the style <select>; without it the group shrinks, its fixed
   34px buttons refuse to, and overflow:hidden clips the last one — which
   chopped the right-hand side off the minus button. */
.preview-zoom {
    flex: none;
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.82);
    box-shadow: var(--shadow-float);
}

.preview-zoom .btn-icon {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 17px;
    line-height: 1;
}

/* An inset shadow rather than a real border, so both buttons keep the exact
   same box and their glyphs stay on the same centre line. */
.preview-zoom .btn-icon + .btn-icon {
    box-shadow: inset 1px 0 0 var(--border);
}

.preview-style-select {
    max-width: 150px;
    background-color: rgba(15, 23, 42, 0.88);
    box-shadow: var(--shadow-float);
}

.preview-controls {
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(560px, calc(100% - 24px));
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.86);
    box-shadow: var(--shadow-float);
}

.preview-controls .btn-icon {
    border-color: transparent;
    background: transparent;
    color: var(--accent);
}

.preview-scrubber {
    flex: 1;
    min-width: 0;
}

.preview-time {
    flex: none;
    color: var(--text-secondary);
    font-size: 11px;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-panel);
    color: var(--text-secondary);
    text-align: center;
}

.preview-placeholder.is-error { color: #fda4af; }

.preview-video {
    padding: 16px;
}

.preview-video-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.preview-video-actions {
    display: flex;
    gap: 8px;
}

#review-video {
    display: block;
    width: 100%;
    max-height: 60vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #000;
}

/* ── Render history ────────────────────────────────────────────────────── */

.filter-chips {
    display: flex;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-app);
}

.chip {
    padding: 4px 10px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.chip:hover { color: var(--text-primary); }

.chip.is-active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.render-cards {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.render-card {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.render-card.is-selected {
    border-color: var(--accent);
}

.render-card[data-render-id] {
    cursor: pointer;
}

.render-card-wide {
    grid-template-columns: minmax(0, 1fr);
}

.render-card-thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-app);
}

.render-card-thumb img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.render-card-thumb .thumb-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
}

.render-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.render-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.render-card-title {
    font-weight: 600;
}

.render-card-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
}

.render-card-summary {
    color: var(--text-secondary);
    font-size: 12px;
}

.render-card-error {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: rgba(244, 63, 94, 0.12);
    color: #fecdd3;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.render-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.render-empty {
    padding: 24px 16px;
    color: var(--text-muted);
    text-align: center;
}

/* Status badges */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-pending { color: var(--status-pending); border-color: rgba(245, 158, 11, 0.4); }
.status-processing,
.status-encoding { color: var(--status-processing); border-color: rgba(34, 211, 238, 0.4); }
.status-completed { color: var(--status-completed); border-color: rgba(16, 185, 129, 0.4); }
.status-failed { color: var(--status-failed); border-color: rgba(244, 63, 94, 0.45); }
.status-canceled { color: var(--status-canceled); border-color: rgba(148, 163, 184, 0.45); border-style: dashed; }

/* Progress bars */

.progress {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg-app);
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-hover), var(--accent));
    transition: width 0.3s ease;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-row .progress { flex: 1; }

/* ── Render queue drawer ───────────────────────────────────────────────── */

.render-queue {
    flex: none;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.queue-head {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.queue-head:hover { background: var(--bg-card); }

.queue-title { font-weight: 600; font-size: 13px; }
.queue-title span { color: var(--accent); font-family: var(--font-mono); }

.progress-mini {
    flex: 1;
    max-width: 320px;
}

.queue-chevron {
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.queue-head[aria-expanded="true"] .queue-chevron {
    transform: rotate(180deg);
}

.queue-body {
    max-height: 40vh;
    overflow-y: auto;
    padding: 4px 16px 16px;
    display: grid;
    gap: 10px;
}

.queue-job {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.queue-job-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.queue-job-track { font-weight: 600; }

.queue-job-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
}

.queue-job-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Right sidebar: render controller ──────────────────────────────────── */

.sidebar-right {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
}

.sidebar-resize-handle {
    position: absolute;
    top: 0;
    left: -5px;
    width: 10px;
    height: 100%;
    z-index: 20;
    cursor: col-resize;
    touch-action: none;
}

.sidebar-resize-handle::after {
    content: "";
    position: absolute;
    top: 0;
    left: 4px;
    width: 2px;
    height: 100%;
    background: transparent;
    transition: background 0.12s ease;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.is-dragging::after,
.sidebar-resize-handle:focus-visible::after {
    background: var(--accent);
}

.sidebar-resize-handle:focus-visible {
    outline: none;
}

.controller-empty {
    padding: 24px 20px;
    color: var(--text-secondary);
}

.controller-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.render-controller {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.controller-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.controller-head-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.controller-notice {
    margin: 12px 16px 0;
    padding: 8px 10px;
    border: 1px solid rgba(34, 211, 238, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(34, 211, 238, 0.08);
    color: var(--accent);
    font-size: 12px;
}

.controller-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 16px 16px;
}

.control-group-label {
    margin: 18px 0 2px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.control-section {
    border-bottom: 1px solid var(--border);
}

.control-section > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 2px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
}

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

.control-section > summary::after {
    content: "▾";
    color: var(--text-muted);
    font-size: 11px;
    transition: transform 0.15s ease;
}

.control-section[open] > summary::after {
    transform: rotate(180deg);
}

.control-section-body {
    display: grid;
    gap: 12px;
    padding: 2px 2px 16px;
}

.field {
    display: grid;
    gap: 5px;
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.field > label,
.field > legend {
    padding: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.field-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-row input { flex: 1; min-width: 0; }

.field-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.field-pair > .field {
    flex: 1 1 110px;
}

.field-unit {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

.field-hint {
    color: var(--text-muted);
    font-size: 11px;
}

.field-error {
    color: #fda4af;
    font-size: 12px;
}

input[type="text"],
input[type="search"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
}

textarea {
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 12px;
}

input[type="color"] {
    width: 100%;
    height: 33px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: var(--accent);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
}

option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.switch {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.switch.is-disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
    width: 15px;
    height: 15px;
    flex: none;
    accent-color: var(--accent);
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    height: 20px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 2px solid var(--bg-app);
    border-radius: 50%;
    background: var(--accent);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: var(--border);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid var(--bg-app);
    border-radius: 50%;
    background: var(--accent);
}

.stat-pairs {
    display: grid;
    gap: 4px;
    margin: 4px 0 0;
}

.stat-pairs > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stat-pairs dt {
    color: var(--text-secondary);
    font-size: 12px;
}

.stat-pairs dd {
    margin: 0;
    color: var(--text-primary);
    font-size: 12px;
}

.map-style-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.map-style-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
}

.map-style-card:hover {
    border-color: var(--text-muted);
}

.map-style-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.map-style-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 5px;
    background: var(--bg-app);
}

.map-style-card img.is-missing {
    min-height: 36px;
}

.map-style-card span {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 10px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-style-card:has(input:checked) {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.1);
}

.map-style-card:has(input:checked) span {
    color: var(--accent);
}

.map-style-card:has(input:checked)::after {
    content: "✓";
    position: absolute;
    top: 6px;
    right: 8px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

.map-style-card:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.marker-icon-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.marker-icon-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
}

.marker-icon-card:hover {
    border-color: var(--text-muted);
}

.marker-icon-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.marker-icon-glyph {
    font-size: 18px;
    line-height: 1.3;
}

.marker-icon-card span:last-child {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 10px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.marker-icon-card:has(input:checked) {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.1);
}

.marker-icon-card:has(input:checked) span:last-child {
    color: var(--accent);
}

.marker-icon-card:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.controller-footer {
    flex: none;
    display: grid;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

/* Storage / capacity notice, directly above the render button. */
.controller-alert {
    padding: 8px 10px;
    border: 1px solid var(--status-failed);
    border-radius: var(--radius-sm);
    background: rgba(244, 63, 94, 0.12);
    color: #fda4af;
    font-size: 12px;
    line-height: 1.4;
}

/* ── Toasts ────────────────────────────────────────────────────────────── */

.toast-region {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    display: grid;
    gap: 8px;
    width: min(340px, calc(100vw - 32px));
}

.toast {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-float);
    font-size: 13px;
    animation: toast-in 0.16s ease-out;
}

.toast.is-success { border-left-color: var(--status-completed); }
.toast.is-error { border-left-color: var(--status-failed); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
    .app-shell {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    .sidebar-right {
        position: fixed;
        top: 0;
        right: 0;
        z-index: 50;
        width: min(360px, 92vw);
        height: 100vh;
        height: 100dvh;
        box-shadow: var(--shadow-float);
        transform: translateX(100%);
        transition: transform 0.18s ease;
    }

    .sidebar-right.is-open {
        transform: none;
    }

    .sidebar-right .sidebar-close {
        display: inline-flex;
    }

    /* The sidebar is a fixed-width slide-over below this breakpoint — dragging
       it wider doesn't apply. */
    .sidebar-resize-handle {
        display: none;
    }
}

@media (max-width: 900px) {
    .mobile-bar { display: flex; }

    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        height: calc(100vh - 49px);
        height: calc(100dvh - 49px);
    }

    .sidebar-left {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        width: min(300px, 88vw);
        height: 100vh;
        height: 100dvh;
        box-shadow: var(--shadow-float);
        transform: translateX(-100%);
        transition: transform 0.18s ease;
    }

    .sidebar-left.is-open { transform: none; }
    .sidebar-left .sidebar-close { display: inline-flex; }

    .view { padding: 16px; }

    .render-card {
        grid-template-columns: minmax(0, 1fr);
    }

    .render-card-thumb { max-width: 240px; }
}

/* =============================================================================
   Operator console
   ============================================================================= */

.admin-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.admin-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-bar-actions form { margin: 0; }

.admin-main {
    display: grid;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.admin-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
}

.admin-stat-value {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
}

.admin-stat-label {
    color: var(--text-secondary);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.admin-table th {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg-card); }

.admin-error {
    margin-top: 4px;
    color: #fda4af;
    font-size: 11px;
    white-space: normal;
}

/* =============================================================================
   Standalone pages (job permalinks, index, results)
   ============================================================================= */

body.simple-page,
body.centered-page {
    padding: 32px 20px;
    max-width: 900px;
    margin: 0 auto;
}

body.centered-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

body.simple-page h1,
body.centered-page h1 {
    margin-bottom: 16px;
}

body.simple-page p,
body.centered-page p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.simple-page ul,
.centered-page ul {
    color: var(--text-secondary);
}

video {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #000;
}

.animation-result,
.error-info,
.progress-container-standalone,
.progress-container,
.job-info,
.help-section {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    margin-bottom: 16px;
}

.error-info pre,
.error-message {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(244, 63, 94, 0.12);
    color: #fecdd3;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.progress-container-standalone {
    width: min(600px, 100%);
    text-align: center;
}

.progress-bar-standalone,
.progress-bar-container {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg-app);
    margin: 12px 0;
}

.progress-bar-fill-standalone,
.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-hover), var(--accent));
    color: transparent;
    transition: width 0.3s ease;
}

.url-box {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.url-input {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 12px;
}

.url-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.copy-button,
.cancel-button,
.download-link,
.button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.copy-button:hover,
.cancel-button:hover:not(:disabled),
.download-link:hover,
.button:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.download-link {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

.download-link:hover {
    background: var(--accent-hover);
    color: var(--accent-ink);
}

.cancel-button {
    border-color: rgba(244, 63, 94, 0.45);
    color: #fda4af;
}

.cancel-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cancel-status {
    color: var(--text-muted);
    font-size: 12px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.strava-connect img {
    max-width: 220px;
}
