/* ============================================================
   iRss — "Ink & Signal" Design System
   Dark-first editorial aesthetic with amber accent
   ============================================================ */

/* --- Dark theme (default) --- */
:root,
[data-theme="dark"] {
    --bg-deep:       #0C0C0E;
    --bg:            #141416;
    --bg-elevated:   #1C1C20;
    --bg-elevated-2: #242428;

    --border:        #2A2A30;
    --border-strong: #3A3A42;

    --text:          #E8E4DF;
    --text-secondary:#9C9890;
    --text-muted:    #6B6760;

    --accent:        #E8A849;
    --accent-hover:  #F0B85A;
    --accent-subtle: rgba(232,168,73,0.12);
    --accent-glow:   rgba(232,168,73,0.06);

    --success:       #5CB77A;
    --danger:        #D4584A;
    --warning:       #D4A24A;
    --info:          #5A8FD4;

    --podcast:       #C474D4;
    --blog:          #5A8FD4;
    --youtube:       #D4584A;

    --score-high:    #5CB77A;
    --score-mid:     #D4A24A;
    --score-low:     #6B6760;

    --radius:        10px;
    --radius-lg:     16px;
    --shadow:        0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.5);

    --glass-bg:      rgba(20,20,22,0.82);
    --glass-border:  rgba(255,255,255,0.06);
    --card-border:   rgba(255,255,255,0.04);
    --overlay:       rgba(0,0,0,0.6);
    --loading-overlay: rgba(12,12,14,0.7);
}

/* --- Light theme --- */
[data-theme="light"] {
    --bg-deep:       #F5F0EB;
    --bg:            #FAF7F3;
    --bg-elevated:   #FFFFFF;
    --bg-elevated-2: #F0ECE6;

    --border:        #E5DED5;
    --border-strong: #D0C8BD;

    --text:          #1A1814;
    --text-secondary:#5C564E;
    --text-muted:    #8A8278;

    --accent:        #C48B30;
    --accent-hover:  #B07A22;
    --accent-subtle: rgba(196,139,48,0.10);
    --accent-glow:   rgba(196,139,48,0.05);

    --success:       #3D8A55;
    --danger:        #B83D30;
    --warning:       #B88A30;
    --info:          #3D6DB8;

    --podcast:       #9B4DAB;
    --blog:          #3D6DB8;
    --youtube:       #B83D30;

    --score-high:    #3D8A55;
    --score-mid:     #B88A30;
    --score-low:     #8A8278;

    --shadow:        0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.10);

    --glass-bg:      rgba(250,247,243,0.85);
    --glass-border:  rgba(0,0,0,0.06);
    --card-border:   rgba(0,0,0,0.06);
    --overlay:       rgba(0,0,0,0.35);
    --loading-overlay: rgba(245,240,235,0.7);
}


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

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: "Noto Sans SC", "Source Serif 4", "Noto Serif SC", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.75;
    transition: background-color 0.35s ease, color 0.35s ease;
    min-height: 100vh;
}

/* Noise texture overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.018;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}


/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: "Fraunces", "Noto Serif SC", Georgia, serif;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

h1 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

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

code, pre, .mono {
    font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
}

small, .text-sm {
    font-size: 0.95rem;
}


/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.25rem;
}


/* ============================================================
   Navbar — frosted glass, sticky
   ============================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    height: 56px;
    background: var(--glass-bg);
    backdrop-filter: blur(14px) saturate(1.6);
    -webkit-backdrop-filter: blur(14px) saturate(1.6);
    border-bottom: 1px solid var(--glass-border);
    transition: background-color 0.35s ease;
}

.nav-brand {
    font-family: "Fraunces", "Noto Serif SC", Georgia, serif;
    font-style: italic;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    margin-right: 2.5rem;
    letter-spacing: -0.02em;
    transition: color 0.2s;
}

.nav-brand:hover {
    color: var(--accent-hover);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.nav-links a {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    position: relative;
    transition: color 0.2s, background-color 0.2s;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--accent-subtle);
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-subtle);
}

.nav-links a.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    animation: navIndicator 0.3s ease forwards;
}

@keyframes navIndicator {
    from { width: 0; opacity: 0; }
    to   { width: 18px; opacity: 1; }
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* APP download QR popup */
.nav-app-download {
    position: relative;
    cursor: pointer;
}
.qr-popup {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    background: var(--bg-elevated);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    z-index: 200;
    text-align: center;
}
.qr-popup.show {
    display: block !important;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.nav-logout {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.88rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0.3rem 0.5rem;
}

.nav-logout:hover {
    color: var(--danger);
}


/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    transition: background-color 0.35s ease, border-color 0.35s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    border-color: var(--border);
}

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


/* ============================================================
   Buttons
   ============================================================ */
.btn {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, transform 0.15s;
    text-decoration: none;
    color: #fff;
    line-height: 1.3;
}

.btn:hover:not(:disabled) {
    transform: scale(1.015);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn-primary {
    background: var(--accent);
    color: var(--bg-deep);
}

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

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #C04A3E;
}

.btn-success {
    background: var(--success);
    color: var(--bg-deep);
}

.btn-success:hover:not(:disabled) {
    background: #4EA56A;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.88rem;
}


/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    display: block;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.35s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: auto;
}

/* Form row */
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
}


/* ============================================================
   Badges
   ============================================================ */
.badge {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.92rem;
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-podcast {
    background: rgba(196,116,212,0.15);
    color: var(--podcast);
}

.badge-blog {
    background: rgba(90,143,212,0.15);
    color: var(--blog);
}

.badge-youtube {
    background: rgba(212,88,74,0.15);
    color: var(--youtube);
}


/* ============================================================
   Score Indicator
   ============================================================ */
.score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    flex-shrink: 0;
    gap: 0.2rem;
}

.score-num {
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

.score-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.score-high .score-num { color: var(--score-high); }
.score-high .score-bar-fill { background: var(--score-high); }

.score-mid .score-num { color: var(--score-mid); }
.score-mid .score-bar-fill { background: var(--score-mid); }

.score-low .score-num { color: var(--score-low); }
.score-low .score-bar-fill { background: var(--score-low); }


/* ============================================================
   Item List (Dashboard)
   ============================================================ */
.item-list .item {
    display: flex;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    align-items: flex-start;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    animation: fadeInUp 0.4s ease both;
}

.item-list .item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    border-color: var(--border);
}

/* Stagger animation for items */
.item-list .item:nth-child(1)  { animation-delay: 0.02s; }
.item-list .item:nth-child(2)  { animation-delay: 0.06s; }
.item-list .item:nth-child(3)  { animation-delay: 0.10s; }
.item-list .item:nth-child(4)  { animation-delay: 0.14s; }
.item-list .item:nth-child(5)  { animation-delay: 0.18s; }
.item-list .item:nth-child(6)  { animation-delay: 0.22s; }
.item-list .item:nth-child(7)  { animation-delay: 0.26s; }
.item-list .item:nth-child(8)  { animation-delay: 0.30s; }
.item-list .item:nth-child(9)  { animation-delay: 0.34s; }
.item-list .item:nth-child(10) { animation-delay: 0.38s; }

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

.item-body {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-family: "Noto Sans SC", "Source Serif 4", system-ui, sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.item-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}

.item-title a:hover {
    color: var(--accent);
}

.item-meta {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

.item-summary {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.75;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}


/* ============================================================
   Star / Favorite Button
   ============================================================ */
.btn-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    transition: transform 0.2s;
    line-height: 1;
}

.btn-star:hover {
    transform: scale(1.2);
}


/* ============================================================
   Source List
   ============================================================ */
.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
}

.source-item:last-child {
    border-bottom: none;
}

.source-item:hover {
    background: var(--accent-glow);
}

.source-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.source-name {
    font-weight: 600;
    font-size: 0.95rem;
    word-break: break-word;
}

.source-name a {
    color: var(--text);
    transition: color 0.2s;
}

.source-name a:hover {
    color: var(--accent);
}

.source-url {
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.92rem;
    color: var(--text-muted);
    word-break: break-all;
    white-space: normal;
}

.source-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}


/* ============================================================
   Date Navigation
   ============================================================ */
.date-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.date-nav input[type="date"],
.date-nav select {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    background: var(--bg-elevated);
    color: var(--text);
    transition: border-color 0.2s, background-color 0.35s;
}

.date-nav input[type="date"]:focus,
.date-nav select:focus {
    outline: none;
    border-color: var(--accent);
}


/* ============================================================
   Podcast Search Results
   ============================================================ */
.podcast-result {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
}

.podcast-result:last-child {
    border-bottom: none;
}

.podcast-result:hover {
    background: var(--accent-glow);
}

.podcast-artwork {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.podcast-result-info {
    flex: 1;
    min-width: 0;
}

.podcast-result-name {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podcast-result-meta {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.92rem;
    color: var(--text-muted);
}


/* ============================================================
   Transcript View
   ============================================================ */
.transcript-segments {
    margin-top: 1rem;
}

.segment {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.segment:last-child {
    border-bottom: none;
}

.segment-time {
    flex-shrink: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.92rem;
    color: var(--text-muted);
    padding-top: 0.2rem;
    min-width: 3.5rem;
}

.segment-text {
    flex: 1;
}

.segment-original {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.segment-translated {
    font-size: 0.95rem;
    color: var(--accent);
}


/* ============================================================
   Audio Player
   ============================================================ */
.audio-player-card {
    position: sticky;
    top: 56px;
    z-index: 100;
    background: var(--bg-elevated);
    border-color: var(--accent-subtle);
}

.audio-player-card audio {
    display: none;
}

.custom-player {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

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

.player-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg-deep);
    font-size: 0.92rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}

.player-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.06);
}

.player-time {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.player-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-speed {
    font-family: "DM Sans", system-ui, sans-serif;
    padding: 0.25rem 0.4rem;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s;
}

.player-speed:hover {
    border-color: var(--accent);
}

/* Seekbar */
.player-seekbar {
    position: relative;
    width: 100%;
    height: 22px;
    background: var(--bg-elevated-2);
    border-radius: 11px;
    cursor: pointer;
    touch-action: none;
    margin-top: 0.25rem;
}

.seekbar-buffered {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--accent-subtle);
    border-radius: 11px;
    width: 0;
    pointer-events: none;
}

.seekbar-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--accent);
    border-radius: 11px;
    width: 0;
    pointer-events: none;
}

.seekbar-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 26px;
    height: 26px;
    background: var(--text);
    border: 3px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    pointer-events: none;
}


/* ============================================================
   Summary & Report Cards
   ============================================================ */
.summary-card {
    border-left: 3px solid var(--accent);
}

.nlm-card {
    border-left: 3px solid var(--danger);
}

.nlm-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0;
}

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

.nlm-controls select {
    font-family: "DM Sans", system-ui, sans-serif;
    padding: 0.35rem 0.5rem;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}

.nlm-audio-player {
    margin-top: 0.75rem;
}

.nlm-audio-player audio {
    width: 100%;
    border-radius: var(--radius);
}

.nlm-summary-content {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Topic tags */
.topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.topic-tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 0.92rem;
    border-radius: 6px;
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
}

/* Key points */
.key-points {
    margin-bottom: 1rem;
}

.key-points h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.key-points ul {
    padding-left: 1.25rem;
}

.key-points li {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.25rem;
}

/* Summary sections */
.summary-section {
    margin-bottom: 1rem;
}

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

.summary-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.summary-section p {
    font-size: 0.95rem;
    line-height: 1.7;
}


/* ============================================================
   Collapsible Sections
   ============================================================ */
.transcript-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0;
}

.transcript-toggle h3 {
    font-size: 0.95rem;
    margin-bottom: 0;
}

.toggle-arrow {
    font-size: 0.92rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.toggle-arrow.expanded {
    transform: rotate(90deg);
}

.full-transcript {
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.full-transcript.collapsed {
    max-height: 0;
}

.full-transcript:not(.collapsed) {
    max-height: 100000px;
    margin-top: 1rem;
}

.transcript-text {
    font-size: 0.95rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.summary-collapsible {
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.summary-collapsible.collapsed {
    max-height: 0;
}

.summary-collapsible:not(.collapsed) {
    max-height: 100000px;
}


/* ============================================================
   Scrollable Transcript + Subtitle Sync
   ============================================================ */
.transcript-scroll {
    max-height: 65vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.transcript-scroll::-webkit-scrollbar {
    width: 5px;
}

.transcript-scroll::-webkit-scrollbar-track {
    background: transparent;
}

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

.sentence-row {
    padding: 0.55rem 0.85rem;
    margin-bottom: 0.2rem;
    border-radius: var(--radius);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s;
}

.sentence-row:hover {
    background: var(--bg-elevated-2);
}

.sentence-row.active {
    background: var(--accent-subtle);
    border-left-color: var(--accent);
    animation: sentenceGlow 0.3s ease;
}

@keyframes sentenceGlow {
    from { border-left-width: 0; }
    to   { border-left-width: 3px; }
}

.sentence-text {
    font-size: 0.95rem;
    line-height: 1.75;
    word-break: break-word;
}

.sentence-zh {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--accent);
    margin-top: 0.2rem;
    opacity: 0.85;
}


/* ============================================================
   NLM Report Card
   ============================================================ */
.nlm-report-card {
    border-left: 3px solid var(--accent);
}

.nlm-report-content {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.75;
}

.nlm-report-content h2 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.nlm-report-content h3 {
    font-size: 0.95rem;
    margin: 1.15rem 0 0.4rem;
}

.nlm-report-content h4 {
    font-size: 0.95rem;
    margin: 0.85rem 0 0.3rem;
}

.nlm-report-content p {
    margin-bottom: 0.65rem;
    color: var(--text-secondary);
}

.nlm-report-content ul,
.nlm-report-content ol {
    padding-left: 1.5rem;
    margin-bottom: 0.65rem;
}

.nlm-report-content li {
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
}

.nlm-report-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 0.85rem;
    margin: 0.75rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.nlm-report-content code {
    font-family: "JetBrains Mono", monospace;
    background: var(--bg-deep);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.88rem;
    color: var(--accent);
}

.nlm-report-content pre {
    background: var(--bg-deep);
    padding: 0.85rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 0.65rem;
}


/* ============================================================
   NLM Cards (Subtitles, Slides, Chinese Audio)
   ============================================================ */
.nlm-subtitles-card {
    border-left: 3px solid var(--success);
}

.nlm-slides-card {
    border-left: 3px solid var(--warning);
}

.nlm-slides-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nlm-slides-header h3 {
    font-size: 0.95rem;
    margin-bottom: 0;
}

.nlm-slides-container {
    margin-top: 0.75rem;
}

.nlm-zh-audio-card {
    border-left: 3px solid var(--danger);
}

.nlm-zh-audio-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0;
}

.nlm-zh-audio-player {
    margin-top: 0.75rem;
}

.nlm-zh-audio-player audio {
    width: 100%;
    border-radius: var(--radius);
}


/* ============================================================
   Loading — podcast-style waveform bars
   ============================================================ */
.spinner {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: 1.2rem;
}

.spinner::before,
.spinner::after {
    content: "";
}

.spinner::before,
.spinner span,
.spinner::after {
    display: block;
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    animation: waveBar 0.8s ease-in-out infinite alternate;
}

.spinner::before {
    height: 40%;
    animation-delay: 0s;
}

.spinner span {
    height: 70%;
    animation-delay: 0.15s;
}

.spinner::after {
    height: 50%;
    animation-delay: 0.3s;
}

@keyframes waveBar {
    0%   { height: 30%; }
    100% { height: 100%; }
}

/* Fallback: if no inner span, show simple 3-bar via background */
.spinner:empty {
    width: 24px;
    height: 1.2rem;
    gap: 0;
    background:
        linear-gradient(var(--accent), var(--accent)) 0   100% / 4px 40%,
        linear-gradient(var(--accent), var(--accent)) 8px 100% / 4px 70%,
        linear-gradient(var(--accent), var(--accent)) 16px 100% / 4px 50%;
    background-repeat: no-repeat;
    animation: waveSpinner 0.8s ease-in-out infinite alternate;
}

@keyframes waveSpinner {
    0%   { background-size: 4px 30%, 4px 70%, 4px 50%; }
    50%  { background-size: 4px 80%, 4px 40%, 4px 90%; }
    100% { background-size: 4px 50%, 4px 100%, 4px 30%; }
}

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--loading-overlay);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay .spinner {
    width: 36px;
    height: 2rem;
}


/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
    color: #fff;
    animation: toastIn 0.35s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
}

.toast-success {
    background: rgba(92,183,122,0.92);
}

.toast-error {
    background: rgba(212,88,74,0.92);
}

.toast-info {
    background: rgba(232,168,73,0.92);
    color: var(--bg-deep);
}

@keyframes toastIn {
    from { transform: translateX(100%) scale(0.9); opacity: 0; }
    to   { transform: translateX(0) scale(1); opacity: 1; }
}


/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state h2 {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.empty-state p {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}


/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 1500;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { transform: translateY(16px) scale(0.97); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal h2 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}


/* ============================================================
   Toggle Switch
   ============================================================ */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--bg-elevated);
    border-radius: 50%;
    transition: transform 0.3s;
}

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

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}


/* ============================================================
   Range Slider
   ============================================================ */
.form-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    margin: 0.5rem 0;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}


/* ============================================================
   Admin Stats Grid
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.stat-value {
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ============================================================
   Tables (Admin)
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.92rem;
}

.data-table thead tr {
    border-bottom: 2px solid var(--border);
}

.data-table th {
    text-align: left;
    padding: 0.65rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background: var(--accent-glow);
}

.data-table .mono {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.88rem;
}


/* ============================================================
   Login / Register (standalone pages)
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    position: relative;
    overflow: hidden;
}

/* Amber radial glow behind the card */
.auth-page::before {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(232,168,73,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

.auth-card .logo {
    font-family: "Fraunces", "Noto Serif SC", Georgia, serif;
    font-style: italic;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin-bottom: 0.35rem;
    letter-spacing: -0.03em;
}

.auth-card .subtitle {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.auth-card .form-group {
    margin-bottom: 1.15rem;
}

.auth-card label {
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.auth-card input::placeholder {
    color: var(--text-muted);
}

.auth-card .auth-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: var(--bg-deep);
    border: none;
    border-radius: var(--radius);
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s, transform 0.15s;
}

.auth-card .auth-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.01);
}

.auth-card .auth-btn:active {
    transform: scale(0.985);
}

.auth-card .auth-btn.secondary {
    background: var(--bg-elevated-2);
    color: var(--text-secondary);
    margin-top: 0;
}

.auth-card .auth-btn.secondary:hover {
    background: var(--border);
}

.auth-card .error {
    color: var(--danger);
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 0.85rem;
    display: none;
}

.auth-card .success {
    color: var(--success);
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 0.85rem;
    display: none;
}

.auth-card .links {
    text-align: center;
    margin-top: 1.25rem;
    font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
    font-size: 0.92rem;
}

.auth-card .links a {
    color: var(--accent);
}

.auth-card .links a:hover {
    color: var(--accent-hover);
}

.code-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.code-row input {
    width: 100%;
}

.code-row button {
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
}

.step { display: none; }
.step.active { display: block; }


/* ============================================================
   Episode Inline Preview
   ============================================================ */
.episodes-inline {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.episodes-inline > div {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.15s;
}

.episodes-inline > div:hover {
    background: var(--accent-glow);
}

.episodes-inline > div:last-child {
    border-bottom: none;
}


/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
        gap: 0.25rem;
    }

    .nav-brand {
        margin-right: 1rem;
        font-size: 1.15rem;
    }

    .nav-links a {
        font-size: 0.88rem;
        padding: 0.3rem 0.5rem;
    }

    .container {
        margin: 1rem auto;
        padding: 0 0.85rem;
    }

    .card {
        padding: 1.15rem;
        border-radius: var(--radius);
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-header h1 {
        font-size: 1.25rem;
    }

    .item-list .item {
        padding: 1rem;
        gap: 0.75rem;
    }

    .item-title {
        font-size: 0.95rem;
    }

    .item-summary {
        font-size: 0.9rem;
        line-height: 1.65;
    }

    .date-nav {
        gap: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.65rem;
    }

    .auth-card {
        margin: 1rem;
        padding: 1.75rem;
    }

    .data-table {
        font-size: 0.88rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.4rem;
    }

    .modal {
        width: 94%;
        padding: 1.25rem;
    }
}

@media (max-width: 640px) {
    .navbar {
        padding: 0 0.75rem;
        height: 50px;
    }

    .nav-brand {
        margin-right: 0.5rem;
        font-size: 1.05rem;
    }

    .nav-links {
        gap: 0;
    }

    .nav-links a {
        font-size: 0.92rem;
        padding: 0.25rem 0.4rem;
    }

    .container {
        margin: 0.75rem auto;
        padding: 0 0.65rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .card-header > div {
        justify-content: stretch;
    }

    .card-header > div .btn {
        flex: 1;
    }

    .item-list .item {
        gap: 0.65rem;
        padding: 0.85rem;
    }

    .score {
        width: 2rem;
    }

    .item-title {
        font-size: 0.9rem;
    }

    .item-meta {
        font-size: 0.8rem;
    }

    .item-summary {
        font-size: 0.85rem;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .podcast-result {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .podcast-artwork {
        width: 42px;
        height: 42px;
        border-radius: 8px;
    }

    .podcast-result-info {
        flex: 1;
        min-width: 0;
    }

    .podcast-result-name {
        font-size: 0.88rem;
        white-space: normal;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .podcast-result-meta {
        font-size: 0.8rem;
    }

    .podcast-result > div:last-of-type {
        width: 100%;
        justify-content: flex-end;
    }

    .date-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .date-nav .date-range-row {
        display: flex;
        gap: 0.4rem;
        align-items: center;
    }

    .date-nav input[type="date"] {
        flex: 1;
        min-width: 0;
    }

    .form-row {
        gap: 0.5rem;
    }

    .source-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .source-name {
        font-size: 0.88rem;
    }

    .source-url {
        font-size: 0.78rem;
        word-break: break-all;
        white-space: normal;
    }

    .source-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .auth-card {
        padding: 1.5rem;
    }
}
