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

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #212529;
    --text-muted: #6c757d;
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --border: #dee2e6;
    --radius: 8px;
}

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

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

header nav {
    max-width: 960px;
    margin: 0 auto;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

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

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text-muted);
}

/* Search */
.search-box {
    margin-bottom: 2rem;
}

.search-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-row input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.search-row select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--surface);
}

.search-row button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
}

.search-row button:hover {
    background: var(--primary-hover);
}

/* Episode grid */
.episodes-list h2 {
    margin-bottom: 1rem;
}

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

.episode-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s;
}

.episode-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.episode-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.episode-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.persons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.person-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: #e9ecef;
    border-radius: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.person-tag a {
    color: var(--primary);
    text-decoration: none;
}

/* Results */
.results h2 {
    margin-bottom: 1rem;
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.result-header a {
    text-decoration: none;
    color: var(--primary);
}

.result-header h3 {
    font-size: 1.05rem;
}

.score {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.hit-count {
    font-weight: 600;
}

.segment-hits {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.segment-hit {
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.segment-hit[open] {
    border-color: var(--border);
}

.segment-hit summary {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    list-style: none;
    font-size: 0.9rem;
}

.segment-hit summary::-webkit-details-marker {
    display: none;
}

.segment-hit summary::before {
    content: "\25B6";
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.15s;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.segment-hit[open] summary::before {
    transform: rotate(90deg);
}

.segment-hit .seg-time {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary);
    white-space: nowrap;
}

.segment-hit .seg-score {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.segment-hit .seg-preview {
    color: var(--text-muted);
    font-size: 0.85rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
}

.segment-hit[open] .seg-preview {
    display: none;
}

.seg-body {
    padding: 0 0.75rem 0.75rem;
}

.seg-body p {
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.seg-body audio {
    width: 100%;
    height: 40px;
}

.audio-link audio {
    width: 100%;
    height: 40px;
}

.no-results {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

/* Episode detail */
.episode-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
}

.episode-detail .episode-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.episode-detail h1 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.episode-detail .episode-meta {
    margin-bottom: 0.75rem;
}

.episode-detail .persons {
    margin-top: 0.75rem;
}

.audio-player {
    margin-bottom: 2rem;
}

.audio-player audio {
    width: 100%;
}

.episode-description {
    margin-bottom: 2.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.7;
}

.episode-description a {
    color: var(--primary);
}

.episode-description ul,
.episode-description ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.episode-detail h2 {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Transcript */
.transcript {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.segment {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    transition: background 0.1s;
}

.segment:hover {
    background: var(--bg);
}

.seg-time {
    flex-shrink: 0;
    font-size: 0.85rem;
    font-family: monospace;
    color: var(--primary);
    text-decoration: none;
    padding-top: 0.2rem;
    min-width: 3.5rem;
}

.segment p {
    line-height: 1.7;
    margin: 0;
}

@media (max-width: 600px) {
    main {
        padding: 1.5rem 1rem;
    }
    .episode-detail {
        padding: 1.25rem 1rem;
    }
    .search-row {
        flex-direction: column;
    }
    .search-row input[type="text"],
    .search-row select,
    .search-row button {
        width: 100%;
    }
    .episode-grid {
        grid-template-columns: 1fr;
    }
    .segment {
        flex-direction: column;
        gap: 0.25rem;
    }
}
