/* ============================================================
   MassComm - modern.css  (loaded AFTER styles.css)
   Visual refresh only: no layout/structure or behaviour changes.
   To go back to the old look, remove the <link> to this file.
   ============================================================ */

:root {
    --mc-ink: #0f172a;
    --mc-ink-2: #334155;
    --mc-muted: #64748b;
    --mc-bg: #f6f7fb;
    --mc-surface: #ffffff;
    --mc-line: #e5e8f0;
    --mc-accent: #c8102e;
    --mc-accent-d: #a50d26;
    --mc-accent-soft: #fdecef;
    --mc-navy: #0f1b3d;
    --mc-accent-rgb: 200,16,46; --mc-deep: #7c1d3a; --mc-navy-2: #1e2f63; --mc-glow-rgb: 59,91,219;
    --mc-t1a: #d6213f; --mc-t1b: #a50d26; --mc-t2a: #1e2f63; --mc-t2b: #0f1b3d; --mc-t3a: #3b5bdb; --mc-t3b: #2a43a8;
    --mc-radius: 16px;
    --mc-radius-sm: 10px;
    --mc-shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
    --mc-shadow-h: 0 2px 4px rgba(15,23,42,.06), 0 16px 36px rgba(15,23,42,.12);

    /* re-point the old tokens so every old rule picks up the new palette */
    --bbc-red: var(--mc-accent);
    --bbc-dark: var(--mc-ink);
    --bbc-black: var(--mc-navy);
    --bbc-white: var(--mc-surface);
    --bbc-gray: var(--mc-muted);
    --bbc-light-gray: #f1f4f9;
    --bbc-border: var(--mc-line);
    --bbc-hover: #eef1f7;
}

html[data-theme="dark"] {
    --mc-ink: #e8ecf7;
    --mc-ink-2: #c3cce0;
    --mc-muted: #94a0bd;
    --mc-bg: #0b1120;
    --mc-surface: #131b2e;
    --mc-line: #26304a;
    --mc-accent: #ef4a63;
    --mc-accent-d: #d93a53;
    --mc-accent-soft: #2a1620;
    --mc-navy: #0b1120;
    --mc-shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --mc-shadow-h: 0 2px 4px rgba(0,0,0,.35), 0 16px 36px rgba(0,0,0,.4);
    --bbc-light-gray: #19223a;
    --bbc-hover: #1d2742;
    color-scheme: dark;
}


/* ---------- Colour palettes: classic (default) / emerald / royal ----------
   Preview any of them with  ?palette=emerald  or  ?palette=royal  on any page
   (the choice is remembered in that browser).  ?palette=classic goes back. */
html[data-palette="emerald"] {
    --mc-accent: #0f8a5f; --mc-accent-d: #0b6e4c; --mc-accent-soft: #e6f6ef; --mc-accent-rgb: 15,138,95;
    --mc-deep: #064e3b; --mc-navy: #07281f; --mc-navy-2: #0f4a39; --mc-glow-rgb: 14,165,164;
    --mc-t1a: #14a374; --mc-t1b: #0b6e4c; --mc-t2a: #0f4a39; --mc-t2b: #07281f; --mc-t3a: #0ea5a4; --mc-t3b: #0b7c7b;
}
html:not([data-palette="classic"]):not([data-palette="emerald"]) {
    --mc-accent: #6d28d9; --mc-accent-d: #5b21b6; --mc-accent-soft: #f1eafe; --mc-accent-rgb: 109,40,217;
    --mc-deep: #3b0764; --mc-navy: #1a1038; --mc-navy-2: #2e1a66; --mc-glow-rgb: 219,39,119;
    --mc-t1a: #7c3aed; --mc-t1b: #5b21b6; --mc-t2a: #2e1a66; --mc-t2b: #1a1038; --mc-t3a: #db2777; --mc-t3b: #a21caf;
}
html[data-theme="dark"][data-palette="emerald"] { --mc-accent: #34d399; --mc-accent-d: #22b883; --mc-accent-soft: #0f2a22; --mc-accent-rgb: 52,211,153; --mc-navy: #0b1120; }
html[data-theme="dark"]:not([data-palette="classic"]):not([data-palette="emerald"]) { --mc-accent: #a78bfa; --mc-accent-d: #8b6cf0; --mc-accent-soft: #231a40; --mc-accent-rgb: 167,139,250; --mc-navy: #0b1120; }

body {
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--mc-bg);
    color: var(--mc-ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}
h1, h2, h3, .section-title, .category-card-title, .logo { letter-spacing: -0.01em; }

/* ---------- Header ---------- */
.header {
    background: color-mix(in srgb, var(--mc-surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--mc-line);
    box-shadow: 0 1px 0 rgba(15,23,42,.02);
}
.header-inner { height: 64px; }
.logo {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--mc-ink);
    letter-spacing: -0.03em;
}
.logo span { color: var(--mc-accent); }
.logo::before {
    content: 'MC';
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; margin-right: 10px; vertical-align: middle;
    background: linear-gradient(135deg, var(--mc-accent), var(--mc-deep));
    color: #fff; border-radius: 9px; font-size: 13px; font-weight: 800; letter-spacing: 0;
}
.nav-links { gap: 4px; margin-left: 24px; }
.nav-link {
    color: var(--mc-ink-2);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .02em;
    padding: 9px 14px;
    border: none;
    border-radius: 999px;
    transition: background .15s, color .15s;
}
.nav-link:hover { color: var(--mc-ink); background: var(--bbc-hover); }
.nav-link.active { color: var(--mc-accent); background: var(--mc-accent-soft); border: none; }

.login-btn, .admin-login-btn, .logout-btn {
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 8px 18px;
    font-size: 12px;
    transition: transform .12s, background .15s, box-shadow .15s;
}
.login-btn { background: var(--mc-accent); color: #fff; box-shadow: 0 4px 12px rgba(var(--mc-accent-rgb),.25); }
.login-btn:hover { background: var(--mc-accent-d); transform: translateY(-1px); }
.admin-login-btn, .logout-btn { background: transparent; color: var(--mc-ink-2); border: 1px solid var(--mc-line); }
.admin-login-btn:hover, .logout-btn:hover { background: var(--bbc-hover); color: var(--mc-ink); }
.user-info, #userName { color: var(--mc-ink); }
#adminDownloadToggle { background: var(--bbc-light-gray) !important; border-radius: 999px !important; }
#siteDlLabel { color: var(--mc-ink) !important; }

.theme-toggle {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--mc-line); background: transparent; color: var(--mc-ink-2);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px; line-height: 1; transition: background .15s, transform .12s;
}
.theme-toggle:hover { background: var(--bbc-hover); transform: rotate(12deg); }
.menu-toggle span { background: var(--mc-ink); }

/* ---------- Hero ---------- */
.hero {
    background:
        radial-gradient(900px 380px at 85% -10%, rgba(var(--mc-accent-rgb),.10), transparent 60%),
        radial-gradient(700px 360px at 0% 0%, rgba(var(--mc-glow-rgb),.10), transparent 60%),
        var(--mc-bg);
    border-bottom: 1px solid var(--mc-line);
    padding: 64px 0 72px;
}
.hero h1 {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: clamp(32px, 4.6vw, 52px);
    line-height: 1.08;
    letter-spacing: -0.035em;
    color: var(--mc-ink);
}
.hero-tag {
    display: inline-block;
    background: var(--mc-accent-soft);
    color: var(--mc-accent);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
}
.hero-desc { color: var(--mc-muted); font-size: 17px; line-height: 1.65; max-width: 520px; }
.search-box {
    max-width: 540px;
    background: var(--mc-surface);
    border: 1px solid var(--mc-line);
    border-radius: 999px;
    box-shadow: var(--mc-shadow);
    padding: 5px 5px 5px 8px;
    transition: box-shadow .2s, border-color .2s;
}
.search-box:focus-within { border-color: var(--mc-accent); box-shadow: 0 0 0 4px var(--mc-accent-soft), var(--mc-shadow); }
.search-box input {
    background: transparent; color: var(--mc-ink);
    padding: 12px 16px; font-size: 15px; border-radius: 999px;
}
.search-box input::placeholder { color: var(--mc-muted); }
.search-btn, #searchBtn {
    background: var(--mc-accent); color: #fff;
    border-radius: 999px; padding: 0 18px; min-width: 48px;
}
#searchBtn svg { stroke: #fff; }
.search-btn:hover, #searchBtn:hover { background: var(--mc-accent-d); }

.hero-card-grid { gap: 14px; }
.hero-card {
    border-radius: var(--mc-radius);
    padding: 24px 12px;
    border: 1px solid var(--mc-line);
    box-shadow: var(--mc-shadow);
}
.hero-card:hover { transform: translateY(-4px); box-shadow: var(--mc-shadow-h); }
.hc-red   { background: linear-gradient(135deg, var(--mc-t1a), var(--mc-t1b)); border-color: transparent; }
.hc-dark  { background: linear-gradient(135deg, var(--mc-t2a), var(--mc-t2b)); border-color: transparent; }
.hc-gray  { background: linear-gradient(135deg, var(--mc-t3a), var(--mc-t3b)); border-color: transparent; }
.hc-label { font-weight: 600; letter-spacing: .04em; }

/* ---------- Sections ---------- */
.categories-section, .most-downloaded-section { padding: 56px 0; background: transparent; border: none; }
.most-downloaded-section { border-top: 1px solid var(--mc-line); }
.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 28px; font-weight: 800;
    border: none; padding: 0; margin-bottom: 26px;
    display: block; position: relative;
}
.section-title::after {
    content: ''; display: block; width: 44px; height: 4px; border-radius: 4px;
    background: var(--mc-accent); margin-top: 10px;
}

/* ---------- Cards ---------- */
.category-card, .subject-card, .most-downloaded-card, .paper-card, .blog-post-card, .toc-note-card {
    background: var(--mc-surface);
    border: 1px solid var(--mc-line);
    border-radius: var(--mc-radius);
    box-shadow: var(--mc-shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.category-card:hover, .subject-card:hover, .most-downloaded-card:hover, .paper-card:hover, .blog-post-card:hover {
    background: var(--mc-surface);
    transform: translateY(-4px);
    box-shadow: var(--mc-shadow-h);
    border-color: color-mix(in srgb, var(--mc-accent) 35%, var(--mc-line));
}
.category-card { padding: 26px 24px; position: relative; overflow: hidden; }
.category-card::after {
    content: '\2192'; position: absolute; right: 20px; bottom: 16px;
    color: var(--mc-accent); font-size: 18px; opacity: 0; transform: translateX(-6px);
    transition: opacity .18s, transform .18s;
}
.category-card:hover::after { opacity: 1; transform: none; }
.category-card-number {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 28px; padding: 0 10px; border-radius: 8px;
    background: var(--mc-accent-soft); color: var(--mc-accent);
    font-size: 12px; font-weight: 800; letter-spacing: .04em; margin-bottom: 14px;
}
.category-card-title {
    font-family: 'Inter', sans-serif; font-weight: 700; font-size: 18px; color: var(--mc-ink);
}
.category-card-count { color: var(--mc-muted); font-weight: 500; }
.categories-grid, .most-downloaded-grid { gap: 18px; }
.admin-add-card { border: 2px dashed var(--mc-line); background: transparent; box-shadow: none; }

.most-downloaded-card { padding: 20px; }
.md-rank { color: var(--mc-accent); font-family: 'Inter', sans-serif; font-weight: 800; }

/* ---------- Buttons ---------- */
.download-btn, .md-download-btn, .toc-btn-read, .action-btn.primary, .submit-btn, .upload-btn, .write-essay-btn {
    background: var(--mc-accent); color: #fff; border: none;
    border-radius: 999px; font-weight: 600; letter-spacing: .02em;
    transition: transform .12s, background .15s, box-shadow .15s;
}
.download-btn:hover, .md-download-btn:hover, .toc-btn-read:hover, .action-btn.primary:hover, .submit-btn:hover, .upload-btn:hover, .write-essay-btn:hover {
    background: var(--mc-accent-d); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(var(--mc-accent-rgb),.25);
}
.back-btn, .toc-btn, .toc-btn-test, .toc-btn-download {
    border-radius: 999px; font-weight: 600;
}
.back-btn { background: transparent; color: var(--mc-ink-2); border: 1px solid var(--mc-line); padding: 8px 18px; }
.back-btn:hover { background: var(--bbc-hover); }

/* ---------- Table-of-contents rows (subjects inside a category) ---------- */
.toc-container, .toc-list {
    background: var(--mc-surface); border: 1px solid var(--mc-line);
    border-radius: var(--mc-radius); overflow: hidden; box-shadow: var(--mc-shadow);
}
.toc-item { border-bottom: 1px solid var(--mc-line); padding: 18px 22px; transition: background .15s; }
.toc-item:last-child { border-bottom: none; }
.toc-item:hover, .toc-item-active { background: var(--bbc-light-gray); }
.toc-group-head { background: var(--bbc-light-gray); border-bottom: 1px solid var(--mc-line); }
.toc-note-card { box-shadow: none; padding: 14px 18px; border-radius: 12px; }
.toc-note-card:hover { border-color: color-mix(in srgb, var(--mc-accent) 35%, var(--mc-line)); transform: none; box-shadow: var(--mc-shadow); }
.toc-note-link { color: var(--mc-ink); font-weight: 600; }
.toc-test-flag { background: #e8f7ee; color: #15803d; border-radius: 999px; padding: 2px 10px; font-weight: 600; }
html[data-theme="dark"] .toc-test-flag { background: #11291d; color: #4ade80; }
.toc-btn-delete, .toc-mini-delete { border-radius: 8px; }
.toc-mini-edit:hover { background: var(--mc-ink); }
.view-header h2 { font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: -0.02em; }

/* ---------- Stats ---------- */
.stats {
    background: linear-gradient(135deg, var(--mc-navy), var(--mc-navy-2));
    border: none;
    margin: 8px 0 0;
}
.stat-number { font-family: 'Inter', sans-serif; font-weight: 800; color: #fff; }
.stat-label { color: rgba(255,255,255,.65); font-weight: 600; }

/* ---------- Contact / request ---------- */
.request-section { background: var(--mc-bg); padding: 64px 0; }
.request-form-wrap, .request-grid > div:last-child {
    background: var(--mc-surface); border: 1px solid var(--mc-line);
    border-radius: 20px; box-shadow: var(--mc-shadow);
}
.request-info h2, .request-info h3 { font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: -0.02em; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
    font-family: inherit; color: var(--mc-ink); background: var(--mc-surface);
    border: 1px solid var(--mc-line); border-radius: var(--mc-radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--mc-accent); box-shadow: 0 0 0 3px var(--mc-accent-soft);
}
.request-section .submit-btn, #contactForm .submit-btn { border-radius: 12px; padding: 14px; }
.request-info a, a.btn-email, a[href^="mailto:"].action-btn { border-radius: 999px; }

/* ---------- Footer ---------- */
.footer { background: var(--mc-navy); color: rgba(255,255,255,.55); padding: 36px 0; }
.footer a, .footer-links a { color: rgba(255,255,255,.8); }
.footer a:hover { color: #fff; }

/* ---------- Modals ---------- */
.modal { background: rgba(10,16,32,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-content {
    background: var(--mc-surface); color: var(--mc-ink);
    border: 1px solid var(--mc-line); border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.form-group label { color: var(--mc-ink-2); font-weight: 600; }

/* ---------- Blog ---------- */
.blog-post-card { overflow: hidden; }
.blog-post-title { font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: -0.02em; }
.blog-card-image { border-radius: 0; }

/* ---------- Search suggestions ---------- */
#searchSuggestions {
    background: var(--mc-surface) !important; border: 1px solid var(--mc-line) !important;
    border-radius: 14px !important; box-shadow: var(--mc-shadow-h) !important; overflow: hidden;
}
.search-suggestion-item:hover { background: var(--bbc-light-gray); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
    .categories-grid > *, .most-downloaded-grid > * { animation: mcRise .45s ease both; }
    .categories-grid > *:nth-child(2) { animation-delay: .04s; } .categories-grid > *:nth-child(3) { animation-delay: .08s; }
    .categories-grid > *:nth-child(4) { animation-delay: .12s; } .categories-grid > *:nth-child(n+5) { animation-delay: .16s; }
}
@keyframes mcRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--mc-accent) 55%, transparent); outline-offset: 2px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .hero { padding: 44px 0 52px; }
}
@media (max-width: 768px) {
    .header-inner { height: 58px; }
    .nav { top: 58px; background: var(--mc-surface); border-bottom: 1px solid var(--mc-line); box-shadow: 0 16px 32px rgba(15,23,42,.12); padding: 10px 12px 0; }
    .nav-links { margin-left: 0; gap: 2px; }
    .nav-link { padding: 13px 14px; border: none; border-radius: 12px; }
    .nav-link.active { border: none; background: var(--mc-accent-soft); }
    .header-right { border-top: 1px solid var(--mc-line); padding: 14px 4px 16px; }
    .header-right .login-btn, .header-right .admin-login-btn { border-radius: 12px; }
    .theme-toggle { width: 100%; border-radius: 12px; height: 44px; }
    .logo::before { width: 28px; height: 28px; margin-right: 8px; font-size: 12px; }
    .logo { font-size: 20px; }
    .hero { padding: 26px 0 30px; }
    .hero h1 { font-size: 30px; margin-bottom: 8px; }
    .hero-tag { font-size: 9px; padding: 5px 10px; }
    .hero-desc { display: block; font-size: 14px; margin-bottom: 16px; }
    .search-box input { font-size: 15px; padding: 11px 14px; }
    .categories-section, .most-downloaded-section { padding: 36px 0; }
    .section-title { font-size: 23px; margin-bottom: 18px; }
    .category-card { padding: 18px 16px; border-radius: 14px; }
    .category-card-title { font-size: 15px; }
    .stats { display: block; }
    .stats-grid { padding: 6px 0; }
    .request-section { padding: 40px 0; }
}

/* search input sits inside the pill: no second border */
.search-box input, .search-box input:focus { border: none !important; box-shadow: none !important; outline: none; background: transparent; }

/* ---------- Inner pages: tidy headings, hide the stats banner outside the home page ---------- */
.toc-title, .toc-number, .about-feature h3, .viewer-header h2, .modal-content h2, .empty-state h3,
.csspms-category-header h3, .pastpaper-cat-header h3, .stat-number, .request-info h2 {
    font-family: 'Inter', sans-serif; letter-spacing: -0.02em;
}
.toc-title { font-weight: 800; font-size: 26px; }
.view-header { border-bottom: 1px solid var(--mc-line); padding-bottom: 16px; margin-bottom: 26px; }
.view-header h2 { font-size: 28px; }
.toc-header { border-bottom: 1px solid var(--mc-line); }
.csspms-category-header, .pastpaper-category { border-radius: var(--mc-radius); }
body:has(#notesView[style*="block"], #pastpapersView[style*="block"], #csspmsView[style*="block"], #blogView[style*="block"], #notesViewer[style*="block"]) .stats { display: none; }

@media (max-width: 768px) {
    .theme-toggle::after { content: ' Light / dark mode'; font-size: 13px; font-weight: 600; margin-left: 8px; }
}

/* Upload / edit forms: some fields were hard-coded dark navy; make them match the modal theme */
.modal-content [style*="1e293b"], .modal-content [style*="#0f172a"] {
    background: var(--bbc-light-gray) !important; color: var(--mc-ink) !important; border-color: var(--mc-line) !important;
}
.modal-content [style*="#334155"] { border-color: var(--mc-line) !important; }
.modal-content [style*="e2e8f0"] { color: var(--mc-ink) !important; }
.modal-content .file-upload-area { border: 2px dashed var(--mc-line); border-radius: 14px; background: var(--bbc-light-gray); }

/* ============================================================
   Round 2: bolder hero, icon cards, document-style note rows,
   skeleton loaders, scroll reveal, phone bottom bar
   ============================================================ */

/* ---------- Dark gradient hero with glass tiles ---------- */
.hero {
    background:
        radial-gradient(760px 420px at 88% -8%, rgba(var(--mc-accent-rgb), .55), transparent 62%),
        radial-gradient(640px 380px at 0% 105%, rgba(var(--mc-glow-rgb), .30), transparent 60%),
        linear-gradient(135deg, var(--mc-navy) 0%, var(--mc-navy-2) 100%);
    border-bottom: none;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.hero h1 { color: #fff; }
.hero-tag { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.hero-desc { color: rgba(255,255,255,.78); }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.hero-chip {
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.16); color: rgba(255,255,255,.85);
    padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.hero-chip b { color: #fff; font-weight: 800; margin-right: 3px; }
.hero-chip-free { background: rgba(255,255,255,.92); color: var(--mc-navy); font-weight: 700; border-color: transparent; }
html[data-theme="dark"] .hero-chip-free { color: #0b1120; }
.search-box { box-shadow: 0 18px 40px rgba(0,0,0,.28); border-color: transparent; }
.hero-card {
    background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
    border: 1px solid rgba(255,255,255,.22);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    box-shadow: 0 16px 40px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.2);
}
.hc-red   { background: linear-gradient(135deg, rgba(var(--mc-accent-rgb), .70), rgba(255,255,255,.06)); border-color: rgba(255,255,255,.25); }
.hc-dark  { background: linear-gradient(135deg, rgba(255,255,255,.14), rgba(255,255,255,.04)); border-color: rgba(255,255,255,.2); }
.hc-gray  { background: linear-gradient(135deg, rgba(var(--mc-glow-rgb), .55), rgba(255,255,255,.06)); border-color: rgba(255,255,255,.25); }
.hero-card:hover { background-color: transparent; transform: translateY(-6px) scale(1.02); }
@media (prefers-reduced-motion: no-preference) {
    .hero-card { animation: mcFloat 7s ease-in-out infinite; }
    .hero-card:nth-child(2n) { animation-delay: -2.5s; }
    .hero-card:nth-child(3n) { animation-delay: -4.5s; }
}
@keyframes mcFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* header gets a touch more compact when scrolled */
.header { transition: box-shadow .2s; }
.header-scrolled { box-shadow: 0 6px 24px rgba(15,23,42,.10); }
.header-scrolled .header-inner { height: 58px; }

/* ---------- Category cards with icons ---------- */
.category-card-icon {
    width: 48px; height: 48px; border-radius: 14px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--mc-accent-soft), color-mix(in srgb, var(--mc-accent) 14%, var(--mc-surface)));
    color: var(--mc-accent);
    transition: transform .2s, background .2s, color .2s;
}
.category-card:hover .category-card-icon { background: linear-gradient(135deg, var(--mc-accent), var(--mc-deep)); color: #fff; transform: rotate(-6deg) scale(1.06); }
.category-card-number { position: absolute; top: 18px; right: 18px; margin: 0; background: transparent; color: var(--mc-muted); font-size: 12px; opacity: .75; }
.category-card-title { min-height: 2.6em; }
.admin-add-card .category-card-icon { display: none; }

/* ---------- Note / paper rows ---------- */
.toc-note-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.toc-note-card::before {
    content: '\1F4C4'; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    background: var(--mc-accent-soft);
}
.toc-note-info { flex: 1 1 auto; min-width: 0; }
.toc-note-card h4 { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.toc-note-card p { color: var(--mc-muted); font-size: 12.5px; }
.toc-note-actions { align-items: center; gap: 8px; }
.toc-btn { padding: 8px 16px; font-size: 12px; border-radius: 999px; letter-spacing: .01em; }
.toc-btn-read { background: var(--mc-accent); color: #fff; border: 1px solid var(--mc-accent); }
.toc-btn-read:hover { background: var(--mc-accent-d); border-color: var(--mc-accent-d); }
.toc-btn-download { background: transparent; color: var(--mc-ink); border: 1px solid var(--mc-line); }
.toc-btn-download:hover { background: var(--bbc-hover); }
.toc-btn-delete { background: transparent; color: #dc2626; border: 1px solid color-mix(in srgb, #dc2626 35%, var(--mc-line)); padding: 8px 12px; }
.toc-btn-delete:hover { background: #dc2626; color: #fff; }
/* admin-only actions stay out of the way until you point at a row (always visible on touch screens) */
@media (hover: hover) {
    .toc-note-card .toc-btn-delete { opacity: 0; transition: opacity .15s, background .15s, color .15s; }
    .toc-note-card:hover .toc-btn-delete, .toc-note-card:focus-within .toc-btn-delete { opacity: 1; }
}
@media (max-width: 640px) {
    .toc-note-card { flex-wrap: wrap; }
    .toc-note-actions { flex: 1 1 100%; justify-content: flex-start; }
    .toc-note-card::before { width: 36px; height: 36px; font-size: 16px; }
}

/* ---------- Skeleton placeholders ---------- */
.skeleton-card {
    min-height: 168px; border-radius: var(--mc-radius); border: 1px solid var(--mc-line);
    background: linear-gradient(100deg, var(--mc-surface) 30%, var(--bbc-hover) 50%, var(--mc-surface) 70%);
    background-size: 300% 100%; animation: mcShimmer 1.3s linear infinite;
}
@keyframes mcShimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-card { animation: none; } }

/* ---------- Scroll reveal (progressive enhancement: browsers without support just show the cards) ---------- */
@supports (animation-timeline: view()) {
    .categories-grid > *, .most-downloaded-grid > * {
        animation: mcReveal linear both; animation-timeline: view(); animation-range: entry 0% entry 40%;
    }
}
@keyframes mcReveal { from { transform: translateY(26px) scale(.98); } to { transform: none; } }

/* ---------- Phone bottom bar ---------- */
.bottom-nav { display: none; }
@media (max-width: 768px) {
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
        background: color-mix(in srgb, var(--mc-surface) 94%, transparent);
        -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid var(--mc-line); box-shadow: 0 -8px 24px rgba(15,23,42,.08);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    }
    .bn-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px;
        color: var(--mc-muted); text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 12px;
        -webkit-tap-highlight-color: transparent;
    }
    .bn-item.active { color: var(--mc-accent); background: var(--mc-accent-soft); }
    body { padding-bottom: 76px; }
    .hero-chips { margin-bottom: 16px; gap: 6px; }
    .hero-chip { padding: 5px 11px; font-size: 12px; }
    .category-card-icon { width: 42px; height: 42px; margin-bottom: 12px; }
    .category-card-title { min-height: 0; }
}

/* cards without an icon (past papers / CSS lists) keep the number as an inline badge so it never overlaps the title */
.category-card:not(:has(.category-card-icon)) .category-card-number {
    position: static; display: inline-flex; margin-bottom: 12px; opacity: 1;
    background: var(--mc-accent-soft); color: var(--mc-accent);
}

/* subject rows: royal tint when open, rounded small admin buttons */
.toc-item.toc-item-active { background: var(--mc-accent-soft); border-left-color: var(--mc-accent); }
.toc-mini-edit, .toc-mini-delete, .cat-admin-btn { border-radius: 999px; }
.toc-mini-delete, .cat-delete { color: #dc2626; border-color: color-mix(in srgb, #dc2626 35%, var(--mc-line)); background: transparent; }
.toc-mini-delete:hover, .cat-delete:hover { background: #dc2626; color: #fff; }

/* ============================================================
   Round 3 ("Round 1" of the redesign): editorial type, live hero cards,
   bento categories, consistent line icons, calmer details
   ============================================================ */
:root {
    --mc-shadow: 0 1px 2px rgba(15,23,42,.04);
    --mc-shadow-h: 0 1px 2px rgba(15,23,42,.05), 0 18px 40px -12px rgba(15,23,42,.22);
    --mc-serif: 'Instrument Serif', 'Source Serif 4', Georgia, serif;
}
html[data-theme="dark"] { --mc-shadow: 0 1px 2px rgba(0,0,0,.35); --mc-shadow-h: 0 18px 40px -12px rgba(0,0,0,.6); }

/* ---------- Type: sentence case, lighter UI weights, one serif accent ---------- */
.nav-link { text-transform: none; font-size: 14px; letter-spacing: 0; font-weight: 600; }
.login-btn, .admin-login-btn, .logout-btn { text-transform: none; font-size: 13px; letter-spacing: 0; }
.hero-tag { text-transform: none; letter-spacing: .01em; font-size: 13px; font-weight: 600; }
.stat-label, .toc-count, .toc-group-title, .subject-category, .form-group label { text-transform: none; letter-spacing: 0; }
.stat-label { font-size: 14px; font-weight: 500; }
.form-group label { font-size: 13px; }
.toc-group-title { font-size: 14px; font-weight: 700; }
.hero h1 { font-weight: 700; letter-spacing: -0.04em; }
.hero h1 em, .section-title em {
    font-family: var(--mc-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; font-size: 1.1em;
}
.hero h1 em { color: color-mix(in srgb, var(--mc-accent) 30%, #fff); }
.section-title { font-weight: 700; font-size: 32px; letter-spacing: -0.03em; }
.section-title em { color: var(--mc-accent); }
.section-title::after { width: 36px; height: 3px; }
.category-card-title { font-weight: 650; }

/* ---------- Line icons (replace emoji) ---------- */
.ic {
    display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.2em; margin-right: 6px; background: currentColor;
    -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
}
.ic-read  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E"); }
.ic-dl    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M4 21h16'/%3E%3C/svg%3E"); }
.ic-trash { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='M6 6l1 14h10l1-14'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
.toc-note-card { position: relative; }
.toc-note-card::before { content: ''; background: var(--mc-accent-soft); }
.toc-note-card::after, .hl-icon::after {
    content: ''; position: absolute; background: var(--mc-accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / 20px no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / 20px no-repeat;
}
.toc-note-card::after { left: 16px; top: 50%; width: 42px; height: 42px; transform: translateY(-50%); }
.hl-icon::after { inset: 0; background: #fff; }
@media (max-width: 640px) { .toc-note-card::after { width: 36px; height: 36px; } }

/* ---------- Hero: recently-added cards ---------- */
.hero h1 { font-size: clamp(34px, 4.4vw, 56px); line-height: 1.04; max-width: 14ch; }
.hero-desc { max-width: 500px; }
.hero-try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; color: rgba(255,255,255,.62); }
.hero-try-chip {
    font: inherit; font-weight: 600; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.24);
    padding: 5px 13px; border-radius: 999px; cursor: pointer; transition: background .15s, border-color .15s;
}
.hero-try-chip:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); }
.hero-latest { width: 100%; max-width: 430px; margin-left: auto; }
.hero-latest-title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: rgba(255,255,255,.7); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: mcPulse 2s infinite; }
@keyframes mcPulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.55); } 70% { box-shadow: 0 0 0 9px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
.hl-card {
    display: flex; align-items: center; gap: 14px; padding: 16px 18px; margin-bottom: 12px; border-radius: 18px; text-decoration: none; color: #fff;
    background: linear-gradient(135deg, rgba(255,255,255,.17), rgba(255,255,255,.06)); border: 1px solid rgba(255,255,255,.2);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 18px 40px -14px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.18);
    transition: transform .2s, background .2s;
}
.hl-card:nth-child(2) { margin-left: 26px; }
.hl-card:nth-child(3) { margin-left: 52px; margin-bottom: 0; }
.hl-card:hover { transform: translateY(-4px); background: linear-gradient(135deg, rgba(255,255,255,.24), rgba(255,255,255,.1)); }
.hl-icon { position: relative; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px; background: rgba(255,255,255,.14); }
.hl-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hl-title { font-size: 15px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hl-meta { font-size: 12.5px; color: rgba(255,255,255,.66); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hl-pill { background: rgba(255,255,255,.18); color: #fff; padding: 2px 9px; border-radius: 999px; font-weight: 600; font-size: 11.5px; }
.hl-skel { height: 78px; border-radius: 18px; margin-bottom: 12px; background: linear-gradient(100deg, rgba(255,255,255,.07) 30%, rgba(255,255,255,.16) 50%, rgba(255,255,255,.07) 70%); background-size: 300% 100%; animation: mcShimmer 1.3s linear infinite; }
.hl-empty { color: rgba(255,255,255,.7); font-size: 14px; padding: 18px; border: 1px dashed rgba(255,255,255,.25); border-radius: 16px; }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } .hl-skel { animation: none; } }
@media (max-width: 768px) {
    .hero-visual { display: block; margin-top: 26px; }
    .hero-latest { max-width: none; }
    .hl-card:nth-child(2), .hl-card:nth-child(3) { margin-left: 0; }
    .hl-card:nth-child(3) { display: none; }
    .hero h1 { font-size: 34px; max-width: none; }
}

/* ---------- Bento categories ---------- */
#categoriesGrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: dense; gap: 18px; }
#categoriesGrid .category-card-featured {
    grid-column: span 2; grid-row: span 2; min-height: 330px; padding: 32px; color: #fff; border: none;
    display: flex; flex-direction: column; justify-content: flex-end;
    background:
        radial-gradient(420px 260px at 100% 0%, rgba(var(--mc-accent-rgb), .55), transparent 65%),
        linear-gradient(150deg, var(--mc-navy-2), var(--mc-navy));
}
#categoriesGrid .category-card-featured:hover { border-color: transparent; }
#categoriesGrid .category-card-featured .category-card-icon { position: absolute; top: 28px; left: 32px; width: 64px; height: 64px; border-radius: 18px; background: rgba(255,255,255,.14); color: #fff; margin: 0; }
#categoriesGrid .category-card-featured .category-card-icon svg { width: 30px; height: 30px; }
#categoriesGrid .category-card-featured:hover .category-card-icon { background: #fff; color: var(--mc-accent); }
#categoriesGrid .category-card-featured .category-card-number { color: rgba(255,255,255,.7); background: transparent; top: 30px; right: 32px; font-size: 14px; }
#categoriesGrid .category-card-featured .category-card-title { color: #fff; font-size: 30px; line-height: 1.12; letter-spacing: -0.03em; min-height: 0; margin-bottom: 8px; }
#categoriesGrid .category-card-featured .category-card-count { color: rgba(255,255,255,.72); font-size: 15px; }
#categoriesGrid .category-card-featured::after { color: #fff; font-size: 22px; right: 28px; bottom: 26px; opacity: .9; transform: none; }
.bento-tag { position: absolute; left: 32px; bottom: 112px; display: none; }
#categoriesGrid .category-card-featured .bento-tag {
    display: inline-block; position: static; align-self: flex-start; margin-bottom: 14px; padding: 5px 12px; border-radius: 999px;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
}
#categoriesGrid .category-card-wide { grid-column: span 2; }
#categoriesGrid .category-card-wide .category-card-title { min-height: 0; }
@media (max-width: 1000px) { #categoriesGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } #categoriesGrid .category-card-featured { grid-row: span 1; min-height: 240px; } }
@media (max-width: 768px) {
    #categoriesGrid { gap: 12px; }
    #categoriesGrid .category-card-featured { padding: 22px; min-height: 210px; }
    #categoriesGrid .category-card-featured .category-card-icon { top: 20px; left: 22px; width: 52px; height: 52px; }
    #categoriesGrid .category-card-featured .category-card-number { top: 22px; right: 22px; }
    #categoriesGrid .category-card-featured .category-card-title { font-size: 24px; }
    #categoriesGrid .category-card-featured::after { right: 20px; bottom: 18px; }
}

/* ---------- Buttons from the contact block ---------- */
.btn-solid, .btn-ghost {
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 600;
    text-decoration: none; margin: 0 8px 8px 0; transition: transform .12s, background .15s, box-shadow .15s;
}
.btn-solid { background: var(--mc-accent); color: #fff; box-shadow: 0 6px 16px rgba(var(--mc-accent-rgb), .28); }
.btn-solid:hover { background: var(--mc-accent-d); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--mc-ink); border: 1px solid var(--mc-line); }
.btn-ghost:hover { background: var(--bbc-hover); }
.request-info .eyebrow { color: var(--mc-accent); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 14px; }

/* ---------- Footer in columns ---------- */
.footer { background: var(--mc-navy); padding: 56px 0 0; color: rgba(255,255,255,.6); text-align: left; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 40px; padding-bottom: 40px; }
.footer-logo { font-weight: 800; font-size: 22px; color: #fff; letter-spacing: -0.03em; margin-bottom: 10px; }
.footer-logo span { color: color-mix(in srgb, var(--mc-accent) 35%, #fff); }
.footer-brand p { font-size: 14px; line-height: 1.6; max-width: 320px; color: rgba(255,255,255,.62); }
.footer-col h4 { color: #fff; font-size: 14px; font-weight: 700; margin: 0 0 14px; }
.footer-col a { display: block; color: rgba(255,255,255,.66); font-size: 14px; padding: 5px 0; text-decoration: none; cursor: pointer; transition: color .15s, transform .15s; }
.footer-col a:hover { color: #fff; transform: translateX(3px); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 18px 0 22px; }
.footer-bottom p { font-size: 13px; color: rgba(255,255,255,.5); margin: 0; }
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; } .footer-brand { grid-column: span 2; } .footer { padding-top: 40px; } }

/* ---------- Views fade in when you switch ---------- */
@media (prefers-reduced-motion: no-preference) {
    #notesView, #pastpapersView, #csspmsView, #blogView, #notesViewer { animation: mcViewIn .32s ease both; }
}
@keyframes mcViewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Round-1 follow-ups ---------- */
.ic-file { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E"); }
.ic-cap  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 10L12 4 2 10l10 6 10-6z'/%3E%3Cpath d='M6 12.5V17c0 1 3 3 6 3s6-2 6-3v-4.5'/%3E%3C/svg%3E"); }
.toc-item-active { background: var(--mc-accent-soft) !important; border-left-color: var(--mc-accent); }
.toc-book-icon {
    width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 22px; font-size: 0;
    display: flex; align-items: center; justify-content: center; color: var(--mc-accent);
    background: linear-gradient(135deg, var(--mc-accent-soft), color-mix(in srgb, var(--mc-accent) 16%, var(--mc-surface)));
}
.toc-book-icon svg { width: 36px; height: 36px; }
.toc-mini-edit, .toc-mini-delete { border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.toc-mini-edit { background: transparent; color: var(--mc-ink-2); border: 1px solid var(--mc-line); }
.toc-mini-edit:hover { background: var(--bbc-hover); color: var(--mc-ink); }
.toc-mini-delete { color: #dc2626; border: 1px solid color-mix(in srgb, #dc2626 35%, var(--mc-line)); }
.toc-mini-delete .ic { width: 1.1em; height: 1.1em; }
.back-btn { font-size: 13px; letter-spacing: 0; font-weight: 600; border-radius: 999px; padding: 8px 18px; }
.upload-btn, .write-essay-btn { font-size: 13px; letter-spacing: 0; padding: 10px 20px; }
.sug-icon .ic { width: 1.15em; height: 1.15em; color: var(--mc-accent); }
@media (max-width: 768px) {
    .hero-tag { font-size: 12px; padding: 6px 12px; border-radius: 14px; display: inline-block; line-height: 1.35; }
}

/* inline-styled admin buttons inside subject rows (past papers / CSS lists) */
.toc-item button[style*="ef4444"], .toc-item button[style*="EF4444"] {
    border-radius: 999px !important; padding: 6px 12px !important; font-size: 12px !important; font-weight: 600 !important;
    color: #dc2626 !important; border-color: color-mix(in srgb, #dc2626 35%, var(--mc-line)) !important;
}
.toc-item button[style*="ef4444"]:hover { background: #dc2626 !important; color: #fff !important; }
