/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Dark Theme (default) ───────────────────────────────────── */
:root, [data-theme="dark"] {
    --bg: #16141f;
    --bg-warm: #1c1a28;
    --surface: #232136;
    --surface2: #2a2740;
    --surface3: #332f4a;
    --border: #3b3558;
    --border-subtle: rgba(59, 53, 88, 0.5);
    --text: #e8e0f0;
    --text-dim: #9890a8;
    --accent: #f5a97f;
    --accent-hover: #f7be9a;
    --accent-warm: #eed49f;
    --accent-glow: rgba(245, 169, 127, 0.15);
    --success: #a6da95;
    --danger: #ed8796;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
    --header-bg: rgba(35, 33, 54, 0.85);
    --speaker-1: #f5a97f;
    --speaker-2: #f5bde6;
    --speaker-3: #a6da95;
    --speaker-4: #eed49f;
    --speaker-5: #c6a0f6;
    --speaker-6: #f0c6c6;
    --speaker-7: #8bd5ca;
    --speaker-8: #f4dbd6;
}

/* ── Light Theme ────────────────────────────────────────────── */
[data-theme="light"] {
    --bg: #faf4ed;
    --bg-warm: #f2e9de;
    --surface: #fffaf3;
    --surface2: #f2e9de;
    --surface3: #e8ddd0;
    --border: #d4c5b0;
    --border-subtle: rgba(212, 197, 176, 0.5);
    --text: #2a2520;
    --text-dim: #797068;
    --accent: #d7827e;
    --accent-hover: #c46a66;
    --accent-warm: #ea9d34;
    --accent-glow: rgba(215, 130, 126, 0.12);
    --success: #3e8a2e;
    --danger: #b4463a;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --header-bg: rgba(255, 250, 243, 0.9);
    --speaker-1: #d7827e;
    --speaker-2: #b4637a;
    --speaker-3: #3e8a2e;
    --speaker-4: #ea9d34;
    --speaker-5: #907aa9;
    --speaker-6: #d7827e;
    --speaker-7: #56949f;
    --speaker-8: #c46a66;
}

body {
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, var(--bg) 0%, var(--bg-warm) 100%);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Header ──────────────────────────────────────────────────── */
header {
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header-icon {
    font-size: 1.4rem;
    line-height: 1;
}

header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.nav-pill:hover {
    color: var(--text);
    background: var(--surface2);
    border-color: var(--border-subtle);
    text-decoration: none;
}

.nav-pill svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-pill:hover svg { opacity: 1; }

.nav-pill-ghost {
    padding: 0.35rem 0.5rem;
}

.nav-pill-ghost:hover {
    color: var(--danger);
    background: rgba(237, 135, 150, 0.1);
    border-color: transparent;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.3rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.username {
    font-weight: 700;
    font-size: 0.85rem;
}

.role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}

.role-admin { background: rgba(237,135,150,0.15); color: var(--danger); }
.role-teacher { background: rgba(245,169,127,0.15); color: var(--accent); }
.role-student { background: rgba(166,218,149,0.15); color: var(--success); }

/* ── Flash Messages ─────────────────────────────────────────── */
.flash-messages {
    padding: 0.75rem 1.5rem;
}

.flash {
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.flash-error { background: rgba(237,135,150,0.12); color: var(--danger); }
.flash-info { background: rgba(245,169,127,0.12); color: var(--accent); }
.flash-success { background: rgba(166,218,149,0.12); color: var(--success); }

/* ── Main Layout ─────────────────────────────────────────────── */
.container {
    display: grid;
    grid-template-columns: 55% 45%;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.panel {
    overflow-y: auto;
    padding: 1.5rem;
}

.panel-left {
    border-right: 1px solid var(--border-subtle);
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Forms ────────────────────────────────────────────────────── */
select, input, textarea, button {
    font-family: inherit;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select, input[type="number"] {
    padding: 0.5rem 0.7rem;
    min-width: 0;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.85rem;
    resize: vertical;
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--surface);
    border-radius: 12px;
}

button {
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
}

button:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-color: transparent;
    color: #1a1520;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-warm));
    border-color: transparent;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}

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

/* ── Scripts Library ─────────────────────────────────────────── */
.scripts-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.tab-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: var(--surface2);
    color: var(--text);
    transform: none;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-color: transparent;
    color: #1a1520;
}

.scripts-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border-radius: 10px;
}

.script-item {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-subtle);
}

.script-item:hover { background: var(--surface2); }
.script-item:last-child { border-bottom: none; }

.script-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.script-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.script-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.fav-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}

.fav-btn.favourited { color: var(--accent-warm); }
.fav-btn:hover { color: var(--accent-warm); transform: none; }

.empty-state {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    padding: 2rem 0;
}

/* ── Settings Panel ──────────────────────────────────────────── */
.settings-panel {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

/* ── Script Lines ────────────────────────────────────────────── */
.parsed-lines {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.parsed-line {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.875rem;
}

.parsed-line:hover { background: var(--surface2); }

.parsed-line.active {
    background: var(--surface2);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 8px;
}

.parsed-line .line-num {
    color: var(--text-dim);
    font-size: 0.72rem;
    min-width: 1.5rem;
    text-align: right;
    padding-top: 3px;
    flex-shrink: 0;
    font-weight: 600;
}

.parsed-line .speaker-tag {
    font-weight: 700;
    flex-shrink: 0;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--accent-glow);
    transition: all 0.15s ease;
    font-size: 0.8rem;
}

.parsed-line .speaker-tag:hover {
    outline: 1px dashed var(--text-dim);
}

.parsed-line .line-text { color: var(--text); }

/* ── Speaker Override Dropdown ───────────────────────────────── */
.speaker-override-dropdown {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.35rem;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    min-width: 130px;
}

.speaker-override-dropdown .override-option {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    border-radius: 8px;
    transition: background 0.1s ease;
}

.speaker-override-dropdown .override-option:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #1a1520;
    transform: none;
}

/* ── Section Headers ─────────────────────────────────────────── */
.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    margin-top: 1.25rem;
}

.section-title:first-child { margin-top: 0; }

/* ── Global Pause Row ────────────────────────────────────────── */
.global-pause-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.global-pause-row label {
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.global-pause-row input[type="number"] {
    width: 80px;
}

/* ── Speaker Config Cards ────────────────────────────────────── */
.speaker-cards {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.speaker-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1rem;
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.speaker-card:hover {
    box-shadow: var(--shadow-md);
}

.speaker-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.speaker-card-actions {
    display: flex;
    gap: 0.35rem;
}

.speaker-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.speaker-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-group label {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 600;
}

.control-group select, .control-group input {
    width: 100%;
}

.control-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    align-items: end;
}

.slider-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.slider-group label {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 600;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: var(--border);
    border: none;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-val {
    font-size: 0.78rem;
    color: var(--text-dim);
    min-width: 3rem;
    text-align: right;
    font-weight: 600;
}

.slider-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    color: var(--text-dim);
    padding-right: 3.5rem;
    margin-top: -2px;
    font-weight: 600;
}

/* ── Playback & Generation ───────────────────────────────────── */
.gen-section {
    margin-top: 1.25rem;
}

.progress-bar-container {
    background: var(--surface);
    border-radius: 8px;
    height: 10px;
    overflow: hidden;
    margin: 0.75rem 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
    border-radius: 8px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: progressShimmer 1.5s infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.playback-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.playback-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-left: auto;
    font-weight: 600;
}

/* ── Export ───────────────────────────────────────────────────── */
.export-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.export-row {
    display: flex;
    gap: 0.5rem;
    align-items: end;
    flex-wrap: wrap;
}

/* ── History ─────────────────────────────────────────────────── */
.history-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.history-item:hover {
    box-shadow: var(--shadow-md);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.history-title {
    font-weight: 600;
}

.history-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
}

/* ── Status Messages ─────────────────────────────────────────── */
.status-msg {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    margin-top: 0.75rem;
}

.status-msg.info { background: rgba(245,169,127,0.12); color: var(--accent); }
.status-msg.success { background: rgba(166,218,149,0.12); color: var(--success); }
.status-msg.error { background: rgba(237,135,150,0.12); color: var(--danger); }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Hidden ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbar Styling ───────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ── Lessons Management (Teacher) ────────────────────────────── */

.lessons-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
}

.lesson-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.lesson-item-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lesson-item-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.lesson-delete-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    border-radius: 50%;
}

/* Share toggle switch */
.share-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    flex-shrink: 0;
}

.share-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.share-toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--surface3);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.share-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.share-toggle input:checked + .share-toggle-slider {
    background: var(--success);
}

.share-toggle input:checked + .share-toggle-slider::after {
    left: 18px;
    background: #fff;
}

.share-toggle-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    min-width: 3.5rem;
}

/* ── Student Lesson Library ──────────────────────────────────── */

.student-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

.library-header {
    margin-bottom: 1.5rem;
}

.library-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
}

.library-subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.lesson-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
    animation: cardFadeIn 0.4s ease both;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.lesson-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.card-date {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-speakers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.card-speaker {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    background: var(--accent-glow);
}

.card-bottom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.card-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
}

.card-play-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #1a1520;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.card-play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* Empty state */
.empty-library {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    border-radius: 50%;
    color: var(--text-dim);
}

.empty-icon svg { width: 28px; height: 28px; }

.empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.empty-text {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ── Lesson Detail ──────────────────────────────────────────── */

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1.25rem;
}

.back-btn:hover {
    color: var(--text);
    background: var(--surface2);
    transform: none;
}

.back-btn svg { width: 16px; height: 16px; }

.lesson-detail-header {
    margin-bottom: 1.25rem;
}

.lesson-detail-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.lesson-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.lesson-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    font-weight: 600;
}

.lesson-meta-item svg { width: 15px; height: 15px; }

/* Player bar */
.player-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 0.65rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.play-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #1a1520;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.play-all-btn:hover { transform: scale(1.03); }
.play-all-btn svg { width: 15px; height: 15px; }

.player-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--surface2);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-btn:hover {
    color: var(--text);
    background: var(--surface3);
    transform: none;
}

.player-btn svg { width: 14px; height: 14px; }

.player-progress {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.player-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.player-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
    white-space: nowrap;
    min-width: 5rem;
    text-align: right;
}

/* Script lines */
.script-lines {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.script-line {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.875rem;
}

.script-line:hover { background: var(--surface2); }

.script-line.active {
    background: var(--surface2);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.script-line .line-num {
    color: var(--text-dim);
    font-size: 0.72rem;
    min-width: 1.5rem;
    text-align: right;
    padding-top: 3px;
    flex-shrink: 0;
    font-weight: 600;
}

.script-line .line-speaker {
    font-weight: 700;
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.script-line .line-text {
    color: var(--text);
    flex: 1;
}

.line-play-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
}

.script-line:hover .line-play-btn,
.script-line.active .line-play-btn {
    opacity: 1;
}

.line-play-btn:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
    transform: none;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .panel-left { border-right: none; border-bottom: 1px solid var(--border-subtle); }
    .panel { max-height: none; }
    textarea { min-height: 180px; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    header {
        padding: 0 1rem;
        height: 50px;
    }
    header h1 { font-size: 1rem; }
    .header-icon { font-size: 1.1rem; }
    .nav-pill { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
    .nav-pill svg { width: 14px; height: 14px; }
    .username { display: none; }
    .nav-divider { display: none; }
    .panel { padding: 1rem; }
    .container { height: calc(100vh - 50px); }
    .speaker-controls { grid-template-columns: 1fr; }
}

/* ── Upload button style ─────────────────────────────────────── */
.upload-label {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    transition: all 0.2s ease;
}

.upload-label:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.upload-label input[type="file"] { display: none; }
