:root {
    /* Light Mode (Default) */
    --bg-color: #f8fafc; /* Matched reference body bg */
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #0f172a; /* Matched reference text */
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --hover-bg: #e2e8f0;
    --accent-blue: #2563eb; /* Matched reference brand blue */

    --font-main: 'Outfit', sans-serif;
    --font-serif: 'Merriweather', serif;

    --tag-bg: #e0e7ff;
    --tag-text: #3730a3;
    --green-bg: #ecfdf5;
    --green-text: #065f46;
    --amber-bg: #fffbeb;
    --amber-text: #92400e;

    --header-bg: #ffffff;
    --modal-bg: #ffffff;
    --notepad-bg: #ffffff;
    --notepad-text: #333333;
    --badge-bg: #eff6ff;
    --tooltip-bg: #ffffff;
    --input-bg: #ffffff;

    --subtitle-text: #000000; /* Black for Light Mode */
}

/* Dark Mode Override */
[data-theme="dark"] {
    --bg-color: #000000;
    --sidebar-bg: #18181b;
    --card-bg: #121212;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --border-color: #27272a;
    --hover-bg: #27272a;
    --accent-blue: #60a5fa;

    --tag-bg: #312e81;
    --tag-text: #e0e7ff;
    --green-bg: #064e3b;
    --green-text: #ecfdf5;
    --amber-bg: #451a03;
    --amber-text: #fef3c7;

    --header-bg: #18181b;
    --modal-bg: #1e1e1e;
    --notepad-bg: #1e1e1e;
    --notepad-text: #e2e2e2;
    --badge-bg: #172554;
    --tooltip-bg: #1e1e1e;
    --input-bg: #27272a;

    --subtitle-text: #ffffff; /* White for Dark Mode */
}

html, body {
    /* max-width: 100%; */
    overflow-x: hidden;
    position: relative;
    /* This prevents the "rubber-band" effect on iPad that breaks sticky headers */
    width: 100%;
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    margin: 0;
    font-family: var(--font-main);
    background: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c7c5; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #8e918f; }

/* --- Header Styles (UI Update) --- */
header {
    height: 64px; /* Reduced to match reference */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px; /* Updated side padding */
    position: sticky;
    top: 0;
    background: var(--header-bg);
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

/* --- Header Titles Wrapper --- */
.header-titles {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.header-subtitle {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--subtitle-text); /* Updated to use theme variable */
    font-weight: 400;
    white-space: nowrap;
    /* Adjust line-height to align nicely with the brand text */
    line-height: 1;
}

/* Logo / Top Brand Styling (Matches Reference) */
.top-logo {
    font-family: var(--font-main); /* Outfit */
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    padding-left: 12px;
    /* border-left: 1px solid var(--border-color); */
}

.logo-accent { color: var(--accent-blue); }

/* Sidebar */
#sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    z-index: 50;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid var(--border-color);
}

body.sidebar-collapsed #sidebar { width: 0; border-right: none; }

/* Mobile Overlay */
#mobile-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    display: none;
}
body.mobile-sidebar-open #mobile-overlay { display: block; }

@media (max-width: 1024px) {
    #sidebar {
        position: fixed;
        height: 100%;
        left: 0; top: 0;
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    body.mobile-sidebar-open #sidebar { transform: translateX(0); }
    body.sidebar-collapsed #sidebar { width: 280px; }
}

/* Sidebar Elements */
.sidebar-header {
    padding-left: 20px;
    display: flex;
    align-items: center;
    height: 64px;
    border-bottom: 1px solid var(--border-color);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}
.btn-icon:hover { background: var(--hover-bg); }

/* Branding Styles */
.brand-text {
    font-weight: 700; /* Bold */
    color: var(--accent-blue); /* Blue */
    font-size: 20px;
    opacity: 1;
    transition: opacity 0.2s;
    font-family: var(--font-main);
    letter-spacing: -0.5px;
    line-height: 1.2;
    gap: 10px;
}

.header-brand-text {
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 20px; /* Kept specific size */
    display: none;
    font-family: var(--font-main);
    letter-spacing: -0.5px;
}

/* Show header brand when sidebar is collapsed */
body.sidebar-collapsed .header-brand-text {
    display: block;
}

/* Mobile Logic */
@media (max-width: 1024px) {
    .header-brand-text { display: block; font-size: 18px; }

    /* Stack titles vertically on mobile */
    .header-titles {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .header-subtitle {
        font-size: 11px;
        white-space: normal;
    }
}

/* Mobile Orientation Overlay */
#mobile-orientation-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none; /* Managed by JS */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: var(--font-main);
    text-align: center;
    padding: 24px;
    backdrop-filter: blur(8px);
}

.overlay-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 24px;
    color: white;
    animation: rotate-phone 2s infinite ease-in-out;
}

.overlay-text {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.5;
    max-width: 300px;
}

.overlay-sub {
    font-size: 14px;
    color: #9ca3af;
    margin-top: 12px;
}

@keyframes rotate-phone {
    0%, 10% { transform: rotate(0deg); opacity: 1; }
    25% { opacity: 0.5; }
    50%, 60% { transform: rotate(90deg); opacity: 1; }
    75% { opacity: 0.5; }
    90%, 100% { transform: rotate(0deg); opacity: 1; }
}

.action-btn-container {
    padding: 0 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-main);
    white-space: nowrap;
    transition: 0.2s;
    margin-top: 15px;
}
.action-btn:hover { background: var(--hover-bg); }
.action-btn svg { flex-shrink: 0; stroke: var(--text-primary); }
.action-btn.active-btn {
    background: var(--badge-bg);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.action-btn.active-btn svg { stroke: var(--accent-blue); }

.archive-container { flex: 1; overflow-y: auto; padding: 8px; }
.archive-label {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.archive-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.archive-item:hover { background: var(--hover-bg); }
.archive-item svg { flex-shrink: 0; }

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0; /* CRITICAL: Prevents flex children from pushing width */
    overflow-x: hidden;
}

#content-scroll { flex: 1; overflow-y: auto; padding-bottom: 40px; }
.container { 
    width: 100%;
    max-width: 1000px; /* Ensures it never goes wider than the screen */
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box; /* Includes padding in the width calculation */
}

.page-header { text-align: center; margin-bottom: 40px; }

.date-badge {
    display: inline-block;
    background: var(--badge-bg);
    color: var(--accent-blue);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.main-headline {
    font-size: 32px;
    font-weight: 500;
    margin: 0;
    line-height: 1.2;
    color: var(--text-primary);
}

/* Article Card Styles */
.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0;
    margin-bottom: 32px;
    transition: 0.2s;
    position: relative;
    color: var(--text-primary);
    overflow: hidden;
}
.article-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #c7c7c7;
}

.article-image {
    width: 100%;
    height: 240px;
    object-fit: cover;
    display: block;
}

.article-content { padding: 32px; }

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: 500;
    align-items: center;
    color: var(--text-secondary);
}

.chip {
    padding: 4px 10px;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--tag-bg);
    color: var(--tag-text);
}

.article-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 500;
    margin: 0 0 16px 0;
    line-height: 1.4;
    color: var(--text-primary);
}

.content-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.content-block {
    margin-bottom: 20px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.content-list { padding-left: 20px; margin: 0; }
.content-list li { margin-bottom: 6px; }

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
@media (max-width: 768px) { .grid-2-col { grid-template-columns: 1fr; } }

.info-box { padding: 16px; border-radius: 12px; }
.box-green { background: var(--green-bg); border: 1px solid var(--green-bg); color: var(--green-text); }
.box-amber { background: var(--amber-bg); border: 1px solid var(--amber-bg); color: var(--amber-text); }
.box-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }

.no-bullet-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.no-bullet-list li { margin-bottom: 4px; display: flex; align-items: flex-start; }
.bullet-icon { margin-right: 8px; margin-top: 4px; }

.key-val-row { display: flex; font-size: 14px; margin-bottom: 4px; }
.key-label { font-weight: 700; min-width: 100px; text-transform: capitalize; }

/* Question Box (Hidden by default, toggled via Mains Practice Button) */
.question-box {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: none; /* Hidden by default */
}
.question-box.active { display: block; animation: fadeIn 0.3s ease-out; }

.question-text {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 16px;
}

/* --- REFINED BUTTON GRID STYLES --- */
.card-actions {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 buttons per row on desktop */
    gap: 12px;
}

/* Base Button Style for Grid Items */
.btn-grid-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    box-sizing: border-box;
    line-height: 1.2;
    color: var(--text-secondary);
}

.btn-grid-item:active { transform: scale(0.98); }

.btn-grid-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}

/* Active State for Grid Buttons */
.btn-grid-item.active-btn {
    background-color: var(--badge-bg);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}
.btn-grid-item.active-btn svg { stroke: var(--accent-blue); }

/* 1. Weightage Analysis (Soft Blue) */
.btn-weightage {
    background-color: var(--badge-bg);
    color: var(--accent-blue);
    border-color: rgba(37, 99, 235, 0.1);
}
.btn-weightage:hover {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-weightage:hover svg { stroke: white; }

/* 2. Deep Dive (Solid Accent) */
.btn-deep-dive {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}
.btn-deep-dive:hover {
    opacity: 0.95;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

/* 3. Practice Buttons (Outline) */
.btn-practice {
    background-color: transparent;
    border-color: var(--border-color);
}
.btn-practice:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background-color: var(--bg-body);
}

/* 4. External Links (Subtle Gray) */
.btn-external {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-external:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

/* 5. Save Article (Full Width Span) */
.btn-save-full {
    grid-column: span 2;
    background-color: transparent;
    border-color: var(--border-color);
    margin-top: 4px;
}
.btn-save-full:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background-color: var(--badge-bg);
}
.btn-save-full.active {
    background-color: var(--green-bg);
    color: var(--green-text);
    border-color: var(--green-text);
}
.btn-save-full.active svg { fill: currentColor; }

/* Mobile Adjustments */
@media (max-width: 768px) {
    .card-actions { grid-template-columns: 1fr; } /* 1 button per row on mobile */
    .btn-save-full { grid-column: span 1 !important; }
}

@media (max-width: 660px){
    .top-logo { display: none; } /* Hide right logo on mobile */
}

/* PRELIMS SECTION STYLES */
.prelims-container {
    display: none;
    background: var(--sidebar-bg);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid var(--border-color);
}
.prelims-container.active { display: block; animation: fadeIn 0.3s ease-out; }

.prelims-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.prelims-q-text { font-weight: 600; margin-bottom: 12px; font-size: 15px; }
.prelims-options { list-style: none; padding: 0; margin: 0 0 12px 0; }
.prelims-options li { padding: 4px 0; font-size: 14px; color: var(--text-secondary); }
.prelims-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 8px; }
.prelims-answer-block { display: none; margin-top: 8px; padding: 8px; background: var(--green-bg); border-radius: 6px; font-size: 13px; color: var(--green-text); }

/* Model Answer Button */
.btn-answer {
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 13px;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-answer:hover { background: var(--badge-bg); }

/* Save Question Button */
.btn-save-q {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 13px;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-save-q:hover { background: var(--hover-bg); }
.btn-save-q.active { background: var(--green-bg); color: var(--green-text); border-color: var(--green-bg); }

.model-answer-container {
    display: none;
    margin-top: 16px;
    padding: 20px;
    background: var(--sidebar-bg);
    border-radius: 12px;
    border-left: 4px solid var(--accent-blue);
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
}
.model-answer-container.active { display: block; animation: fadeIn 0.3s ease-out; }

/* MODAL & OVERLAY */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: var(--modal-bg);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    border-radius: 24px;
    padding: 0;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: start;
}
.modal-title { font-size: 22px; font-family: var(--font-serif); margin: 0; color: var(--text-primary); line-height: 1.3; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--text-secondary); line-height: 1; padding: 0; margin-left: 16px; }
.modal-body { padding: 32px; overflow-y: auto; color: var(--text-secondary); font-size: 16px; line-height: 1.8; }

/* Saved Question Item Styles */
.saved-q-item { border-bottom: 1px solid var(--border-color); padding-bottom: 16px; margin-bottom: 16px; }
.saved-q-item:last-child { border-bottom: none; }
.saved-q-title { font-size: 14px; color: var(--accent-blue); margin-bottom: 4px; font-weight: 600; display: flex; justify-content: space-between; }
.saved-q-type { font-size: 10px; background: var(--tag-bg); color: var(--tag-text); padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.saved-q-text { font-family: var(--font-serif); font-style: italic; margin-bottom: 12px; display: block; }
.saved-q-actions { display: flex; gap: 12px; }
.btn-delete-q { color: #ef4444; background: none; border: none; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }

/* Floating Buttons */
.fab-container {
    position: fixed;
    bottom: 30px; right: 30px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 90;
    align-items: center;
}
.fab {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    color: white;
}
.fab:hover { transform: scale(1.05); }
#notepad-fab { background-color: var(--accent-blue); }
#pdf-fab { background-color: #3b82f6; }

#notepad-container {
    position: fixed;
    bottom: 170px; right: 30px;
    width: 320px; height: 450px;
    background: var(--notepad-bg);
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 90;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}
#notepad-container.active { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }

.notepad-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sidebar-bg);
    border-radius: 20px 20px 0 0;
}
.notepad-title { font-weight: 600; color: var(--text-primary); font-size: 16px; }
.notepad-actions button { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 4px; margin-left: 4px; }
#notepad-area {
    flex: 1;
    border: none;
    padding: 16px;
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.6;
    color: var(--notepad-text);
    resize: none;
    outline: none;
    background: var(--notepad-bg);
}

#highlight-tooltip {
    position: absolute;
    background: var(--tooltip-bg);
    padding: 8px 12px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 8px;
    z-index: 80;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--border-color);
}
#highlight-tooltip.active { opacity: 1; pointer-events: auto; }

.color-btn {
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s;
}
.color-btn:hover { transform: scale(1.2); border-color: var(--border-color); }
.color-btn.remove {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
}
.highlight-span {
    border-radius: 4px;
    padding: 2px 0;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #000;
}

.article-card.bookmarked {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue), 0 4px 20px rgba(11, 87, 208, 0.15);
}
[data-theme="dark"] .article-card.bookmarked {
    box-shadow: 0 0 0 1px var(--accent-blue), 0 4px 20px rgba(96, 165, 250, 0.2);
}

.date-search-container { padding: 0 16px; margin-bottom: 16px; }

.search-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.search-wrapper:focus-within { border-color: var(--accent-blue); }

.sidebar-date-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 0 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
    min-width: 0;
}
.sidebar-date-input::placeholder { color: var(--text-secondary); opacity: 0.7; }

.sidebar-search-btn {
    background: transparent;
    border: none;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid transparent;
    transition: color 0.2s;
}
.sidebar-search-btn:hover {
    color: var(--accent-blue);
    background: var(--hover-bg);
}

/* Sidebar Load More Button */
.sidebar-load-more {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    margin-bottom: 16px;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}
.sidebar-load-more:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: var(--hover-bg);
}

.modal-search-container {
    padding: 0 32px 16px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--modal-bg);
    position: sticky;
    top: 0;
    z-index: 5;
}

.modal-search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--badge-bg);
}

/* --- ARTICLE MODE TOGGLE STYLES --- */
.article-mode-wrapper {
    margin: 0 0 24px 0;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none; /* Firefox */
}
.article-mode-wrapper::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.article-mode-toggle {
    display: inline-flex;
    background: var(--hover-bg);
    border-radius: 50px;
    padding: 6px;
    gap: 4px;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--card-bg);
    color: var(--accent-blue);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* Highly optimized hiding class */
.mode-hidden {
    display: none !important;
}

/* Small adjustments for the new Static points block */
.box-blue { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
[data-theme="dark"] .box-blue { background: #172554; border: 1px solid #1e3a8a; color: #bfdbfe; }

/* --- MOBILE MODE SELECTOR STYLES --- */
.mobile-mode-selector {
    display: none; /* Hidden on Desktop */
    width: 100%;
    background: var(--badge-bg);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-blue);
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.mobile-mode-selector svg {
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    /* Show the mobile button */
    .mobile-mode-selector {
        display: flex;
    }
    
    /* Hide horizontal toggle and convert to vertical column */
    .article-mode-toggle {
        display: none; /* Hidden until button is clicked */
        flex-direction: column;
        width: 100%;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 8px;
        gap: 4px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }
    
    /* Show vertical list when wrapper has 'show-modes' class */
    .article-mode-wrapper.show-modes .article-mode-toggle {
        display: flex;
        animation: fadeIn 0.2s ease-in-out;
    }
    
    /* Rotate arrow when open */
    .article-mode-wrapper.show-modes .mobile-mode-selector svg {
        transform: rotate(180deg);
    }

    /* Make buttons full width */
    .mode-btn {
        width: 100%;
        text-align: left;
        padding: 10px 16px;
    }
}

/* --- INFO MODAL SPECIFIC STYLES --- */
.info-hero {
    text-align: center;
    padding: 30px 0 20px 0;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 24px;
}
.info-hero svg {
    color: var(--accent-blue);
    margin-bottom: 12px;
}
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 600px) {
    .info-grid { grid-template-columns: 1fr 1fr; }
    .info-grid .info-card:last-child { grid-column: span 2; } /* Center the 3rd item */
}
.info-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform 0.2s, border-color 0.2s;
}
.info-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-blue);
}
.info-icon-wrapper {
    background: var(--badge-bg);
    color: var(--accent-blue);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.info-card-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--text-primary);
}
.info-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Beautiful colored badges for reading modes */
.mode-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 100px;
    text-align: center;
}
.mb-quick { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.mb-deep { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.mb-analytics { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; }
.mb-overload { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.mb-examiner { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

/* Dark mode adjustments for badges */
[data-theme="dark"] .mb-quick { background: #172554; color: #93c5fd; border-color: #1e3a8a; }
[data-theme="dark"] .mb-deep { background: #052e16; color: #86efac; border-color: #14532d; }
[data-theme="dark"] .mb-analytics { background: #422006; color: #fde047; border-color: #713f12; }
[data-theme="dark"] .mb-overload { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .mb-examiner { background: #3b0764; color: #d8b4fe; border-color: #581c87; }

/* --- Language Selector Styles --- */
.lang-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text-secondary);
    transition: 0.2s;
}

.lang-selector-wrapper:hover {
    background: var(--hover-bg);
}

.lang-selector-wrapper select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 4px; /* Space for the arrow */
}

.lang-selector-wrapper select option {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* --- Hide Default Google Translate UI --- */
.goog-te-banner-frame.skiptranslate,
.goog-te-gadget-icon,
#goog-gt-tt,
.goog-tooltip,
.activity-root,
.status-message,
.started-activity-container {
    display: none !important;
}

body {
    top: 0px !important; /* Prevents Google from pushing the body down */
}

/* Removes the hover box around translated text */
.goog-text-highlight {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* --- Custom Language Dropdown Styles --- */
.lang-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

/* Styled exactly like your mobile-mode-selector */
.lang-dropdown-btn {
    display: flex;
    background: var(--badge-bg);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-blue);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lang-dropdown-btn .chevron {
    transition: transform 0.3s ease;
}

.lang-dropdown-wrapper.show-menu .chevron {
    transform: rotate(180deg);
}

/* Styled exactly like your mobile article-mode-toggle column */
.lang-dropdown-list {
    display: none;
    position: absolute;
    top: 110%; /* Just below the button */
    right: 0;
    width: 200px;
    max-height: 350px; /* Prevents 23 items from breaking the screen */
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    gap: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 100;
}

.lang-dropdown-wrapper.show-menu .lang-dropdown-list {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease-in-out;
}

.lang-dropdown-list .mode-btn {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    border-radius: 8px; /* Tighter radius for vertical list */
}

/* Custom scrollbar for the language list */
.lang-dropdown-list::-webkit-scrollbar { width: 6px; }
.lang-dropdown-list::-webkit-scrollbar-track { background: transparent; }
.lang-dropdown-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.lang-dropdown-list::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* --- Aggressively Hide Google Translate Ribbon --- */
iframe.goog-te-banner-frame, 
.goog-te-banner-frame {
    display: none !important;
}

body {
    top: 0px !important; 
    position: static !important; 
}

/* --- Sidebar Restore Language Button --- */
.restore-lang-btn {
    background: var(--badge-bg);
    color: var(--accent-blue);
    border-color: rgba(37, 99, 235, 0.2);
    margin-top: 8px; /* Adds a tiny bit of separation from the regular buttons */
}

.restore-lang-btn svg {
    stroke: var(--accent-blue);
}

.restore-lang-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.restore-lang-btn:hover svg {
    stroke: white;
}

/* --- Audio Button Active State --- */
.btn-listen {
    background-color: transparent;
    border-color: var(--border-color);
}

.btn-listen:hover {
    border-color: #10b981; /* Emerald green hover */
    color: #10b981;
    background-color: #ecfdf5;
}

[data-theme="dark"] .btn-listen:hover {
    background-color: #064e3b;
}

/* When audio is actively playing */
.btn-listen.playing {
    background-color: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

[data-theme="dark"] .btn-listen.playing {
    background-color: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

/* --- AGGRESSIVELY NUKE GOOGLE TRANSLATE BANNER --- */

/* 1. Hide the iframe regardless of how it's injected */
.skiptranslate > iframe.skiptranslate,
iframe.goog-te-banner-frame,
.goog-te-banner-frame.skiptranslate {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* 2. Prevent Google from pushing the HTML or BODY down */
html {
    top: 0px !important;
    margin-top: 0px !important;
    position: static !important;
}

body {
    top: 0px !important;
    margin-top: 0px !important;
    position: static !important;
}

/* 3. Hide the annoying hover tooltips over translated text */
#goog-gt-tt, 
.goog-te-balloon-frame {
    display: none !important;
}

/* 4. Remove the background highlight on translated text */
.goog-text-highlight {
    background: none !important;
    box-shadow: none !important;
}

/* --- EXCEL-STYLE TAB BAR --- */
.excel-tab-bar {
    display: flex;
    overflow-x: auto; /* Allows swiping on mobile */
    background: var(--header-bg);
    z-index: 9;
    scrollbar-width: none; /* Hides scrollbar in Firefox */
    backdrop-filter: blur(8px);
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Enables smooth finger scrolling on iPad */
    flex-wrap: nowrap; /* Ensures tabs stay in one line */
    width: 100%;
}

/* Hides scrollbar in Chrome/Safari */
.excel-tab-bar::-webkit-scrollbar { 
    display: none; 
}

/* --- TAB BAR FADE WRAPPER --- */
.tab-bar-wrapper {
    position: sticky;
    top: 64px; /* Sticks right below your 60px header */
    z-index: 9;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
}

/* The invisible gradient boxes on the left and right */
.tab-bar-wrapper::before,
.tab-bar-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px; /* How wide the fade effect is */
    pointer-events: none; /* CRITICAL: Lets clicks pass through to the buttons */
    z-index: 10;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease;
}

/* Left Fade */
.tab-bar-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--header-bg) 0%, transparent 100%);
}

/* Right Fade */
.tab-bar-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--header-bg) 0%, transparent 100%);
}

/* Classes to trigger the fades (added by JavaScript) */
.tab-bar-wrapper.can-scroll-left::before {
    opacity: 1;
}
.tab-bar-wrapper.can-scroll-right::after {
    opacity: 1;
}

.tab-link {
    padding: 14px 20px;
    white-space: nowrap; /* Keeps text on one line */
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-bottom: 3px solid transparent; /* The "Excel" active line */
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-main);
    text-decoration: none;
}

.tab-link:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* The Active Tab Indicator */
.tab-link.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.05);
}

/* --- QUICK READS DROPDOWN --- */
.tab-dropdown {
    position: relative;
    display: inline-block;
}

.tab-dropdown-menu {
    display: none;
    position: fixed; /* This will now work perfectly */
    transform: translateX(-50%);
    background: var(--card-bg);
    min-width: 250px;
    box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.2));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
}

/* Ensure it looks great on small mobile screens */
@media (max-width: 640px) {
    .tab-dropdown-menu {
        width: 90%;
    }
}

.tab-dropdown-menu.show {
    display: flex;
    animation: fadeIn 0.2s ease-in-out;
}

.tab-dropdown-menu a {
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s, color 0.2s;
}

.tab-dropdown-menu a:hover {
    background: var(--hover-bg);
    color: var(--accent-blue);
}

.tab-dropdown-menu a:last-child { 
    border-bottom: none; 
}

/* Rotate the arrow when dropdown is open */
.dropdown-toggle.open svg {
    transform: rotate(180deg);
}
.dropdown-toggle svg {
    transition: transform 0.3s ease;
}
