/* Global Design Tokens & Theme Setup */
:root {
    --font-sans: 'Urbanist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Clash Display', 'Urbanist', -apple-system, sans-serif;
    
    /* Light Mode Palette */
    --bg-app: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.65);
    --bg-sidebar: rgba(255, 255, 255, 0.4);
    --bg-navbar: rgba(255, 255, 255, 0.5);
    --border-color: rgba(226, 232, 240, 0.5);
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #ffffff;
    
    /* Brand Colors */
    --primary: #3b82f6;
    --primary-hover: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --shadow-main: 0 8px 32px 0 rgba(31, 38, 135, 0.03);
    --shadow-hover: 0 16px 40px 0 rgba(31, 38, 135, 0.06);
    --bg-reader: #ffffff;
}

/* Dark Mode Palette override */
[data-theme="dark"] {
    --bg-app: #030712;
    --bg-card: rgba(17, 24, 39, 0.6);
    --bg-sidebar: rgba(17, 24, 39, 0.45);
    --bg-navbar: rgba(17, 24, 39, 0.5);
    --border-color: rgba(255, 255, 255, 0.06);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 16px 48px 0 rgba(0, 0, 0, 0.3);
    --bg-reader: #111827;
}

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

body, .sidebar, .navbar, .topic-card, .tab-button, .tab-logout-btn, .tab-add-btn, .date-item, .search-box input, .view-toggle, .theme-toggle, .reader-view {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: var(--font-sans);
    font-weight: 300;
    background-color: #ffffff;
    background-image: linear-gradient(to bottom, #e3f2fd 0%, #f1f8ff 400px, #ffffff 800px);
    background-repeat: no-repeat;
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
}

[data-theme="dark"] body {
    background-color: var(--bg-app);
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 27, 75, 0.4) 0px, transparent 50%), 
        radial-gradient(at 100% 0%, rgba(2, 6, 23, 0.8) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(15, 23, 42, 0.5) 0px, transparent 50%);
    background-attachment: fixed;
    background-repeat: repeat;
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
    padding: 16px 10px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    text-decoration: none;
    width: 100%;
}

.logo-img {
    width: 240px;
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.logo h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 200;
    letter-spacing: 0.05em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 500;
}

.month-header {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-main);
    margin: 22px 0 10px 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.date-list > .month-header:first-of-type {
    margin-top: 0;
}

.date-list {
    list-style: none;
}

.date-item {
    position: relative;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: 300;
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    background-color: rgba(15, 23, 42, 0.02);
    border: 2px solid transparent;
}

.date-item:hover, .date-item.active {
    background-color: rgba(59, 130, 246, 0.08);
    color: var(--primary);
}

.date-item.active {
    font-weight: 500;
    --date-border-start: rgba(59, 130, 246, 0.45);
    --date-border-end: rgba(59, 130, 246, 0.1);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-main);
    cursor: pointer;
}

.nav-title {
    display: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Search Box */
.search-box {
    position: relative;
    width: 280px;
    border-radius: 99px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.82) 0%, rgba(147, 51, 234, 0.66) 48%, rgba(219, 39, 119, 0.58) 100%);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border-radius: 99px;
    border: 0;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background-color: var(--bg-sidebar);
}

/* Theme Toggle Button */
.theme-toggle {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.toggle-icon {
    font-size: 18px;
}

/* Page Body */
.page-body {
    flex: 1;
    padding: 32px;
    max-width: none;
    width: 100%;
    margin: 0;
    background-color: rgba(240, 249, 255, 0.42);
    border-radius: 0;
    overflow: hidden;
}

.page-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 2px 0 30px;
    text-align: center;
}

.page-logo img {
    width: 340px;
    height: auto;
    max-width: min(68vw, 420px);
    display: block;
    object-fit: contain;
    transition: all 0.3s ease;
}

[data-theme="dark"] .page-logo img {
    background: transparent !important;
}

.page-logo h2 {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 200;
    letter-spacing: 0.05em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.tabs {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin-bottom: 24px;
}

.tab-button {
    position: relative;
    --tab-border: linear-gradient(135deg, rgba(56, 189, 248, 0.45) 0%, rgba(167, 139, 250, 0.38) 50%, rgba(244, 114, 182, 0.34) 100%);
    min-width: 112px;
    min-height: 44px;
    padding: 8px 16px;
    border: 2px solid transparent !important;
    border-radius: 12px;
    background: linear-gradient(rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.02)) padding-box,
                var(--tab-border) border-box;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 300;
    line-height: 1.2;
}

.tab-button:hover,
.tab-button.active {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    --tab-border: linear-gradient(135deg, rgba(14, 165, 233, 0.82) 0%, rgba(147, 51, 234, 0.66) 48%, rgba(219, 39, 119, 0.58) 100%);
    background: linear-gradient(rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.08)) padding-box,
                var(--tab-border) border-box;
}

.tab-button.active {
    font-weight: 500;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

#tab-prep.active {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}


/* Logout Button */
.tab-logout-btn {
    position: relative;
    --tab-border: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    min-width: 112px;
    min-height: 44px;
    padding: 8px 16px;
    border: 2px solid transparent !important;
    border-radius: 12px;
    background: linear-gradient(rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.12)) padding-box,
                var(--tab-border) border-box;
    color: #ffffff !important;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all 0.2s ease;
}

.tab-logout-btn:hover {
    color: #ffffff !important;
    --tab-border: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    background: linear-gradient(rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.2)) padding-box,
                var(--tab-border) border-box;
}

[data-theme="dark"] .tab-logout-btn {
    --tab-border: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: #ffffff !important;
    background: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)) padding-box,
                var(--tab-border) border-box;
}

[data-theme="dark"] .tab-logout-btn:hover {
    color: #ffffff !important;
    --tab-border: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    background: linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1)) padding-box,
                var(--tab-border) border-box;
}

/* Glassmorphic Intro Card */
.intro-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-main);
}

.intro-card p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-muted);
}

/* Topics Responsive Grid */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
}

@media (max-width: 1800px) {
    .topics-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Topic Card */
.topic-card {
    position: relative;
    min-width: 0;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-main);
    border: 2px solid transparent !important;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    background: linear-gradient(to bottom, var(--card-bg-start, rgba(255, 255, 255, 0.65)) 0%, #ffffff 100%) padding-box,
                linear-gradient(135deg, var(--card-border-color, rgba(15, 23, 42, 0.15)) 0%, rgba(15, 23, 42, 0.02) 100%) border-box;
}

.card-body {
    height: 380px;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    padding-right: 6px;
    margin-bottom: 12px;
}

/* Custom Scrollbar for Card Body */
.card-body::-webkit-scrollbar {
    width: 6px;
}
.card-body::-webkit-scrollbar-track {
    background: transparent;
}
.card-body::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.1);
    border-radius: 99px;
}
[data-theme="dark"] .card-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}
.card-body::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.2);
}
[data-theme="dark"] .card-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}



[data-theme="dark"] .topic-card::before {
    background: linear-gradient(135deg, var(--card-border-color, rgba(255, 255, 255, 0.25)) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.topic-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 300;
    color: var(--card-title-color, #0f172a);
    margin-bottom: 12px;
    line-height: 1.4;
}

.topic-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    margin-bottom: 8px;
}

.article-date {
    font-size: 10px;
    font-weight: 300;
    line-height: 1.2;
    color: var(--text-muted);
}

.topic-artist {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    color: #0f172a;
    margin-bottom: 4px;
    line-height: 1.35;
}

[data-theme="dark"] .topic-card {
    background: linear-gradient(rgba(17, 24, 39, 0.6), rgba(17, 24, 39, 0.6)) padding-box,
                linear-gradient(135deg, var(--card-border-color, rgba(255, 255, 255, 0.25)) 0%, rgba(255, 255, 255, 0.03) 100%) border-box !important;
}

[data-theme="dark"] .page-body {
    background-color: rgba(15, 23, 42, 0.28);
}

[data-theme="dark"] .topic-title {
    color: #f8fafc !important;
}

.topic-summary {
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 300;
    line-height: 1.6;
    color: #334155;
    margin-bottom: 18px;
}

[data-theme="dark"] .topic-summary {
    color: #cbd5e1 !important;
}

.topic-summary strong {
    font-weight: 600;
    color: var(--text-main);
}

.fact-list {
    display: grid;
    gap: 7px;
    margin: 0 0 24px;
    padding-top: 2px;
}

.fact-row {
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: 10px;
    align-items: baseline;
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.45;
}

.fact-label {
    font-weight: 800;
}

.fact-value {
    color: #334155;
    font-weight: 300;
}

[data-theme="dark"] .fact-value {
    color: #cbd5e1 !important;
}

/* Dark Mode Color Overrides (Blue to White) */
[data-theme="dark"] .logo h2 {
    background: none;
    -webkit-text-fill-color: #ffffff;
    color: #ffffff;
}

[data-theme="dark"] .page-logo h2 {
    background: none;
    -webkit-text-fill-color: #ffffff;
    color: #ffffff;
}

[data-theme="dark"] .date-item {
    border: 2px solid transparent;
    --date-border-start: rgba(255, 255, 255, 0.25);
    --date-border-end: rgba(255, 255, 255, 0.04);
    background: linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03)) padding-box,
                linear-gradient(135deg, var(--date-border-start) 0%, var(--date-border-end) 100%) border-box;
}

[data-theme="dark"] .tab-button {
    --tab-border: linear-gradient(135deg, rgba(125, 211, 252, 0.42) 0%, rgba(196, 181, 253, 0.34) 50%, rgba(249, 168, 212, 0.3) 100%);
    background: linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03)) padding-box,
                var(--tab-border) border-box;
}

[data-theme="dark"] .date-item:hover, [data-theme="dark"] .date-item.active {
    background: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) padding-box,
                linear-gradient(135deg, var(--date-border-start) 0%, var(--date-border-end) 100%) border-box;
    color: #ffffff;
}

[data-theme="dark"] .tab-button:hover, [data-theme="dark"] .tab-button.active {
    color: #ffffff;
    --tab-border: linear-gradient(135deg, rgba(125, 211, 252, 0.82) 0%, rgba(196, 181, 253, 0.68) 50%, rgba(249, 168, 212, 0.58) 100%);
    background: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) padding-box,
                var(--tab-border) border-box;
}

[data-theme="dark"] .date-item.active {
    --date-border-start: rgba(255, 255, 255, 0.45);
    --date-border-end: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .topic-source {
    color: #ffffff !important;
}

[data-theme="dark"] .article-date {
    color: rgba(255, 255, 255, 0.58);
}

[data-theme="dark"] .btn-action {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--btn-color) 18%, transparent) 0%, 
        color-mix(in srgb, var(--btn-color) 4%, transparent) 100%
    ) !important;
    border-color: color-mix(in srgb, var(--btn-color) 25%, transparent) !important;
    color: color-mix(in srgb, var(--btn-color) 90%, #ffffff) !important;
}

[data-theme="dark"] .btn-action:hover {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--btn-color) 28%, transparent) 0%, 
        color-mix(in srgb, var(--btn-color) 8%, transparent) 100%
    ) !important;
    border-color: color-mix(in srgb, var(--btn-color) 40%, transparent) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .date-badge {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}

.card-footer {
    display: flex;
    justify-content: flex-start;
}

.source-link {
    display: inline-block;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    transition: all 0.2s ease;
}

.source-link:hover {
    text-decoration: underline;
    filter: brightness(0.85);
    transform: translateX(2px);
}

.btn-action {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--btn-color) 22%, #ffffff) 0%, 
        color-mix(in srgb, var(--btn-color) 6%, #ffffff) 100%
    );
    border: 1px solid color-mix(in srgb, var(--btn-color) 28%, #ffffff);
    color: var(--btn-color);
}

.btn-action:hover {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--btn-color) 30%, #ffffff) 0%, 
        color-mix(in srgb, var(--btn-color) 12%, #ffffff) 100%
    );
    border-color: color-mix(in srgb, var(--btn-color) 45%, #ffffff);
    color: var(--btn-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* No Results State */
.no-results {
    display: none;
    text-align: center;
    padding: 80px 20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-results-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.no-results h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

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

/* Footer */
.app-footer {
    padding: 24px 32px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    background-color: var(--bg-sidebar);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Breakpoints */
@media (max-width: 767px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
        background: rgba(15, 23, 42, 0.04);
        padding: 8px 12px;
        border-radius: 8px;
        border: 1px solid var(--border-color);
        transition: all 0.2s ease;
    }
    [data-theme="dark"] .menu-toggle {
        background: rgba(255, 255, 255, 0.04);
    }
    
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(24px) saturate(180%);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        border-bottom: 1px solid var(--border-color);
        padding: 12px 16px;
        z-index: 99;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    [data-theme="dark"] .navbar {
        background: rgba(3, 7, 18, 0.82);
    }
    
    .nav-left {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
    }
    
    .nav-title {
        display: block;
        font-family: var(--font-sans);
        font-size: 15.5px;
        font-weight: 600;
        color: var(--text-main);
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-right {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    
    .search-box {
        flex: 1;
        max-width: none;
        width: auto;
    }
    
    .view-toggle, .theme-toggle {
        flex-shrink: 0;
    }

    .page-body {
        padding: 128px 0 24px;
    }

    .page-logo {
        display: none;
    }

    .intro-card {
        margin-left: 16px;
        margin-right: 16px;
        margin-bottom: 20px;
        padding: 20px;
    }

    .tabs {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        gap: 8px;
        margin-left: 16px;
        margin-right: 16px;
        padding-bottom: 8px;
        margin-bottom: 16px;
        scrollbar-width: none; /* Hide scrollbar for Firefox */
    }
    
    .tabs::-webkit-scrollbar {
        display: none; /* Hide scrollbar for Chrome, Safari and Opera */
    }
    
    .tab-button, .tab-logout-btn, .tab-add-btn {
        flex-shrink: 0;
        min-width: auto;
        padding: 10px 16px;
        font-size: 15px;
    }

    .topics-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 16px;
    }

    .topic-card {
        border-radius: 16px;
        padding: 20px;
    }

    .topic-card::before {
        border-radius: 16px;
    }

    .topic-card:hover {
        transform: none;
    }

    .fact-row {
        grid-template-columns: 74px 1fr;
        gap: 8px;
    }
}

@media (max-width: 1200px) {
    .topics-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }

    .topic-card {
        padding: 22px;
    }
}

/* Password Gate Styling */
.password-gate {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    animation: fadeIn 0.4s ease-out;
}

.password-gate-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: all 0.3s ease;
}

[data-theme="dark"] .password-gate-card {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(17, 24, 39, 0.6);
}

.password-gate-icon {
    font-size: 44px;
    margin-bottom: 4px;
    display: inline-block;
}

.password-gate-card h3 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 500;
    color: var(--text-main);
    margin: 0;
}

.password-gate-card p {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.password-gate-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.password-gate-form input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 99px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 15px;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
}

.password-gate-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.password-gate-form button {
    width: 100%;
    padding: 12px 24px;
    border-radius: 99px;
    border: none;
    background: var(--primary-gradient);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.password-gate-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.password-gate-form button:active {
    transform: translateY(1px);
}

#password-error {
    color: #ef4444;
    font-size: 13.5px;
    font-weight: 500;
    display: none;
    margin-top: 4px;
}

/* Card action buttons */
.btn-close-card,
.btn-edit-card {
    position: absolute;
    top: 14px;
    width: 24px;
    height: 24px;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: var(--text-muted);
    transition: all 0.2s ease;
    z-index: 2;
}

.btn-close-card {
    right: 14px;
    border-radius: 50%;
}

.btn-edit-card {
    right: 44px;
    width: 25px;
    height: 25px;
    border-radius: 8px;
    color: var(--primary);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.btn-edit-card svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

[data-theme="dark"] .btn-close-card,
[data-theme="dark"] .btn-edit-card {
    background: rgba(255, 255, 255, 0.08);
}

.btn-close-card:hover {
    background: #ef4444;
    color: #ffffff !important;
    transform: scale(1.1);
}

.btn-edit-card:hover {
    background: var(--primary);
    color: #ffffff !important;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Custom Confirmation Modal Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-hover);
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 38px;
    display: block;
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--text-main);
    margin: 0;
}

.modal-content p {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 99px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.modal-btn.confirm {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.modal-btn.confirm:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.modal-btn.cancel {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .modal-btn.cancel {
    background: rgba(255, 255, 255, 0.08);
}

.modal-btn.cancel:hover {
    background: rgba(15, 23, 42, 0.1);
    color: var(--text-main);
}

[data-theme="dark"] .modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Billing Alert Banner */
.billing-alert-banner {
    background-color: #ef4444;
    color: #ffffff;
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #b91c1c;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    position: relative;
}

[data-theme="dark"] .billing-alert-banner {
    background-color: #dc2626;
    border-bottom-color: #991b1b;
}

/* View Toggle Button */
.view-toggle {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-toggle:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.view-toggle-icon {
    font-size: 18px;
}

/* Reader View styling */
.reader-view {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-reader);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 40px;
    box-shadow: var(--shadow-main);
    animation: fadeIn 0.4s ease-out;
}

.reader-article {
    position: relative;
    padding-bottom: 32px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.reader-article:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reader-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 300;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.35;
}

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

.reader-meta-tag {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.reader-summary {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-main);
    margin-bottom: 20px;
}

.reader-summary p {
    margin-bottom: 12px;
}

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

.reader-facts {
    background-color: rgba(15, 23, 42, 0.02);
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .reader-facts {
    background-color: rgba(255, 255, 255, 0.02);
}

.reader-fact-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14.5px;
    line-height: 1.5;
}

.reader-fact-row:last-child {
    margin-bottom: 0;
}

.reader-fact-label {
    font-weight: 700;
    width: 90px;
    flex-shrink: 0;
}

.reader-fact-value {
    flex: 1;
}

.reader-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.reader-link {
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}

.reader-link:hover {
    text-decoration: underline;
    transform: translateX(2px);
}

/* Mobile responsive for Reader View */
@media (max-width: 767px) {
    .reader-view {
        border-radius: 0;
        padding: 24px 20px;
        margin: 0;
        max-width: none;
    }
    
    .reader-title {
        font-size: 22px;
    }
    
    .reader-summary {
        font-size: 15px;
    }
    
    .reader-facts {
        padding: 14px 16px;
    }
    
    .reader-fact-row {
        gap: 8px;
        font-size: 13.5px;
    }
    
    .reader-fact-label {
        width: 80px;
    }
}

/* Plus Button & Modal Add CSS Styling */
.tab-add-btn {
    position: relative;
    --tab-border: linear-gradient(135deg, rgba(56, 189, 248, 0.45) 0%, rgba(167, 139, 250, 0.38) 50%, rgba(244, 114, 182, 0.34) 100%);
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent !important;
    border-radius: 12px;
    background: linear-gradient(rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.02)) padding-box,
                var(--tab-border) border-box;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    margin-left: 6px;
    transition: all 0.2s ease;
}

.tab-add-btn:hover {
    color: var(--primary);
    --tab-border: linear-gradient(135deg, rgba(14, 165, 233, 0.82) 0%, rgba(147, 51, 234, 0.66) 48%, rgba(219, 39, 119, 0.58) 100%);
    background: linear-gradient(rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.08)) padding-box,
                var(--tab-border) border-box;
    transform: scale(1.05);
}

[data-theme="dark"] .tab-add-btn {
    --tab-border: linear-gradient(135deg, rgba(125, 211, 252, 0.42) 0%, rgba(196, 181, 253, 0.34) 50%, rgba(249, 168, 212, 0.3) 100%);
    background: linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03)) padding-box,
                var(--tab-border) border-box;
}

[data-theme="dark"] .tab-add-btn:hover {
    color: #ffffff;
    --tab-border: linear-gradient(135deg, rgba(125, 211, 252, 0.82) 0%, rgba(196, 181, 253, 0.68) 50%, rgba(249, 168, 212, 0.58) 100%);
    background: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) padding-box,
                var(--tab-border) border-box;
}

.modal-btn.confirm-add {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.modal-btn.confirm-add:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.edit-modal-content {
    max-width: 760px;
    text-align: left;
    max-height: min(92vh, 860px);
    overflow-y: auto;
}

.edit-modal-content h3,
.edit-modal-content p,
.edit-modal-content .modal-icon {
    text-align: center;
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.edit-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.edit-form input,
.edit-form textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 300;
    line-height: 1.5;
    padding: 10px 12px;
    outline: none;
    resize: vertical;
    text-transform: none;
    letter-spacing: 0;
}

.edit-form textarea {
    min-height: 70px;
}

#edit-summary-input {
    min-height: 180px;
}

.edit-facts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

#edit-error-msg {
    display: none;
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

@media (max-width: 767px) {
    .edit-facts-grid {
        grid-template-columns: 1fr;
    }
}

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

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(15, 23, 42, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

[data-theme="dark"] .spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 350px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(20px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.toast.success {
    border-color: rgba(34, 197, 94, 0.4);
}
[data-theme="dark"] .toast.success {
    border-color: rgba(34, 197, 94, 0.2);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
}
[data-theme="dark"] .toast.error {
    border-color: rgba(239, 68, 68, 0.2);
}

.toast-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-main);
}

.toast-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s ease;
}

.toast-close-btn:hover {
    color: var(--text-main);
}

/* Toast Progress Bar */
.toast {
    position: relative;
    overflow: hidden;
}

.toast-progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(15, 23, 42, 0.05);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    overflow: hidden;
}
[data-theme="dark"] .toast-progress-bar-container {
    background: rgba(255, 255, 255, 0.08);
}
.toast-progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.4s cubic-bezier(0.1, 0.8, 0.1, 1);
}
.toast.success .toast-progress-bar {
    background: #22c55e;
}
.toast.error .toast-progress-bar {
    background: #ef4444;
}
