
:root {
    --bg: #050505;
    --bg-elev: #0e0e0e;
    --panel: #121212;
    --ink: #f7f4ef;
    --muted: #a8a29a;
    --line: rgba(255,255,255,0.08);
    --mint: #9af5c8;
    --sky: #9ad7ff;
    --peach: #ffc4a8;
    --lilac: #d7c4ff;
    --butter: #ffe59a;
    --coral: #ff9aa8;
    --font: "Manrope", sans-serif;
    --display: "Syne", sans-serif;
}
* { box-sizing: border-box; }
html, body {
    margin: 0; min-height: 100%;
    color: var(--ink);
    font-family: var(--font);
    background:
        radial-gradient(900px 500px at 10% -5%, rgba(154,215,255,.12), transparent 50%),
        radial-gradient(800px 420px at 90% 0%, rgba(154,245,200,.10), transparent 48%),
        radial-gradient(700px 500px at 70% 110%, rgba(215,196,255,.10), transparent 45%),
        var(--bg);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; }

.gate {
    min-height: 100dvh; position: relative;
    display: grid; grid-template-columns: 1.2fr .8fr; align-items: end;
    padding: 48px; overflow: hidden;
}
.hero-film, .hero-shade { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade {
    background:
        linear-gradient(to top, rgba(5,5,5,.9) 0%, rgba(5,5,5,.25) 50%, transparent 100%),
        linear-gradient(to right, rgba(5,5,5,.65) 0%, rgba(5,5,5,.1) 55%, transparent 100%);
}
.hero-copy, .login-card { position: relative; z-index: 2; max-width: 560px; }
.eyebrow { letter-spacing: .28em; font-size: 12px; color: var(--mint); margin: 0 0 16px; font-weight: 700; }
.hero-copy h1 { font-family: var(--display); font-size: clamp(40px, 6vw, 72px); line-height: .95; margin: 0 0 18px; font-weight: 700; }
.lede { max-width: 460px; color: rgba(247,244,239,.86); line-height: 1.5; }

.login-card {
    justify-self: end; width: min(100%, 380px); display: grid; gap: 14px; padding: 22px;
    border: 1px solid rgba(255,255,255,.12); background: rgba(8,8,8,.6);
    backdrop-filter: blur(16px); border-radius: 18px;
}
.login-card label, .panel label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input, .panel input {
    width: 100%; background: #0a0a0a; color: var(--ink);
    border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
/* Prompt / chat text boxes — high-contrast white field with yellow edge */
.panel textarea {
    width: 100%;
    max-width: 100%;
    min-height: 130px;
    resize: vertical;
    background: #ffffff;
    color: #14110c;
    border: 2px solid #f0c933;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    padding: 14px 16px;
    line-height: 1.45;
    font-size: 15px;
    font-weight: 500;
    caret-color: #b8860b;
}
.panel textarea::placeholder {
    color: rgba(20, 17, 12, 0.42);
}
.panel textarea:focus {
    outline: none;
    border-color: #ffe14a;
    box-shadow:
        inset 0 0 0 1px #ffffff,
        0 0 0 3px rgba(240, 201, 51, 0.35);
}
.panel textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
.panel textarea.is-enhancing {
    color: var(--butter);
    font-style: italic;
    letter-spacing: 0.02em;
    opacity: 1;
    cursor: wait;
    border-color: rgba(255, 229, 154, 0.45);
    background:
        linear-gradient(90deg, rgba(255,229,154,.08), rgba(154,215,255,.08), rgba(255,229,154,.08));
    background-size: 200% 100%;
    animation: enhancePulse 1.2s ease-in-out infinite;
}
@keyframes enhancePulse {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.login-card button, .panel button, .modal-card button {
    border: 0; border-radius: 999px; padding: 12px 18px;
    background: linear-gradient(135deg, var(--sky), var(--mint));
    color: #061018; font-weight: 800;
}
.panel button.gen-exhausted,
.panel button.gen-exhausted:disabled {
    background: linear-gradient(135deg, #ff5a5a, #c62828);
    color: #fff;
    cursor: not-allowed;
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(255,90,90,.35);
}
.panel button.gen-wait-enhance,
.panel button.gen-wait-enhance:disabled {
    background: #2a2d33 !important;
    color: rgba(247, 244, 239, 0.45) !important;
    cursor: not-allowed;
    opacity: 1;
    box-shadow: none;
    filter: grayscale(0.35);
}
.chip.tokens-empty {
    color: #ff9aa8;
    border-color: rgba(255,154,168,.45);
    background: rgba(255,90,90,.12);
}
#logout {
    border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px;
    background: transparent; color: var(--muted);
}
.auth-links {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700;
}
.auth-links[hidden] { display: none !important; }
.auth-sep { color: var(--muted); font-weight: 500; }
.text-link {
    appearance: none; border: 0; background: none; padding: 0; margin: 0;
    color: var(--sky); font: inherit; font-weight: 700; cursor: pointer;
    width: auto !important;
}
.text-link:hover { color: var(--mint); text-decoration: underline; }
.modal-text-actions {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin: 4px 0 0;
}
.form-error { color: var(--coral); margin: 0; }
.signup-retention {
    margin: 0 0 4px; padding: 12px 14px; border-radius: 12px;
    border: 1px solid rgba(255,154,168,.35); background: rgba(255,90,90,.1);
    color: #ffc9d0; font-size: 13px; line-height: 1.45;
}
.signup-retention strong { color: #fff; font-weight: 800; }

.auth-form { display: grid; gap: 10px; }
.auth-form button[hidden],
.panel button[hidden],
.modal-card button[hidden] { display: none !important; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.78); display: grid; place-items: center; }
.modal[hidden], #password-gate[hidden], #signin-gate[hidden], #signup-gate[hidden], #confirm-tokens-gate[hidden] { display: none !important; }
.modal-card {
    width: min(92vw, 420px); background: var(--panel); border: 1px solid var(--line);
    border-radius: 20px; padding: 28px;
}
.modal-card form { display: grid; gap: 12px; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 14px 24px; border-bottom: 1px solid var(--line);
    background: transparent;
}
.studio-chrome {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(5, 5, 5, 0.94);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-family: var(--display); font-size: 1.15rem; }
.mark {
    width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px;
    background: linear-gradient(135deg, var(--mint), var(--sky)); color: #061018; font-size: 11px; font-weight: 800;
}
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
    background: var(--bg-elev); border: 1px solid var(--line); color: var(--ink); font-weight: 600;
}
.chip[hidden],
#queue-pill[hidden],
#token-pill[hidden],
#logout[hidden],
#admin-hostbar[hidden],
#load-text[hidden],
#disk-text[hidden] { display: none !important; }
.chip.dim { color: var(--muted); }
.chip.ok { border-color: rgba(154,245,200,.45); background: rgba(154,245,200,.08); color: var(--mint); }

.admin-hostbar {
    display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
    border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--line);
    max-width: min(70vw, 560px); min-width: 0;
}
.host-heart {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; font-weight: 750; color: var(--muted);
    padding: 1px 7px 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0,0,0,.18);
    line-height: 1.2;
}
.host-heart .host-heart-icon {
    font-size: 11px;
    line-height: 1;
    transform-origin: center;
}
.host-heart.online {
    color: var(--ink);
    border-color: rgba(255,70,90,.4);
}
.host-heart.online .host-heart-icon {
    color: #ff2d4a;
    animation: host-heart-pulse 1.15s ease-in-out infinite;
}
.host-heart.offline {
    color: rgba(255,255,255,.72);
    border-color: rgba(255,255,255,.22);
}
.host-heart.offline .host-heart-icon {
    color: #fff;
    filter: grayscale(1) brightness(2.4) contrast(1.1);
}
@keyframes host-heart-pulse {
    0%, 100% { transform: scale(1); opacity: .85; }
    45% { transform: scale(1.28); opacity: 1; }
    70% { transform: scale(0.96); opacity: .8; }
}
.load-text {
    color: var(--ink);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    padding-left: 8px;
    border-left: 1px solid var(--line);
    max-width: min(48vw, 360px);
    overflow: hidden;
    text-overflow: ellipsis;
}
.load-text .gpu-busy { color: #e8a838; }
.load-text .gpu-hot { color: #e23b3b; }
.disk-text {
    padding-left: 8px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}

.metrics-tools-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 0 24px 8px;
    min-width: 0;
}
@media (max-width: 720px) {
    .metrics-tools-row {
        flex-direction: column;
        align-items: stretch;
        padding: 0 12px 6px;
        gap: 8px;
    }
    .admin-hostbar {
        max-width: 100%;
        flex-wrap: wrap;
    }
}

.progress-model {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--sky);
    line-height: 1.4;
}
.progress-model b { color: var(--ink); font-weight: 700; }

.tool-deck {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 6px;
    padding: 0;
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
body.workspace-basic .tool-deck,
body.workspace-full .tool-deck {
    flex-wrap: nowrap;
}
/* PC: keep every tool icon on one row, left-aligned. */
@media (min-width: 981px) {
    .tool-deck,
    body.workspace-basic .tool-deck,
    body.workspace-full .tool-deck {
        overflow-x: hidden;
        justify-content: flex-start;
    }
}
.tool-deck[hidden] { display: none !important; }
.tool-tile[hidden] { display: none !important; }
.tool-tile {
    appearance: none; border: 1px solid var(--line); background: var(--panel);
    border-radius: 10px; padding: 4px; display: grid; gap: 3px; text-align: left;
    color: var(--ink); width: 72px; flex: 0 0 auto;
    transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.tool-tile:hover { transform: translateY(-1px); border-color: rgba(154,215,255,.35); }
.tool-tile.on { border-color: var(--sky); box-shadow: 0 0 0 1px rgba(154,215,255,.25), 0 6px 14px rgba(0,0,0,.3); }
.tile-art {
    width: 40px; height: 40px; border-radius: 7px; display: block;
    position: relative; overflow: hidden; background: #0a0a0a;
}
.tile-art img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.tool-tile:hover .tile-art img { transform: scale(1.06); }
.tile-title { font-family: var(--display); font-size: 9px; font-weight: 700; line-height: 1.2; }
.tile-admin { width: 40px; height: 40px; border-radius: 7px; }
.tile-admin-mark { font-size: 13px; }
.tile-library {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 30% 30%, rgba(154,215,255,.25), transparent 55%),
        radial-gradient(circle at 70% 70%, rgba(255,229,154,.22), transparent 50%),
        #0a0a0a;
}
.tile-music {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 35% 25%, rgba(255,160,120,.3), transparent 55%),
        radial-gradient(circle at 70% 75%, rgba(200,100,160,.28), transparent 50%),
        #0a0a0a;
}
.tile-lipsync {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 30% 35%, rgba(120,200,255,.32), transparent 55%),
        radial-gradient(circle at 75% 70%, rgba(255,140,180,.26), transparent 50%),
        #0a0a0a;
}

.workspace {
    display: grid; grid-template-columns: minmax(0, 1.4fr) 400px;
    min-height: calc(100dvh - 280px); padding: 8px 24px 0; gap: 16px;
}
.stage {
    background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
    display: grid; place-items: center; justify-items: center; padding: 28px; min-height: 420px;
    position: relative;
}
.stage-pane {
    width: 100%;
    max-width: 100%;
}
/* Author display rules must not defeat the hidden attribute — only one stage mode at a time. */
.stage-pane[hidden],
.image-pane[hidden],
.video-pane[hidden],
.audio-pane[hidden],
.chat-pane[hidden],
#preview-empty[hidden],
#preview-image-pane[hidden],
#preview-video-pane[hidden],
#preview-audio-pane[hidden],
#preview-chat-pane[hidden],
#preview-image[hidden],
#preview-video[hidden],
#preview-audio[hidden],
#preview-chat[hidden] {
    display: none !important;
}
.stage[data-mode="empty"] { place-items: center; }
.stage[data-mode="image"],
.stage[data-mode="video"],
.stage[data-mode="audio"] {
    place-items: center;
    padding: 24px;
}
.stage[data-mode="chat"] {
    place-items: stretch;
    align-content: stretch;
    padding: 0;
    overflow: hidden;
}
/* Exclusive stage modes: never show more than one pane. */
.stage #preview-empty,
.stage #preview-image-pane,
.stage #preview-video-pane,
.stage #preview-audio-pane,
.stage #preview-chat-pane {
    display: none !important;
}
.stage[data-mode="empty"] #preview-empty:not([hidden]) { display: block !important; }
.stage[data-mode="image"] #preview-image-pane:not([hidden]) { display: grid !important; }
.stage[data-mode="video"] #preview-video-pane:not([hidden]) { display: grid !important; }
.stage[data-mode="audio"] #preview-audio-pane:not([hidden]) { display: grid !important; }
.stage[data-mode="chat"] #preview-chat-pane:not([hidden]) { display: grid !important; }
/* Media elements themselves must not leak display when parent is off. */
#preview-image[hidden],
#preview-video[hidden],
#preview-audio[hidden],
#preview-chat[hidden] { display: none !important; }
.stage:not([data-mode="image"]) #preview-image { display: none !important; }
.stage:not([data-mode="video"]) #preview-video { display: none !important; }
.stage:not([data-mode="audio"]) #preview-audio,
.stage:not([data-mode="audio"]) #preview-audio-pane { display: none !important; }
.stage:not([data-mode="chat"]) #preview-chat,
.stage:not([data-mode="chat"]) #preview-chat-pane { display: none !important; }
.stage[data-mode="chat"] #preview-image-pane,
.stage[data-mode="chat"] #preview-video-pane,
.stage[data-mode="chat"] #preview-audio-pane,
.stage[data-mode="chat"] #preview-image,
.stage[data-mode="chat"] #preview-video,
.stage[data-mode="chat"] #preview-audio { display: none !important; }

.empty { text-align: center; max-width: 560px; margin: 0 auto; }
.empty h2 { font-family: var(--display); font-size: 40px; margin: 0 0 12px; }
.empty p, .panel p, .hint, .status { color: var(--muted); line-height: 1.5; }

.image-pane, .video-pane, .audio-pane {
    place-items: center;
    width: 100%;
    min-height: 360px;
}
.audio-stage {
    width: min(100%, 520px);
    padding: 28px 24px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at 20% 0%, rgba(255,160,120,.18), transparent 55%),
        rgba(0,0,0,.35);
    display: grid;
    gap: 16px;
    justify-items: stretch;
}
.audio-stage-label {
    margin: 0;
    font-family: var(--display);
    font-size: 14px;
    color: var(--muted);
}
#preview-audio {
    width: 100%;
}
.audio-stage-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.audio-stage-actions .ghost-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
#preview-image {
    display: block;
    margin: 0 auto;
    width: auto;
    height: auto;
    max-width: min(100%, 1100px);
    max-height: min(70vh, 760px);
    object-fit: contain;
    object-position: center center;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.45);
    background: #050505;
}
#preview-video {
    display: block;
    margin: 0 auto;
    width: min(100%, 1100px);
    max-height: min(70vh, 760px);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.45);
    background: #050505;
}

.chat-pane {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100%;
    min-height: 420px;
    max-height: calc(100dvh - 280px);
}
.chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(0,0,0,.25);
}
.chat-toolbar-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.chat-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-toolbar-actions .ghost-btn { margin: 0 !important; }
.thumb-color-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.85rem 1.1rem;
    margin: 0.35rem 0 0.75rem;
}
.thumb-color-row label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.85;
}
.thumb-color-row input[type="color"] {
    width: 2.6rem;
    height: 2rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.35rem;
    background: transparent;
    cursor: pointer;
}
.thumb-heading-preview {
    flex: 1 1 12rem;
    min-height: 2.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.4rem;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(20, 20, 20, 0.35));
    font-family: "DejaVu Sans", "Arial Black", Impact, sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, 0.65);
    border-bottom: 4px solid #ffd400;
    display: flex;
    align-items: center;
}
#thumb-heading {
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.prompt-enhance-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 8px 0 4px;
}
.prompt-enhance-row .ltx-check { margin: 0; }
.ghost-btn {
    width: auto !important; margin: 0 !important; padding: 8px 12px !important;
    font-size: 12px; background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.ghost-btn:hover { color: var(--ink); border-color: rgba(154,215,255,.45); }

.rail {
    border: 1px solid var(--line); border-radius: 24px; padding: 22px; background: var(--panel);
}
.panel { display: none; }
.panel.on { display: block; }
.panel h3 { margin-top: 0; font-family: var(--display); font-size: 1.35rem; }
.drop {
    margin: 14px 0; padding: 16px; border: 1px dashed rgba(255,255,255,.16); border-radius: 14px;
    display: grid; gap: 6px; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.drop strong { font-size: .95rem; }
.drop span { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.drop.on-drop {
    border-color: rgba(154,215,255,.65);
    background: rgba(154,215,255,.08);
}
.panel button { width: 100%; margin-top: 8px; }
.status { min-height: 1.4em; }

.quality {
    display: grid; gap: 8px; margin: 14px 0 6px;
}
.quality-labels {
    display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600;
}
.quality-labels span.on {
    color: var(--sky);
    text-shadow: 0 0 12px rgba(154,215,255,.35);
}
.quality input[type=range] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
    background: linear-gradient(90deg, var(--mint), var(--sky), var(--lilac));
    outline: none; border: 0; padding: 0;
    /* Override generic .panel input padding which breaks range hit-testing */
    background-color: transparent;
    box-sizing: border-box;
    cursor: pointer;
}
.panel .quality input[type=range] {
    border: 0 !important;
    border-radius: 999px !important;
    padding: 0 !important;
    height: 28px;
    background: linear-gradient(90deg, var(--mint), var(--sky), var(--lilac));
    background-size: 100% 6px;
    background-repeat: no-repeat;
    background-position: center;
}
.quality-labels span { cursor: pointer; user-select: none; }
.quality input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid var(--sky); box-shadow: 0 0 0 4px rgba(154,215,255,.18);
    cursor: grab;
}
.quality input[type=range]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid var(--sky); cursor: grab;
}
.quality input[type=range]::-moz-range-track {
    height: 6px; border-radius: 999px;
    background: linear-gradient(90deg, var(--mint), var(--sky), var(--lilac));
}
.quality-hint { font-size: 12px; color: var(--muted); margin: 0; }

.size-picker {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px;
}
/* Beat .panel button gradient so unselected chips stay muted */
.panel button.size-chip,
.size-chip {
    appearance: none;
    border: 1px solid var(--line) !important;
    background: #141414 !important;
    color: var(--muted) !important;
    border-radius: 999px;
    padding: 8px 12px !important;
    font-size: 12px;
    font-weight: 700;
    width: auto !important;
    margin: 0 !important;
    box-shadow: none !important;
}
.panel button.size-chip.on,
.size-chip.on {
    color: #061018 !important;
    border-color: transparent !important;
    background: linear-gradient(135deg, var(--sky), var(--mint)) !important;
    box-shadow: 0 0 0 1px rgba(154,215,255,.35), 0 0 18px rgba(154,245,200,.18) !important;
}
.music-style-picker {
    display: grid; gap: 10px; margin: 6px 0 10px;
}
.music-style-group-label {
    display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted); margin: 0 0 4px;
}
.music-tag-picker { margin: 0; gap: 6px; }
.music-tag-chip { padding: 6px 10px; font-size: 11px; font-weight: 650; }
.size-edit {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 4px;
}
.size-edit label {
    display: grid; gap: 4px; font-size: 12px; color: var(--muted);
}
.size-edit input[type=number],
.size-edit select {
    width: 100%; background: #0a0a0a; color: var(--ink);
    border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.field-label {
    display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px;
}
.video-controls { margin-top: 10px; }

.tile-admin {
    display: grid; place-items: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,229,154,.35), transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(154,215,255,.25), transparent 40%),
        #101010;
}
.tile-admin-mark {
    font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: .04em;
    color: var(--butter);
}
.admin-form { display: grid; gap: 10px; margin: 14px 0; }
.admin-users { display: grid; gap: 10px; margin-top: 16px; }
.admin-user {
    display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #0a0a0a;
}
.admin-user .email { font-weight: 700; color: var(--ink); }
.admin-user .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.admin-user .controls { display: flex; gap: 8px; align-items: center; }
.admin-user input[type=number] {
    width: 110px; background: #050505; color: var(--ink);
    border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.admin-user button {
    width: auto; margin: 0; padding: 8px 12px; font-size: 12px;
}

.ltx-features {
    display: grid;
    gap: 8px;
    margin: 10px 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #0a0a0a;
}
.ltx-features .ltx-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}
.ltx-features .ltx-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--butter);
}
.ltx-features .hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
}
.quality-labels span[data-admin-only][hidden] {
    display: none;
}

.confirm-tokens-card .confirm-tokens-detail {
    margin: 0 0 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #0a0a0a;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
}
.confirm-tokens-card .confirm-tokens-detail strong {
    color: var(--butter);
    font-variant-numeric: tabular-nums;
}
.confirm-tokens-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}
.confirm-tokens-actions .ghost-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
}
.confirm-tokens-actions .ghost-btn:hover {
    background: rgba(255,255,255,.04);
}

.library, .queue-board { width: min(1200px, calc(100% - 48px)); margin: 0 auto 28px; padding: 18px 0 8px; }
.library h3, .queue-head h3 { font-family: var(--display); margin: 0 0 14px; }
.library-pane {
    width: 100%;
    height: 100%;
    min-height: 360px;
    overflow: auto;
    align-self: stretch;
    padding: 8px 4px 16px;
}
.library-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 0 0 14px;
    padding: 0 6px;
}
.library-page-head h2 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.5rem;
}
.library-pane .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.stage[data-mode="library"] {
    place-items: stretch;
    align-content: start;
    padding: 18px 16px;
}
.stage-pane.library-pane[hidden],
#preview-library-pane[hidden] {
    display: none !important;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
    position: relative;
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
    color: inherit; text-decoration: none; cursor: pointer;
}
.card .card-del {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 28px !important;
    height: 28px;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255,255,255,.18) !important;
    background: rgba(0,0,0,.72) !important;
    color: #fff !important;
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
}
.card .card-del:hover {
    background: rgba(180,40,60,.92) !important;
    border-color: rgba(255,154,168,.55) !important;
}
.card .media {
    height: 150px; background: #171717; display: grid; place-items: center; overflow: hidden;
}
.card .media img, .card .media video {
    width: 100%; height: 100%; object-fit: contain; object-position: center center; display: block;
}
.card .media .kind-fallback { font-family: var(--display); font-weight: 700; color: var(--sky); }
.card .meta { padding: 12px; display: grid; gap: 6px; }
.card .card-top {
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.card b { display: block; font-size: 13px; margin: 0; text-transform: capitalize; }
.card .when {
    color: var(--muted); font-size: 11px; font-weight: 700;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.card .owner {
    color: var(--sky); font-size: 11px; font-weight: 700;
}
.card .prompt {
    margin: 0;
    color: var(--ink);
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}
.card .card-foot { color: var(--muted); font-size: 12px; }
.card span { color: var(--muted); font-size: 12px; }

.ref-picker { display: grid; gap: 8px; margin: 12px 0; }
.ref-chip {
    display: grid; grid-template-columns: 18px 42px 1fr; gap: 10px; align-items: center;
    padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #0a0a0a;
}
.ref-chip.on { border-color: rgba(154,215,255,.55); }
.ref-chip img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }
.ref-grid { display: grid; gap: 10px; margin-top: 16px; }
.ref-card {
    display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 10px;
    border: 1px solid var(--line); border-radius: 14px; background: #0a0a0a;
}
.ref-card img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.ref-card b { display: block; margin-bottom: 4px; }
.ref-card span { color: var(--muted); font-size: 12px; display: block; margin-bottom: 8px; }
.ref-del {
    width: auto !important; margin: 0 !important; padding: 6px 10px !important;
    background: transparent !important; color: var(--coral) !important;
    border: 1px solid rgba(255,154,168,.35) !important; border-radius: 999px !important; font-size: 12px;
}

.queue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.queue-list { display: grid; gap: 8px; }
.comfy-queue-board {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.comfy-queue-board .queue-row.engine {
    grid-template-columns: 72px 1fr auto;
}
.queue-row .owner {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}
.library-admin-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin: 8px 0 4px;
}
.library-owner-label {
    display: grid;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}
.library-owner-label select {
    min-width: min(280px, 70vw);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--ink);
}
.queue-row {
    display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: start;
    padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
}
.queue-pos { font-family: var(--display); font-size: 1.35rem; color: var(--peach); padding-top: 2px; }
.queue-row b { display: block; font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.queue-row .desc { color: var(--muted); font-size: 13px; line-height: 1.35; }
.queue-meta { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.queue-meta strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 2px; }
.queue-cancel {
    display: inline-block;
    width: auto !important;
    margin-top: 8px !important;
    padding: 6px 14px !important;
    font-size: 12px;
    font-weight: 700;
    color: #ffb4be !important;
    background: rgba(255,90,110,.12) !important;
    border: 1px solid rgba(255,154,168,.45) !important;
    border-radius: 999px;
    cursor: pointer;
}
.queue-cancel:hover { background: rgba(255,154,168,.1); }
.queue-row.running .queue-pos { color: var(--mint); }
.queue-row .queue-progress {
    grid-column: 2 / -1;
    display: grid;
    gap: 6px;
}
.queue-row .queue-tip {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    font-style: italic;
}

.progress-panel {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(154,215,255,.08), rgba(255,184,154,.06));
}
.progress-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 10px;
}
.progress-head strong { font-size: 14px; color: var(--ink); line-height: 1.35; max-width: 58%; }
.progress-times {
    display: grid;
    gap: 4px;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    min-width: 7.5rem;
}
.progress-times > div {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: baseline;
}
.progress-times .time-key { color: var(--muted); opacity: .85; }
.progress-times span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-activity {
    display: block;
    margin: 0 0 12px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,.18);
    border: 1px solid var(--line);
}
.activity-phase {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent, #9ad7ff);
    letter-spacing: .02em;
}
.activity-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}
.activity-where {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--accent, #9ad7ff);
    white-space: nowrap;
}
.activity-meter {
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    overflow: hidden;
}
.activity-meter-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #5ec8ff, #9dffb0 55%, #ffd36a);
    transition: width .6s ease;
    box-shadow: 0 0 12px rgba(94,200,255,.35);
}
.activity-cpu {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    min-width: 4.5rem;
    text-align: right;
}
.progress-steps {
    list-style: none;
    display: flex;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    overflow-x: auto;
}
.progress-steps li {
    flex: 1 1 0;
    min-width: 4.2rem;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    padding: 8px 4px 6px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255,255,255,.03);
    position: relative;
}
.progress-steps li .step-dot {
    display: block;
    width: 8px;
    height: 8px;
    margin: 0 auto 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
}
.progress-steps li.done {
    color: var(--ink);
}
.progress-steps li.done .step-dot {
    background: #9dffb0;
}
.progress-steps li.active {
    color: var(--ink);
    border-color: rgba(154,215,255,.35);
    background: rgba(154,215,255,.1);
}
.progress-steps li.active .step-dot {
    background: #5ec8ff;
    box-shadow: 0 0 0 4px rgba(94,200,255,.18);
    animation: stepPulse 1.1s ease-in-out infinite;
}
@keyframes stepPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: .75; }
}
.queue-meta .elapsed { display: block; color: var(--ink); font-size: 12px; margin-bottom: 2px; }
.progress-runway,
.queue-runway {
    position: relative;
    padding-top: 48px;
    overflow: visible;
}
.queue-runway {
    padding-top: 36px;
}
.progress-runner {
    position: absolute;
    top: 0;
    left: clamp(4%, var(--run, 0%), 96%);
    transform: translateX(-50%);
    transition: left .7s ease;
    z-index: 2;
    pointer-events: none;
    line-height: 0;
    background: transparent;
}
/* Waiting / queued: thinking emoji stays centered — no left-right pace */
.progress-runner.is-thinking {
    left: 50%;
    transition: none;
    animation: thinkBob 1.5s ease-in-out infinite;
}
.progress-runner.is-thinking .runner-emoji { display: none; }
.progress-runner:not(.is-thinking) .runner-think { display: none; }
.runner-think {
    display: block;
    font-size: 36px;
    line-height: 1;
    width: 44px;
    height: 44px;
    text-align: center;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,.4));
    user-select: none;
}
.runner-emoji {
    display: block;
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: transparent;
    border: 0;
    box-shadow: none;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,.4));
}
.queue-runway .runner-emoji,
.queue-runway .runner-think {
    width: 36px;
    height: 36px;
    font-size: 30px;
}
@keyframes thinkBob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

.progress-track, .queue-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    overflow: hidden;
    border: 1px solid var(--line);
}
.progress-bar, .queue-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--mint), var(--peach), var(--coral));
    background-size: 200% 100%;
    transition: width .7s ease;
    animation: progressShimmer 2.4s linear infinite;
}
.progress-bar.indeterminate, .queue-bar.indeterminate {
    width: 34% !important;
    margin-left: 33%;
    animation: progressShimmer 2.4s linear infinite;
}
.progress-tip {
    margin: 10px 0 0;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
    transition: opacity .25s ease, transform .25s ease;
}
.progress-tip.tip-swap, .queue-tip.tip-swap {
    opacity: .35;
    transform: translateY(3px);
}
@keyframes progressShimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
@keyframes progressSlide {
    0% { transform: translateX(-20%); }
    50% { transform: translateX(180%); }
    100% { transform: translateX(-20%); }
}

@media (max-width: 980px) {
    .gate, .workspace, .topbar { display: grid; grid-template-columns: 1fr; }
    .login-card, .hero-copy { justify-self: stretch; }
    .account { flex-wrap: wrap; }
    .tool-deck,
    body.workspace-full .tool-deck,
    body.workspace-basic .tool-deck {
        overflow-x: auto;
    }
    .library, .queue-board { width: calc(100% - 24px); }
    .queue-row { grid-template-columns: 44px 1fr; }
    .queue-meta { grid-column: 2; text-align: left; }
    .studio-chrome { padding-bottom: 2px; }
}


/* YouTube Edit — server clip picker */
.yt-hero { margin-bottom: 14px; }
.yt-hero h3 { margin-bottom: 4px; }
.yt-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.yt-section-title {
    margin: 18px 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
}
.yt-options { display: grid; gap: 8px; margin: 10px 0 12px; }
.yt-url-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: stretch;
    margin: 8px 0;
}
.yt-url-row input { margin: 0; }
.yt-url-row button {
    width: auto !important;
    margin-top: 0 !important;
    min-width: 44px;
    padding: 10px 14px;
}
.yt-clip-cards {
    display: grid;
    gap: 8px;
    margin: 4px 0 6px;
}
.yt-clip-card {
    display: grid !important;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    width: 100%;
    margin-top: 0 !important;
    text-align: left;
    border: 1px solid var(--line) !important;
    border-radius: 14px !important;
    padding: 12px 14px !important;
    background: rgba(255,255,255,.04) !important;
    color: var(--ink) !important;
    font-weight: 600 !important;
    cursor: pointer;
    align-items: center;
}
.yt-clip-card .yt-ord {
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    background: rgba(255,255,255,.06);
    border: 1px solid var(--line);
}
.yt-clip-card.on .yt-ord {
    color: #06241a;
    background: var(--mint);
    border-color: transparent;
}
.yt-clip-card:hover {
    border-color: rgba(120, 200, 255, .45) !important;
    background: rgba(120, 200, 255, .08) !important;
}
.yt-clip-card.on {
    border-color: var(--mint) !important;
    background: rgba(80, 220, 180, .12) !important;
    box-shadow: inset 0 0 0 1px rgba(80, 220, 180, .35);
}
.yt-clip-card b {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.yt-clip-card span {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}
.yt-order-hint {
    margin: 0 0 8px;
    color: var(--ink);
    font-weight: 600;
}
.panel button.secondary,
.yt-url-row button.secondary {
    background: rgba(255,255,255,.08) !important;
    color: var(--ink) !important;
    font-weight: 650 !important;
}
.yt-drop-small { padding: 12px; margin-top: 6px; }
.yt-run { margin-top: 14px !important; }
@media (max-width: 640px) {
    .tool-deck,
    body.workspace-full .tool-deck,
    body.workspace-basic .tool-deck {
        display: flex;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 3px;
        padding: 6px 8px 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        grid-template-columns: none;
    }
    /* Non-admin: six tools on one row, no horizontal scroll. */
    body.workspace-basic .tool-deck {
        overflow-x: hidden;
        justify-content: space-between;
    }
    .tool-tile,
    body.workspace-full .tool-tile,
    body.workspace-basic .tool-tile {
        flex: 0 0 auto;
        width: 52px;
        padding: 2px;
        gap: 2px;
        border-radius: 8px;
    }
    body.workspace-basic .tool-tile {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        max-width: 64px;
    }
    /* Admin: same compact size so more tools fit before scrolling. */
    body.workspace-full .tool-tile {
        width: 48px;
        max-width: 48px;
        padding: 2px;
    }
    .tile-art,
    .tile-admin,
    body.workspace-full .tile-art,
    body.workspace-full .tile-admin,
    body.workspace-basic .tile-art,
    body.workspace-basic .tile-admin {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        margin: 0 auto;
    }
    body.workspace-basic .tile-art,
    body.workspace-basic .tile-admin {
        width: 28px;
        height: 28px;
    }
    .tile-title,
    body.workspace-full .tile-title,
    body.workspace-basic .tile-title {
        font-size: 7px;
        line-height: 1.1;
        text-align: center;
    }
    .tile-admin-mark { font-size: 9px; }
    .yt-url-row { grid-template-columns: 1fr 1fr; }
    .yt-url-row input { grid-column: 1 / -1; }
    .rail { padding: 16px; border-radius: 18px; }
    .panel textarea {
        min-height: 108px;
        font-size: 16px; /* stops iOS zooming the field on focus */
        padding: 12px 14px;
        border-radius: 12px;
        border-width: 2px;
        line-height: 1.4;
    }
    #chat-prompt,
    #image-prompt,
    #video-prompt,
    #director-prompt {
        min-height: 96px;
    }
    #video-style,
    #edit-prompt {
        min-height: 72px;
    }
}

.queue-row.stale {
    border-color: rgba(255, 170, 70, .45);
    box-shadow: inset 0 0 0 1px rgba(255, 170, 70, .25);
}
.queue-row.stale .desc { color: #ffc078; }

.ytv2-ready {
    display: flex; flex-wrap: wrap; gap: 6px 10px;
    margin: 10px 0 4px;
}
.ytv2-check {
    font-size: 12px; font-weight: 650; color: var(--muted);
    padding: 3px 8px; border-radius: 999px;
    border: 1px solid var(--line); background: rgba(0,0,0,.16);
}
.ytv2-check.ok {
    color: var(--mint);
    border-color: rgba(154,245,200,.4);
    background: rgba(154,245,200,.08);
}
.ytv2-check.miss {
    color: #ffc078;
    border-color: rgba(255,192,120,.35);
}
.yt-run:disabled {
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(.2);
}
.yt-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
    align-items: stretch;
}
.yt-actions .yt-run { margin-top: 0 !important; }
.yt-cancel, .progress-cancel, .queue-cancel-all {
    border: 1px solid rgba(255,154,168,.45) !important;
    background: rgba(255,90,110,.12) !important;
    color: #ffb4be !important;
    font-weight: 700 !important;
    border-radius: 999px !important;
    cursor: pointer;
}
.yt-cancel {
    width: auto !important;
    margin-top: 0 !important;
    padding: 12px 18px !important;
    min-width: 110px;
}
.progress-cancel {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
}
.queue-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.queue-head h3 { margin: 0; flex: 1; }
.queue-cancel-all {
    width: auto !important;
    margin: 0 !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
}
.panel button.yt-cancel,
.panel button.progress-cancel {
    background: rgba(255,90,110,.12) !important;
    color: #ffb4be !important;
}

/* Chat transcript — text document style in the main stage */
.preview-chat {
    width: 100%;
    height: 100%;
    min-height: 320px;
    overflow: auto;
    display: grid;
    gap: 14px;
    align-content: start;
    padding: 18px 20px 24px;
    background: #0a0a0a;
}
.preview-chat .chat-empty {
    margin: auto;
    text-align: center;
    color: var(--muted);
    max-width: 420px;
    padding: 48px 12px;
}
.preview-chat .chat-empty h2 {
    font-family: var(--display);
    font-size: 2rem;
    margin: 0 0 10px;
    color: var(--ink);
}
.chat-bubble {
    padding: 0;
    border-radius: 0;
    background: transparent;
    max-width: 100%;
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding-bottom: 14px;
}
.chat-bubble.you,
.chat-bubble.bot {
    background: transparent;
    justify-self: stretch;
}
.chat-role {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.chat-text {
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1.02rem;
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}
.chat-text-plain {
    /* used for copy/PDF export helpers */
    display: none;
}
#chat-model {
    width: 100%;
    margin-top: 6px;
}
.tile-chat {
    background: linear-gradient(145deg, rgba(90, 160, 255, 0.25), rgba(40, 80, 140, 0.35));
}

/* Chat replies live with the text prompt in the rail */
.chat-prompt-thread {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0,0,0,.28);
    max-height: min(48vh, 520px);
    display: grid;
    grid-template-rows: auto 1fr;
}
.chat-toolbar-compact {
    padding: 10px 12px;
}
.chat-thread {
    overflow: auto;
    padding: 12px 14px 16px;
    display: grid;
    gap: 12px;
    align-content: start;
    min-height: 120px;
}
.chat-thread .chat-empty {
    margin: 12px auto;
    text-align: center;
    color: var(--muted);
    max-width: 280px;
}
.chat-thread .chat-empty h2 {
    font-family: var(--display);
    font-size: 1.35rem;
    margin: 0 0 8px;
    color: var(--ink);
}
#panel-chat:not(.on) .chat-prompt-thread { display: none; }
