/* =========================================
           1. DESIGN TOKENS & THEME ENGINE
           ========================================= */
:root {

    --accent-gold: #fbbf24;
    --red: #f43f5e;
    --green: #10b981;
    --orange: #f97316;
    --blue: #3b82f6;
    --font-ui: 'Outfit', sans-serif;
    --font-read: 'Merriweather', serif;
    --header-h: 44px;
    --card-radius: 24px;
    --max-width: 1200px;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* DARK THEME */
:root[data-theme="dark"] {
    --bg-body: #09090b;
    --bg-card: #18181b;
    --bg-modal: #18181b;
    --bg-overlay: #09090b;
    --text-main: #f4f4f5;
    --text-muted: #c5c5d1;
    --primary: #fbbf24;
    --primary-dim: rgba(251, 191, 36, 0.15);
    --highlight-bg: rgba(251, 191, 36, 0.15);
    --highlight-bold-text: #eac587;
    --chip-active: #fbbf24;
    --border-glass: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(9, 9, 11, 0.85);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.6);
    --highlight-bg: rgba(45, 212, 191, 0.15);
    --cloze-bg: rgba(255, 255, 255, 0.1);
    --cloze-border: #52525b;
    --quiz-bg: #121214;
    --quiz-mask: #27272a;
    --gradient-text-card: radial-gradient(circle at 0% 100%, #1e1b4b 0%, #18181b 50%),
        radial-gradient(circle at 100% 0%, #0f766e 0%, #18181b 50%);
    --scroll-track: #27272a;
    --scroll-thumb: #52525b;
    --chip-bg: #27272a;
    --chip-active-text: #000;
    --toolbar-bg: rgba(24, 24, 27, 0.75);
    --toolbar-border: rgba(255, 255, 255, 0.1);
    --toolbar-text: rgba(255, 255, 255, 0.8);
    --toolbar-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* LIGHT THEME */
:root[data-theme="light"] {
    --bg-body: #f0fdfa;
    --bg-card: #ffffff;
    --bg-modal: #ffffff;
    --bg-overlay: #f0fdfa;
    --text-main: #1e293b;
    --text-muted: #64748b;

    --primary: #1bc4b6;
    --primary-dim: rgba(13, 148, 136, 0.15);
    --highlight-bg: rgba(13, 148, 136, 0.15);
    --highlight-bold-text: #296863;

    --border-glass: rgba(0, 0, 0, 0.06);
    --bg-glass: rgba(255, 255, 255, 0.9);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.1);
    --highlight-bg: rgba(45, 212, 191, 0.25);
    --cloze-bg: rgba(0, 0, 0, 0.05);
    --cloze-border: #cbd5e1;
    --quiz-bg: #f8fafc;
    --quiz-mask: #e2e8f0;
    --gradient-text-card: radial-gradient(circle at 0% 100%, #e0f2fe 0%, #ffffff 60%),
        radial-gradient(circle at 100% 0%, #f0fdfa 0%, #ffffff 60%);
    --scroll-track: #e2e8f0;
    --scroll-thumb: #94a3b8;
    --chip-bg: #e2e8f0;
    --chip-active: #24e3ca;
    --chip-active-text: #000;
    --toolbar-bg: rgba(255, 255, 255, 0.75);
    --toolbar-border: rgba(0, 0, 0, 0.1);
    --toolbar-text: #334155;
    --toolbar-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);

}

:root[data-theme="sepia"] {
    /* Refined Warm Palette - Premium Reading Experience */
    --bg-body: #f5eedc;
    --bg-card: #fffef8;
    --bg-modal: #fffef8;
    --bg-overlay: #f5eedc;
    --text-main: #2d1f0f;
    --text-muted: #6b5d4f;
    --primary: #c17011;
    --primary-dim: rgba(193, 112, 17, 0.12);
    --border-glass: rgba(45, 31, 15, 0.12);
    --bg-glass: rgba(255, 254, 248, 0.95);
    --shadow-soft: 0 10px 40px rgba(45, 31, 15, 0.1);
    --shadow-hover: 0 20px 50px rgba(45, 31, 15, 0.15);
    --highlight-bg: rgba(193, 112, 17, 0.15);
    --highlight-bold-text: #8b5a0f;
    --cloze-bg: rgba(193, 112, 17, 0.08);
    --cloze-border: #e8dcc4;
    --gradient-text-card: linear-gradient(135deg, #fffef8 0%, #f5eedc 100%);
    --chip-bg: #e8dcc4;
    --chip-active: #c17011;
    --chip-active-text: #fffef8;
    --scroll-thumb: #d4c3a4;

    --toolbar-bg: rgba(255, 254, 248, 0.92);
    --toolbar-border: rgba(45, 31, 15, 0.12);
    --toolbar-text: #2d1f0f;
    --toolbar-shadow: 0 12px 30px rgba(45, 31, 15, 0.12);
}


/* =========================================
           2. BASE & UTILITY
           ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background var(--transition-smooth), color var(--transition-smooth);
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

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

/* Noise Texture for that "Premium" feel */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* =========================================
           3. LOADER & ERROR SCREEN (The Safety Net)
           ========================================= */
#startup-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-glass);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#debug-console {
    display: none;
    width: 90%;
    max-width: 600px;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 15px;
    border-radius: 12px;
    font-family: monospace;
    font-size: 0.8rem;
    margin-top: 20px;
    text-align: left;
}

/* =========================================
           4. HEADER
           ========================================= */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.brand {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.2px;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    /* Sleek Compact Pill Background */
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 3px 11px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
}

.brand:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.brand span {
    color: var(--primary);
    font-weight: 900;
}

/* Sepia Theme - Sleek Warm Pill */
[data-theme="sepia"] .brand {
    background: linear-gradient(135deg, rgba(193, 112, 17, 0.85) 0%, rgba(139, 90, 15, 0.8) 100%);
    border: 1px solid rgba(193, 112, 17, 0.35);
    box-shadow: 0 2px 10px rgba(45, 31, 15, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.12);
    color: #fffef8;
}

[data-theme="sepia"] .brand span {
    color: #ffd68a;
}

[data-theme="sepia"] .brand:hover {
    box-shadow: 0 4px 14px rgba(45, 31, 15, 0.22), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

/* Dark Theme - Sleek Dark Pill */
[data-theme="dark"] .brand {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(251, 191, 36, 0.2);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 15px rgba(251, 191, 36, 0.08);
    color: #ffffff;
}

[data-theme="dark"] .brand span {
    color: var(--primary);
}

/* Light Theme - Sleek Light Pill */
[data-theme="light"] .brand {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(20, 184, 166, 0.15);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06), inset 0 1px 1px rgba(255, 255, 255, 0.7);
    color: #0f172a;
}

[data-theme="light"] .brand span {
    color: #0d9488;
}

.header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    outline: none;
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--border-glass);
}

.icon-btn:active {
    transform: translateY(0) scale(0.95);
    box-shadow: none;
}

.icon-btn.active-state {
    color: var(--primary);
    background: var(--highlight-bg);
}

.icon-btn.liked svg {
    fill: var(--red);
    stroke: var(--red);
}

.icon-btn svg {
    width: 23px;
    height: 23px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    display: none;
}

/* Info about note export */
.info-icon-btn {
    color: var(--primary);
    opacity: 0.8;
    transition: all 0.2s ease;
}

.info-icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.tutorial-list li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--text-muted);
}

.tutorial-highlight {
    color: var(--primary);
    font-weight: 700;
}

#modal-notekash-tutorial {
    z-index: 300 !important;
    /* Higher than settings (200) */
}

/* =========================================
        5. MAIN FEED & CARDS
        ========================================= */
#app-container {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-top: var(--header-h);
    overscroll-behavior-y: contain;
    will-change: scroll-position;
}

@media (min-width: 769px) {
    #feed-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
        gap: 40px;
        padding: 40px;
        max-width: var(--max-width);
        margin: 0 auto;
    }

    .news-card {
        height: 650px;
        border-radius: var(--card-radius);
        border: 1px solid var(--border-glass);
        box-shadow: var(--shadow-soft);
        overflow: hidden;
    }
}

.action-toolbar-container {
    padding: 15px 20px 30px 20px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.action-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 15px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--toolbar-border);
    box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    padding: 4px 20px;
    border-radius: 50px;
    min-width: 180px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.action-toolbar .icon-btn svg {
    width: 28px;
    height: 28px;
    stroke-width: 1.8;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-toolbar .icon-btn:hover svg {
    transform: scale(1.2);
}

.action-toolbar .icon-btn {
    padding: 8px;
    color: var(--toolbar-text);
}

.action-toolbar .icon-btn:hover {
    color: var(--primary);
    transform: scale(1.15);
    background: transparent;
}

.action-toolbar .icon-btn.liked {
    color: var(--red) !important;
}

@media (max-width: 768px) {
    #app-container {
        scroll-snap-type: y mandatory;
        padding-top: 0;
        height: 100dvh;
    }

    header {
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
        backdrop-filter: none;
        border: none;
        pointer-events: none;
        height: 56px;
        padding: 0 16px;
        display: flex;
        align-items: center;
        width: 100%;
        box-shadow: none;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
    }

    header>* {
        pointer-events: auto;
    }

    .brand {
        color: #fff;
        font-size: 1.2rem;
        font-weight: 800;
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        display: flex;
        align-items: center;
    }

    .brand span {
        color: var(--primary);
        font-weight: 900;
    }

    .icon-btn {
        color: rgba(255, 255, 255, 0.95);
    }

    .news-card {
        height: 100dvh;
        width: 100%;
        scroll-snap-align: start;
        scroll-snap-stop: normal;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
    }

    .scroll-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        padding-bottom: 20px;
    }

    .card-footer {
        display: none !important;
    }

    .card-img {
        height: 40vh;
        background-position: center top !important;
    }
}

.news-card {
    background: var(--bg-card);
    position: relative;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Sepia Theme - Premium Paper Feel */
[data-theme="sepia"] .news-card {
    box-shadow: 0 4px 20px rgba(45, 31, 15, 0.08), 0 1px 3px rgba(45, 31, 15, 0.05);
    border: 1px solid rgba(193, 112, 17, 0.08);
}

[data-theme="sepia"] .news-card:hover {
    box-shadow: 0 12px 35px rgba(45, 31, 15, 0.12), 0 4px 10px rgba(45, 31, 15, 0.08);
    border-color: rgba(193, 112, 17, 0.15);
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.card-img {
    height: 45vh;
    min-height: 250px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    position: relative;
}

.spin-active {
    animation: spin 1s linear infinite;
    color: var(--primary) !important;
}

.card-body {
    padding: 24px 24px 4px 24px;
    position: relative;
    z-index: 2;
}

/* --- TEXT ONLY CARD (LIVE APP) --- */
.news-card.text-only .scroll-content {
    background: var(--bg-card);
    background-image: linear-gradient(to bottom right, var(--bg-card), var(--bg-body));
}

.news-card.text-only .card-body {
    padding: 80px 30px 40px 30px;
    height: auto;
    display: block;
    position: relative;
    overflow: visible;
}

.news-card.text-only .card-body::before {
    content: '“';
    position: absolute;
    top: -20px;
    left: 20px;
    font-family: var(--font-read);
    font-size: 10rem;
    line-height: 1;
    color: var(--primary);
    opacity: 0.1;
    pointer-events: none;
    z-index: -1;
}

.news-card.text-only h2 {
    font-size: 2rem;
    margin-bottom: 24px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.news-card.text-only .summary-box {
    text-align: left;
    font-size: 1.25rem;
    line-height: 1.8;
    position: relative;
    z-index: 2;
}

/* Uncluttered Header for Text Cards */
.news-card.text-only .meta-row {
    justify-content: center !important;
    gap: 25px !important;
    margin-bottom: 30px !important;
    position: relative;
    z-index: 5;
}

.news-card.text-only .date::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 12px;
    background: var(--text-muted);
    opacity: 0.4;
}

/* --- EXPORT CARD (MAGAZINE STYLE) --- */
.news-card.export-mode {
    height: auto !important;
    min-height: auto !important;
    width: 600px !important;
    background: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: none !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    z-index: -9999;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Fix Overlay Issue: Move Metadata to Left/Right Split */
.news-card.export-mode .meta-row {
    justify-content: space-between !important;
    padding-left: 0 !important;
    margin-top: 10px !important;
    width: 100%;
    position: relative;
    z-index: 5;
}

/* PREMIUM TEXT-ONLY MODE (When no image exists) */
.news-card.export-mode.premium-text-only {
    background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%) !important;
    position: relative;
}

/* Extra margin for text-only mode to clear the top-right watermark */
.news-card.export-mode.premium-text-only .meta-row {
    margin-top: 80px !important;
}

.news-card.export-mode.premium-text-only::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(#334155 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

.news-card.export-mode.premium-text-only::after {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    filter: blur(60px);
    z-index: 0;
}

.news-card.export-mode.premium-text-only h2 {
    color: #ffffff !important;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.news-card.export-mode.premium-text-only .summary-box {
    color: #cbd5e1 !important;
    font-weight: 500 !important;
}

.news-card.export-mode.premium-text-only .date {
    color: rgba(255, 255, 255, 0.6) !important;
    text-shadow: none !important;
}

/* Hide UI in Export */
.news-card.export-mode .card-img,
.news-card.export-mode .action-toolbar-container,
.news-card.export-mode .card-footer,
.news-card.export-mode .watermark-overlay,
.news-card.export-mode .ad-label-corner,
.news-card.export-mode .export-logo-top {
    display: none !important;
}

/* 16:11 Aspect Ratio Image */
.export-image-16x11 {
    width: 100% !important;
    aspect-ratio: 16 / 11 !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    border-bottom: 1px solid var(--border-glass);
    z-index: 1;
    background-color: var(--bg-body);
    margin: 0 !important;
}

/* Export Typography (Tight & Optimized) */
.news-card.export-mode .card-body {
    padding: 15px 20px 40px 20px !important;
    /* Optimized Padding */
    background: var(--bg-card) !important;
    flex: 1;
    /* Ensure text wrapping for all child elements */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Quote Mark for Text-Only Export */
.news-card.export-mode .card-body::before {
    content: '“';
    position: absolute;
    top: -15px;
    left: 20px;
    font-family: var(--font-read);
    font-size: 8rem;
    line-height: 1;
    color: var(--primary);
    opacity: 0.07;
    pointer-events: none;
    z-index: 0;
}

.news-card.export-mode h2 {
    font-size: 2.4rem !important;
    line-height: 1.2 !important;
    margin-bottom: 12px !important;
    color: var(--text-main) !important;
    letter-spacing: -0.03em !important;
    position: relative;
    z-index: 2;
    /* Fix text wrapping */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    width: 100% !important;
    max-width: 100% !important;
}

.news-card.export-mode .summary-box {
    font-family: var(--font-read) !important;
    font-size: 1.35rem !important;
    line-height: 1.6 !important;
    color: var(--text-muted) !important;
    opacity: 0.95 !important;
    position: relative;
    z-index: 2;
    /* Fix text wrapping and prevent overlap */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Export Header Fix (Uncluttered) */


.news-card.export-mode .badge {
    font-size: 0.95rem !important;
    padding: 6px 14px !important;
    letter-spacing: 1px !important;
}

.news-card.export-mode .date {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    opacity: 0.9 !important;
}

.news-card.export-mode .date::before {
    display: none !important;
}


/* --- 1. EXPORT MODE: CLOZE, FOOTER & CLEAN BADGES --- */
.news-card.export-mode .keyword {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 4px !important;
    margin: 0 !important;
    color: var(--primary) !important;
    font-family: var(--font-ui) !important;
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    letter-spacing: 1.5px !important;
    opacity: 1 !important;
    display: inline-block !important;
    vertical-align: baseline !important;
    /* Ensure keywords wrap properly */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
}

.news-card.export-mode .keyword::after {
    content: none !important;
}

/* EXPORT MODE: Replace Bold with Color Highlighting (Fixes html2canvas overlap) */
.news-card.export-mode .summary-box b,
.news-card.export-mode .summary-box strong,
.news-card.export-mode b,
.news-card.export-mode strong {
    /* REMOVE BOLD - Use color instead to prevent overlap */
    font-weight: inherit !important;
    /* Theme-sensitive highlight color - Default (Dark theme) */
    color: #fbbf24 !important;
    /* Warm gold for dark mode */
    /* Clean text properties */
    display: inline !important;
    word-spacing: normal !important;
    letter-spacing: normal !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Light Theme: Teal accent color */
[data-theme="light"] .news-card.export-mode .summary-box b,
[data-theme="light"] .news-card.export-mode .summary-box strong,
[data-theme="light"] .news-card.export-mode b,
[data-theme="light"] .news-card.export-mode strong {
    color: #0d9488 !important;
    /* Beautiful teal */
    font-weight: inherit !important;
}

/* Sepia Theme: Rich amber color */
[data-theme="sepia"] .news-card.export-mode .summary-box b,
[data-theme="sepia"] .news-card.export-mode .summary-box strong,
[data-theme="sepia"] .news-card.export-mode b,
[data-theme="sepia"] .news-card.export-mode strong {
    color: #c17011 !important;
    /* Warm amber */
    font-weight: inherit !important;
}

.export-footer {
    display: none !important;
}

.news-card.export-mode .badge {
    box-shadow: none !important;
    border: none !important;
}

/* --- 2. WATERMARK ENGINE (3D & THEME AWARE) - ENHANCED VISIBILITY --- */
.export-watermark-top {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 100 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4)) !important;
    /* Enhanced 3D Pop */
    padding: 10px 18px !important;
    border-radius: 50px !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
    transition: all 0.3s ease !important;
}

.watermark-text {
    font-family: var(--font-ui) !important;
    font-weight: 900 !important;
    font-size: 1.25rem !important;
    line-height: 1 !important;
    letter-spacing: -0.5px !important;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2) !important;
    /* Carved Depth */
}

.watermark-badge {
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* Watermark Themes - Enhanced for Premium Visibility */
[data-theme="dark"] .export-watermark-top {
    background: rgba(0, 0, 0, 0.75) !important;
    border: 1.5px solid rgba(251, 191, 36, 0.3) !important;
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.15) !important;
}

[data-theme="dark"] .watermark-text {
    color: #ffffff !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .watermark-text span {
    color: var(--primary) !important;
}

[data-theme="dark"] .watermark-badge {
    background: var(--primary) !important;
    color: #000000 !important;
}

[data-theme="sepia"] .export-watermark-top {
    background: linear-gradient(135deg, rgba(193, 112, 17, 0.95) 0%, rgba(139, 90, 15, 0.92) 100%) !important;
    border: 1.5px solid rgba(193, 112, 17, 0.4) !important;
    box-shadow: 0 8px 24px rgba(45, 31, 15, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.1) !important;
}

[data-theme="sepia"] .watermark-text {
    color: #fffef8 !important;
    text-shadow: 0 2px 6px rgba(45, 31, 15, 0.4) !important;
}

[data-theme="sepia"] .watermark-text span {
    color: #ffd68a !important;
    font-weight: 900 !important;
}

[data-theme="sepia"] .watermark-badge {
    background: rgba(255, 254, 248, 0.95) !important;
    color: #8b5a0f !important;
    font-weight: 800 !important;
    border: 1px solid rgba(193, 112, 17, 0.2) !important;
}

[data-theme="light"] .export-watermark-top {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1.5px solid rgba(20, 184, 166, 0.25) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.8) !important;
}

[data-theme="light"] .watermark-text {
    color: #0f172a !important;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8) !important;
}

[data-theme="light"] .watermark-text span {
    color: #0d9488 !important;
}

[data-theme="light"] .watermark-badge {
    background: #14b8a6 !important;
    color: #ffffff !important;
}


/* --- 3. METADATA & CARVED EFFECTS (Main App) --- */
.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    opacity: 0.9;
}

.badge {
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.2s ease;
    background: var(--badge-bg, var(--primary));
    color: var(--badge-text, #000);
    box-shadow: var(--badge-shadow, none);
    border-color: var(--badge-border, transparent);
}

.badge:active {
    transform: scale(0.95);
}

.date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--date-text, var(--text-muted));
    text-shadow: var(--text-carve, none);
    /* Carved Effect */
}

/* Metadata Theme Variables */
:root[data-theme="dark"] {
    --badge-bg: var(--primary);
    --badge-text: #000000;
    --badge-shadow: 0 2px 10px rgba(251, 191, 36, 0.2);
    --date-text: var(--text-muted);
    --text-carve: 0 1px 2px rgba(0, 0, 0, 0.8);
}

:root[data-theme="sepia"] {
    --badge-bg: linear-gradient(135deg, rgba(193, 112, 17, 0.12) 0%, rgba(139, 90, 15, 0.08) 100%);
    --badge-text: #8b5a0f;
    --badge-border: rgba(193, 112, 17, 0.25);
    --badge-shadow: 0 2px 6px rgba(45, 31, 15, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.6);
    --date-text: #6b5d4f;
    --text-carve: 1px 1px 0 rgba(255, 255, 255, 0.9);
}

:root[data-theme="light"] {
    --badge-bg: #f1f5f9;
    --badge-text: #0f766e;
    --badge-border: #e2e8f0;
    --badge-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --date-text: #64748b;
    --text-carve: 0 1px 0 rgba(255, 255, 255, 1);
}

/* --- 4. TYPOGRAPHY & FOOTER --- */
h2 {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 16px;
    font-family: var(--font-ui);
    letter-spacing: -0.02em;
}

.summary-box {
    font-family: var(--font-read);
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.keyword {
    background: var(--highlight-bg);
    color: var(--primary);
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dashed var(--primary);
    transition: all 0.3s ease;
    user-select: none;
}

/* Sepia Theme - Premium Keyword Highlighting */
[data-theme="sepia"] .keyword {
    background: rgba(193, 112, 17, 0.15);
    color: #8b5a0f;
    border-bottom: 1.5px dashed rgba(193, 112, 17, 0.5);
    box-shadow: 0 1px 3px rgba(193, 112, 17, 0.08);
    font-weight: 700;
}

[data-theme="sepia"] .keyword:hover {
    background: rgba(193, 112, 17, 0.22);
    border-bottom-color: #c17011;
    box-shadow: 0 2px 4px rgba(193, 112, 17, 0.15);
}

.keyword.is-hidden {
    background: var(--cloze-bg);
    color: transparent;
    border-bottom: 2px solid var(--cloze-border);
}

.keyword.is-hidden:hover {
    border-color: var(--primary);
}

.summary-box b,
.summary-box strong {
    background: transparent;
    color: var(--highlight-bold-text);
    padding: 0;
    font-weight: 800;
    /* CRITICAL FIX: Prevent text overlap in bold highlights */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    white-space: normal !important;
    display: inline !important;
    /* Preserve natural word spacing */
    word-spacing: normal !important;
    letter-spacing: normal !important;
}


.card-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    align-items: center;
    border-top: 1px solid var(--border-glass);
    background: var(--bg-card);
    z-index: 10;
}

/* =========================================
6. 3D QUIZ SYSTEM (PREMIUM & FLIP RESTORED)
========================================= */
#quiz-fullscreen-layer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: var(--bg-overlay);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding-top: 10px;
}

#quiz-fullscreen-layer.active {
    opacity: 1;
    pointer-events: auto;
}

.quiz-navbar {
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    flex-shrink: 0;
}

.quiz-progress-track {
    flex: 1;
    height: 6px;
    background: var(--border-glass);
    border-radius: 10px;
    margin: 0 20px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.5s ease;
}

.quiz-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    perspective: 2000px;
    overflow: hidden;
}

/* THE CARD OBJECT */
.quiz-card-wrapper {
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 75vh;
    min-height: 400px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    transform: translateX(0) rotateY(0deg) scale(1);
    margin-bottom: 20px;
}

.quiz-card-wrapper.is-flipped {
    transform: translateX(0) rotateY(180deg);
}

.card-exit-left {
    animation: swipeOut 0.4s forwards cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

@keyframes swipeOut {
    0% {
        transform: translateX(0) rotateY(0deg) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateX(-120%) rotateY(-20deg) scale(0.9);
        opacity: 0;
    }
}

.card-enter-stack {
    animation: stackIn 0.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes stackIn {
    0% {
        transform: translateY(40px) scale(0.9);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.card-center-active {
    transform: translateX(0) rotateY(0deg);
    opacity: 1;
}

/* THE VISUAL FACES (Front & Back) */
.quiz-face {
    position: absolute;
    inset: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: linear-gradient(145deg, var(--bg-card), var(--bg-body));
    border-radius: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow:
        0 20px 50px -10px rgba(0, 0, 0, 0.5),
        0 10px 20px -10px rgba(0, 0, 0, 0.3);

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.quiz-back {
    transform: rotateY(180deg);
}

.quiz-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}

.quiz-scroll-area::-webkit-scrollbar {
    display: none;
}

.quiz-question-text {
    font-family: var(--font-read);
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--text-main);
    text-align: left;
    margin-top: 0;
    padding-top: 0;
    transition: font-size 0.2s ease;
}

.quiz-question-text.enlarged {
    font-size: 1.6rem;
    line-height: 1.5;
}

@media (max-width: 768px) {

    #quiz-fullscreen-layer {
        padding-top: 0 !important;
    }

    .quiz-navbar {
        padding: 4px 12px;
        height: 45px;
        min-height: 45px;
    }

    .quiz-navbar .quiz-header-label {
        font-size: 0.8rem;
    }

    .quiz-actions-area {
        padding: 10px 12px !important;
        padding-bottom: 20px !important;
    }

    .quiz-stage {
        padding: 5px 10px;
    }

    .quiz-card-wrapper {
        margin-bottom: 5px;
        height: 100%;
    }

    .quiz-scroll-area {
        padding: 20px 15px;
    }

    .srs-btn {
        padding: 8px 4px;
        border-radius: 12px;
    }

    .srs-btn span:first-child {
        font-size: 0.8rem;
    }

    .srs-btn span:last-child {
        font-size: 0.55rem;
    }

    .btn-large {
        padding: 10px;
    }

}

.quiz-navbar .icon-btn {
    color: var(--text-main) !important;
    background: rgba(125, 125, 125, 0.15);
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-glass);
    z-index: 2002;
}

.quiz-navbar .icon-btn:hover {
    background: var(--red);
    color: white !important;
    border-color: var(--red);
}

/* Sepia Theme - Enhanced Quiz Close Button Visibility */
[data-theme="sepia"] .quiz-navbar .icon-btn {
    color: #2d1f0f !important;
    background: rgba(193, 112, 17, 0.15) !important;
    border: 1.5px solid rgba(193, 112, 17, 0.3) !important;
    box-shadow: 0 2px 6px rgba(45, 31, 15, 0.1);
}

[data-theme="sepia"] .quiz-navbar .icon-btn:hover {
    background: #c17011 !important;
    color: #fffef8 !important;
    border-color: #c17011 !important;
    box-shadow: 0 3px 8px rgba(193, 112, 17, 0.3);
}

/* Sepia Theme - Quiz Menu Modal Close Button */
[data-theme="sepia"] #modal-quiz-menu .icon-btn {
    color: #2d1f0f !important;
    background: rgba(193, 112, 17, 0.2) !important;
    border: 1.5px solid rgba(193, 112, 17, 0.35) !important;
    box-shadow: 0 2px 8px rgba(45, 31, 15, 0.12);
    opacity: 1 !important;
}

[data-theme="sepia"] #modal-quiz-menu .icon-btn:hover {
    background: #c17011 !important;
    color: #fffef8 !important;
    border-color: #a05a0d !important;
    box-shadow: 0 4px 12px rgba(193, 112, 17, 0.3);
    transform: scale(1.05);
}

[data-theme="light"] .quiz-navbar .icon-btn,
[data-theme="light"] #modal-quiz-menu .icon-btn {
    color: #000000 !important;
    background: rgba(0, 0, 0, 0.08) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    opacity: 1 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .quiz-navbar .icon-btn:hover,
[data-theme="light"] #modal-quiz-menu .icon-btn:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

.quiz-navbar .icon-btn svg {
    stroke: currentColor;
    stroke-width: 2.5;
}

.quiz-actions-area {
    padding: 24px;
    border-top: 1px solid var(--border-glass);
    background: var(--bg-card);
    flex-shrink: 0;
    border-bottom-left-radius: 32px;
    border-bottom-right-radius: 32px;
}

/* CLOZE STYLING */
.quiz-mask {
    background: var(--quiz-mask);
    color: transparent;
    border-radius: 6px;
    padding: 2px 12px;
    margin: 0 4px;
    display: inline-block;
    border: 1px dashed var(--text-muted);
    vertical-align: middle;
    min-width: 60px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quiz-mask::after {
    content: '?';
    color: var(--text-muted);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
}

.quiz-revealed {
    color: var(--primary);
    font-weight: 800;
    background: var(--highlight-bg);
    padding: 4px 10px;
    border-radius: 6px;
    animation: highlightPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
}

@keyframes highlightPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* BUTTONS */
.srs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.srs-btn {
    padding: 14px 10px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    user-select: none;
}

.srs-btn:hover {
    transform: translateY(-4px);
    background: var(--bg-glass);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-dim);
}

.srs-btn:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

.srs-btn span:first-child {
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.srs-btn span:last-child {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.srs-again {
    border-bottom: 4px solid #ef4444;
}

.srs-again:hover {
    color: #ef4444;
}

.srs-hard {
    border-bottom: 4px solid #f59e0b;
}

.srs-hard:hover {
    color: #f59e0b;
}

.srs-good {
    border-bottom: 4px solid #3b82f6;
}

.srs-good:hover {
    color: #3b82f6;
}

.srs-easy {
    border-bottom: 4px solid #10b981;
}

.srs-easy:hover {
    color: #10b981;
}

#quiz-summary {
    position: absolute;
    inset: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 5;
    display: none;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 40px 20px;
    padding-bottom: 60px;
}

#quiz-summary.visible {
    display: flex;
    animation: summarySpringIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes summarySpringIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* GRADE PILL SYSTEM */
.grade-pill {
    padding: 6px 18px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.grade-gold {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #f59e0b 100%);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), 0 4px 15px rgba(245, 158, 11, 0.4);
    animation: goldPulse 2s ease-in-out infinite;
}

@keyframes goldPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), 0 4px 15px rgba(245, 158, 11, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(251, 191, 36, 0.8), 0 6px 20px rgba(245, 158, 11, 0.6);
    }
}

.grade-green {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.grade-blue {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.grade-indigo {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.grade-orange {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.grade-burnt-orange {
    background: linear-gradient(135deg, #c2410c 0%, #ea580c 100%);
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.4);
}

.grade-red {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
    animation: redPulse 1.5s ease-in-out infinite;
}

@keyframes redPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* RESULT CARD STYLING */
.result-card {
    background: var(--bg-glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 24px;
    border: 1px solid var(--border-glass);
    padding: 30px 25px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.95rem;
}

.stat-row:last-child {
    border-bottom: none;
}

/* BAR CHART STYLES */
.chart-container {
    background: var(--bg-elevated);
    border-radius: 16px;
    padding: 15px;
    border: 1px solid var(--border-glass);
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 80px;
    gap: 4px;
    padding-top: 10px;
}

.chart-bar {
    flex: 1;
    min-width: 12px;
    max-width: 20px;
    background: linear-gradient(to top, var(--primary), var(--primary-dim));
    border-radius: 4px 4px 0 0;
    transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.chart-bar::after {
    content: attr(data-score);
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.chart-bar:hover::after {
    opacity: 1;
}

.chart-bar.animate {
    animation: barGrow 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes barGrow {
    0% {
        height: 0 !important;
    }

    100% {
        height: var(--bar-height);
    }
}

/* 1. STREAK FIRE ENGINE */
.streak-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    position: relative;
}

.fire-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    margin-bottom: 5px;
}

.fire-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 0 10px rgba(255, 100, 0, 0.5));
    animation: breatheFire 2s infinite ease-in-out;
    transform-origin: center bottom;
    display: block;
}

.streak-count {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--bg-card);
    border: 2px solid var(--border-glass);
    color: var(--text-main);
    font-weight: 800;
    font-size: 0.9rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.streak-label {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
}

.streak-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

@keyframes breatheFire {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(255, 69, 0, 0.4));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 15px rgba(255, 69, 0, 0.8));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(255, 69, 0, 0.4));
    }
}

/* DAILY MASTERY BUTTON (Gold Theme) */
.btn-mastery {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-bottom: 4px solid #b45309;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-mastery:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.45);
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-mastery:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

/* 2. CRAM MODE BUTTON STYLING */
.btn-cram {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-bottom: 4px solid #3730a3;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-cram:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
}

.btn-cram:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

/* 3. STATUS CAPSULE (On Flashcards) */
.status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    width: 100%;
    position: relative;
}

.clean-capsule {
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    display: inline-block;
    backdrop-filter: blur(6px);
    transition: transform 0.2s ease;
}

.clean-capsule:hover {
    transform: scale(1.05);
}

.status-new {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.35);
}

.status-again {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    border-color: rgba(244, 63, 94, 0.3);
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.35);
}

.status-hard {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    border-color: rgba(249, 115, 22, 0.3);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.35);
}

.status-good {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.35);
}

.status-easy {
    background: rgba(20, 184, 166, 0.15);
    color: #14b8a6;
    border-color: rgba(20, 184, 166, 0.3);
    box-shadow: 0 0 15px rgba(20, 184, 166, 0.35);
}

/* The Reset Button (FIX B: Outside & Aesthetic) */
.capsule-reset-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.capsule-reset-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
    transform: rotate(-180deg);
    opacity: 1;
}

.card-status-capsule {
    display: none !important;
}

/* =========================================
7. MODALS, CHIPS & SETTINGS
========================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.visible {
    opacity: 1;
}

.modal-card {
    background: var(--bg-modal);
    width: 90%;
    max-width: 450px;
    border-radius: 24px;
    padding: 30px;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-hover);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 85vh;
    overflow-y: auto;
    padding-right: 26px;
}

.modal-card::-webkit-scrollbar {
    width: 6px;
}

.modal-card::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}

.modal-card::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
}

.modal-card::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Time Filter Modal */
.time-filter-modal {
    max-width: 400px !important;
    text-align: center;
}

.time-period-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.time-period-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-ui);
    position: relative;
    overflow: hidden;
}

.time-period-btn:hover {
    border-color: var(--primary);
    background: var(--primary-dim);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.time-period-btn:active {
    transform: translateY(0px);
}

.period-icon {
    font-size: 2rem;
    display: block;
    filter: grayscale(0.3);
    transition: filter 0.3s ease;
}

.time-period-btn:hover .period-icon {
    filter: grayscale(0);
}

.period-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    letter-spacing: -0.2px;
}

/* Sepia Theme Enhancement */
[data-theme="sepia"] .time-period-btn {
    border-color: rgba(193, 112, 17, 0.2);
}

[data-theme="sepia"] .time-period-btn:hover {
    border-color: #c17011;
    background: rgba(193, 112, 17, 0.1);
    box-shadow: 0 8px 20px rgba(45, 31, 15, 0.15);
}

/* Responsive */
@media (max-width: 480px) {
    .time-period-grid {
        grid-template-columns: 1fr;
    }
}

/* Sepia Modal Premium Enhancement */
[data-theme="sepia"] .modal-card {
    box-shadow: 0 20px 60px rgba(45, 31, 15, 0.18), 0 8px 20px rgba(45, 31, 15, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border: 1.5px solid rgba(193, 112, 17, 0.15);
}

.modal-backdrop.visible .modal-card {
    transform: translateY(0);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-glass);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 600;
    font-size: 1rem;
}

.setting-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

select {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-ui);
    outline: none;
}

/* Chips / Categories */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--chip-bg);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.chip:hover {
    background: var(--border-glass);
    color: var(--text-main);
}

.chip.active {
    background: var(--chip-active);
    color: var(--chip-active-text);
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.3);
}

/* Special 3D Depth for "All" and "Curated" chips */
.chip.chip-special {
    position: relative;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(0);
    transition: all 0.2s ease;
}

.chip.chip-special:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chip.chip-special.active {
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

[data-theme="light"] .chip.chip-special {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

[data-theme="sepia"] .chip.chip-special {
    box-shadow: 0 6px 18px rgba(45, 31, 15, 0.15),
        inset 0 1px 0 rgba(255, 254, 248, 0.6),
        inset 0 -1px 0 rgba(193, 112, 17, 0.1);
    border: 1px solid rgba(193, 112, 17, 0.12);
}

[data-theme="sepia"] .chip.chip-special.active {
    box-shadow: 0 8px 24px rgba(193, 112, 17, 0.3),
        inset 0 1px 0 rgba(255, 254, 248, 0.4),
        inset 0 -1px 0 rgba(139, 90, 15, 0.2);
}

/* Buttons */
.btn-large,
.btn-primary,
.btn-outline {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
    border: none;
    text-decoration: none;
}

.btn-large {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(to bottom, var(--primary), var(--primary));
    color: #fff;
    border-bottom: 4px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 15px var(--primary-dim);
}

/* Theme-specific Primary refinement */
[data-theme="light"] .btn-primary {
    background: linear-gradient(to bottom, #2dd4bf, #0d9488);
    border-bottom-color: #065f46;
}

[data-theme="dark"] .btn-primary {
    background: linear-gradient(to bottom, #fbbf24, #d97706);
    color: #000;
    border-bottom-color: #92400e;
}

[data-theme="sepia"] .btn-primary {
    background: linear-gradient(135deg, #c17011 0%, #a05a0d 100%);
    color: #fffef8;
    border-bottom-color: #7d4809;
    box-shadow: 0 4px 12px rgba(193, 112, 17, 0.25), 0 2px 4px rgba(45, 31, 15, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-dim);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

.btn-outline {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-bottom: 4px solid var(--border-glass);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-glass);
    border-color: var(--primary);
    border-bottom-color: var(--primary);
    transform: translateY(-2px);
}

.btn-outline:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    border-bottom: 2px solid rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-small:active {
    transform: translateY(1px);
    border-bottom-width: 0;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-main);
    color: var(--bg-body);
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-spring);
    z-index: 20000 !important;
    box-shadow: var(--shadow-soft);
    white-space: nowrap;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Micro-Interactions */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-glass);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

/* HEART POP ANIMATION */
.heart-pop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 6rem;
    color: var(--red);
    pointer-events: none;
    z-index: 50;
    opacity: 0;
}

.heart-pop.animate {
    animation: popFade 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popFade {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* SNAPSHOT STYLES */
.watermark-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.news-card.capturing .action-toolbar-container {
    display: none !important;
}

.news-card.capturing .watermark-overlay {
    top: 20px;
    right: 20px;
    display: block !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.news-card.capturing .card-img {
    margin-top: 0 !important;
    border-radius: 0 !important;
}

.news-card.capturing {
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 40px !important;
    transform: none !important;
    border: none !important;
}

.news-card.capturing .scroll-content {
    overflow: visible !important;
    height: auto !important;
}

/* DESKTOP LAYOUT ENGINE (NEW)*/
@media (min-width: 1024px) {

    /* 1. Main Container */
    #feed-list.layout-paper {
        display: block;
        max-width: 100%;
        margin: 0;
        padding: 40px;
        background: var(--bg-body);
    }

    /* 2. The Card (Viewport Window) */
    #feed-list.layout-paper .news-card {
        width: 100%;
        max-width: 1150px;
        height: 80vh;
        /* Fixed height relative to screen */
        margin: 0 auto 80px auto;

        background: var(--bg-card);
        border: 1px solid var(--border-glass);
        border-radius: 20px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);

        /* Reset any transforms */
        transform: none !important;
        /* Do NOT hide overflow here, let the child handle it */
        overflow: hidden;
    }

    /* 3. The Layout Engine (Grid) */
    #feed-list.layout-paper .scroll-content {
        display: grid;
        width: 100%;
        height: 100%;

        /* 40% Image | 60% Content (Requested Split) */
        grid-template-columns: 40% 60%;

        /* Allow rows to form naturally */
        grid-auto-rows: min-content;

        /* THIS IS THE SCROLLER */
        overflow-y: auto;
        scroll-behavior: smooth;
    }

    /* 4. LEFT PANE: Sticky Image */
    #feed-list.layout-paper .card-img {
        grid-column: 1;
        grid-row: 1 / span 10;
        position: sticky;
        top: 0;
        left: 0;
        width: 100%;
        height: 80vh;
        object-fit: cover;
        border-radius: 0;
        border-right: 1px solid var(--border-glass);
        margin: 0;
        z-index: 2;
    }

    /* 5. RIGHT PANE: Content Flow */
    #feed-list.layout-paper .card-body {
        grid-column: 2;

        padding: 60px 60px 20px 60px;
        width: 100%;

        display: flex;
        flex-direction: column;
        justify-content: flex-start;

    }

    /* 6. RIGHT PANE: Toolbar (Flows naturally after text) */
    #feed-list.layout-paper .action-toolbar-container {
        grid-column: 2;
        padding: 20px 60px 60px 60px;
        width: 100%;
        display: flex;
        justify-content: flex-end;
        background: transparent;
        border: none;
    }

    /* --- Styling Polish --- */
    #feed-list.layout-paper .action-toolbar {
        margin: 0;
        width: fit-content;
        background: var(--bg-body);
        border: 1px solid var(--border-glass);
    }

    #feed-list.layout-paper h2 {
        font-family: var(--font-read);
        font-size: 2.6rem;
        line-height: 1.2;
        margin-bottom: 25px;
        color: var(--text-main);
    }

    #feed-list.layout-paper .summary-box {
        font-family: var(--font-read);
        font-size: 1.15rem;
        line-height: 1.8;
        color: var(--text-muted);
        -webkit-line-clamp: unset;
        line-clamp: unset;
        /* Show Full Text */
        display: block;
    }

    #feed-list.layout-paper .meta-row {
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        gap: 15px;
    }

    /* Scrollbar Polish */
    #feed-list.layout-paper .scroll-content::-webkit-scrollbar {
        width: 8px;
    }

    #feed-list.layout-paper .scroll-content::-webkit-scrollbar-track {
        background: var(--bg-card);
    }

    #feed-list.layout-paper .scroll-content::-webkit-scrollbar-thumb {
        background: var(--border-glass);
        border-radius: 4px;
    }

    /* --- Text Only Card Fix --- */
    #feed-list.layout-paper .news-card.text-only .scroll-content {
        grid-template-columns: 100%;
        /* Full width */
    }

    #feed-list.layout-paper .news-card.text-only .card-img {
        display: none;
    }

    #feed-list.layout-paper .news-card.text-only .card-body,
    #feed-list.layout-paper .news-card.text-only .action-toolbar-container {
        grid-column: 1;
        max-width: 800px;
        /* Constrain reading width */
        margin: 0 auto;
    }
}

/* Search Input Styling inside Modal */
.search-input-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 45px;
    background: var(--bg-body);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-ui);
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.search-icon-overlay {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Highlight Styling for Search Matches */
.search-highlight {
    background-color: rgba(244, 63, 94, 0.25);
    color: var(--red);
    font-weight: 800;
    border-radius: 2px;
    padding: 0 2px;
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    /* Larger clickable area */
    display: none;
    /* Hidden by default */
    transition: color 0.2s;
}

.search-clear-btn:hover {
    color: var(--primary);
}

/* --- NATIVE AD STYLING --- */
.news-card.ad-unit {
    border: 1px solid var(--primary-dim);
    /* Subtle border to distinguish */
}

.news-card.ad-unit .badge {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    font-size: 0.65rem;
    letter-spacing: 1px;
}

.ad-cta-container {
    padding: 15px 24px 30px 24px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.ad-cta-btn {
    width: 100%;
    background: var(--text-main);
    color: var(--bg-card);
    padding: 14px;
    border-radius: 50px;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ad-cta-btn:hover {
    transform: scale(1.02);
    opacity: 0.95;
}

.ad-cta-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

/* --- ADVERTISING CONTAINERS --- */
.news-card.google-ad-unit {
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.google-ad-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
}

.ad-label-corner {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.6rem;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
}

.google-ad-unit {
    min-height: 280px;
    background: radial-gradient(circle, var(--bg-card) 0%, var(--bg-body) 100%);
    border: 1px dashed var(--border-glass);
}

.google-ad-unit:empty::before {
    content: 'Advertisement Loading...';
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* PULL TO REFRESH (PTR) - NEW */
#ptr-zone {
    height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: transparent;
    transition: height 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: height;
}

.ptr-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s;
}

#ptr-zone.visible .ptr-content {
    opacity: 1;
    transform: translateY(0);
}

.ptr-icon-arrow {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
    stroke-width: 2.5;
    fill: none;
    transition: transform 0.3s ease;
}

.ptr-icon-arrow.rotate {
    transform: rotate(180deg);
}

.ptr-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-glass);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

/* Prevent browser native refresh on Android to avoid conflict */
body {
    overscroll-behavior-y: contain;
}

/* =========================================
   8. WEB (ARTICLE) LAYOUT - DESKTOP
   ========================================= */

/* 1. Container Setup */
#feed-list.layout-web {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding: 40px 20px 100px 20px;
    max-width: 100%;
    margin: 0;
    background: var(--bg-body);
}

/* 2. The Article Card - "Modern Card" Aesthetic */
#feed-list.layout-web .news-card {
    width: 100%;
    max-width: 800px;
    height: auto !important;
    min-height: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-hard);
    overflow: hidden;
    margin: 0;
    padding-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#feed-list.layout-web .news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

#feed-list.layout-web .scroll-content {
    overflow: visible;
    height: auto;
    display: block;
    padding: 0;
}

/* 3. Typography & Spacing */
#feed-list.layout-web .card-body {
    padding: 30px 40px 10px 40px;
    /* Reduced bottom padding */
}

#feed-list.layout-web h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
    color: var(--text-main);
    text-align: left;
}

#feed-list.layout-web .summary-box {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--text-muted);
    opacity: 0.95;
    text-align: left;
    -webkit-line-clamp: unset !important;
    line-clamp: unset !important;
    display: block;
    margin-top: 15px;
}

/* 4. Image Handling (Edge-to-Edge) */
#feed-list.layout-web .card-img {
    width: 100%;
    height: 450px;
    border-radius: 0;
    margin-bottom: 0;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--border-glass);
}

/* 5. Meta Data & Toolbar */
#feed-list.layout-web .meta-row {
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 15px;
    padding-left: 0;
}

#feed-list.layout-web .badge {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--primary);
    font-weight: 700;
}

#feed-list.layout-web .action-toolbar-container {
    padding: 10px 40px 20px 40px;
    justify-content: flex-start;
    border-top: none;
    background: transparent;
    margin-top: 20px;
}

#feed-list.layout-web .action-toolbar {
    background: transparent;
    border: none;
    padding: 0;
    gap: 15px;
    display: flex;
    align-items: center;
}

#feed-list.layout-web .icon-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

#feed-list.layout-web .icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
    transform: scale(1.1);
}

#feed-list.layout-web .icon-btn svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

/* Specific color for Like button when active */
#feed-list.layout-web .icon-btn.liked {
    color: var(--red);
    fill: var(--red);
}

/* =========================================
   8. CURATED NOTES MODAL & SELECTION TOOLBAR
   ========================================= */

/* --- NOTE MODAL STYLING --- */
.note-modal {
    max-width: 520px;
    background: var(--bg-modal);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    overflow: hidden;
}

.note-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.note-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
}

.note-form-group {
    margin-bottom: 20px;
}

.note-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.note-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
    opacity: 0.7;
    font-style: italic;
}

.note-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-body);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-ui);
    transition: all 0.3s ease;
}

.note-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.note-textarea {
    width: 100%;
    padding: 16px;
    background: var(--bg-body);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-read);
    line-height: 1.6;
    resize: vertical;
    min-height: 180px;
    transition: all 0.3s ease;
}

.note-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
    outline: none;
}

.note-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.note-actions .btn-large {
    flex: 1;
}

/* --- SELECTION TOOLBAR --- */
/* --- SELECTION TOOLBAR --- */
.selection-toolbar {
    position: absolute;
    top: -36px;
    /* Moved to top */
    left: 50%;
    transform: translateX(-50%) translateY(10px) scale(0.95);
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.selection-toolbar.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

.selection-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-bottom: 3px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.selection-btn:hover {
    background: var(--primary);
    transform: translateY(-2px);
    border-color: var(--primary);
    border-bottom-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 6px 15px var(--primary-dim);
}

/* Theme-sensitive hover text */
[data-theme="light"] .selection-btn:hover {
    color: #fff;
}

[data-theme="dark"] .selection-btn:hover {
    color: #000;
}

[data-theme="sepia"] .selection-btn:hover {
    color: #fff;
}

.selection-btn:active {
    transform: translateY(0) scale(0.98);
}

.selection-btn svg {
    flex-shrink: 0;
}

/* --- CURATED CARD CONTROLS --- */
.curated-toolbar {
    gap: 10px !important;
}

.curated-edit-btn,
.curated-delete-btn {
    color: var(--text-muted) !important;
    transition: all 0.2s ease !important;
}

.curated-edit-btn:hover {
    color: var(--primary) !important;
    background: var(--primary-dim) !important;
}

.curated-delete-btn:hover {
    color: var(--red) !important;
    background: rgba(244, 63, 94, 0.1) !important;
}

.curated-edit-btn svg,
.curated-delete-btn svg {
    width: 22px !important;
    height: 22px !important;
}

/* Curated Badge Styling */
.news-card[id^="curated_"] .badge {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-gold) 100%);
    color: #000;
    font-weight: 800;
}

/* --- THEME ADJUSTMENTS --- */
[data-theme="light"] .selection-toolbar {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .selection-btn {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="sepia"] .note-textarea,
[data-theme="sepia"] .note-input {
    background: rgba(60, 47, 31, 0.05);
    border: 1px solid rgba(60, 47, 31, 0.1);
}

[data-theme="sepia"] .selection-toolbar {
    background: #fefefa;
    border: 1px solid #e5dec9;
    box-shadow: 0 10px 30px rgba(60, 47, 31, 0.15);
}

/* Mobile adjustments for selection toolbar */
@media (max-width: 768px) {
    .selection-toolbar {
        top: -42px;
        bottom: auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .selection-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
        /* Larger touch targets on mobile */
        min-height: 36px;
    }

    .note-modal {
        max-width: 95%;
        margin: 10px;
        padding: 20px;
    }

    .note-textarea {
        min-height: 150px;
    }
}

/* =========================================
   ISSUE #1 FIX: NEW CONTENT AVAILABLE TOAST
   ========================================= */
.new-content-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: 50px;
    padding: 10px 16px 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border-glass);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.new-content-toast.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.new-content-icon {
    font-size: 1.2rem;
    animation: pulse 2s ease-in-out infinite;
}

.new-content-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.new-content-btn {
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
}

/* Sepia Theme - Better Refresh Button Contrast */
[data-theme="sepia"] .new-content-btn {
    background: linear-gradient(135deg, #c17011 0%, #a05a0d 100%);
    color: #fffef8;
    border: 1px solid rgba(139, 90, 15, 0.3);
    box-shadow: 0 2px 8px rgba(193, 112, 17, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

[data-theme="sepia"] .new-content-btn:hover {
    background: linear-gradient(135deg, #d98518 0%, #b86610 100%);
    box-shadow: 0 4px 12px rgba(193, 112, 17, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.new-content-btn:active {
    transform: scale(0.98);
}

/* Enhanced Toast Styling for Sepia */
[data-theme="sepia"] .new-content-toast {
    background: rgba(255, 254, 248, 0.95);
    border: 1.5px solid rgba(193, 112, 17, 0.25);
    box-shadow: 0 12px 40px rgba(45, 31, 15, 0.2), inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.new-content-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.new-content-close:hover {
    opacity: 1;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .new-content-toast {
        top: 60px;
        padding: 8px 12px 8px 16px;
        gap: 10px;
        max-width: 90vw;
    }

    .new-content-text {
        font-size: 0.8rem;
    }

    .new-content-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* =========================================
   ISSUE #2 FIX: VIRTUAL SCROLL PLACEHOLDERS
   ========================================= */
.placeholder-card {
    width: 100%;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-body) 100%);
    border-radius: var(--card-radius);
    position: relative;
    overflow: hidden;
}

.placeholder-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.03) 50%,
            transparent 100%);
    animation: shimmer 2s infinite;
}

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

    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 768px) {
    .placeholder-card {
        border-radius: 0;
        scroll-snap-align: start;
    }
}

/* =========================================
   PREMIUM FLASHCARD EXPORT STYLES
   ========================================= */
.flashcard-export-canvas {
    width: 600px;
    background: linear-gradient(145deg, #18181b 0%, #09090b 100%);
    color: #ffffff;
    padding: 40px;
    border-radius: 32px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 32px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Subtle background accent */
.flashcard-export-canvas::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(40px);
}

.export-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.export-pill-category {
    background: rgba(255, 255, 255, 0.1);
    color: #e4e4e7;
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.export-watermark-logo {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
    opacity: 0.9;
}

.export-watermark-logo span {
    color: #f59e0b;
}

/* Gold accent */
.export-watermark-logo .tld {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    font-size: 0.9em;
}

.export-card-body {
    flex-grow: 1;
    display: flex;
    align-items: center;
    min-height: 220px;
    /* Ensure space */
    position: relative;
    z-index: 2;
}

.export-text-content {
    font-size: 1.7rem;
    line-height: 1.5;
    font-weight: 500;
    color: #fafafa;
    /* FIX: Ensure proper text wrapping for html2canvas */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal;
    word-spacing: normal;
    width: 100%;
    max-width: 100%;
}

/* Bold text in export - Replace with COLOR instead of bold weight */
.export-text-content b,
.export-text-content strong {
    /* REMOVE BOLD - Use color to highlight and prevent overlap */
    font-weight: inherit !important;
    color: #fbbf24 !important;
    /* Warm gold - matches the dark export canvas */
    display: inline;
    word-spacing: normal;
    letter-spacing: normal;
}

/* THE CLOZE (Answer) STYLE - Reddish & Premium */
.export-cloze {
    color: #f87171;
    font-weight: 800;
    border-bottom: 2px dashed rgba(248, 113, 113, 0.4);
    padding: 0 4px;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.2);
}

.export-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 24px;
    position: relative;
    z-index: 2;
}

.export-meta-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 60%;
}

.export-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.1em;
    font-weight: 600;
}

.export-topic-title {
    font-size: 0.95rem;
    color: #e4e4e7;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-app-badge {
    background: #ef4444;
    color: white;
    padding: 10px 18px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.export-app-badge span {
    transform: translateY(-1px);
}

/* Ensure images embedded in flashcard text are handled nicely */
.export-text-content img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 12px;
}


/* =========================================
           14. FLASHCARD NOTIFICATION POPUP (Premium & Lustrous)
           ========================================= */
.flashcard-popup {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 380px;
    min-height: 140px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 2px solid var(--popup-border, var(--primary-dim));
    box-shadow: var(--popup-shadow, 0 12px 40px rgba(0, 0, 0, 0.4));
    border-radius: 24px;
    padding: 22px 20px;
    padding-bottom: 22px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px) scale(0.94);
    transition:
        opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
        visibility 0.4s;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* 3D POP EFFECT BASE */
    border-width: 2px;
    border-bottom-width: 6px;
    /* Thick bottom for 3D feel */
}

/* Add a subtle top-gradient "lustre" for wow factor */
.flashcard-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, var(--highlight-bg) 0%, transparent 100%);
    pointer-events: none;
    opacity: 0.5;
    z-index: 0;
}

.flashcard-popup.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ===== POPUP CONTENT ===== */
.flashcard-popup-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-main);
    max-height: 210px;
    overflow-y: auto;
    font-family: var(--font-read);
    position: relative;
    z-index: 10;
    cursor: pointer;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

#popup-face-back {
    padding-bottom: 45px;
}

.flashcard-popup-content::-webkit-scrollbar {
    width: 3px;
}

.flashcard-popup-content::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
    opacity: 0.4;
}

/* Cloze Blank Style */
.flashcard-popup-content .cloze-blank {
    background: var(--highlight-bg);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-family: var(--font-ui);
    margin: 0 3px;
    font-size: 0.9em;
    display: inline-block;
}

/* Revealed Answer Style */
.flashcard-popup-content strong {
    color: var(--primary);
    font-weight: 800;
}

/* ===== PILL ACTION BAR (Compact & Aesthetic) ===== */
.flashcard-popup-actions {
    position: absolute;
    bottom: 12px;
    left: 16px;
    right: 16px;
    transform: none;
    display: flex;
    justify-content: space-between;
    gap: 7px;
    padding: 0;
    background: transparent;
    z-index: 20;
    pointer-events: none;
}

/* Ensure buttons capture clicks */
.flashcard-popup-actions>* {
    pointer-events: auto;
}

/* Hide action bar when popup is hidden */
.flashcard-popup:not(.visible) .flashcard-popup-actions {
    display: none;
}

/* Pill Buttons */
.flashcard-popup-btn {
    flex: 1;
    height: 32px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--chip-bg);
    position: relative;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Base Hover Effect */
.flashcard-popup-btn:hover {
    transform: translateY(-2px) scale(1.02);
    filter: brightness(1.1);
    z-index: 5;
}

.flashcard-popup-btn:active {
    transform: scale(0.95) translateY(0);
}

/* Hard Button - Red */
.btn-popup-hard {
    background: linear-gradient(to bottom, #ef4444, #dc2626);
    color: white;
    border: none;
    border-bottom: 3px solid #b91c1c;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-popup-hard:hover {
    background: #ef4444;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

/* Good Button - Green */
.btn-popup-good {
    background: linear-gradient(to bottom, #10b981, #059669);
    color: white;
    border: none;
    border-bottom: 3px solid #047857;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-popup-good:hover {
    background: #10b981;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

/* More Button - Neutral */
.btn-popup-more {
    background: linear-gradient(to bottom, #4b5563, #374151);
    color: white;
    border: none;
    border-bottom: 3px solid #1f2937;
    box-shadow: 0 4px 10px rgba(55, 65, 81, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-popup-more:hover {
    background: #4b5563;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

/* Share Button - Primary Accent */
.btn-popup-share {
    background: linear-gradient(to bottom, #0ea5e9, #0284c7);
    color: white;
    border: none;
    border-bottom: 3px solid #0369a1;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-popup-share:hover {
    background: #0ea5e9;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

[data-theme="dark"] .flashcard-popup {
    background: linear-gradient(165deg, #1f1f23 0%, #18181b 40%, #0f0f11 100%);
    /* 3D Pop Dark */
    border-color: #27272a;
    border-bottom-color: var(--primary-dim);
    /* Highlight edge */
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.8),
        0 4px 0 rgba(0, 0, 0, 0.5);
    /* Hard shadow */
}

[data-theme="dark"] .flashcard-popup::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(30px);
    pointer-events: none;
    z-index: 0;
}

/* [data-theme="dark"] .flashcard-popup::after - REMOVED (The Dot) */

[data-theme="dark"] .flashcard-popup-actions {
    --action-bar-bg: transparent;
    --action-bar-border: transparent;
    box-shadow: none;
    background: transparent;
}

[data-theme="dark"] .btn-popup-hard {
    background: linear-gradient(to bottom, #ef4444, #b91c1c);
    border-bottom: 3px solid #7f1d1d;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-popup-good {
    background: linear-gradient(to bottom, #10b981, #065f46);
    border-bottom: 3px solid #064e3b;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-popup-more {
    background: linear-gradient(to bottom, #3f3f46, #18181b);
    border-bottom: 3px solid #09090b;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-popup-share {
    background: linear-gradient(to bottom, #f59e0b, #d97706);
    color: #fff;
    border-bottom: 3px solid #92400e;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .flashcard-popup {
    background: linear-gradient(165deg, #ffffff 0%, #f8fffe 50%, #f0fdfa 100%);
    /* 3D Pop Light */
    border-color: #cbd5e1;
    border-bottom-color: #0d9488;
    /* Teal edge */
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 5px 0 rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .flashcard-popup::before {
    content: '';
    position: absolute;
    top: -40px;
    right: 40px;
    width: 160px;
    height: 100px;
    background: radial-gradient(ellipse, rgba(27, 196, 182, 0.15) 0%, transparent 70%);
    filter: blur(25px);
    pointer-events: none;
    z-index: 0;
}

/* [data-theme="light"] .flashcard-popup::after - REMOVED (The Dot) */

[data-theme="light"] .flashcard-popup-actions {
    --action-bar-bg: transparent;
    --action-bar-border: transparent;
    box-shadow: none;
    background: transparent;
}

[data-theme="light"] .flashcard-popup-btn::after {
    background: #1e293b;
    color: #fff;
}

[data-theme="sepia"] .flashcard-popup {
    background: linear-gradient(165deg, #fffdf7 0%, #fbf6e6 50%, #f5ead3 100%);
    border-color: #d6cab3;
    border-bottom-color: #be6724;
    box-shadow:
        0 20px 50px rgba(67, 52, 34, 0.25),
        0 5px 0 rgba(67, 52, 34, 0.1);
}

[data-theme="sepia"] .flashcard-popup::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 130px;
    height: 130px;
    background: radial-gradient(circle, rgba(217, 119, 6, 0.12) 0%, transparent 70%);
    filter: blur(25px);
    pointer-events: none;
    z-index: 0;
}

[data-theme="sepia"] .flashcard-popup-actions {
    --action-bar-bg: transparent;
    --action-bar-border: transparent;
    box-shadow: none;
    background: transparent;
}

[data-theme="sepia"] .btn-popup-hard {
    background: linear-gradient(to bottom, #b91c1c, #991b1b);
    color: #fff;
    border: none;
    border-bottom: 3px solid #7f1d1d;
    box-shadow: 0 4px 12px rgba(153, 27, 27, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="sepia"] .btn-popup-hard:hover {
    background: #b91c1c;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

[data-theme="sepia"] .btn-popup-good {
    background: linear-gradient(to bottom, #15803d, #166534);
    color: #fff;
    border: none;
    border-bottom: 3px solid #14532d;
    box-shadow: 0 4px 12px rgba(22, 101, 52, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="sepia"] .btn-popup-good:hover {
    background: #15803d;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

[data-theme="sepia"] .btn-popup-more {
    background: linear-gradient(to bottom, #5d4e42, #4b3f35);
    color: #fff;
    border: none;
    border-bottom: 3px solid #362d26;
    box-shadow: 0 4px 12px rgba(75, 63, 53, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="sepia"] .btn-popup-more:hover {
    background: #5d4e42;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

[data-theme="sepia"] .btn-popup-share {
    background: linear-gradient(to bottom, #f59e0b, #d97706);
    color: #fff;
    border: none;
    border-bottom: 3px solid #b45309;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="sepia"] .btn-popup-share:hover {
    background: #f59e0b;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

/* MOBILE RESPONSIVE DESIGN */
@media (max-width: 600px) {
    .flashcard-popup {
        right: 12px;
        left: 12px;
        bottom: 8px;
        width: auto;
        border-radius: 20px;
        padding: 10px 15px;
        padding-bottom: 10px;
        transform: translateY(100px);
    }

    .flashcard-popup.visible {
        transform: translateY(0);
    }

    .flashcard-popup-content {
        max-height: 190px;
        font-size: 0.9rem;
    }

    .flashcard-popup-actions {
        bottom: 10px;
        left: 10px;
        right: 10px;
        gap: 6px;
    }

    .flashcard-popup-btn {
        width: auto;
        height: 32px;
        flex: 1;
        font-size: 0.75rem;
    }

    /* Hide tooltips on mobile */
    .flashcard-popup-btn::after {
        display: none;
    }
}

/* Tablet/Small Desktop */
@media (min-width: 601px) and (max-width: 900px) {
    .flashcard-popup {
        width: 360px;
        right: 20px;
        bottom: 25px;
    }
}

/* =========================================
   HEADER RESPONSIVE MENU
   ========================================= */
.header-menu-toggle {
    display: none;
}

.header-extras {
    display: flex;
    align-items: center;
    gap: inherit;
}

/* Mobile Header Grouping */
@media (max-width: 600px) {
    .header-menu-toggle {
        display: flex;
    }

    .header-extras {
        display: none;
        position: absolute;
        top: 60px;
        right: 12px;
        flex-direction: column;
        background: var(--bg-card);
        border: 1px solid var(--border-glass);
        padding: 12px;
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        min-width: 50px;
        gap: 12px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        align-items: center;
    }

    .header-extras.active {
        display: flex;
        animation: floatIn 0.2s ease-out;
    }

    /* FIX: Ensure icons are visible in dropdown on Light/Sepia themes */
    [data-theme="sepia"] .header-extras .icon-btn,
    [data-theme="light"] .header-extras .icon-btn {
        color: var(--text-main) !important;
    }
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- SRS Buttons (Reverted) --- */
.srs-btn {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 5px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-main);
}

.srs-btn:hover {
    transform: translateY(-4px);
    background: var(--bg-card);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.srs-btn:active {
    transform: scale(0.95);
}

.srs-btn span:first-child {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.srs-btn span:last-child {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.srs-again {
    border-bottom: 4px solid var(--red);
}

.srs-hard {
    border-bottom: 4px solid var(--orange);
}

.srs-good {
    border-bottom: 4px solid var(--blue);
}

.srs-easy {
    border-bottom: 4px solid var(--green);
}

/* CUSTOM CHECKMARK TOGGLE */
.custom-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 50px;
    height: 28px;
    background: var(--bg-elevated);
    border: 2px solid var(--border-glass);
    border-radius: 99px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.custom-toggle::after {
    content: '';
    position: absolute;
    left: 4px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.custom-toggle:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.custom-toggle:checked::after {
    left: 26px;
    background: white;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.1);
}

/* Add a checkmark icon to the toggle thumb when checked */
.custom-toggle:checked::before {
    content: '✓';
    position: absolute;
    left: 8px;
    color: white;
    font-size: 14px;
    font-weight: 900;
    opacity: 0;
    animation: fadeInCheck 0.3s forwards;
    pointer-events: none;
}

@keyframes fadeInCheck {
    to {
        opacity: 1;
    }
}

/* =========================================
   LASER ANNOTATION TOOL (Secret Feature)
   ========================================= */
#annotation-canvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    pointer-events: auto;
    cursor: crosshair;
    background: transparent;
}

#annotation-canvas-overlay.select-mode {
    pointer-events: none;
    cursor: default;
}

.laser-toolbar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 99px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    animation: slideUpLaser 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpLaser {
    from {
        transform: translateY(100%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.laser-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--bg-card);
    border: none;
    border-bottom: 3px solid var(--border-glass);
    color: var(--text-muted);
    position: relative;
    user-select: none;
}

.laser-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.laser-btn:hover {
    transform: translateY(-2px);
    color: var(--primary);
}

.laser-btn.active {
    background: var(--primary);
    color: #000;
    border-bottom-color: rgba(0, 0, 0, 0.2);
    transform: translateY(1px);
    border-bottom-width: 1px;
    box-shadow: 0 0 12px var(--primary-dim);
}

.laser-btn-close {
    background: var(--red);
    color: white !important;
    border-bottom-color: rgba(0, 0, 0, 0.2);
}

.laser-btn-close:hover {
    background: #e11d48;
}

/* Annotation Aesthetic Core (v4) */
:root {
    --laser-color: #a855f7;
    /* Cosmic Purple Default */
    --laser-thickness: 1.8;
    --laser-core: #faf5ff;
}

.laser-btn-color {
    background: var(--laser-color);
    box-shadow: 0 0 10px var(--laser-color);
    border: 2px solid white;
    border-radius: 50% !important;
}

.laser-btn-color:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 0 15px var(--laser-color);
}

.laser-btn-eraser {
    background: #475569;
    /* Slate Gray for Eraser */
    color: white !important;
}

.laser-btn-eraser:hover {
    background: #334155;
}

.laser-btn-eraser.active {
    background: #1e293b;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

.laser-btn-clear {
    background: var(--bg-body);
    color: var(--text-muted);
}

.laser-btn-clear:hover {
    color: var(--primary);
    background: var(--primary-dim);
}

/* Local Annotation Layer (v5) */
.annotation-layer-local {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
    background: transparent;
}

/* Ensure scroll content tracks its children for positioning */
.scroll-content {
    position: relative;
}



/* --- INTERACTIVE POP-OUT IMAGE VIEWER --- */
.image-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    /* No dimmed background - can read article behind */
    z-index: 100000;
    display: none;
    pointer-events: none;
    /* Allow interaction with underlying page */
}

.image-viewer-modal.visible {
    display: block;
}

/* The Draggable, Resizable Container */
.image-viewer-container {
    position: absolute;
    /* Transformation handled by JS for centering/dragging */
    background: transparent;
    /* FIXED: Transparent so no 'blank box' */
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    /* Re-enable pointer events for the image itself */
    border-radius: 16px;
    /* Modern Rounded Corners */
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.45),
        0 8px 25px rgba(0, 0, 0, 0.3);
    transition: width 0.3s cubic-bezier(0.1, 0.7, 0.1, 1), height 0.3s cubic-bezier(0.1, 0.7, 0.1, 1), top 0.3s cubic-bezier(0.1, 0.7, 0.1, 1), left 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
    cursor: grab;
    overflow: hidden;
}

.image-viewer-container.interacting {
    transition: none;
    cursor: grabbing;
}

.image-viewer-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* FIXED: Show FULL image without cropping */
    border-radius: 16px;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    background: transparent;
}

/* --- TOOLBAR (Top Rightmost End - Overlay Header) --- */
.viewer-toolbar {
    position: fixed;
    top: 12px;
    /* Overlaying the header icons */
    right: 12px;
    /* Rightmost end */
    left: auto;
    transform: none;
    display: flex;
    gap: 4px;
    /* Tighter gap */
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 8px;
    /* Smaller padding */
    border-radius: 50px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 100010;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.viewer-btn {
    width: 28px;
    /* Smaller buttons (was 32px) */
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.viewer-btn:hover {
    background: var(--highlight-bg);
    transform: translateY(-2px);
}

.viewer-btn svg {
    width: 16px;
    /* Smaller icons (was 18px) */
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.viewer-btn.close-btn:hover {
    background: var(--red);
    color: white;
    transform: rotate(90deg);
}

/* --- ZOOM INDICATOR (Centered Overlay) --- */
.viewer-zoom-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    /* Slightly smaller padding */
    border-radius: 30px;
    font-size: 1rem;
    /* Smaller font */
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100020;
    backdrop-filter: blur(4px);
}

.viewer-zoom-indicator.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* --- RESIZE HANDLE (Bottom Right) --- */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    cursor: nwse-resize;
    z-index: 100003;
    pointer-events: auto;
    border-bottom-right-radius: 16px;
    touch-action: none;
}

.resize-handle::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-bottom: 3px solid var(--text-muted);
    border-right: 3px solid var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.resize-handle:hover::after {
    opacity: 1;
    border-color: var(--primary);
}

/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 768px) {
    .viewer-toolbar {
        top: 12px;
        /* Keep consistent */
        right: 12px;
        left: auto;
        transform: none;
        width: auto;
        padding: 4px 8px;
        /* Tighter on mobile too */
    }

    .viewer-btn {
        width: 32px;
        /* Slightly larger than desktop for touch, but smaller than before (36px) */
        height: 32px;
    }

    .resize-handle {
        display: block !important;
    }
}
