:root {
    --bg-main: #f3f6f9;
    --bg-sidebar: #fdfdfe;
    --text-primary: #1e293b;
    --text-secondary: #526071;
    --accent: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --accent-hover: #2563eb;
    --accent-warm: #f59e0b;
    --accent-warm-light: #fef3c7;
    --border: #d1d5db;
    --card-bg: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.03), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.05), 0 10px 10px -5px rgba(0,0,0,0.02);
    --blue-glow: 0 0 15px rgba(37, 99, 235, 0.4);
    --warm-glow: 0 0 15px rgba(245, 158, 11, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    box-shadow: 4px 0 15px rgba(0,0,0,0.03);
    position: relative;
}

.sidebar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(to top, var(--bg-sidebar), rgba(255,255,255,0));
    pointer-events: none;
}

.logo {
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.logo h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-section {
    margin-bottom: 2.5rem;
}

.nav-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

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

.topic-item {
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.3rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    color: var(--text-primary);
}

.topic-item:hover {
    background-color: var(--bg-main);
}

.topic-item.active {
    background-color: #eff6ff;
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Calendar */
.calendar-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
}

.calendar-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.calendar-header button:hover {
    background-color: var(--bg-main);
    color: var(--text-primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.day-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day:not(.empty):hover {
    background-color: var(--bg-main);
}

.calendar-day.has-articles {
    font-weight: 700;
    color: #b45309;
    background-color: var(--accent-warm-light);
}

.calendar-day.has-articles:hover {
    background-color: #fde68a;
}

.calendar-day.selected {
    background-color: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--blue-glow);
}

.btn-clear {
    margin-top: 1rem;
    width: 100%;
    padding: 0.6rem;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 3rem 4rem;
    max-width: 1200px;
}

.top-header {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    margin-bottom: 3.5rem;
    min-height: 160px;
    display: flex;
    align-items: center;
    padding: 3rem;
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.header-banner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.6;
    mix-blend-mode: multiply;
}

.top-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--accent-gradient);
    z-index: 2;
}

.top-header h1 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.8;
}

.top-header h1 {
    position: relative;
    z-index: 1;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Articles List */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s, border-color 0.3s;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.article-card::after {
    content: '→';
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.article-card:hover::after {
    opacity: 1;
    color: var(--accent);
    transform: translateX(0);
}

.article-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topic-badge {
    background: #e0e7ff;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    color: var(--accent);
    border: 1px solid #c7d2fe;
}

.article-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    line-height: 1.3;
}

.article-preview {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Reader Overlay */
.reader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.reader-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.reader-panel {
    background: var(--card-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 3rem 4rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reader-overlay.hidden .reader-panel {
    transform: translateY(20px);
}

.reader-panel::-webkit-scrollbar {
    width: 8px;
}
.reader-panel::-webkit-scrollbar-track {
    background: transparent; 
}
.reader-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 10px;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.reader-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Markdown Reading Styles */
.markdown-body {
    color: #334155;
    font-size: 1.1rem;
    line-height: 1.7;
}

.markdown-body h1 {
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.markdown-body h2 {
    font-size: 1.6rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.markdown-body h3 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.markdown-body p {
    margin-bottom: 1.2rem;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    background: var(--bg-main);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #db2777;
    border: 1px solid var(--border);
}

.markdown-body pre {
    background: #f1f5f9;
    padding: 1.2rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px dashed var(--border);
    font-size: 1.1rem;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1024px) {
    .sidebar { width: 280px; }
    .main-content { padding: 2rem; }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar::after { display: none; }

    .nav-section {
        margin-bottom: 1.5rem;
    }

    /* Make topics horizontally scrollable */
    .topic-list {
        display: flex;
        overflow-x: auto;
        gap: 0.8rem;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .topic-list::-webkit-scrollbar { height: 4px; }
    .topic-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

    .topic-item {
        white-space: nowrap;
        margin-bottom: 0;
    }

    .main-content {
        padding: 1.5rem;
    }

    .top-header {
        min-height: 120px;
        padding: 2rem 1.5rem;
        border-radius: 16px;
        margin-bottom: 2rem;
    }

    .top-header h1 {
        font-size: 1.6rem;
    }

    .article-card {
        padding: 1.5rem;
    }

    .article-card::after { display: none; /* Hide hover arrow on mobile */ }

    /* Reader Panel Full Screen */
    .reader-overlay {
        padding: 0;
        background: var(--card-bg); /* Opaque bg on mobile */
    }

    .reader-panel {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        padding: 1.5rem;
        padding-top: 5rem; /* Room for close button */
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
        background: var(--bg-main);
        z-index: 10;
        position: fixed; /* Stick to top right even when scrolling */
        box-shadow: var(--shadow-sm);
    }

    .markdown-body h1 {
        font-size: 1.8rem;
    }
    
    .markdown-body p, .markdown-body li {
        font-size: 1.05rem;
    }
}
