* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a5276;
    --primary-dark: #154360;
    --accent: #e74c3c;
    --success: #27ae60;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --border: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

nav {
    background: var(--primary);
    padding: 1rem 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

nav a:hover { opacity: 0.8; }

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hero {
    text-align: center;
    padding: 1.5rem 0;
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.hero .subtitle {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 500;
}

/* Chapter tabs */
.chapter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab:disabled:not(.active) {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Player */
.player {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.play-btn {
    width: 56px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.play-btn:hover:not(:disabled) { background: var(--primary-dark); }
.play-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.scrubber-wrap {
    flex: 1;
    min-width: 0;
}

.scrubber {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.scrubber:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.time-display {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    text-align: center;
}

.download-btn {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--success);
    border-radius: 6px;
    background: white;
    color: var(--success);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.download-btn:hover:not(:disabled) {
    background: var(--success);
    color: white;
}

.download-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.generate-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.generate-row select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.generate-btn {
    flex: 1;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.generate-btn:hover:not(:disabled) { background: #c0392b; }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Progress */
.progress-wrap {
    margin-top: 1rem;
    background: var(--border);
    border-radius: 6px;
    height: 28px;
    position: relative;
    overflow: hidden;
}

.progress-wrap.hidden { display: none; }

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

#progressText {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
}

/* Transcript */
.transcript {
    margin-bottom: 1.5rem;
}

.section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 4px solid transparent;
    transition: border-color 0.3s, background 0.3s;
}

.section.active {
    border-left-color: var(--accent);
    background: #fef9f8;
}

.section.played {
    border-left-color: var(--success);
}

.section h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.section p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.7;
}

.section p:last-child { margin-bottom: 0; }

.source-note {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
    text-align: center;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

@media (max-width: 600px) {
    .player-controls {
        flex-wrap: wrap;
    }

    .scrubber-wrap {
        order: 3;
        flex-basis: 100%;
    }

    .generate-row {
        flex-direction: column;
    }

    .generate-btn {
        width: 100%;
    }

    .chapter-tabs {
        flex-direction: column;
    }
}
