/* ══════════════════════════════════════
   CSS Variables — Dark / Light Theme
   ══════════════════════════════════════ */
:root,
[data-theme="dark"] {
    --bg-body: #08090e;
    --bg-surface: #12141e;
    --bg-surface-hover: #191c2a;
    --bg-surface-alt: #0e1018;
    --bg-input: #0c0d15;
    --bg-glass: rgba(18, 20, 30, 0.7);
    --border: #1e2136;
    --border-hover: #2d3250;
    --border-glow: rgba(124, 106, 239, 0.15);
    --text: #eaecf0;
    --text-secondary: #9ca3b4;
    --text-muted: #5f667a;
    --primary: #8b7cf8;
    --primary-hover: #7a6ae8;
    --primary-bg: rgba(139, 124, 248, 0.08);
    --primary-glow: rgba(139, 124, 248, 0.25);
    --accent-ai: #38bdf8;
    --accent-ai-bg: rgba(56, 189, 248, 0.06);
    --accent-edu: #f472b6;
    --accent-edu-bg: rgba(244, 114, 182, 0.06);
    --success: #34d399;
    --warning: #fbbf24;
    --error: #fb7185;
    --bookmark: #f43f5e;
    --gradient-ai: linear-gradient(135deg, #38bdf8, #8b7cf8);
    --gradient-edu: linear-gradient(135deg, #f472b6, #c084fc);
    --gradient-hero: linear-gradient(135deg, #38bdf8, #8b7cf8, #f472b6);
    --gradient-card: linear-gradient(135deg, rgba(139,124,248,0.12), rgba(56,189,248,0.08));
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.25);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.2);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.25);
    --shadow-glow: 0 0 20px rgba(139, 124, 248, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --navbar-bg: rgba(8, 9, 14, 0.8);
}

[data-theme="light"] {
    --bg-body: #f4f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f7f8fc;
    --bg-surface-alt: #f0f1f6;
    --bg-input: #f0f1f6;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --border: #e0e3eb;
    --border-hover: #c5c9d6;
    --border-glow: rgba(108, 92, 231, 0.1);
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --primary: #6c5ce7;
    --primary-hover: #5b4bd4;
    --primary-bg: rgba(108, 92, 231, 0.06);
    --primary-glow: rgba(108, 92, 231, 0.15);
    --accent-ai: #0284c7;
    --accent-ai-bg: rgba(2, 132, 199, 0.05);
    --accent-edu: #db2777;
    --accent-edu-bg: rgba(219, 39, 119, 0.05);
    --success: #059669;
    --warning: #d97706;
    --error: #e11d48;
    --bookmark: #e11d48;
    --gradient-ai: linear-gradient(135deg, #0284c7, #6c5ce7);
    --gradient-edu: linear-gradient(135deg, #db2777, #9333ea);
    --gradient-hero: linear-gradient(135deg, #0284c7, #6c5ce7, #db2777);
    --gradient-card: linear-gradient(135deg, rgba(108,92,231,0.06), rgba(2,132,199,0.04));
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.08);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.06);
    --navbar-bg: rgba(244, 245, 249, 0.85);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition-slow), color var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

::selection { background: var(--primary-bg); color: var(--primary); }

/* ══════════════════════════════════════
   Navigation
   ══════════════════════════════════════ */
.navbar {
    background: var(--navbar-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background var(--transition), border var(--transition);
}

.nav-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 60px;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    margin-right: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: var(--gradient-hero);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
}

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

.nav-spacer { flex: 1; }

.nav-link {
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.nav-link:hover { color: var(--text); background: var(--primary-bg); }
.nav-link.active { color: var(--primary); background: var(--primary-bg); font-weight: 600; }

.nav-user {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0 0.5rem;
}

.nav-logout { color: var(--text-muted) !important; font-size: 0.8rem; }
.nav-logout:hover { color: var(--error) !important; background: none !important; }

.btn-register {
    background: var(--primary) !important;
    color: #fff !important;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-xs);
    font-weight: 600;
}
.btn-register:hover { background: var(--primary-hover) !important; }

.theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.theme-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: auto;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

/* ══════════════════════════════════════
   Container
   ══════════════════════════════════════ */
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* ══════════════════════════════════════
   Hero
   ══════════════════════════════════════ */
.hero {
    text-align: center;
    padding: 5rem 1rem 3rem;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, var(--primary-glow) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0.4;
}

.hero h1 {
    font-size: 3.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.04em;
    line-height: 1.1;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 550px;
    margin: 0 auto;
    position: relative;
}

/* ══════════════════════════════════════
   Stats Bar
   ══════════════════════════════════════ */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0 3rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 0 1rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-top: 0.15rem;
}

/* ══════════════════════════════════════
   Category Cards (Main)
   ══════════════════════════════════════ */
.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3.5rem;
}

.category-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    text-align: center;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    transition: height 0.35s;
}

.ai-card::before { background: var(--gradient-ai); }
.edu-card::before { background: var(--gradient-edu); }

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--border-hover);
}

.category-card:hover::before { height: 4px; }

.card-icon { font-size: 3rem; margin-bottom: 1rem; filter: saturate(1.2); }
.category-card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; font-weight: 700; }
.category-card p { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.9rem; line-height: 1.6; }
.card-count {
    display: inline-block;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.25rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}

/* ══════════════════════════════════════
   Section Headers
   ══════════════════════════════════════ */
.section-header, .feed-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.feed-header h1 { font-size: 1.5rem; font-weight: 700; }
.feed-header p { color: var(--text-muted); font-size: 0.85rem; }

.see-all {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.see-all:hover { color: var(--primary); gap: 0.5rem; }

.preview-section { margin-bottom: 3rem; }
.preview-section h2 { font-size: 1.3rem; font-weight: 700; }

/* ══════════════════════════════════════
   Article Grid
   ══════════════════════════════════════ */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.article-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text);
    display: flex;
    flex-direction: column;
    position: relative;
}

.article-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    background: var(--gradient-card);
}

.article-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.5rem 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-summary {
    color: var(--text-secondary);
    font-size: 0.82rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.6rem;
    line-height: 1.6;
}

.card-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.73rem;
    color: var(--text-muted);
}

/* ══════════════════════════════════════
   Badges
   ══════════════════════════════════════ */
.card-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 5px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-news { background: var(--accent-ai-bg); color: var(--accent-ai); border: 1px solid rgba(56, 189, 248, 0.15); }
.badge-paper { background: var(--primary-bg); color: var(--primary); border: 1px solid rgba(139, 124, 248, 0.15); }
.badge-ai { background: var(--accent-ai-bg); color: var(--accent-ai); border: 1px solid rgba(56, 189, 248, 0.15); }
.badge-edu { background: var(--accent-edu-bg); color: var(--accent-edu); border: 1px solid rgba(244, 114, 182, 0.15); }

/* ══════════════════════════════════════
   Feed Controls
   ══════════════════════════════════════ */
.feed-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 0.2rem;
    background: var(--bg-surface);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.tab {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition);
}

.tab:hover { color: var(--text); background: var(--bg-surface-hover); }
.tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }

.search-form { display: flex; gap: 0.4rem; }

.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    width: 240px;
    transition: all var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.search-input::placeholder { color: var(--text-muted); }

/* ══════════════════════════════════════
   Article List (Feed)
   ══════════════════════════════════════ */
.article-list { display: flex; flex-direction: column; gap: 0.5rem; }

.article-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-row:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
    background: var(--gradient-card);
    transform: translateX(4px);
}

.article-row-content {
    flex: 1;
    padding: 0.9rem 1.2rem;
    color: var(--text);
    min-width: 0;
}

.article-row-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.article-row-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-row-summary {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin: 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ══════════════════════════════════════
   Bookmark Button
   ══════════════════════════════════════ */
.bookmark-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.6rem 0.8rem;
    transition: all var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.bookmark-btn:hover { color: var(--bookmark); transform: scale(1.15); }
.bookmark-btn.bookmarked { color: var(--bookmark); }

.bookmark-btn.large {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.bookmark-btn.large.bookmarked { background: rgba(244, 63, 94, 0.06); border-color: var(--bookmark); }

/* ══════════════════════════════════════
   Article Detail
   ══════════════════════════════════════ */
.article-detail { max-width: 800px; margin: 0 auto; }

.article-detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.article-detail h1 {
    font-size: 1.75rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.article-one-line {
    font-size: 1.05rem;
    color: var(--accent-ai);
    margin-bottom: 1.5rem;
    font-weight: 500;
    line-height: 1.6;
    padding: 1rem 1.25rem;
    background: var(--accent-ai-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-ai);
}

.article-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.article-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.article-summary { margin-bottom: 2rem; }

.article-summary p {
    color: var(--text);
    line-height: 1.85;
    margin-bottom: 1.25rem;
    padding-left: 1.25rem;
    border-left: 3px solid var(--primary);
    font-size: 0.95rem;
}

.article-original-title {
    margin-top: 2rem;
    padding: 1.2rem;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.article-original-title h3 {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.article-original-title p { font-size: 0.85rem; color: var(--text-secondary); }

.article-actions {
    margin-top: 2rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Related Articles */
.related-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.related-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.related-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--text);
    transition: all var(--transition);
}

.related-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.related-card h4 {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.related-card .card-meta { font-size: 0.68rem; }

/* ══════════════════════════════════════
   Q&A Section
   ══════════════════════════════════════ */
.qa-section {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.qa-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-ai);
}

.qa-section h2 {
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
    background: var(--gradient-ai);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.qa-description { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 1.2rem; }

.qa-input-area { display: flex; gap: 0.6rem; align-items: flex-end; }

.qa-input-area textarea {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    transition: border-color var(--transition);
}

.qa-input-area textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

.qa-input-area .btn { min-width: 100px; height: 48px; }

.qa-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.qa-results { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }

.qa-item {
    padding: 1.2rem;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: fadeSlide 0.3s ease;
}

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

.qa-question-display {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.qa-answer { color: var(--text); font-size: 0.88rem; line-height: 1.75; }
.qa-answer strong { color: var(--accent-ai); }
.qa-error { color: var(--error); font-size: 0.88rem; }

.qa-tools {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.qa-login-prompt { text-align: center; padding: 2rem; }
.qa-login-prompt a { color: var(--primary); font-weight: 600; }

/* ══════════════════════════════════════
   Buttons
   ══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    gap: 0.4rem;
}

.btn:hover { background: var(--bg-surface-hover); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: var(--shadow-sm), 0 0 15px var(--primary-glow); }
.btn-secondary { background: transparent; }
.btn-search { padding: 0.5rem 0.9rem; }
.btn-full { width: 100%; padding: 0.65rem; }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); padding: 0.4rem 0.6rem; }
.btn-ghost:hover { color: var(--primary); background: var(--primary-bg); }

/* ══════════════════════════════════════
   Auth Forms
   ══════════════════════════════════════ */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-hero);
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 { font-size: 1.5rem; margin-bottom: 0.4rem; font-weight: 700; }
.auth-header p { color: var(--text-secondary); font-size: 0.85rem; }

.auth-form { display: flex; flex-direction: column; gap: 1.2rem; }

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-group input::placeholder { color: var(--text-muted); }

.auth-link { text-align: center; margin-top: 1.25rem; color: var(--text-muted); font-size: 0.85rem; }

/* ══════════════════════════════════════
   Flash Messages
   ══════════════════════════════════════ */
.flash-container { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 0.4rem; }

.flash {
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeSlide 0.3s ease;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.6;
}
.flash-close:hover { opacity: 1; }

.flash-success { background: rgba(52, 211, 153, 0.06); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.15); }
.flash-error { background: rgba(251, 113, 133, 0.06); color: var(--error); border: 1px solid rgba(251, 113, 133, 0.15); }
.flash-warning { background: rgba(251, 191, 36, 0.06); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.15); }
.flash-info { background: var(--primary-bg); color: var(--primary); border: 1px solid rgba(139, 124, 248, 0.15); }

/* ══════════════════════════════════════
   Pagination
   ══════════════════════════════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    margin-top: 2rem;
}

.page-link {
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.page-link:hover { background: var(--bg-surface); color: var(--text); border-color: var(--border); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-dots { color: var(--text-muted); padding: 0 0.2rem; font-size: 0.8rem; }

/* ══════════════════════════════════════
   Empty State & Error
   ══════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-muted);
}

.empty-state p { font-size: 1rem; margin-bottom: 1rem; }

.error-page { text-align: center; padding: 5rem 1rem; }

.error-page h1 {
    font-size: 5rem;
    font-weight: 800;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.error-page p { color: var(--text-secondary); margin-bottom: 2rem; font-size: 1.05rem; }

/* ══════════════════════════════════════
   Popular Section
   ══════════════════════════════════════ */
.popular-section {
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.popular-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }

.popular-list { display: flex; flex-direction: column; gap: 0.5rem; }

.popular-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: all var(--transition);
}

.popular-item:hover { background: var(--bg-surface); }

.popular-rank {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.popular-item h4 {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.popular-item .card-badge { flex-shrink: 0; }

/* ══════════════════════════════════════
   View Count
   ══════════════════════════════════════ */
.view-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ══════════════════════════════════════
   Footer
   ══════════════════════════════════════ */
.footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
    transition: border var(--transition);
}

.footer-content p { color: var(--text-muted); font-size: 0.8rem; }
.footer-sub { font-size: 0.7rem; margin-top: 0.2rem; color: var(--text-muted); opacity: 0.5; }

/* ══════════════════════════════════════
   Responsive
   ══════════════════════════════════════ */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        padding: 1rem 1.5rem;
        gap: 0.2rem;
        box-shadow: var(--shadow-lg);
    }
    .nav-links.open { display: flex; }
    .nav-toggle { display: flex; }
    .nav-spacer { display: none; }
    .nav-user { padding: 0.4rem 0.75rem; }
    .nav-container { padding: 0 1rem; }

    .hero h1 { font-size: 2rem; }
    .hero { padding: 3rem 1rem 2rem; }
    .hero::before { width: 300px; height: 200px; }
    .stats-bar { gap: 1rem; }
    .stat-value { font-size: 1.4rem; }
    .article-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr; }
    .feed-controls { flex-direction: column; align-items: stretch; }
    .search-input { width: 100%; }
    .search-form { width: 100%; }
    .article-detail h1 { font-size: 1.3rem; }
    .article-row-header h3 { white-space: normal; }
    .category-cards { grid-template-columns: 1fr; }
    .auth-container { margin: 1.5rem; padding: 1.5rem; }
    .theme-toggle { margin-left: 0; margin-top: 0.5rem; align-self: flex-start; }

    .qa-input-area { flex-direction: column; }
    .qa-input-area .btn { width: 100%; }
}

@media (max-width: 480px) {
    .container { padding: 1rem; }
    .hero h1 { font-size: 1.6rem; }
    .category-card { padding: 1.5rem; }
    .article-card { padding: 1rem; }
    .popular-section { padding: 1.2rem; }
}
