/* ------------------------------------------------------------------
   ABS Manager – clean, flat, no gradients
------------------------------------------------------------------ */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --border: #e3e6ea;
    --border-strong: #cfd4da;
    --text: #1a1d21;
    --text-muted: #6b7280;
    --text-subtle: #9aa1a9;
    --accent: #2f6feb;
    --accent-hover: #1f5ad8;
    --accent-soft: #e8f0fe;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #059669;
    --success-soft: #d1fae5;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 20, 30, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 20, 30, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1114;
        --surface: #1a1d22;
        --surface-alt: #22262c;
        --border: #2d323a;
        --border-strong: #3d434c;
        --text: #e6e8ec;
        --text-muted: #9aa1ab;
        --text-subtle: #6b7280;
        --accent: #4d8bff;
        --accent-hover: #6ba0ff;
        --accent-soft: #1e2a4a;
        --danger: #f87171;
        --danger-soft: #3a1c1c;
        --success: #34d399;
        --success-soft: #143028;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
}

* { box-sizing: border-box; }

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

#app { height: 100vh; display: flex; flex-direction: column; }

.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.spacer { flex: 1; }

/* --------------------------- Buttons --------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Deterministic height: <button> and <label class="btn"> otherwise render 1-3px apart
   because native <button> has different baseline handling than <label>. */
.btn {
    height: 34px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1;
}
.btn-block { height: auto; min-height: 34px; }

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

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-alt); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

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

.confirm-message {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.btn-block { display: flex; width: 100%; }

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.btn-close:hover { background: var(--surface-alt); color: var(--text); }

/* --------------------------- Inputs --------------------------- */
input[type="text"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="email"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: inherit; }

label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}
label input, label select, label textarea { margin-top: 4px; }

.select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236b7280' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    appearance: none;
}

/* --------------------------- Login / Setup View --------------------------- */
#view-login,
#view-setup {
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.login-card h1 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 600;
}
.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 13px;
}
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card small { color: var(--text-subtle); font-weight: 400; font-size: 11px; }
.login-card .btn-primary { margin-top: 8px; }

.help {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}
.help summary { cursor: pointer; user-select: none; }
.help code {
    background: var(--surface-alt);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 11px;
}

.error {
    padding: 10px 12px;
    background: var(--danger-soft);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

/* --------------------------- Top Bar --------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* --------------------------- Toolbar --------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .select { min-width: 140px; }
.count {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* --------------------------- List Table --------------------------- */
.list-wrap {
    flex: 1;
    overflow: auto;
    padding: 0;
    position: relative;
}
.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.items-table thead {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.items-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.items-table tbody tr:hover { background: var(--surface-alt); }
.items-table tbody tr.selected { background: var(--accent-soft); }
.items-table .col-check { width: 36px; }
.items-table .col-cover { width: 56px; padding: 4px 8px; cursor: pointer; }
.items-table .col-seq {
    width: 56px;
    text-align: right;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.items-table .cover-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--surface-alt);
    display: block;
    border: 1px solid var(--border);
    transition: opacity 0.12s, transform 0.12s;
}
.items-table .col-cover:hover .cover-thumb,
.items-table .col-cover:hover .cover-thumb-placeholder { opacity: 0.75; }
.items-table .cover-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 10px;
}

.items-table th.sortable {
    cursor: pointer;
    user-select: none;
}
.items-table th.sortable:hover { color: var(--text); }
.items-table th.sortable .sort-ind {
    display: inline-block;
    width: 10px;
    margin-left: 4px;
    color: var(--text-subtle);
    font-size: 10px;
}
.items-table th.sortable.sorted { color: var(--text); }
.items-table th.sortable.sorted .sort-ind { color: var(--accent); }
.items-table .title-cell { font-weight: 500; color: var(--text); }
.items-table .subtitle-cell { font-size: 11px; color: var(--text-muted); }

.empty, .loading {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* --------------------------- Status Bar --------------------------- */
.statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.status-left { flex: 1; display: flex; align-items: center; min-width: 0; }
.progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.progress-label {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
}
.progress-track {
    flex: 1;
    height: 4px;
    max-width: 320px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.15s ease;
}
.progress-num {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}
.progress.indeterminate .progress-fill {
    width: 30%;
    animation: indeterminate 1.2s ease-in-out infinite;
}
@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* --------------------------- Modal --------------------------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-panel-sm { max-width: 500px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
}
.modal-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
}

.modal-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    margin-right: auto;
}
.modal-progress .progress-track {
    flex: 1;
    max-width: none;
}
.modal-progress.indeterminate .progress-fill {
    width: 30%;
    animation: indeterminate 1.2s ease-in-out infinite;
}

/* --------------------------- Edit Form --------------------------- */
.edit-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
}
@media (max-width: 640px) {
    .edit-grid { grid-template-columns: 1fr; }
}

.cover-section { display: flex; flex-direction: column; gap: 10px; }
.cover-preview {
    aspect-ratio: 1 / 1;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}
.cover-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cover-preview img[hidden] { display: none; }
.cover-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 12px;
}
.cover-url-row { display: flex; gap: 6px; }
.cover-url-row input { flex: 1; }

.edit-form { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row span { color: var(--text); font-weight: 500; }

/* --------------------------- Bulk Form --------------------------- */
.bulk-row {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.bulk-row:last-child { border-bottom: none; }
.bulk-row > input[type="checkbox"] { margin-top: 24px; }
.bulk-row label { margin-bottom: 0; }

/* --------------------------- Crop Modal --------------------------- */
#modal-crop { z-index: 110; }
.crop-hint { margin: 0 0 12px; font-size: 12px; }
.crop-stage {
    position: relative;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 60vh;
    user-select: none;
    touch-action: none;
}
.crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    pointer-events: none;
    -webkit-user-drag: none;
}
.crop-frame {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    cursor: move;
    box-sizing: border-box;
}
.crop-guide {
    position: absolute;
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}
.crop-guide-v1, .crop-guide-v2 { top: 0; bottom: 0; width: 1px; }
.crop-guide-h1, .crop-guide-h2 { left: 0; right: 0; height: 1px; }
.crop-guide-v1 { left: 33.3333%; }
.crop-guide-v2 { left: 66.6666%; }
.crop-guide-h1 { top: 33.3333%; }
.crop-guide-h2 { top: 66.6666%; }

/* --------------------------- Cover Modal --------------------------- */
.cover-dropzone {
    aspect-ratio: 1 / 1;
    background: var(--surface-alt);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: border-color 0.15s, background 0.15s;
}
.cover-dropzone img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cover-dropzone img[hidden] { display: none; }
.cover-large-placeholder {
    color: var(--text-subtle);
    font-size: 14px;
    position: absolute;
}
.cover-drop-hint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(47, 111, 235, 0.12);
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    pointer-events: none;
}
.cover-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.cover-dropzone.drag-over .cover-drop-hint { display: flex; }
.cover-modal-btn { margin-top: 8px; }
.cover-modal-row { margin-top: 8px; }

/* --------------------------- Import Preview --------------------------- */
.import-stats {
    display: flex;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.stat { display: inline-flex; align-items: center; gap: 6px; }
.stat strong { color: var(--text); font-weight: 600; }
.stat-change strong { color: var(--accent); }
.stat-missing strong { color: var(--danger); }

.import-diff-list {
    max-height: 55vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diff-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--surface-alt);
}
.diff-item.missing {
    border-color: var(--danger);
    background: var(--danger-soft);
}
.diff-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text);
}
.diff-warn {
    font-size: 12px;
    color: var(--danger);
}
.diff-warn code {
    background: var(--surface);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 11px;
}
.diff-row {
    display: grid;
    grid-template-columns: 130px 1fr 16px 1fr;
    gap: 8px;
    padding: 3px 0;
    font-size: 12px;
    align-items: baseline;
}
.diff-field {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 11px;
}
.diff-old {
    color: var(--text-subtle);
    text-decoration: line-through;
    text-decoration-color: var(--text-subtle);
    word-break: break-word;
}
.diff-arrow {
    color: var(--text-subtle);
    text-align: center;
}
.diff-new {
    color: var(--success);
    font-weight: 500;
    word-break: break-word;
}
.diff-empty {
    color: var(--text-subtle);
    font-style: italic;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 4px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.section-title:not(:first-child) { margin-top: 24px; }

/* --------------------------- File info in edit modal --------------------------- */
.file-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.file-info summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.file-info[open] summary { margin-bottom: 8px; }
.file-info-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.file-info-row {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 8px;
    align-items: baseline;
}
.file-info-label {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--mono);
}
.file-info-value {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text);
    word-break: break-all;
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 3px;
}
.file-info-files {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.file-info-files li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    padding: 3px 6px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 11px;
}
.file-info-files .file-name { color: var(--text); word-break: break-all; }
.file-info-files .file-meta { color: var(--text-muted); white-space: nowrap; }
.file-info-files .supp { color: var(--text-subtle); font-style: italic; }

.chapter-list {
    margin: 8px 0 0;
    padding: 0 0 0 24px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 240px;
    overflow: auto;
    font-size: 11px;
}
.chapter-list li {
    padding: 3px 6px;
    background: var(--surface);
    border-radius: 3px;
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px;
    align-items: baseline;
}
.chapter-list .ch-time {
    font-family: var(--mono);
    color: var(--text-muted);
}
.chapter-list .ch-title {
    color: var(--text);
    word-break: break-word;
}

/* --------------------------- Path column in items table --------------------------- */
.items-table th.col-path,
.items-table td.col-path {
    /* default width; adjustable via drag */
    width: 200px;
    max-width: 200px;
}
.col-path .path-cell {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Column resizer handle on <th> */
.items-table th {
    position: relative;
}
.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
}
.col-resizer:hover,
.col-resizer.dragging {
    background: var(--accent-soft);
}

.ai-key-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
/* --------------------------- Audit Log --------------------------- */
.audit-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 65vh;
    overflow: auto;
}
.audit-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--surface-alt);
}
.audit-entry.failed {
    border-color: var(--danger);
    background: var(--danger-soft);
}
.audit-entry.reverted {
    opacity: 0.7;
}
.audit-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.audit-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}
.audit-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
    flex-wrap: wrap;
}
.audit-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.audit-badge.action-patch_item { color: var(--accent); border-color: var(--accent); }
.audit-badge.action-set_cover { color: var(--success); border-color: var(--success); }
.audit-badge.action-chapters_replace { color: #a855f7; border-color: #a855f7; }
.audit-badge.reverted-badge { color: var(--text-subtle); }
.audit-badge.failed-badge { color: var(--danger); border-color: var(--danger); }
.audit-diff {
    display: grid;
    grid-template-columns: 130px 1fr 16px 1fr;
    gap: 6px 8px;
    padding: 4px 0;
    font-size: 12px;
    align-items: baseline;
}
.audit-diff .field {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 11px;
}
.audit-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}
.audit-actions .btn { padding: 0 10px; font-size: 12px; height: 26px; }
.audit-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.ai-key-row input {
    flex: 1;
    font-family: var(--mono);
    font-size: 12px;
    padding: 6px 10px;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.desc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.btn-clean-desc { padding: 0 10px; font-size: 12px; height: 26px; }

/* --------------------------- RSS Sync --------------------------- */
.rss-summary {
    display: flex;
    gap: 18px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.rss-diff-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rss-category {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    overflow: hidden;
}
.rss-cat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.rss-cat-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.rss-cat-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}
.rss-cat-actions {
    display: flex;
    gap: 6px;
}
.rss-cat-actions .btn { padding: 0 10px; font-size: 12px; height: 28px; }

.rss-cat-body {
    display: flex;
    flex-direction: column;
    max-height: 40vh;
    overflow: auto;
}
.rss-cat-body.collapsed { display: none; }

.rss-suggestion {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    align-items: start;
}
.rss-suggestion:first-child { border-top: none; }
.rss-suggestion input[type="checkbox"] { margin-top: 3px; }

.rss-sugg-book {
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.rss-sugg-book .rss-ep-title {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}
.rss-sugg-diff {
    display: grid;
    grid-template-columns: 1fr 16px 1fr;
    gap: 8px;
    font-size: 12px;
    align-items: start;
}
.rss-sugg-diff .diff-old,
.rss-sugg-diff .diff-new {
    white-space: pre-wrap;
    max-height: 6.4em;
    overflow: auto;
}
/* Cover comparison: force flex row with centered fixed-size thumbs.
   (Grid stretches images to fill the 1fr column, which distorts aspect ratio.) */
.rss-sugg-diff-cover {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    grid-template-columns: none;
}
.rss-sugg-diff-cover .diff-arrow {
    width: 16px;
    text-align: center;
}
.rss-sugg-cover-old,
.rss-sugg-cover-new {
    display: block;
    width: 80px;
    height: 80px;
    flex: 0 0 80px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
}
.rss-cover-placeholder {
    width: 80px;
    height: 80px;
    flex: 0 0 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 10px;
    border: 1px dashed var(--border);
    border-radius: 4px;
    background: var(--surface);
}

.rss-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.rss-unmatched-list {
    margin: 0;
    padding: 10px 14px 12px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    max-height: 30vh;
    overflow: auto;
    list-style: none;
}
.rss-unmatched-list li { list-style: none; }
.rss-unmatched-list.collapsed { display: none; }

/* --------------------------- Toast --------------------------- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}
.toast {
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    max-width: 360px;
    animation: slideIn 0.2s ease-out;
    pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --------------------------- Scrollbar --------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------- Veröffentlichungen ---------- */
.audit-badge.rel-planned { color: var(--accent); border-color: var(--accent); }
.audit-badge.rel-done { color: var(--success); border-color: var(--success); }
.audit-badge.action-release_hide { color: var(--text-muted); }
.audit-badge.action-release_publish { color: var(--success); border-color: var(--success); }
.rel-items { font-size: 12px; margin-top: 6px; }
.rel-items ul { margin: 6px 0 0; padding-left: 18px; }
.rel-resched { height: 26px; font-size: 12px; }
.rel-users { display: flex; flex-direction: column; gap: 6px; }
.rel-user { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.rel-user.disabled { opacity: .6; cursor: default; }
.rel-user-name { font-weight: 600; min-width: 90px; }
.rel-user-note { font-size: 12px; }
.rel-lock { font-size: 11px; }
