/* ─────────────────────────────────────────────────────────────────────────────
   SPLATTER — global stylesheet
   Design language: dark terminal aesthetic, DM Mono + Fraunces typography.
───────────────────────────────────────────────────────────────────────────── */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
    --bg: #090b0d;
    --surface: #101318;
    --surface2: #141820;
    --border: #1c2128;
    --muted: #252c38;
    --text-dim: #617888;
    --text-mid: #90a8be;
    --text: #b8c8d8;
    --text-hi: #ddeaf5;

    --amber: #c8982a;
    --amber-lo: #61410a;
    --amber-bg: rgba(200, 152, 42, 0.06);
    --teal: #2a9b8a;
    --teal-lo: #0a4840;
    --teal-bg: rgba(42, 155, 138, 0.06);
    --violet: #7a62c8;
    --violet-lo: #2a1f5a;
    --violet-bg: rgba(122, 98, 200, 0.06);
    --green: #4a9e72;
    --green-lo: #1a3828;
    --green-bg: rgba(74, 158, 114, 0.06);
    --red: #b85858;
    --red-bg: rgba(184, 88, 88, 0.08);
    --blue: #4a82b8;
    --blue-lo: #1a3058;

    --radius-sm: 2px;
    --radius-md: 4px;
    --font-mono:
        "DM Mono", ui-monospace, "Cascadia Code", "Fira Mono", monospace;
    --font-serif: "Fraunces", "Palatino Linotype", Georgia, serif;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
html,
body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Prevent any overflowing child from forcing the viewport to zoom out */
    overflow-x: hidden;
}

body {
    padding: 24px 16px 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    /* Ensure body never exceeds the visible viewport width */
    width: 100%;
    box-sizing: border-box;
}

/* main is a flex item inside body { align-items: center }. Without an
   explicit width it can collapse to min-content in Safari/iOS, which makes
   .shell's width:100% resolve incorrectly and breaks the entire layout. */
#main-content {
    width: 100%;
}

/* Grid background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 56px 56px;
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1,
h2,
h3 {
    font-family: var(--font-serif);
    font-weight: 300;
    color: var(--text-hi);
    letter-spacing: -0.3px;
}
h1 {
    font-size: 18px;
}
h2 {
    font-size: 15px;
}
h3 {
    font-size: 13px;
}

em,
i {
    font-style: italic;
}
strong {
    font-weight: 500;
    color: var(--text-hi);
}

a {
    color: var(--teal);
    text-decoration: none;
}
a:hover {
    color: var(--text-hi);
}

/* ── Shell (outer card) ───────────────────────────────────────────────────── */
.shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface2);
    margin: 0 auto;
}

.shell-wide {
    max-width: 1280px;
}

/* ── Shell header ─────────────────────────────────────────────────────────── */
.shell-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 18px 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    flex-wrap: wrap;
}

/* Colourful top accent bar */
.shell-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--amber) 20%,
        var(--teal) 50%,
        var(--violet) 80%,
        transparent 100%
    );
}

.shell-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 300;
    color: var(--text-hi);
    letter-spacing: -0.3px;
    white-space: nowrap;
}
.shell-title em {
    font-style: italic;
    color: var(--teal);
}

.shell-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

/* ── Shell body / sections ────────────────────────────────────────────────── */
.shell-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.shell-section {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.shell-section:last-child {
    border-bottom: none;
}

.shell-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    margin-bottom: 14px;
}

/* ── Shell footer ─────────────────────────────────────────────────────────── */
.shell-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 0;
    width: 74px;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--muted);
    color: var(--text-dim);
    flex-shrink: 0;
    transition:
        border-color 0.3s,
        color 0.3s;
}
.badge-sm {
    width: 58px;
    font-size: 9px;
    padding: 2px 0;
}
.badge.ready {
    border-color: var(--teal-lo);
    color: var(--teal);
}
.badge.done {
    border-color: var(--green-lo);
    color: var(--green);
}
.badge.running {
    border-color: var(--teal-lo);
    color: var(--teal);
    animation: badge-pulse 2s ease-in-out infinite;
}
.badge.error {
    border-color: var(--red);
    color: var(--red);
}

@keyframes badge-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.55;
    }
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--muted);
    background: transparent;
    color: var(--text-mid);
    transition:
        border-color 0.2s,
        color 0.2s,
        background 0.2s;
    white-space: nowrap;
    user-select: none;
}
.btn:hover:not(:disabled) {
    border-color: var(--teal);
    color: var(--teal);
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-active {
    border-color: var(--amber);
    color: var(--amber);
    background: var(--amber-bg);
}

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

.btn-danger {
    border-color: var(--red);
    color: var(--red);
}
.btn-danger:hover:not(:disabled) {
    background: var(--red-bg);
}

.btn-sm {
    padding: 3px 8px;
    font-size: 9px;
    letter-spacing: 0.06em;
}

.btn-lg {
    padding: 9px 22px;
    font-size: 11px;
    letter-spacing: 0.1em;
}

/* Toggle group (Source / Mask etc.) */
.btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Separators ───────────────────────────────────────────────────────────── */
.sep-v {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex-shrink: 0;
}
.sep-h {
    height: 1px;
    background: var(--border);
    margin: 0;
}

/* ── Form elements ────────────────────────────────────────────────────────── */
label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 8px 12px;
    transition: border-color 0.2s;
    outline: none;
}
input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--teal);
}

/* Hide number input spinners for a cleaner look */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.4;
}

/* Range input */
input[type="range"] {
    display: block;
    height: 4px;
    cursor: pointer;
    border: none;
    padding: 0;
    background: transparent;
}

/* ── Dropzone ─────────────────────────────────────────────────────────────── */
.dropzone {
    position: relative;
    border: 1px dashed var(--muted);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition:
        border-color 0.2s,
        background 0.2s;
    text-align: center;
    overflow: hidden;
}
.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--teal);
    background: var(--teal-bg);
}
.dropzone.has-files {
    border-color: var(--amber);
    border-style: solid;
    background: var(--amber-bg);
}

/* Invisible <input type="file"> stretched over the whole zone */
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.dropzone-icon {
    font-size: 22px;
    line-height: 1;
    color: var(--text-dim);
    transition: color 0.2s;
}
.dropzone:hover .dropzone-icon,
.dropzone.drag-over .dropzone-icon {
    color: var(--teal);
}
.dropzone.has-files .dropzone-icon {
    color: var(--amber);
}

.dropzone-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    transition: color 0.2s;
}
.dropzone:hover .dropzone-title,
.dropzone.drag-over .dropzone-title {
    color: var(--text-hi);
}
.dropzone.has-files .dropzone-title {
    color: var(--amber);
}

.dropzone-hint {
    font-size: 10px;
    color: var(--text-dim);
}

/* ── Option row (label + toggle pair) ────────────────────────────────────── */
.option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(28, 33, 40, 0.5);
}
.option-row:first-child {
    padding-top: 0;
}
.option-row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.option-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.option-label-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
}
.option-label-hint {
    font-size: 10px;
    color: var(--text-mid);
}

/* ── Chips ────────────────────────────────────────────────────────────────── */
.chip {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    border: 1px solid;
    line-height: 16px;
    white-space: nowrap;
}
.chip-green {
    border-color: var(--green-lo);
    color: var(--green);
    background: var(--green-bg);
}
.chip-amber {
    border-color: var(--amber-lo);
    color: var(--amber);
    background: var(--amber-bg);
}
.chip-teal {
    border-color: var(--teal-lo);
    color: var(--teal);
    background: var(--teal-bg);
}
.chip-violet {
    border-color: var(--violet-lo);
    color: var(--violet);
    background: var(--violet-bg);
}
.chip-muted {
    border-color: var(--muted);
    color: var(--text-dim);
}
.chip-red {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-bg);
}

/* ── Flash / alert notifications ─────────────────────────────────────────── */
.flash {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 820px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--muted);
    background: var(--surface);
    font-size: 11px;
    color: var(--text);
}
.flash[data-flash-kind="success"] {
    border-color: var(--green-lo);
    background: var(--green-bg);
    color: var(--green);
}
.flash[data-flash-kind="error"] {
    border-color: var(--red);
    background: var(--red-bg);
    color: var(--red);
}
.flash[data-flash-kind="warn"] {
    border-color: var(--amber-lo);
    background: var(--amber-bg);
    color: var(--amber);
}
.flash[data-flash-kind="info"] {
    border-color: var(--teal-lo);
    background: var(--teal-bg);
    color: var(--teal);
}

.flash-dismiss {
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}
.flash-dismiss:hover {
    opacity: 1;
}

/* ── Toast stack (Alpine store) ───────────────────────────────────────────── */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 340px;
}
.toast {
    pointer-events: auto;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--muted);
    background: var(--surface);
    font-size: 11px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.toast-success {
    border-color: var(--green-lo);
    color: var(--green);
    background: var(--green-bg);
}
.toast-error {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-bg);
}
.toast-info {
    border-color: var(--teal-lo);
    color: var(--teal);
    background: var(--teal-bg);
}
.toast-warn {
    border-color: var(--amber-lo);
    color: var(--amber);
    background: var(--amber-bg);
}

/* ── Page-level loading indicator ────────────────────────────────────────── */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--amber),
        var(--teal),
        var(--violet)
    );
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s;
}
#page-loader.htmx-request {
    opacity: 1;
}

/* ── Upload source type indicator strip ──────────────────────────────────── */
.source-accent {
    height: 2px;
    border-radius: 1px;
    background: var(--amber);
    transition: background 0.3s;
    margin-bottom: 16px;
}
.source-accent.images {
    background: var(--teal);
}

/* ── Summary row (shows selected file info) ───────────────────────────────── */
.summary-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-mid);
    margin-top: 10px;
    min-height: 34px;
}
.summary-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber);
    flex-shrink: 0;
}
.summary-dot.teal {
    background: var(--teal);
}
.summary-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.summary-clear {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s;
}
.summary-clear:hover {
    color: var(--red);
}

/* ── Misc utility ─────────────────────────────────────────────────────────── */
/* ── Job list rows ────────────────────────────────────────────────────────── */
.job-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
}
.job-row:last-child {
    border-bottom: none;
}
.job-row:hover {
    background: var(--surface);
}

.job-row-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.job-row-name {
    font-size: 13px;
    color: var(--text-hi);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.job-row:hover .job-row-name {
    color: var(--text-hi);
}

.job-row-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.job-row-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.job-row-arrow {
    font-size: 16px;
    transition:
        transform 0.15s,
        color 0.15s;
}
.job-row:hover .job-row-arrow {
    transform: translateX(2px);
    color: var(--teal);
}

/* ── Splat metadata grid ──────────────────────────────────────────────────── */
.splat-meta-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

.splat-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 20px 10px 0;
    min-width: 120px;
    margin-right: 24px;
}

.splat-meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
}

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

/* ── Pipeline stages ──────────────────────────────────────────────────────── */
.pipeline-stage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.pipeline-stage:last-child {
    border-bottom: none;
}
.pipeline-stage:last-of-type {
    border-bottom: none;
}

.pipeline-stage-active {
    background: transparent;
}

.pipeline-stage-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pipeline-stage-index {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    width: 18px;
}

.pipeline-stage-name {
    font-size: 12px;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.pipeline-stage-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Stage step counter badge — shown in the stage row while running (e.g. "1/3") */
.stage-step-badge {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    background: var(--muted);
    border-radius: 3px;
    padding: 1px 5px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* Detail row rendered below a .pipeline-stage row (running message / done stats) */
.pipeline-stage-detail {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 10px 28px; /* indent to align with stage name */
    border-bottom: 1px solid var(--border);
}

/* Remove the border when this detail row is the final child of the container */
.pipeline-stage-detail:last-child {
    border-bottom: none;
}

/* Running stage: current step name */
.stage-detail-step {
    font-size: 10px;
    color: var(--text-mid);
    letter-spacing: 0.02em;
}

/* Running stage: human-readable worker message */
.stage-detail-message {
    font-size: 10px;
    color: var(--text-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Stats detail row — lays out .stat-item / .stat-sep inline */
.pipeline-stage-stats {
    padding-top: 2px;
}

/* A single metric: value + optional label stacked or inline */
.stat-item {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
}

.stat-value {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--text-mid);
    letter-spacing: 0.02em;
}

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

/* Dot separator between stat items */
.stat-sep {
    font-size: 10px;
    color: var(--text-dim);
    user-select: none;
}

/* ── Sub-step list ────────────────────────────────────────────────────────── */

/* Container rendered below a running .pipeline-stage */
.step-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 2px 0 10px 28px; /* indent to align under stage name */
    border-bottom: 1px solid var(--border);
}

.step-list:last-child {
    border-bottom: none;
}

/* A single row in the step list */
.step-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    min-height: 20px;
}

/* Icon column — fixed width so names stay aligned */
.step-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 10px;
}

/* ✓ check for completed steps */
.step-icon-done {
    color: var(--green);
    font-size: 9px;
    font-weight: 600;
}

/* Step name */
.step-name {
    font-size: 11px;
    color: var(--text-mid);
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.step-name-active {
    color: var(--text-hi);
    font-weight: 500;
}

.step-name-dim {
    color: var(--text-dim);
}

/* Elapsed time shown after a completed step name */
.step-elapsed {
    font-size: 10px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
    padding-left: 8px;
    flex-shrink: 0;
    align-self: center;
}

/* Body column for the active step: stacks name + message vertically */
.step-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Worker message line beneath the active step name */
.step-message {
    font-size: 11px;
    color: var(--text-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.4;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */

.step-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid var(--amber-lo);
    border-top-color: var(--amber);
    animation: step-spin 0.75s linear infinite;
    flex-shrink: 0;
}

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

/* Progress track sits between two .pipeline-stage rows */
.pipeline-progress-track {
    height: 3px;
    background: var(--muted);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 0 1px;
}

.pipeline-progress-fill {
    height: 100%;
    border-radius: 1px;
    background: linear-gradient(
        90deg,
        var(--amber),
        var(--teal) 60%,
        var(--violet)
    );
    /* Transition is applied dynamically by app.js after each htmx settle so
       the bar animates from its previous position rather than snapping. */
    transition: none;
    position: relative;
    overflow: hidden;
}
.pipeline-progress-fill::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25));
    animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* .badge.skipped — muted style for skipped/cancelled stages */
.badge.skipped {
    border-color: var(--muted);
    color: var(--text-dim);
}
.badge.cancelled {
    border-color: var(--muted);
    color: var(--text-dim);
}

/* ── File list ────────────────────────────────────────────────────────────── */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.file-row:last-child {
    border-bottom: none;
}

.file-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.file-row-name {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

[x-cloak] {
    display: none !important;
}

/* ── Confirm dialog ───────────────────────────────────────────────────────── */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 11, 13, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.dialog-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: calc(100% - 32px);
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0;
    animation: dialog-in 0.12s ease both;
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dialog-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
}

.dialog-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--red);
    color: var(--red);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
    line-height: 1;
}

.dialog-title-text {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

.dialog-message {
    padding: 16px 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-mid);
    line-height: 1.6;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 14px;
    border-top: 1px solid var(--border);
}

/* ── Eval images viewer ───────────────────────────────────────────────────── */

.eval-empty {
    padding: 12px 0;
}

.eval-waiting {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Set selector bar */
.eval-set-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.eval-set-bar-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

.eval-set-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.eval-set-tab {
    appearance: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-mid);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 8px;
    cursor: pointer;
    transition:
        background 0.1s,
        border-color 0.1s,
        color 0.1s;
    white-space: nowrap;
}
.eval-set-tab:hover {
    background: var(--muted);
    border-color: var(--text-dim);
    color: var(--text);
}
.eval-set-tab-active {
    background: var(--amber-bg);
    border-color: var(--amber-lo);
    color: var(--amber);
}

.eval-set-bar-count {
    font-size: 10px;
    font-family: var(--font-mono);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

/* Live indicator dot (pulses while job is running) */
.eval-live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    animation: eval-pulse 2s ease-in-out infinite;
}
@keyframes eval-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.75);
    }
}

/* Image grid */
.eval-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.eval-thumb-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: zoom-in;
    transition: border-color 0.15s;
}

/* Shimmer skeleton shown while the image is fetching */
.eval-thumb-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface2) 40%,
        var(--muted) 50%,
        var(--surface2) 60%,
        var(--surface) 100%
    );
    background-size: 200% 100%;
    animation: eval-shimmer 1.4s ease-in-out infinite;
    z-index: 1;
    transition: opacity 0.3s;
}
/* Once the image has loaded, fade the shimmer out */
.eval-thumb-wrap.img-loaded::before {
    opacity: 0;
    pointer-events: none;
}

@keyframes eval-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
.eval-thumb-wrap:hover {
    border-color: var(--text-dim);
}
.eval-thumb-wrap:hover .eval-thumb-label {
    opacity: 1;
}

.eval-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
    position: relative;
    z-index: 2;
}
.eval-thumb-wrap:hover .eval-thumb {
    transform: scale(1.03);
}

.eval-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    font-size: 9px;
    background: rgba(9, 11, 13, 0.78);
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lightbox */
.eval-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(9, 11, 13, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.eval-lightbox-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: min(90vw, 1200px);
    max-height: 90vh;
}

.eval-lightbox-img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    object-fit: contain;
    display: block;
}

.eval-lightbox-caption {
    font-size: 11px;
}

.eval-lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    appearance: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-mid);
    font-size: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition:
        background 0.1s,
        color 0.1s;
    z-index: 1;
}
.eval-lightbox-close:hover {
    background: var(--muted);
    color: var(--text-hi);
}

.text-dim {
    color: var(--text-dim);
}
.text-mid {
    color: var(--text-mid);
}
.text-hi {
    color: var(--text-hi);
}
.text-teal {
    color: var(--teal);
}
.text-amber {
    color: var(--amber);
}

.mono {
    font-family: var(--font-mono);
}
.serif {
    font-family: var(--font-serif);
}

.uppercase {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 9px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    /* ── Base layout ──────────────────────────────────────────────────────── */
    body {
        padding: 12px 10px 40px;
    }

    /* ── iOS Safari input zoom prevention ────────────────────────────────── */
    /* iOS Safari auto-zooms the page when focusing any input whose font-size
       is below 16px. Bumping to 16px on mobile prevents that jarring zoom
       while keeping the compact look on larger screens. */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px;
    }

    /* ── Shell frame ──────────────────────────────────────────────────────── */
    .shell-header {
        padding: 14px 16px 12px;
        gap: 10px;
    }
    /* Allow long job names to wrap instead of pushing the right side off-screen */
    .shell-title {
        font-size: 15px;
        white-space: normal;
    }
    /* Hide the decorative vertical separator in headers — wastes space on mobile */
    .shell-header .sep-v {
        display: none;
    }
    /* Allow badge + back-link to wrap if the title column is very long */
    .shell-header-right {
        gap: 8px;
        flex-wrap: wrap;
    }
    .shell-section {
        padding: 14px 16px;
    }
    .shell-footer {
        padding: 12px 16px;
        gap: 10px;
    }

    /* ── Buttons & form controls ──────────────────────────────────────────── */
    .btn-lg {
        padding: 8px 16px;
        font-size: 10px;
    }
    /* Allow multi-button toggle groups to wrap onto a second line */
    .btn-group {
        flex-wrap: wrap;
    }
    .dropzone {
        padding: 28px 16px;
    }

    /* ── Option rows (form settings) ─────────────────────────────────────── */
    /* Stack the label above its control instead of forcing them side-by-side */
    .option-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* ── Job list ─────────────────────────────────────────────────────────── */
    .job-row {
        padding: 12px 16px;
        gap: 10px;
    }
    .job-row-meta {
        flex-wrap: wrap;
    }

    /* ── Pipeline stages ──────────────────────────────────────────────────── */
    /* Allow the right-side badge / timer / retry cluster to drop below the
       stage name when the row is too narrow to fit everything on one line */
    .pipeline-stage {
        flex-wrap: wrap;
        gap: 6px;
    }
    .pipeline-stage-right {
        flex-wrap: wrap;
        gap: 6px;
    }
    /* Reduce the left indent on sub-step rows so they don't eat into
       the already-narrow content area */
    .step-list {
        padding-left: 14px;
    }
    .pipeline-stage-detail {
        padding-left: 8px;
    }

    /* ── Splat metadata grid ─────────────────────────────────────────────── */
    /* Two-column grid on mobile — fills the row evenly */
    .splat-meta-item {
        flex: 1 1 calc(50% - 12px);
        min-width: 0;
        margin-right: 0;
        padding: 8px 12px 8px 0;
    }

    /* ── File list ────────────────────────────────────────────────────────── */
    /* Stack role+name on the first line, size+type on the second */
    .file-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .file-row-left {
        width: 100%;
    }
    .file-row-right {
        width: 100%;
        flex-shrink: 1;
    }

    /* ── Upload-action row (final file submit button) ─────────────────────── */
    .upload-submit-row {
        justify-content: stretch;
    }
    .upload-submit-row > .btn {
        width: 100%;
    }

    /* ── Eval images ──────────────────────────────────────────────────────── */
    .eval-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    /* Scroll the step tabs horizontally rather than wrapping to multiple rows */
    .eval-set-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 3px;
    }
    .eval-set-tab {
        font-size: 9px;
        padding: 2px 6px;
        flex-shrink: 0;
    }

    /* ── Toast notifications ─────────────────────────────────────────────── */
    /* Stretch toasts edge-to-edge on mobile instead of floating in the corner */
    .toast-stack {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }
}
