.chatterbox-voice-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.chatterbox-voice-form .form-actions {
    display: flex;
    align-items: flex-end;
}

/* Voice List Controls */
.voice-list-controls {
    margin: 20px 0 15px;
    padding: 15px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.voice-filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.voice-search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
}

.voice-filter-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    min-width: 120px;
}

.voice-list-stats {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.voice-batch-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin: 12px 0;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.voice-batch-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.voice-batch-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.voice-list-table .select-col {
    width: 40px;
    text-align: center;
}

.voice-list-table .select-col input[type="checkbox"] {
    transform: scale(1.05);
    cursor: pointer;
}

.job-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.job-detail-grid > div {
    background: rgba(15, 18, 32, 0.55);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.job-detail-grid strong {
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.job-detail-speakers {
    grid-column: 1 / -1;
}

.job-detail-timing {
    background: rgba(15, 18, 32, 0.55);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.job-detail-timing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.timing-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 7px;
    background: rgba(255,255,255,0.03);
}

.timing-row.timing-highlight {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.timing-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.timing-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.chunk-chart {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(99, 102, 241, 0.15);
}

.chunk-chart-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.chunk-chart-estimated {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

.job-detail-text label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.job-detail-text textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: rgba(15, 18, 32, 0.6);
    color: var(--text-color);
}

.voice-archive-section {
    margin-top: 18px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
}

/* Voice List Table */
.voice-list-table-container {
    overflow-x: auto;
    margin-top: 10px;
}

.voice-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.voice-list-table th,
.voice-list-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.voice-list-table th {
    background: rgba(15, 23, 42, 0.7);
    font-weight: 600;
    color: var(--text-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.voice-list-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.voice-list-table th.sortable:hover {
    background: rgba(99, 102, 241, 0.2);
}

.voice-list-table th.sort-asc .sort-icon::after {
    content: ' ▲';
}

.voice-list-table th.sort-desc .sort-icon::after {
    content: ' ▼';
}

.voice-list-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.voice-list-table .voice-name-cell {
    font-weight: 500;
}

.voice-list-table .voice-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.voice-list-table .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.voice-list-table .badge-male {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.voice-list-table .badge-female {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
}

.voice-list-table .badge-local {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.voice-list-table .badge-external {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.voice-list-table .badge-downloaded {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.voice-list-table .btn-download {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.voice-list-table .btn-download:hover {
    background: var(--primary-color);
    color: white;
}

/* Legacy card styles - keep for backwards compatibility */
.chatterbox-voice-list-legacy {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.chatterbox-voice-card {
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 12px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatterbox-voice-card.missing {
    border-color: rgba(239, 68, 68, 0.7);
    background: rgba(239, 68, 68, 0.08);
}

.chatterbox-voice-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    font-weight: 600;
    color: var(--text-color);
}

.chatterbox-voice-timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chatterbox-voice-meta {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
}

.chatterbox-voice-meta code {
    background: rgba(15, 23, 42, 0.85);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text-color);
    display: block;
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.chatterbox-voice-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.queue-table td {
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 10px;
    text-align: left;
}

.queue-table .review-col {
    width: 240px;
}

.review-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.review-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.review-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
}

.review-chip.muted {
    background: rgba(148, 163, 184, 0.4);
    color: #0f172a;
}

.review-chip.accent {
    background: rgba(99, 102, 241, 0.85);
}

.review-chip.warning {
    background: rgba(245, 158, 11, 0.85);
}

.review-chip.danger {
    background: rgba(239, 68, 68, 0.85);
}

.review-panel-row td {
    background: rgba(15, 23, 42, 0.6);
    padding: 0;
    border: none;
}

.review-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.review-panel.open {
    max-height: 1200px;
}

.review-panel-loading,
.review-panel-error,
.review-panel-empty,
.review-panel-collapsed {
    padding: 20px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.review-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
    gap: 12px;
}

.review-panel-body {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 8px;
}

.review-panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chunk-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px 20px;
}

.chunk-row {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    background: rgba(30, 41, 59, 0.7);
}

.chunk-row-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chunk-row-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chunk-row-audio {
    display: flex;
    align-items: flex-start;
}

.chunk-row-editor {
    grid-column: 1 / -1;
}

.chunk-row-editor textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: rgba(15, 23, 42, 0.8);
}

.chunk-row-controls {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chunk-tag {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-color);
}

.chunk-tag.subtle {
    background: rgba(148, 163, 184, 0.15);
}

.chunk-tag.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.chunk-tag.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.chunk-tag.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.review-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.6);
    padding: 14px 18px;
    border-radius: 12px;
    color: var(--text-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
}

.review-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.btn-ghost {
    border: 1px solid rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.12);
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.btn-ghost:hover {
    border-color: rgba(99, 102, 241, 0.85);
    background: rgba(99, 102, 241, 0.25);
    color: #fff;
}

.badge-danger {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    background: rgba(239, 68, 68, 0.9);
    margin-left: 8px;
}
/* Kokoro-Story Styles */

:root {
    --primary-color: #818cf8;
    --secondary-color: #a78bfa;
    --success-color: #34d399;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --bg-color: #080c14;
    --card-bg: #111827;
    --text-color: #f1f5f9;
    --text-muted: #9ca3af;
    --border-color: #374151;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.status-bar {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 0.9rem;
}

.status-bar span {
    color: var(--text-muted);
}

.status-bar strong {
    color: var(--text-color);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    color: var(--text-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Sections */
.section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.section h2 {
    margin-bottom: 15px;
    color: var(--text-color);
}

.help-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.help-text code {
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
}

/* Form Elements */
textarea {
    width: 100%;
    padding: 15px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    margin-bottom: 15px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1rem;
}

input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.chapter-sub-option {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed rgba(99, 102, 241, 0.4);
}

.chapter-sub-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 500;
}

.review-mode-card {
    margin-top: 20px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.review-mode-card ul {
    margin: 8px 0 0 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: grid;
    gap: 4px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-group small a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.generation-toolbar {
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.generation-output-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.generation-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.gemini-preset-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 260px;
}

.gemini-preset-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.gemini-preset-row select {
    min-width: 220px;
    flex: 1;
}

.select-compact {
    width: auto;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.95rem;
}

.select-compact:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.compact-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}

.compact-field label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.bitrate-field.disabled {
    opacity: 0.5;
}

.bitrate-field.disabled select {
    pointer-events: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.btn-xs {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.gemini-progress {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 8px;
}

.gemini-progress .progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(99, 102, 241, 0.22);
    color: #eef2ff;
    border: 1px solid rgba(99, 102, 241, 0.6);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.35);
    border-color: rgba(99, 102, 241, 0.8);
}

.chunk-review-sequence {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    margin: 10px 0 18px;
}

.chunk-review-play-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 0.95rem;
}

.chunk-review-play-icon.playing {
    background: rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.6);
}

.chunk-review-play-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.library-chunk-card.is-playing-sequence .library-chunk-summary {
    background: rgba(99, 102, 241, 0.12);
    border-left-color: var(--primary-color);
}

.library-chunk-card.is-playing-sequence-stopped .library-chunk-summary {
    background: rgba(34, 197, 94, 0.14);
    border-left-color: rgba(34, 197, 94, 0.7);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.stat-card {
    background: rgba(15, 23, 42, 0.7);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    text-align: center;
    box-shadow: none;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg-color);
    border-radius: 15px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

#progress-text {
    text-align: center;
    color: var(--text-muted);
}

/* Audio Player */
#result-section {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
}

audio {
    width: 100%;
    margin: 20px 0;
    background: #000;
}

/* Voice Library */
#voice-library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.default-voice-card {
    margin-top: 15px;
    padding: 20px;
    border-radius: 12px;
    background: rgba(11, 17, 32, 0.8);
    border: 2px solid rgba(99, 102, 241, 0.45);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35);
}

.default-voice-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #f8fafc;
}

.default-voice-header p {
    margin: 4px 0 12px;
    color: rgba(226, 232, 240, 0.9);
    font-size: 0.9rem;
}

.default-voice-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-start;
}

/* Kokoro Card Styling */
.kokoro-card {
    padding: 16px 20px;
}

.kokoro-header {
    margin-bottom: 16px;
}

.kokoro-header h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
}

.kokoro-header p {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.7);
}

.kokoro-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.kokoro-main-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.kokoro-voice-dropdown {
    min-width: 200px;
    flex: 0 0 auto;
}

/* Sliders panel - inline and compact */
.kokoro-sliders {
    flex: 1;
    min-width: 280px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.kokoro-sliders .fx-inline-layout {
    gap: 4px;
}

.kokoro-sliders .fx-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.kokoro-sliders .fx-field.fx-slider {
    flex: 1 1 130px;
}

/* Test area - textarea with button inline */
.kokoro-test-area {
    width: 100%;
}

.kokoro-test-area .fx-field.fx-preview {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.kokoro-test-area textarea {
    flex: 1;
    min-height: 44px;
    max-height: 100px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-color);
    font-size: 0.9rem;
    resize: vertical;
}

.kokoro-test-area .fx-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.kokoro-test-area .fx-preview-actions .btn {
    min-width: 90px;
}

/* Available Voices Accordion */
.voices-accordion {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.voices-section {
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.4);
    overflow: hidden;
}

.voices-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    background: rgba(99, 102, 241, 0.08);
    transition: background 0.2s ease;
}

.voices-section-header:hover {
    background: rgba(99, 102, 241, 0.16);
}

.voices-section-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.voices-section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.voices-section-toggle {
    font-size: 0.95rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.voices-section.collapsed .voices-section-toggle {
    transform: rotate(-90deg);
}

.voices-section-content {
    padding: 18px 20px 22px;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
}

.voices-section.collapsed .voices-section-content {
    display: none;
}

.qwen-voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 12px;
}

.qwen-voice-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.qwen-voice-actions .help-text {
    margin: 0;
}

.qwen-voice-preview {
    margin-top: 10px;
}

/* Responsive: stack on mobile */
@media (max-width: 640px) {
    .kokoro-main-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .kokoro-voice-dropdown {
        width: 100%;
        min-width: unset;
    }
    
    .kokoro-sliders {
        width: 100%;
        min-width: unset;
    }
    
    .kokoro-sliders .fx-fields {
        flex-direction: column;
        align-items: stretch;
    }
    
    .kokoro-sliders .fx-field.fx-slider {
        width: 100%;
    }
    
    .kokoro-test-area .fx-field.fx-preview {
        flex-direction: column;
    }
    
    .kokoro-test-area .fx-preview-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .kokoro-test-area .fx-preview-actions .btn {
        flex: 1;
    }
}

.fx-preview-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.fx-preview-row textarea {
    flex: 1;
    min-height: 44px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-color);
    font-size: 0.9rem;
    resize: vertical;
}

.fx-preview-row .btn {
    white-space: nowrap;
    padding: 10px 18px;
}

.fx-tone-actions {
    flex-wrap: nowrap;
}

.fx-tone-actions .tone-pill-group {
    flex: 0 0 auto;
}

.fx-tone-actions .btn {
    margin-left: auto;
}

.default-voice-select {
    flex: 0 0 240px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.default-voice-select label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.default-voice-select select {
    width: 100%;
    min-width: 0;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.9);
    font-size: 0.95rem;
    color: var(--text-color);
}

#inline-voice-assignment-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    width: 100%;
}

@media (max-width: 1400px) {
    #inline-voice-assignment-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1050px) {
    #inline-voice-assignment-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    #inline-voice-assignment-list {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

.voice-assignment-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(99, 102, 241, 0.18);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
    min-height: 220px;
}

.assignment-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.speaker-rename {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.speaker-rename-input {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-color);
    font-size: 0.85rem;
}

.speaker-rename-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.speaker-rename-btn {
    white-space: nowrap;
}

.assignment-header .speaker-label {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.assignment-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.compact-assignment .assignment-selection-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

/* Hide empty voice-fx panels completely */
.voice-inline-card:empty,
.voice-fx-inline:empty,
[data-role="kokoro-panel"]:empty {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.assignment-select {
    width: 100%;
    min-width: 0;
}

.assignment-select label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.assignment-select select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-color);
    font-size: 0.95rem;
}

.gemini-preset-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.gemini-preset-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.gemini-preset-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.gemini-preset-title {
    font-weight: 600;
    color: var(--text-color);
}

.gemini-preset-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.gemini-preset-form {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gemini-preset-form .compact-field input,
.gemini-preset-form .compact-field textarea {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-color);
    resize: vertical;
}

.gemini-preset-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.gemini-preset-empty {
    border: 1px dashed rgba(148, 163, 184, 0.4);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#gemini-preset-form-hint[data-tone="warning"] {
    color: var(--warning-color);
}

#gemini-preset-form-hint[data-tone="success"] {
    color: var(--success-color);
}

#gemini-preset-form-hint[data-tone="info"] {
    color: var(--primary-color);
}

.assignment-select.voice-select-inline select {
    min-width: unset;
}

.assignment-selection-group [data-role="kokoro-control"] {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assignment-selection-group [data-role="turbo-control"] {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.voice-sample-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-sample-row select {
    flex: 1;
    min-width: 0;
}

.voice-sample-preview-btn {
    white-space: nowrap;
    min-width: 72px;
}

.qwen3-inline-options {
    width: 100%;
    margin-top: 8px;
}

.qwen3-options-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.qwen3-lang-select {
    width: 100%;
}

.qwen3-instruct-field {
    width: 100%;
}

.qwen3-inline-options input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.qwen3-inline-options select {
    width: 100%;
    box-sizing: border-box;
}

.qwen3-inline-options input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.assignment-selection-group {
    align-items: flex-end;
}

.assignment-turbo .inline-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assignment-turbo label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.assignment-turbo select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-color);
    font-size: 0.95rem;
}

.voice-fx-panel,
.voice-fx-inline {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-color);
}

.voice-inline-card {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Hide kokoro panel completely when not displayed */
.voice-inline-card[style*="display: none"],
.voice-fx-inline[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.voice-fx-inline {
    flex: 1 1 auto;
}

.voice-fx-panel {
    flex: 1;
}

.voice-fx-panel.fx-disabled .fx-fields,
.voice-fx-inline.fx-disabled .fx-fields {
    opacity: 0.55;
}

.voice-inline-card .fx-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
}

.voice-inline-card .fx-field {
    margin-bottom: 0;
    flex: 1 1 180px;
    min-width: 160px;
}

.voice-select-inline {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
    width: 100%;
}

.voice-select-inline label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.voice-select-inline .voice-select {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-color);
    font-size: 0.92rem;
    height: auto;
    min-height: unset;
    max-height: 42px;
}

.voice-inline-card .fx-field.fx-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.voice-inline-card .fx-field.fx-inline label {
    text-align: left;
    width: 100%;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.voice-inline-card .fx-field.fx-inline .slider-group {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-inline-card .fx-field.fx-inline input[type="range"] {
    flex: 1;
    min-width: 120px;
}

.fx-panel-layout,
.fx-inline-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.fx-inline-layout .fx-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.fx-inline-layout .fx-field.fx-preview,
.fx-inline-layout .fx-field.fx-actions {
    flex: 1 1 100%;
}

.fx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.fx-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.fx-field.fx-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.fx-field.fx-inline label {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.fx-field.fx-slider .slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.fx-field.fx-slider input[type="range"] {
    flex: 1;
    min-width: 120px;
}

.fx-field.fx-preview {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.fx-field.fx-preview textarea {
    flex: 1 1 220px;
    min-width: 160px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    padding: 6px 8px;
    color: var(--text-color);
    font-size: 0.85rem;
    resize: vertical;
}

.fx-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.fx-preview-actions .btn {
    flex: 0 0 auto;
}

.fx-field.fx-inline.fx-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.fx-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.fx-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.fx-field.fx-inline {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.fx-field.fx-inline label {
    margin: 0;
    min-width: 54px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.fx-field.fx-inline .slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fx-field.fx-inline input[type="range"] {
    width: 140px;
}

.fx-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.fx-toggle input {
    transform: scale(1.05);
}

.voice-category {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.voice-category h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.voice-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.voice-item {
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.voice-item:hover {
    transform: translateX(4px);
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.35);
}

.voice-item.has-preview .voice-status {
    color: #10b981;
}

.voice-item .voice-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-item .voice-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
}

.voice-item .voice-code {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.voice-item .voice-status {
    font-size: 0.85rem;
    font-weight: 600;
}

.voice-item .voice-status.muted {
    color: var(--text-muted);
    font-weight: 500;
}

.voice-item.playing {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    transform: translateX(6px);
}

/* Custom voice manager */
#custom-voices-section {
    margin-top: 25px;
}

.custom-voices-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.custom-voices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 15px;
}

.custom-voice-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-voice-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.voice-badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-muted {
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.custom-voice-components {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.custom-voice-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.custom-voice-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--danger-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.section-title-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.help-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.15);
    color: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-icon:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.85);
    color: #fff;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: min(720px, 94vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
}

.modal.hidden {
    display: none;
}

.modal-header,
.modal-footer {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    justify-content: flex-end;
    gap: 10px;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: 70vh;
    position: relative;
}

.help-topics-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 16px;
}

.help-topics-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-topics-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(24, 31, 48, 0.75);
    color: var(--text-color);
    cursor: pointer;
    text-align: left;
}

.help-topics-section-header:hover {
    background: rgba(32, 41, 60, 0.85);
}

.help-topics-section-title {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-text);
}

.help-topics-section-toggle {
    font-size: 0.9rem;
    color: var(--muted-text);
}

.help-topics-section-content {
    padding: 0 4px;
}

.help-topics-section.collapsed .help-topics-section-content {
    display: none;
}

.help-topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.help-topic-card {
    text-align: left;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(66, 99, 235, 0.2);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-topic-card:hover {
    border-color: rgba(129, 140, 248, 0.8);
    background: rgba(99, 102, 241, 0.12);
}

.help-topic-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.help-topic-description {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.help-search-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.help-search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(24, 31, 48, 0.75);
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
}

.help-search-result:hover {
    border-color: rgba(129, 140, 248, 0.8);
    background: rgba(99, 102, 241, 0.12);
}

.help-search-result-title {
    font-weight: 600;
}

.help-search-result-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.help-search-empty {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    text-align: center;
}

.speaker-assignment-host {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.speaker-assignment-host .voice-assignment-row {
    width: 100%;
}

.speaker-profile-summary {
    margin: 12px 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.2);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.speaker-profile-summary.hidden {
    display: none;
}

.speaker-profile-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
}

.speaker-profile-fields {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.speaker-profile-fields label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.speaker-profile-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-color);
    font-size: 0.9rem;
}

.speaker-profile-input[data-role="speaker-profile-description"] {
    min-height: 96px;
    resize: vertical;
}

.speaker-profile-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.speaker-profile-actions {
    display: flex;
    align-items: flex-start;
    padding-top: 28px;
}

.speaker-profile-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.speaker-profile-row strong {
    color: var(--text-color);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Edit Voice Modal - positioned fixed and centered */
#edit-voice-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: min(480px, 90vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#edit-voice-modal.hidden {
    display: none;
}

#edit-voice-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

#edit-voice-modal-overlay.hidden {
    display: none;
}

/* Chunk Review Modal */
.chunk-review-header {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.chunk-review-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.95rem;
}

.chunk-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.chunk-review-full-story {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#help-modal-overlay {
    z-index: 1400;
}

#help-modal {
    z-index: 1401;
}

/* Chapter Sections */
.chapter-section {
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

/* Book Sections */
.book-section {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.25);
}

.book-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.book-header:hover {
    background: rgba(16, 185, 129, 0.2);
}

.book-toggle {
    font-size: 0.85rem;
    color: #10b981;
    width: 16px;
    text-align: center;
}

.book-title {
    font-weight: 600;
    flex: 1;
}

.book-chapter-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

.book-chapters {
    padding: 0;
    overflow: hidden;
}

.book-chapters.collapsed {
    max-height: 0;
    padding: 0;
}

.book-chapters:not(.collapsed) {
    padding: 0;
    max-height: none;
    overflow: visible;
}

.chapter-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    position: sticky;
    top: 8px;
    z-index: 2;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chapter-header:hover {
    background: rgba(99, 102, 241, 0.2);
}

.chapter-toggle {
    font-size: 0.85rem;
    color: var(--primary-color);
    width: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.chapter-title {
    font-weight: 600;
    flex: 1;
}

.chapter-chunk-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

.chapter-chunks {
    padding: 0;
    overflow: hidden;
}

.chapter-chunks.collapsed {
    max-height: 0;
    padding: 0;
}

.chapter-chunks:not(.collapsed) {
    padding: 8px;
    max-height: none;
    overflow: visible;
}

/* Bulk Speaker Section */
.bulk-speaker-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

.bulk-speaker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
}

.bulk-speaker-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.bulk-speaker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.bulk-speaker-row:last-child {
    border-bottom: none;
}

.bulk-speaker-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.bulk-speaker-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.bulk-speaker-name {
    font-weight: 600;
    color: var(--primary-color);
}

.bulk-speaker-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.bulk-speaker-voice {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: 8px;
    padding: 2px 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.bulk-speaker-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.bulk-speaker-voice-select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    min-width: 180px;
}

.bulk-speaker-regen {
    white-space: nowrap;
}

.chunk-review-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-chunk-row {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    align-items: start;
}

.library-chunk-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.library-chunk-play.playing {
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.library-chunk-speaker {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(var(--primary-rgb, 99, 102, 241), 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.library-chunk-voice-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
    width: 100%;
}

.library-chunk-text {
    flex: 1;
}

.library-chunk-textarea {
    width: 100%;
    resize: vertical;
    font-size: 0.9rem;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
}

.library-chunk-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.library-chunk-voice-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.85rem;
}

.chunk-review-loading,
.chunk-review-error,
.chunk-review-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.chunk-review-error {
    color: var(--danger-color);
}

/* Section Review Modal */
.section-review-loading,
.section-review-empty,
.section-review-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.section-review-error {
    color: var(--danger-color);
}

.section-review-summary {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-color);
    font-size: 0.9rem;
}

.section-review-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-review-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
}

.section-review-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.section-review-preview {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.section-review-book {
    border: 1px solid rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
}

.section-review-book-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 8px;
}

.section-review-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .library-chunk-row {
        grid-template-columns: 1fr;
    }
    
    .library-chunk-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .library-chunk-voice-select {
        flex: 1;
        min-width: 120px;
    }
}

.component-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.component-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    background: var(--bg-color);
}

.component-row select,
.component-row input {
    flex: 1;
}

.component-row .remove-component {
    border: none;
    background: transparent;
    color: var(--danger-color);
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
}

/* Voice Assignments */
.voice-assignment {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.voice-assignment h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.voice-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.voice-selector select {
    flex: 1;
    min-width: 200px;
}

/* Speakers List */
#speakers-list {
    margin-top: 15px;
}

.speaker-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.speakers-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.speakers-actions {
    margin-top: 4px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.batch-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.batch-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.batch-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.9), rgba(99, 102, 241, 0.95));
    transition: width 0.3s ease;
}

.batch-progress-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.batch-complete {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(34, 197, 94, 0.35);
    background: rgba(16, 185, 129, 0.15);
    color: var(--text-color);
    text-align: center;
}

.batch-complete.hidden {
    display: none;
}

.speaker-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 999px;
    font-size: 0.85rem;
    line-height: 1.2;
    letter-spacing: 0.01em;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.speaker-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

.speaker-tag.ready {
    background: rgba(34, 197, 94, 0.85);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.9);
}

.speaker-modal-hint {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.speaker-ready-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.speaker-ready-toggle input {
    accent-color: #22c55e;
}

.speakers-header {
    margin: 0 0 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.speakers-edit-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.speakers-edit-list {
    display: grid;
    gap: 10px;
}

.speaker-edit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.speaker-edit-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    min-width: 92px;
}

.speaker-edit-input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

.speaker-edit-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.speakers-duplicates {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duplicate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
}

.duplicate-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.5);
    white-space: nowrap;
}

.emotion-detection-info {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
}

/* Inline Voice Assignment */
.voice-assignment-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.voice-assignment-row label {
    font-weight: 600;
    min-width: 120px;
    color: var(--primary-color);
}

.voice-assignment-row select {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
}

/* Library Items */
#library-items {
    display: grid;
    gap: 20px;
}

.library-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.library-item-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-wrap: nowrap;
    min-width: 0;
}

.library-item-toggle {
    border: none;
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-color);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.library-item-toggle:focus {
    outline: 2px solid rgba(99, 102, 241, 0.6);
    outline-offset: 2px;
}

.library-item-play {
    white-space: nowrap;
}

.library-item-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.library-item-control-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border-radius: 8px;
}

.library-item-details {
    margin-top: 16px;
}

.library-item-details.collapsed {
    display: none;
}

.library-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.library-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.library-item-summary.library-item-header {
    justify-content: flex-start;
    margin-bottom: 0;
}

.library-item-info strong {
    color: var(--text-color);
    font-size: 1.1rem;
}

.library-item-date {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

.library-item-meta {
    display: flex;
    gap: 6px;
    color: var(--text-muted);
    align-items: center;
    flex-wrap: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

.library-item-meta-action {
    padding: 4px 10px;
    font-size: 0.75rem;
    height: auto;
    line-height: 1.2;
}

.library-action-spinner {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    margin-left: 6px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: button-spinner 0.8s linear infinite;
    vertical-align: middle;
}

.chapter-controls {
    margin: 15px 0;
    padding: 15px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    position: relative;
}

.chapter-controls-header {
    margin-bottom: 10px;
    color: var(--text-color);
}

.chapter-pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chapter-pill {
    font-size: 0.85rem;
    padding: 6px 12px;
}

.chapter-pill.active {
    background: var(--primary-color);
    color: #fff;
    border-color: transparent;
}

.chapter-action-menu {
    position: absolute;
    z-index: 5;
    min-width: 180px;
    padding: 8px;
    background: rgba(15, 17, 32, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(10, 12, 24, 0.35);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chapter-action-menu.hidden {
    display: none;
}

.chapter-action-menu-item {
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    background: rgba(99, 102, 241, 0.18);
    color: var(--text-color);
    font-size: 0.85rem;
    cursor: pointer;
}

.chapter-action-menu-item:hover {
    background: rgba(99, 102, 241, 0.35);
}

.library-item-size,
.library-item-format,
.library-item-engine {
    background: var(--bg-color);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.library-item-format {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.library-item-engine {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-weight: 500;
}

.library-item-player {
    margin: 15px 0;
}

.library-item-player audio {
    width: 100%;
    margin: 0;
}

.library-item-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: nowrap;
    align-items: center;
}

@media (max-width: 1100px) {
    .library-item-actions {
        flex-wrap: wrap;
    }
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .voice-inline-card .fx-fields {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .voice-inline-card .fx-field.fx-tone {
        flex-wrap: wrap;
    }
    
    .voice-inline-card .fx-field.fx-tone .btn {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .default-voice-controls {
        flex-direction: column;
    }
    
    .default-voice-select,
    .voice-fx-inline {
        width: 100%;
    }
    
    .voice-inline-card .fx-fields {
        flex-direction: column;
        align-items: stretch;
    }
    
    .voice-select-inline .voice-select {
        width: 100%;
    }
    
    .fx-tone-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fx-tone-actions .btn {
        width: 100%;
        margin-left: 0;
    }
    
    .fx-preview-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .fx-preview-row .btn {
        width: 100%;
    }
    
    .fx-field.fx-preview {
        flex-direction: column;
        align-items: stretch;
    }
    
    .fx-field.fx-preview .btn {
        width: 100%;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Queue Table */
.queue-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

.queue-table th,
.queue-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.queue-table th {
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
    color: var(--primary-color);
}

.queue-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.queue-table tr.current-job {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--success-color);
}

.text-preview {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9em;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.status-queued {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.status-processing {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
}

.status-pausing {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
}

.status-paused {
    background: rgba(148, 163, 184, 0.25);
    color: var(--text-muted);
}

.status-completed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.status-interrupted {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.status-cancelled {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.queue-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.queue-progress-header,
.queue-progress-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}

.queue-progress-footer {
    font-size: 0.8rem;
}

.queue-progress .progress-bar {
    height: 8px;
    background: rgba(148, 163, 184, 0.15);
}

.queue-progress .progress-bar-fill {
    background: var(--success-color);
}

.queue-post-progress {
    margin-top: 4px;
    opacity: 0.8;
}

.queue-post-progress .progress-bar {
    height: 6px;
    background: rgba(148, 163, 184, 0.12);
}

.progress-bar-fill.indeterminate {
    width: 45%;
    animation: queue-indeterminate 1.2s ease-in-out infinite;
}

@keyframes queue-indeterminate {
    0% {
        transform: translateX(-60%);
    }
    50% {
        transform: translateX(110%);
    }
    100% {
        transform: translateX(210%);
    }
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.error-text {
    color: var(--danger-color);
    font-size: 0.9em;
}

/* Queue Indicator */
.queue-indicator {
    margin-top: 15px;
    padding: 12px 20px;
    background: rgba(99, 102, 241, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--danger-color);
    color: var(--danger-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
    color: var(--primary-color);
}

/* Generate Page Two-Column Layout */
.generate-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.generate-cards-row > .section:only-child {
    grid-column: 1 / -1;
}

.generate-card-left,
.generate-card-right {
    display: flex;
    flex-direction: column;
}

.generate-card-right {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.generation-options-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.chapter-split-section {
    padding: 15px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 8px;
    border: 1px dashed rgba(99, 102, 241, 0.4);
}

.output-format-section {
    padding: 15px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
}

.format-controls-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.text-input-toolbar {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-top: 12px;
}

.document-upload-bar {
    flex: 1 1 auto;
}

.gemini-section-inline {
    padding: 0;
    background: transparent;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    margin-left: auto;
    min-width: 320px;
}

.gemini-section-inline .gemini-preset-row {
    justify-content: flex-end;
}

.gemini-section-inline .help-text {
    max-width: 360px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .text-input-toolbar {
        flex-wrap: wrap;
    }

    .gemini-section-inline {
        align-items: flex-start;
        text-align: left;
        margin-left: 0;
        min-width: 0;
    }

    .gemini-section-inline .help-text {
        white-space: normal;
    }
}

.gemini-section {
    padding: 15px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
}

.generate-button-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
}

.generation-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.generation-options-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-large {
    padding: 14px 32px;
    font-size: 1.1rem;
    width: 100%;
}

/* Document Upload / Drag-Drop Styles */
.text-input-wrapper {
    position: relative;
}

.text-input-wrapper textarea {
    width: 100%;
}

.clear-text-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #f87171;
    border-radius: 4px;
    cursor: pointer;
    z-index: 5;
    transition: all 0.15s ease;
    line-height: 1;
}

.clear-text-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    border-color: #ef4444;
    color: #fff;
}

.clear-text-btn:active {
    transform: scale(0.9);
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.15);
    border: 3px dashed var(--primary-color);
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

.text-input-wrapper.drag-over .drop-overlay {
    display: flex;
}

.drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
}

.drop-overlay .drop-icon {
    font-size: 3rem;
}

.document-upload-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.document-upload-bar .upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.document-upload-bar .upload-status {
    font-size: 0.85rem;
    color: var(--success-color);
}

.document-upload-bar .upload-status.error {
    color: var(--error-color);
}

.document-upload-bar .upload-status.loading {
    color: var(--warning-color);
}

.section-title-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.project-controls-inline {
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: 0;
}

.project-controls-inline .project-controls-actions {
    gap: 8px;
}

.project-controls {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.project-controls-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.project-controls-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.project-save-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.project-list {
    display: grid;
    gap: 10px;
}

.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.project-row-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}

.project-row-info span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.project-row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-left: 6px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: button-spinner 0.8s linear infinite;
}

@keyframes button-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Paralinguistic Tags Bar */
.paralinguistic-tags-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.paralinguistic-tags-bar .tags-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.paralinguistic-tags-bar .tags-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-tag {
    padding: 4px 10px;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--primary-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-tag:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-tag:active {
    transform: scale(0.95);
}

/* Responsive: Stack cards on smaller screens */
@media (max-width: 900px) {
    .generate-cards-row {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Settings Accordion Styles
   ======================================== */

.settings-accordion {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-group {
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.4);
    overflow: hidden;
}

.settings-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(99, 102, 241, 0.08);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.settings-group-header:hover {
    background: rgba(99, 102, 241, 0.15);
}

.settings-group-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-group-header .group-icon {
    font-size: 1.2rem;
}

.settings-group-header .collapse-icon {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.settings-group.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.settings-group-content {
    padding: 18px;
    display: block;
    border-top: 1px solid rgba(99, 102, 241, 0.15);
}

.settings-group.collapsed .settings-group-content {
    display: none;
}

/* Engine sub-tabs within Engine Settings group */
.engine-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.engine-tab-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.engine-tab-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text-color);
}

.engine-tab-btn.active {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--primary-color);
    color: #fff;
}

.engine-panel {
    display: none;
}

.engine-panel.active {
    display: block;
}

/* Quick settings grid */
.quick-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Settings section within accordion */
.settings-subsection {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.settings-subsection:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-subsection h4 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-light);
}

/* Compact form layout for settings */
.settings-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.settings-form-grid .form-group {
    margin-bottom: 0;
}

/* Badge for engine status */
.engine-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    margin-left: 8px;
}

.engine-badge.local {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.engine-badge.cloud {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

/* Engine override section in chunk review modal */
.engine-override-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.engine-override-section label {
    margin: 0;
    white-space: nowrap;
}

.library-engine-select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    min-width: 200px;
}

.library-engine-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.engine-override-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================
   BULK SPEAKER CARD LAYOUT (Accordion)
   ============================================ */
.bulk-speaker-card {
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.bulk-speaker-card:last-child {
    border-bottom: none;
}

.bulk-speaker-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    background: rgba(30, 41, 59, 0.6);
    border-left: 3px solid rgba(139, 92, 246, 0.5);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.bulk-speaker-summary:hover {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--secondary-color);
}

.bulk-expand-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    transition: transform 0.2s ease;
}

.bulk-speaker-checkbox {
    cursor: pointer;
}

.bulk-speaker-name {
    font-weight: 600;
    color: var(--primary-light);
}

.bulk-speaker-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.bulk-speaker-voice {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    margin-left: auto;
}

.bulk-speaker-details {
    padding: 12px 16px 16px 42px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(99, 102, 241, 0.08);
}

.bulk-speaker-details.collapsed {
    display: none;
}

.bulk-speaker-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.bulk-fx-section,
.bulk-regen-section {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 12px;
}

.bulk-fx-title,
.bulk-regen-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bulk-fx-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bulk-fx-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bulk-fx-control label {
    min-width: 45px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.bulk-speed-slider,
.bulk-pitch-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(99, 102, 241, 0.25);
    border-radius: 3px;
    cursor: pointer;
}

.bulk-speed-slider::-webkit-slider-thumb,
.bulk-pitch-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.bulk-speed-slider::-moz-range-thumb,
.bulk-pitch-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.bulk-speed-value,
.bulk-pitch-value {
    min-width: 40px;
    text-align: right;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary-light);
}

.bulk-speaker-apply-fx {
    margin-top: 8px;
    width: 100%;
}

.bulk-regen-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.bulk-regen-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.bulk-regen-field label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bulk-speaker-engine-select,
.bulk-speaker-voice-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.bulk-speaker-regen {
    flex-shrink: 0;
    align-self: flex-end;
}

/* ============================================
   CHUNK CARD LAYOUT (Collapsible)
   ============================================ */
.library-chunk-card {
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.library-chunk-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card-bg);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    position: sticky;
    top: 36px;
    z-index: 1;
    border-bottom: 1px solid var(--border-color);
}

.library-chunk-summary:hover {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--primary-color);
}

.chunk-expand-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    transition: transform 0.2s ease;
}

.library-chunk-speaker {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.library-chunk-preview {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-chunk-details {
    padding: 12px 16px 16px 42px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(99, 102, 241, 0.08);
}

.library-chunk-details.collapsed {
    display: none;
}

.chunk-detail-section {
    margin-bottom: 14px;
}

.chunk-detail-section:last-child {
    margin-bottom: 0;
}

.chunk-detail-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.chunk-detail-label .library-chunk-voice-label {
    color: var(--primary-light);
}

.chunk-text-section label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.library-chunk-textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
}

.chunk-fx-section,
.chunk-regen-section {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 6px;
    padding: 12px;
}

.chunk-fx-title,
.chunk-regen-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chunk-fx-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.chunk-fx-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chunk-fx-control label {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 40px;
}

.chunk-speed-slider,
.chunk-pitch-slider {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(99, 102, 241, 0.25);
    border-radius: 3px;
    cursor: pointer;
}

.chunk-speed-slider::-webkit-slider-thumb,
.chunk-pitch-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.chunk-speed-slider::-moz-range-thumb,
.chunk-pitch-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.chunk-speed-value,
.chunk-pitch-value {
    min-width: 40px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary-light);
}

.chunk-regen-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.library-chunk-engine-select,
.library-chunk-voice-select {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.library-chunk-voice-select {
    min-width: 180px;
}

/* Qwen3 options in library view */
.bulk-qwen3-options,
.chunk-qwen3-options {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
}

.bulk-qwen3-options input[type="text"],
.chunk-qwen3-options input[type="text"] {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.bulk-qwen3-options input[type="text"]:focus,
.chunk-qwen3-options input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chunk-qwen3-language {
    flex: 1;
    min-width: 100px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.chunk-qwen3-instruct {
    flex: 2;
    min-width: 150px;
}

/* ============================================================
   Alt Word Registry
   ============================================================ */

.awr-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 14px 0;
    line-height: 1.5;
}

.awr-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.awr-count-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.awr-table-wrapper {
    overflow-x: auto;
}

.awr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.awr-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.awr-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}

.awr-table tr:last-child td {
    border-bottom: none;
}

.awr-table .awr-empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 24px 12px;
}

.awr-original-cell {
    font-weight: 600;
    color: #f59e0b;
}

.awr-replacement-cell {
    color: #34d399;
}

.awr-instances-cell {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.awr-instances-badge {
    display: inline-block;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.8rem;
    min-width: 28px;
    text-align: center;
}

.awr-instances-badge.awr-zero {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: var(--text-muted);
}

.awr-actions-cell {
    white-space: nowrap;
    text-align: right;
}

.awr-edit-btn,
.awr-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.awr-edit-btn {
    color: var(--text-muted);
}

.awr-edit-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #eef2ff;
}

.awr-delete-btn {
    color: var(--danger-color, #ef4444);
}

.awr-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Entry sub-modal */
.awr-entry-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.awr-field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.awr-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.awr-text-input {
    width: 100%;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--input-bg, rgba(255,255,255,0.05));
    color: var(--text-color);
    font-size: 0.95rem;
    box-sizing: border-box;
}

.awr-text-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.awr-preview-section {
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.awr-preview-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.awr-preview-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 140px;
}

.awr-preview-field-voice {
    flex: 2;
}

.awr-select {
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #1e2a3a;
    color: #e2e8f0;
    font-size: 0.88rem;
}

.awr-select option,
.awr-select optgroup {
    background: #1e2a3a;
    color: #e2e8f0;
}

.awr-preview-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.awr-preview-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Library section header — single flex row */
.library-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: nowrap;
}

.library-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
    min-width: 0;
}

.library-section-title h2 {
    margin: 0;
    white-space: nowrap;
}

.library-section-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-section-actions {
    flex-shrink: 0;
    margin: 0;
}

/* AWR overlay modal (shared by main page and library) */
.awr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.awr-overlay.hidden {
    display: none;
}

.awr-modal {
    background: #1e2a3a;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.awr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.awr-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.awr-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}

.awr-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
}

.awr-modal-body {
    padding: 1rem 1.25rem;
    flex: 1;
}

.awr-input {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-size: 0.88rem;
}

.awr-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ── Tag-error banner ─────────────────────────────────── */
.tag-error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 8px;
    font-size: 0.875rem;
    color: #fbbf24;
    flex-wrap: wrap;
}

.tag-error-banner.hidden {
    display: none;
}

.tag-error-banner-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
}

.tag-error-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.tag-error-banner-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#input-text.tag-error-highlight {
    border-color: rgba(245, 158, 11, 0.6) !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.auto-assign-threshold-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.auto-assign-threshold-row label {
    font-size: 0.9rem;
    white-space: nowrap;
    color: var(--text-color);
}

.auto-assign-threshold-row input[type="range"] {
    flex: 1 1 120px;
    min-width: 100px;
    accent-color: var(--primary-color, #6366f1);
    cursor: pointer;
}

#auto-assign-threshold-label {
    font-size: 0.9rem;
    font-weight: 700;
    min-width: 38px;
    text-align: right;
    color: var(--primary-color, #6366f1);
}

.auto-assign-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
    font-size: 0.9rem;
}

.auto-assign-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auto-assign-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

.auto-assign-table tr:last-child td {
    border-bottom: none;
}

.auto-assign-table .speaker-name-cell {
    font-weight: 500;
    white-space: nowrap;
}

.auto-assign-table select {
    width: 100%;
    min-width: 180px;
}

.auto-assign-score {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 600;
}

.auto-assign-score.score-high {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.auto-assign-score.score-med {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.auto-assign-score.score-none {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-muted, #94a3b8);
}

/* ── Time Codes Modal ──────────────────────────────────────────── */
.timecodes-intro-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.timecodes-intro-row label {
    font-size: 0.9rem;
    white-space: nowrap;
}

.timecodes-intro-row input[type="number"] {
    background: var(--input-bg, rgba(255,255,255,0.07));
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: 6px;
    color: var(--text-color);
    padding: 5px 8px;
    font-size: 0.9rem;
}

.timecodes-help-text {
    font-size: 0.82rem;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 14px;
}

.timecodes-result {
    background: var(--input-bg, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 8px;
    overflow: hidden;
    margin-top: 6px;
}

.timecodes-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(99,102,241,0.08);
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    font-size: 0.85rem;
    font-weight: 600;
}

.timecodes-output {
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 0.88rem;
    line-height: 1.7;
    padding: 12px 14px;
    margin: 0;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-color);
}

.timecodes-loading {
    font-size: 0.88rem;
    color: var(--text-muted, #94a3b8);
    padding: 10px 0;
    text-align: center;
}

.timecodes-error {
    font-size: 0.88rem;
    color: var(--danger-color, #ef4444);
    padding: 8px 0;
}
