/* Global Ascend LLC — dark theme.
   Every class from the light theme is preserved; only the skin changed. */

:root {
    --bg: #0b0b10;
    --surface: #14141c;
    --surface-2: #1a1a26;
    --border: #272738;
    --border-soft: #1f1f2c;
    --text: #e8e8f0;
    --text-muted: #9a9aac;
    --accent: #8b5cf6;
    --accent-soft: #b79aff;
    --gradient: linear-gradient(135deg, #4d9fff, #b388ff 50%, #ff6ec7);
    --gradient-btn: linear-gradient(135deg, #7c3aed, #ec4899);
    --ok: #34d399;
    --fail: #f87171;
}

/* ---- Base chrome ---- */
body {
    font-family: sans-serif;
    max-width: 1500px;
    margin: 0 auto 40px;
    color: var(--text);
    padding: 0;
    background: var(--bg);
}
h1 { font-size: 26px; }
a { color: #9db8ff; }
code { background: #1e1e2b; color: #d9d9ea; padding: 2px 5px; border-radius: 4px; }
.ok { color: var(--ok); }
.fail { color: var(--fail); }
.pending { color: var(--text-muted); }

textarea {
    width: 100%; height: 140px; padding: 8px; box-sizing: border-box;
    font-family: monospace; font-size: 13px; line-height: 1.5;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text);
}
select, input[type="number"], input[type="password"], input[type="text"] {
    padding: 6px; width: 100%; box-sizing: border-box;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
}
input[type="file"] {
    padding: 8px; border: 1px dashed var(--border); border-radius: 6px;
    width: 100%; box-sizing: border-box;
    background: var(--surface); color: var(--text-muted);
}
button {
    padding: 8px 20px; margin-top: 10px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface-2); color: var(--text);
}
button:hover { border-color: var(--accent); color: var(--accent-soft); }

table { border-collapse: collapse; width: 100%; margin-top: 20px; background: var(--surface); }
th, td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }
th { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
tr:hover td { background: var(--surface-2); }

/* ---- Brand band ---- */
.brand-band {
    background: linear-gradient(135deg, #0f1e3d, #1a1440);
    border-bottom: 1px solid #2a2250;
    padding: 32px 20px 26px;
    text-align: center;
    margin-bottom: 30px;
}
.brand-band h1 {
    margin: 0;
    font-size: 44px;
    font-weight: 900;
    letter-spacing: 5px;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.brand-band .tagline {
    margin: 6px 0 0;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #9aa5c9;
}
.brand-band .quote {
    margin: 14px auto 0;
    max-width: 520px;
    font-style: italic;
    font-size: 14px;
    color: #cdd3ec;
}

.page-content { padding: 0 20px; }

/* ---- Nav ---- */
nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 30px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
nav a {
    text-decoration: none;
    font-weight: bold;
    color: #b5b5c5;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 14px;
    white-space: nowrap;
}
nav a:hover { background: #232336; color: var(--accent-soft); }
nav a.active { background: var(--gradient-btn); color: white; }
nav .logout-form { margin-left: auto; }
nav .logout-form button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    margin: 0;
}
nav .logout-form button:hover { border-color: var(--fail); color: var(--fail); }

@media (max-width: 700px) {
    .brand-band h1 { font-size: 30px; letter-spacing: 3px; }
}

/* ---- Footer ---- */
footer {
    margin-top: 60px;
    padding: 24px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 13px;
}
footer .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 18px;
}
footer .footer-links a:hover { color: var(--accent-soft); }

/* ---- Shared form fields ---- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 4px; font-weight: bold; }

/* ---- Ordered file-picker widget ---- */
.file-order-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-order-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px;
    font-size: 14px;
    background: var(--surface);
}
.file-order-list li .item-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-order-list li .reused-badge {
    flex-shrink: 0;
    background: #2a2250;
    color: var(--accent-soft);
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 999px;
}
.file-order-list button {
    border: 1px solid var(--border); background: var(--surface-2); border-radius: 4px;
    cursor: pointer; padding: 2px 8px; margin: 0; color: var(--text);
}
.file-order-list li .thumb-small {
    width: 100px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border);
    background: #000;
}
.file-order-list li .thumb-audio { width: 240px; }
.thumb-preview {
    display: block; margin-top: 8px; max-width: 160px; max-height: 160px;
    border-radius: 6px; border: 1px solid var(--border); object-fit: cover;
}

/* ---- Result grid / cards ---- */
.results { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 16px; }
.result-item { width: 320px; }
.result-video, .result-image {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    margin-bottom: 8px;
    background: #000;
}
.result-audio { width: 100%; margin-bottom: 8px; }
.result-file {
    display: flex; align-items: center; justify-content: center;
    height: 120px; border: 1px dashed var(--border); border-radius: 8px;
    margin-bottom: 8px; color: var(--text-muted); font-size: 14px; word-break: break-all; padding: 10px;
    box-sizing: border-box;
}
.source { font-size: 12px; color: var(--text-muted); margin: 0 0 4px; word-break: break-all; }
.fail-list { list-style: none; padding: 0; margin: 0 0 16px; }
.fail-list li { margin-bottom: 6px; }
.filename { font-size: 14px; word-break: break-all; margin: 0 0 10px; }
.download-btn {
    display: block;
    text-align: center;
    background: #16843a;
    color: white;
    font-weight: bold;
    font-size: 16px;
    padding: 12px 0;
    border-radius: 6px;
    text-decoration: none;
}
.download-btn:hover { background: #1da349; }
.recreate-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: transparent;
    color: var(--accent-soft);
    border: 1px solid var(--accent);
    font-weight: bold;
    font-size: 14px;
    padding: 8px 0;
    margin-top: 8px;
    border-radius: 6px;
    cursor: pointer;
}
.recreate-btn:hover { background: var(--accent); color: white; }

/* Action log actor badges */
.actor-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
}
.actor-admin { background: #3b2a63; color: #cdb8ff; }
.actor-va { background: #1c4a2c; color: #86e6a9; }

/* Partial-failure note inside a done card */
.fail-note { height: auto; padding: 8px; margin-top: 8px; color: var(--fail); border-color: #6b2525; }

/* ---- Todo page ---- */
.todo-add-form { max-width: 640px; margin-bottom: 20px; }
.todo-io-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
/* Shared pill-button + file-input look for every upload/download action on
   this page (Download/Upload JSON, upload/replace asset, approve, upload to
   Drive) -- one style so the whole page reads as one consistent set of
   actions instead of a different button per feature. */
.todo-io-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    box-sizing: border-box;
    background: none;
    border: 1px solid var(--accent-soft);
    border-radius: 6px;
    color: var(--accent-soft);
    font-size: 13px;
    padding: 0 14px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.todo-io-btn:hover { background: var(--surface); }
.todo-io-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: none;
}
/* A native <input type="file">'s "choose file" control is OS chrome that
   ordinary CSS on the input itself can't reach -- only the
   ::file-selector-button pseudo-element (Chrome/Firefox/Edge) and its older
   -webkit- alias can restyle it. This is what actually reskins the button in
   the screenshot; styling .todo-file-input alone only affects the trailing
   "no file chosen" text. */
.todo-file-input {
    height: 50px;
    box-sizing: border-box;
    font-size: 13px;
    color: var(--text-muted);
    max-width: 220px;
}
.todo-file-input::file-selector-button,
.todo-file-input::-webkit-file-upload-button {
    display: inline-flex;
    align-items: center;
    height: 32px;
    box-sizing: border-box;
    background: none;
    border: 1px solid var(--accent-soft);
    border-radius: 6px;
    color: var(--accent-soft);
    font-size: 13px;
    padding: 0 12px;
    margin-right: 10px;
    cursor: pointer;
}
.todo-file-input::file-selector-button:hover,
.todo-file-input::-webkit-file-upload-button:hover { background: var(--surface); }
.todo-import-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.todo-table .todo-comments {
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-muted);
}
.todo-link { max-width: 260px; word-break: break-all; }
.todo-added { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
tr.todo-done td { opacity: 0.5; }
tr.todo-done td.todo-comments,
tr.todo-done .todo-link,
tr.todo-done td:nth-child(2) { text-decoration: line-through; }
.todo-toggle-form, .todo-delete-form { margin: 0; display: inline; }
.todo-checkbox {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--accent-soft);
}
.todo-checkbox-readonly { font-size: 20px; color: var(--text-muted); }
.todo-delete-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--fail);
    font-size: 12px;
    padding: 4px 10px;
    margin: 0;
    cursor: pointer;
}
.todo-delete-btn:hover { border-color: var(--fail); background: #2a1518; }
/* Asset column -- reuses the same .result-item/.result-image/.result-video/
   .download-btn card look every other asset preview in the app uses (see
   _asset_grid.html / job_status.html), just contained in a bordered card
   (a table cell is much tighter than the open grid those normally sit in,
   so without a visible boundary the media/buttons/status just float loose
   against the row) and height-capped so a portrait video/image can't blow
   out the row's height. */
.todo-asset { min-width: 280px; vertical-align: top; }
.todo-asset-card {
    width: 260px;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.todo-asset-card .result-video,
.todo-asset-card .result-image {
    max-height: 260px;
    object-fit: contain;
}
.todo-asset-status {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
    font-size: 13px;
}
.todo-drive-uploaded { color: var(--ok); }
.todo-approved { color: var(--text-muted); }
.todo-uploading { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); }
.todo-upload-error {
    color: var(--fail);
    font-size: 12px;
    word-break: break-word;
    margin: 0 0 8px;
}
.todo-asset-status form { margin: 0; }
.todo-asset-status .todo-io-btn { width: 100%; }

/* The upload/replace form sits below the card (or stands alone with no
   asset yet) -- stacked full-width, not inline with the button, so a long
   filename/native "no file chosen" text never crowds or truncates against
   the button the way it does when squeezed onto one row (see conversation:
   this was the "clunky" file-input layout). */
.todo-asset-form {
    margin: 10px 0 0;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.todo-asset-form .todo-file-input {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}
.todo-asset-form .todo-io-btn { width: 100%; }

/* Job-status "Inputs" section (prompt/settings/reference files a job was
   actually run with -- seedance/kling3/nanobanana/fake_ai job pages) */
.job-inputs { margin-bottom: 30px; }
.inputs-table { max-width: 640px; margin-top: 0; }
.inputs-table th { width: 1%; white-space: nowrap; padding-right: 24px; text-transform: capitalize; }
.inputs-table td { word-break: break-word; }
.inputs-long-text {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
}
.inputs-refs { margin-top: 8px; }
.inputs-refs .result-item { width: 200px; }

/* ---- Two-column tool pages (/generate, /download-assets) ---- */
.generate-layout {
    display: grid;
    grid-template-columns: minmax(360px, 460px) 1fr;
    gap: 0;
    align-items: start;
    margin-top: 10px;
}
.generate-form-col {
    padding-right: 28px;
    border-right: 1px solid var(--border);   /* the divider */
    min-width: 0;   /* let content truncate instead of widening the column */
}
.generate-gallery-col { padding-left: 28px; min-width: 0; }
.col-title {
    margin: 0 0 18px;
    font-size: 18px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
}
.generate-form-col button[type="submit"] {
    width: 100%;
    background: var(--gradient-btn);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 0;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}
.generate-form-col button[type="submit"]:hover { filter: brightness(1.15); }
.generate-form-col button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: none;
}
.form-hint { color: var(--text-muted); font-size: 13px; margin-top: 10px; }
.picker-help { color: var(--text-muted); font-size: 13px; margin-top: -4px; }

.generate-layout fieldset.tool-fields {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin: 0 0 16px;
    background: var(--surface);
    /* Fieldsets default to min-inline-size: min-content -- without this, a
       long unbreakable filename WIDENS the whole fieldset past its column
       instead of letting the name truncate. */
    min-inline-size: 0;
    min-width: 0;
}
.generate-layout fieldset.tool-fields legend {
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent-soft);
    padding: 0 8px;
}

/* Gallery cards on the two-column pages: responsive grid of clean cards. */
.generate-gallery-col .results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
    margin-top: 0;
}
.generate-gallery-col .result-item {
    width: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.generate-gallery-col .source { margin-top: 8px; }

@media (max-width: 980px) {
    .generate-layout { grid-template-columns: 1fr; }
    .generate-form-col { border-right: none; padding-right: 0; }
    .generate-gallery-col { padding-left: 0; margin-top: 30px; }
}

/* "Reuse an uploaded file" preview browser */
.ref-toggle {
    display: block;
    width: 100%;
    margin-top: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 0;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
}
.ref-toggle:hover { background: #232336; border-color: var(--accent); color: var(--accent-soft); }
.ref-browser {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    max-height: 280px;
    overflow-y: auto;
    font-size: 13px;
    color: var(--text-muted);
}
.ref-tile {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    padding: 0;
    margin: 0;
    cursor: pointer;
    overflow: hidden;
    text-align: left;
}
.ref-tile:hover { border-color: var(--accent); }
.ref-tile.added { border-color: var(--ok); box-shadow: 0 0 0 2px #34d39955; }
.ref-tile img, .ref-tile video {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
    background: #000;
}
.ref-tile .ref-tile-icon {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: var(--surface-2);
}
.ref-tile .ref-tile-name {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ref-empty { grid-column: 1 / -1; }

/* ---- Prompt reference highlighting ---- */
/* The backdrop mirrors the textarea's text behind it -- its font/padding/
   border metrics MUST stay identical to the textarea rule above, or the
   highlights drift out of alignment with the typed text. */
.prompt-wrap { position: relative; }
.prompt-wrap textarea {
    position: relative;
    z-index: 1;
    background: transparent;
    display: block;
}
.prompt-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--surface);
    color: transparent;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    box-sizing: border-box;
}
.prompt-backdrop mark { color: transparent; border-radius: 3px; }
.prompt-backdrop .ref-mark-image { background: #1e3a6e; }
.prompt-backdrop .ref-mark-video { background: #43297a; }
.prompt-backdrop .ref-mark-audio { background: #6b4a15; }

/* ---- Inline results panel ---- */
#results-panel { margin-top: 20px; }
#results-panel .generation-pending {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-muted); font-size: 14px; margin-bottom: 16px;
}
#results-panel .generation-error {
    color: #ff9e9e; background: #2a1518; border: 1px solid #5c2a2a;
    border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; white-space: pre-wrap;
}
.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid #3a3a4c; border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login page ---- */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background:
        radial-gradient(1000px 600px at 15% 0%, #1c144088 0%, transparent 60%),
        radial-gradient(800px 500px at 90% 100%, #3a103055 0%, transparent 55%),
        var(--bg);
}
.login-card {
    width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.login-logo {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    text-align: center;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 8px 0 28px;
}
.login-error {
    background: #2a1518;
    border: 1px solid #5c2a2a;
    color: #ff9e9e;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.login-card input[type="password"] { padding: 11px 12px; font-size: 15px; }
.login-btn {
    width: 100%;
    margin-top: 14px;
    background: var(--gradient-btn);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 0;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}
.login-btn:hover { filter: brightness(1.15); }
