/* ytcartel — premium dark UI, gold + silver accents inspired by the YC logo. */

:root {
    --bg:           #0a0a0a;
    --bg-elev:      #131316;
    --bg-elev-2:    #1c1c20;
    --bg-elev-3:    #25252b;
    --fg:           #efece0;
    --fg-dim:       #8c8c95;
    --fg-mute:      #5a5a62;

    --gold:         #d4af37;
    --gold-bright:  #e9c655;
    --gold-dim:     #997d24;
    --silver:       #c5c7ce;
    --silver-dim:   #7a7c84;

    --border:       #2a2a30;
    --border-strong:#3a3a42;

    --danger:       #c84545;
    --success:      #4a9d68;
    --warn:         #d49a3a;
    --busy:         #5d8fce;

    --accent:       var(--gold);
    --accent-hover: var(--gold-bright);
    --radius:       4px;
    --radius-lg:    6px;

    --font:         "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono:    ui-monospace, "Cascadia Mono", "JetBrains Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: #000; }

a { color: var(--gold); text-decoration: none; transition: color 0.12s ease; }
a:hover { color: var(--gold-bright); }

input, textarea, select {
    font-family: inherit; font-size: inherit;
    background: var(--bg-elev-2); color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55em 0.75em;
    transition: border-color 0.12s ease, background 0.12s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--bg-elev-3);
}
textarea {
    font-family: var(--font-mono);
    min-height: 6.5em;
    resize: vertical;
    line-height: 1.45;
}
label {
    display: block;
    margin: 0.9em 0 0.35em;
    color: var(--fg-dim);
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

button {
    cursor: pointer;
    font-family: inherit; font-size: inherit;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 60%, var(--gold-dim));
    color: #0a0a0a;
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    padding: 0.55em 1.1em;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: filter 0.12s ease, transform 0.05s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

button.secondary {
    background: var(--bg-elev-2);
    color: var(--silver);
    border-color: var(--border-strong);
}
button.secondary:hover { background: var(--bg-elev-3); color: var(--fg); }
button.danger {
    background: linear-gradient(180deg, #e25656, var(--danger) 60%, #9c2f2f);
    color: #fff;
    border-color: #7a2828;
}

.muted { color: var(--fg-dim); font-size: 0.92em; }
.err   { color: var(--danger); margin: 0.5em 0; font-weight: 500; }
.ok    { color: var(--success); margin: 0.5em 0; font-weight: 500; }
code   {
    background: var(--bg-elev-2);
    padding: 0.15em 0.45em;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--silver);
    word-break: break-all;
}

/* ── brand wordmark ──────────────────────────────────────────────────── */
.brand {
    display: flex; align-items: center; gap: 0.7em;
    margin-bottom: 1.8em;
}
.brand-logo {
    width: 36px; height: 36px;
    border-radius: 5px;
    object-fit: cover;
    background: #000;
    border: 1px solid var(--border);
}
.brand-mark {
    font-family: var(--font);
    font-weight: 800;
    letter-spacing: 0.08em;
    font-size: 1.1em;
    line-height: 1;
    text-transform: uppercase;
}
.brand-mark .yt     { color: var(--gold); }
.brand-mark .cartel { color: var(--silver); font-weight: 600; margin-left: 1px; }

/* ── auth pages — centered card ──────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 2em;
    background:
        radial-gradient(circle at 20% 10%, rgba(212,175,55,0.06), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(197,199,206,0.04), transparent 45%),
        var(--bg);
}
.auth-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.2em 2em;
    width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,0.7);
}
.auth-logo {
    display: block; margin: 0 auto 1em;
    width: 80px; height: 80px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #000;
}
.auth-brand {
    text-align: center; margin-bottom: 1.5em;
    font-weight: 800; letter-spacing: 0.1em; font-size: 1.15em;
}
.auth-brand .yt     { color: var(--gold); }
.auth-brand .cartel { color: var(--silver); font-weight: 600; }
.auth-card h1 {
    margin: 0 0 1em;
    font-size: 1.25em;
    font-weight: 600;
    color: var(--fg);
    text-align: center;
}
.auth-card .field { margin-bottom: 0.9em; }
.auth-card .field input { width: 100%; }
.auth-card button[type="submit"] { width: 100%; margin-top: 0.8em; padding: 0.7em; }
.auth-card .qr {
    display: block; margin: 1em auto;
    width: 200px; height: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    padding: 8px;
}

/* ── app layout — sidebar + main ─────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1.5em 1em;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.15em; }
.sidebar nav a {
    display: block;
    padding: 0.55em 0.8em;
    border-radius: var(--radius);
    color: var(--fg-dim);
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}
.sidebar nav a:hover { background: var(--bg-elev-2); color: var(--fg); }
.sidebar nav a.active {
    background: var(--bg-elev-2);
    color: var(--gold);
    border-left: 2px solid var(--gold);
    padding-left: calc(0.8em - 2px);
}
.sidebar .spacer { flex: 1; }
.sidebar .who {
    font-size: 0.82em; color: var(--fg-dim);
    margin-bottom: 0.7em; word-break: break-all;
    padding: 0.5em 0; border-top: 1px solid var(--border);
}
.sidebar .who .role {
    color: var(--silver-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.85em;
}
.sidebar form { margin: 0; }
.sidebar button.logout {
    width: 100%;
    background: transparent;
    color: var(--fg-dim);
    border: 1px solid var(--border);
    font-weight: 500;
}
.sidebar button.logout:hover {
    color: var(--fg);
    border-color: var(--border-strong);
    background: var(--bg-elev-2);
}

.main {
    padding: 2.5em 3em;
    max-width: 1200px;
    width: 100%;
}
.main h1 {
    margin: 0 0 0.4em;
    font-size: 1.7em;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.main h2 {
    font-size: 0.92em;
    margin: 0 0 1em;
    color: var(--fg-dim);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── cards ────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5em 1.8em;
    margin-bottom: 1.2em;
}
.card-tight { padding: 1em 1.2em; }

/* ── table ────────────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
table th {
    text-align: left;
    padding: 0.4em 1em 0.7em;
    color: var(--fg-mute);
    font-weight: 500;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
}
table td {
    padding: 0.9em 1em;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg-elev-2); }
.text-right { text-align: right; }
.text-mute  { color: var(--fg-dim); }
.text-mono  { font-family: var(--font-mono); font-size: 0.92em; }

/* table action link styled as subtle button */
a.row-action {
    color: var(--gold);
    padding: 0.3em 0.7em;
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: all 0.12s ease;
    font-weight: 500;
}
a.row-action:hover {
    border-color: var(--gold-dim);
    background: rgba(212,175,55,0.08);
}

/* ── badges ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2em 0.7em;
    border-radius: 99px;
    font-size: 0.78em;
    font-weight: 500;
    background: var(--bg-elev-3);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    text-transform: lowercase;
}
.badge.ok   { background: rgba(74,157,104,0.12);  color: var(--success); border-color: rgba(74,157,104,0.25); }
.badge.warn { background: rgba(212,154,58,0.12);  color: var(--warn);    border-color: rgba(212,154,58,0.25); }
.badge.err  { background: rgba(200,69,69,0.12);   color: var(--danger);  border-color: rgba(200,69,69,0.25); }
.badge.busy { background: rgba(93,143,206,0.12);  color: var(--busy);    border-color: rgba(93,143,206,0.25); }
.badge.gold { background: rgba(212,175,55,0.12);  color: var(--gold);    border-color: rgba(212,175,55,0.25); }

/* ── rows / utility ───────────────────────────────────────────────────── */
.row { display: flex; gap: 0.7em; align-items: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.spacer-v { height: 1em; }
.pill {
    display: inline-block;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    padding: 0.2em 0.7em;
    border-radius: 99px;
    font-size: 0.85em;
    color: var(--silver);
}

/* ── workspace specifics ─────────────────────────────────────────────── */
.section-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.8em;
}
.section-head h2 { margin: 0; }
.asset-list {
    display: grid; gap: 0.4em; margin-top: 1em;
    font-size: 0.92em;
}
.asset-row {
    display: grid; grid-template-columns: 1fr auto; gap: 0.8em;
    padding: 0.5em 0.7em;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.asset-row.audio { grid-template-columns: 200px 1fr auto; }
.asset-row .name { color: var(--silver); font-family: var(--font-mono); font-size: 0.92em; }
.asset-row .size { color: var(--fg-mute); font-size: 0.85em; }
.asset-row .transcript {
    color: var(--fg-dim); font-style: italic; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-row .transcript.pending { color: var(--warn); font-style: normal; }
.asset-row .transcript.missing { color: var(--fg-mute); font-style: normal; }

/* Image thumbnail grid */
.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6em;
    margin-top: 1em;
}
.thumb-card {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.thumb-card img {
    width: 100%; aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background: var(--bg);
}
.thumb-card .meta {
    padding: 0.4em 0.55em;
    display: flex; justify-content: space-between; gap: 0.4em;
    font-size: 0.78em;
    border-top: 1px solid var(--border);
}
.thumb-card .meta .name {
    color: var(--silver); font-family: var(--font-mono);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}
.thumb-card .meta .size { color: var(--fg-mute); white-space: nowrap; }

/* Audio row with inline player */
.audio-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4em;
    padding: 0.6em 0.7em;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5em;
}
.audio-row .head {
    display: flex; justify-content: space-between; align-items: center; gap: 0.8em;
}
.audio-row .head .name {
    color: var(--silver); font-family: var(--font-mono); font-size: 0.92em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}
.audio-row .head .size { color: var(--fg-mute); font-size: 0.85em; }
.audio-row audio {
    width: 100%; height: 32px;
    filter: invert(0.92) hue-rotate(180deg);
}
.audio-row .transcript {
    color: var(--fg-dim); font-style: italic; font-size: 0.88em;
    border-top: 1px dashed var(--border);
    padding-top: 0.4em;
}
.audio-row .transcript.pending { color: var(--warn); font-style: normal; }

/* LoRA settings card */
.lora-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em 1.2em;
    margin-top: 0.6em;
}
.lora-grid .field { display: flex; flex-direction: column; gap: 0.3em; }
.lora-grid label { color: var(--silver); font-size: 0.86em; }
.lora-grid .value { color: var(--gold); font-family: var(--font-mono); font-size: 0.85em; }
.lora-grid input[type=range] {
    width: 100%; accent-color: var(--gold);
}
.lora-grid .radio-row {
    display: flex; gap: 0.8em; flex-wrap: wrap;
}
.lora-grid .radio-row label {
    display: flex; align-items: center; gap: 0.35em;
    cursor: pointer; color: var(--fg);
}
@media (max-width: 720px) {
    .lora-grid { grid-template-columns: 1fr; }
}

/* Job edit / new dialog */
.job-dialog {
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--fg);
    padding: 1.4em 1.6em;
    width: min(640px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(212, 175, 55, 0.08);
}
.job-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}
.job-dialog h3 {
    margin: 0 0 1em;
    color: var(--gold);
    font-size: 1.1em;
    letter-spacing: 0.02em;
}
.job-form .field { display: flex; flex-direction: column; gap: 0.25em; }
.job-form .field label { color: var(--silver); font-size: 0.86em; }
.job-form select, .job-form input[type=number], .job-form textarea {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.4em 0.55em;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95em;
}
.job-form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.8em 1em;
}
@media (max-width: 540px) {
    .job-form-grid { grid-template-columns: 1fr; }
}

/* ── Workspace split layout (wavespeed-style) ────────────────────────── */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 1.2em;
    align-items: start;
}
.workspace-left {
    display: flex; flex-direction: column; gap: 1em;
    min-width: 0;
}
.workspace-right {
    min-width: 0;
    position: sticky;
    top: 1em;
    max-height: calc(100vh - 2em);
    overflow: hidden;
    display: flex;
}
.workspace-results {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding-right: 0.4em;
}
@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .workspace-right { position: static; max-height: none; }
}

/* Job result cards */
.job-cards {
    display: flex; flex-direction: column; gap: 0.8em;
    margin-top: 0.6em;
}
.job-card {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.9em;
    padding: 0.7em;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.job-card .thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    display: block;
}
.job-card .thumb img,
.job-card .thumb video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    background: var(--bg);
}
.job-card .thumb .badge-wrap {
    position: absolute; left: 0.4em; bottom: 0.4em;
    z-index: 1;
    pointer-events: none;  /* don't block video controls */
}
.job-card .meta {
    display: flex; flex-direction: column; gap: 0.4em;
    min-width: 0;
}
.job-card .meta .head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.6em;
}
.job-card .meta .v {
    color: var(--gold); font-family: var(--font-mono); font-weight: 600;
}
.job-card .meta .audio-name {
    color: var(--fg-mute); font-size: 0.82em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0; flex: 1;
}
.job-card .meta .prompt {
    color: var(--fg-dim); font-size: 0.88em;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.job-card .meta .actions {
    display: flex; flex-wrap: wrap; gap: 0.3em;
    margin-top: auto;
}
.job-card .meta .actions .row-action { margin-left: 0; }
@media (max-width: 540px) {
    .job-card { grid-template-columns: 80px 1fr; }
}

/* Inline banner (used for idle-warn + similar notices) */
.banner {
    padding: 0.55em 0.8em;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--bg-elev-2);
    font-size: 0.9em;
}
.banner-warn {
    border-color: var(--warn);
    background: rgba(212, 154, 58, 0.08);
    color: var(--warn);
}
.banner-err {
    border-color: var(--danger);
    background: rgba(200, 69, 69, 0.08);
    color: var(--danger);
}

/* Compact details/summary for session asset accordion in manual mode */
details.card > summary {
    cursor: pointer;
    list-style: none;
    display: flex; align-items: center; gap: 0.6em;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
    content: '▸';
    color: var(--gold);
    font-size: 0.9em;
    transition: transform 0.15s;
}
details.card[open] > summary::before {
    transform: rotate(90deg);
    display: inline-block;
}

/* Row action buttons (small, inline in jobs table) */
.row-action {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0.18em 0.55em;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--silver);
    font-size: 0.85em;
    border-radius: var(--radius);
    cursor: pointer;
}
.row-action:hover { color: var(--gold); border-color: var(--gold-dim); }
button.row-action { font-family: inherit; }

.upload-form {
    display: flex; gap: 0.6em; align-items: center;
    background: var(--bg-elev-2);
    padding: 0.6em 0.8em;
    border-radius: var(--radius);
    border: 1px dashed var(--border-strong);
}
.upload-form input[type=file] {
    flex: 1; background: transparent; border: none; padding: 0;
}
.upload-form button { white-space: nowrap; }

.gpu-status {
    display: grid; grid-template-columns: 1fr auto; gap: 1em; align-items: center;
}
.gpu-status .state-label {
    font-size: 1.1em; font-weight: 600;
}
.gpu-status .meta { color: var(--fg-dim); font-size: 0.9em; margin-top: 0.2em; }
.gpu-actions { display: flex; gap: 0.5em; }

.job-thumb {
    display: inline-block;
    width: 40px; height: 24px;
    background: var(--bg-elev-3);
    border-radius: 3px; vertical-align: middle;
}

.errbox {
    margin-top: 0.5em;
    padding: 0.4em 0.6em;
    background: rgba(200,69,69,0.08);
    color: var(--danger);
    border: 1px solid rgba(200,69,69,0.25);
    border-radius: var(--radius);
    font-size: 0.88em;
}
