:root {
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --bg-hover: #f0f2f4;
    --bg-input: #eef1f4;
    --bg-input-focus: #ffffff;
    --text-primary: #1a1d21;
    --text-secondary: #656d76;
    --text-tertiary: #8b949e;
    --border-primary: #d1d5db;
    --border-secondary: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: #eff6ff;
    --accent-text: #1e40af;
    --red: #dc2626;
    --red-subtle: #fef2f2;
    --green: #16a34a;
    --green-subtle: #f0fdf4;
    --amber: #d97706;
    --amber-subtle: #fffbeb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-lg: 14px;
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #1c2128;
    --bg-input: #1c2128;
    --bg-input-focus: #22272e;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --border-primary: #30363d;
    --border-secondary: #21262d;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-subtle: #0d1f3c;
    --accent-text: #79b8ff;
    --red: #f85149;
    --red-subtle: #2d1214;
    --green: #3fb950;
    --green-subtle: #0d2818;
    --amber: #d29922;
    --amber-subtle: #2e1f0f;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-secondary);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.logo-text h1 {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.logo-text p {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

/* ── Header Links ── */
.header-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    transition: all 0.2s;
    text-decoration: none;
}

.header-links a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

.header-links a svg {
    width: 14px;
    height: 14px;
}

.header-momo {
    width: auto !important;
    padding: 0 12px !important;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, #ff6b35, #e84118);
    color: #fff !important;
    border-color: transparent !important;
}

.header-momo:hover {
    background: linear-gradient(135deg, #e84118, #c0392b) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(232,65,24,0.3);
}

/* ── Search ── */
.search-box {
    position: relative;
    width: 100%;
    max-width: 360px;
}

.search-box input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.search-box input::placeholder { color: var(--text-tertiary); }

.search-box input:focus {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

[data-theme="dark"] .search-box input:focus {
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}

.search-box svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* ── Theme Toggle ── */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--border-primary);
    background: var(--bg-input);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.theme-toggle svg { width: 18px; height: 18px; }

.theme-toggle .icon-sun,
.theme-toggle .icon-moon,
.theme-toggle .icon-auto { display: none; }

[data-theme-mode="light"] .theme-toggle .icon-sun { display: block; }
[data-theme-mode="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme-mode="system"] .theme-toggle .icon-auto { display: block; }

/* ── Hero Stats ── */
.hero {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px 0;
}

.stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    flex: 1;
    min-width: 140px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--border-primary);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Download All ── */
.section-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-download-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.btn-download-all:hover {
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    transform: translateY(-1px);
}

.btn-download-all:active {
    transform: translateY(0);
}

.btn-download-all:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-download-all svg {
    width: 16px;
    height: 16px;
}

.download-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
}

.progress-bar {
    flex: 1;
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    min-width: 70px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #7c3aed);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Main Content ── */
main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

.section {
    margin-bottom: 28px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.section-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 7px;
    border-radius: 10px;
}

/* ── File List ── */
.file-list {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-secondary);
    overflow: hidden;
    transition: border-color 0.2s;
}

.file-list:hover { border-color: var(--border-primary); }

.file-item {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-secondary);
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-hover); }

.file-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 14px;
    background: var(--red-subtle);
    color: var(--red);
}

.file-icon svg { width: 20px; height: 20px; }

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 550;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.file-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 12px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.file-item:hover .file-actions { opacity: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 550;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn svg { width: 15px; height: 15px; }

.btn-download {
    background: var(--accent-subtle);
    color: var(--accent-text);
    border-color: transparent;
}

.btn-download:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-view {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

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

/* ── Link Button & Highlight ── */
.btn-link {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    padding: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn-link svg { width: 15px; height: 15px; }

.btn-link:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.btn-link.copied::after {
    content: 'Copied!';
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    animation: tooltipFade 1.5s ease forwards;
}

@keyframes tooltipFade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

.file-card.highlight {
    animation: highlightPulse 2s ease;
}

@keyframes highlightPulse {
    0%, 100% { background: transparent; }
    15%, 50% { background: var(--accent-subtle); }
}

/* ── File Card & Syllabus Preview ── */
.file-card {
    border-bottom: 1px solid var(--border-secondary);
}

.file-card:last-child { border-bottom: none; }

.file-card .file-item {
    border-bottom: none;
}

.file-card.has-topics .file-item {
    cursor: pointer;
}

.btn-syllabus {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    padding: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-syllabus .chevron-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.25s;
}

.file-card.expanded .btn-syllabus .chevron-icon {
    transform: rotate(180deg);
}

.syllabus-preview {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 18px 0 70px;
    background: var(--bg-tertiary);
    border-top: 1px solid transparent;
}

.file-card.expanded .syllabus-preview {
    max-height: 500px;
    padding: 14px 18px 14px 70px;
    border-top-color: var(--border-secondary);
}

.syllabus-preview ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.syllabus-preview li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 14px;
    position: relative;
}

.syllabus-preview li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.5;
}

.syllabus-preview li strong {
    color: var(--text-primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .syllabus-preview,
    .file-card.expanded .syllabus-preview {
        padding-left: 14px;
    }
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    margin-left: 8px;
    vertical-align: middle;
}

.badge-syllabus { background: var(--green-subtle); color: var(--green); }
.badge-questions { background: var(--amber-subtle); color: var(--amber); }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-tertiary);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    font-weight: 500;
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-tertiary);
    font-size: 13px;
    border-top: 1px solid var(--border-secondary);
    margin-top: 32px;
}

footer p {
    margin-top: 14px;
}

footer p a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

footer p a:hover { text-decoration: underline; }

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.footer-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-secondary);
    color: var(--text-secondary);
    transition: all 0.2s;
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text-primary);
    border-color: var(--border-primary);
    background: var(--bg-hover);
}

.footer-links a svg {
    width: 14px;
    height: 14px;
}

.footer-momo {
    width: auto !important;
    padding: 0 14px !important;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #ff6b35, #e84118);
    color: #fff !important;
    border-color: transparent !important;
}

.footer-momo:hover {
    background: linear-gradient(135deg, #e84118, #c0392b) !important;
    color: #fff !important;
    box-shadow: 0 2px 10px rgba(232,65,24,0.3);
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .header-content { height: 56px; gap: 10px; }
    .logo-text p { display: none; }
    .hero { padding: 20px 16px 0; }
    .stats-row { gap: 8px; }
    .stat-card { padding: 12px 14px; min-width: 100px; }
    .stat-value { font-size: 22px; }
    main { padding: 16px; }
    .file-item { padding: 12px 14px; }
    .btn span { display: none; }
    .btn { padding: 7px; }
    .file-actions { gap: 4px; opacity: 1; }
    .search-box { max-width: none; }
    .header-momo { display: none !important; }
    .header-links { display: none; }
    .btn-link { display: none; }
    .btn-download-all { font-size: 11px; padding: 6px 10px; }
    .btn-download-all svg { width: 13px; height: 13px; }
}

@media (max-width: 420px) {
    .stat-card { min-width: 80px; }
    .logo-icon { width: 32px; height: 32px; border-radius: 8px; }
    .logo-icon svg { width: 16px; height: 16px; }
    .logo-text h1 { font-size: 15px; }
}
