:root {
    --paper: #F0F1E9;
    --paper-card: #FBFBF6;
    --ink: #1E2A22;
    --pine: #2F5D4E;
    --pine-dark: #234438;
    --mustard: #E3A73C;
    --mustard-dark: #A8792A;
    --line: #D3D6C6;
    --muted: #5B6459;
}

* { box-sizing: border-box; }

body {
    font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 16px 32px;
    background: var(--paper-card);
    border-bottom: 1px solid var(--line);
}

.site-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--ink);
    text-decoration: none;
}

.logo-mark {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--paper);
    box-shadow: inset 0 0 0 2px var(--pine);
}

.site-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Hamburger button — hidden on desktop, shown below the breakpoint */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 34px;
    height: 34px;
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--ink);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-active span:nth-child(2) { opacity: 0; }
.nav-toggle.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
    .site-header { padding: 14px 20px; }

    .nav-toggle { display: flex; }

    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        background: var(--paper-card);
        border-bottom: 1px solid var(--line);
        padding: 12px 20px 16px;
        box-shadow: 0 8px 16px -12px rgba(30, 42, 34, 0.25);
        z-index: 20;
    }

    .site-nav.is-open { display: flex; }

    .nav-tab, .nav-link {
        margin-left: 0;
        padding: 10px 4px;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
    }

    .nav-tab:last-of-type, .nav-link:last-child { border-bottom: none; }
}

.nav-tab {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}

.nav-tab--notes { color: var(--pine-dark); }
.nav-tab--notes:hover { border-color: var(--pine); background: rgba(47, 93, 78, 0.08); }

.nav-tab--blog { color: var(--mustard-dark); }
.nav-tab--blog:hover { border-color: var(--mustard); background: rgba(227, 167, 60, 0.14); }

.nav-link {
    font-family: 'Work Sans', sans-serif;
    font-size: 0.88rem;
    text-decoration: none;
    color: var(--muted);
    margin-left: 6px;
}

.nav-link:hover { color: var(--ink); }

.site-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 60vh;
    flex: 1;
    width: 100%;
}

.site-main--full {
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.site-main--wide {
    max-width: 1400px;
    width: 80%;
    margin: 0 auto;
    padding: 40px 20px;
    flex: 1;
}

.site-footer {
    position: relative;
    text-align: center;
    padding: 32px 24px 26px;
    background: var(--pine-dark);
    color: #DDE6DF;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.85rem;
    margin-top: 40px;
}
.footer-links {
    margin-bottom: 8px !important;
}

.footer-links a {
    color: #DDE6DF;
    text-decoration: none;
    font-size: 0.82rem;
    margin: 0 8px;
}

.footer-links a:hover {
    text-decoration: underline;
}

.site-footer p { margin: 0; }
.site-footer .footer-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: rgba(221, 230, 223, 0.6);
    margin-top: 6px;
}

.footer-holes {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.footer-holes::before,
.footer-holes::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--paper);
    opacity: 0.9;
}

.post-list { display: flex; flex-direction: column; gap: 24px; }

.post-card {
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
}

.post-card h2, .post-card h3 { margin: 8px 0 4px; }
.post-card h2 a, .post-card h3 a { text-decoration: none; color: #111; }
.post-card time { color: #999; font-size: 0.85rem; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-note { background: #e0f2fe; color: #0369a1; }
.badge-blog { background: #dcfce7; color: #15803d; }
.badge-solution { background: #fef3c7; color: #b45309; }

.post-full h1 { margin-top: 8px; }
.post-content { margin-top: 24px; font-size: 1.05rem; }
.post-content img { max-width: 100%; border-radius: 6px; }

.admin-form { display: flex; flex-direction: column; gap: 16px; max-width: 100%; }
.admin-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.admin-form input, .admin-form select, .admin-form textarea {
    padding: 10px; font-size: 1rem; border: 1px solid #ccc; border-radius: 6px; font-family: inherit;
}
.admin-form button {
    padding: 12px; background: #111; color: #fff; border: none; border-radius: 6px;
    font-size: 1rem; cursor: pointer; width: fit-content;
}
.admin-form button:hover { background: #333; }

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.button-secondary {
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
}

.button-secondary:hover {
    border-color: var(--muted);
    color: var(--ink);
}

#semester-subject-fields { display: flex; flex-direction: column; gap: 16px; }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px; border-bottom: 1px solid #eee; }

.link-button {
    background: none; border: none; padding: 0; margin-left: 10px;
    color: #dc2626; text-decoration: underline; cursor: pointer; font-size: inherit; font-family: inherit;
}

.button {
    display: inline-block; padding: 10px 16px; background: #111; color: #fff;
    text-decoration: none; border-radius: 6px; font-size: 0.9rem;
}

.home-links { display: flex; gap: 16px; margin-top: 24px; }
.success { color: #15803d; font-weight: 600; }
.error { color: #dc2626; font-weight: 600; }

.breadcrumb { font-size: 0.85rem; color: #888; margin-bottom: 16px; }
.breadcrumb a { color: #666; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }


.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.subject-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 24px 22px 20px;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.subject-card:hover {
    transform: translateY(-4px);
    border-color: var(--pine);
    box-shadow: 0 14px 28px -16px rgba(30, 42, 34, 0.35);
}

.subject-card-title {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.15rem;
    margin-bottom: 14px;
    line-height: 1.3;
}

.subject-card-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}

.mini-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    padding: 3px 9px;
    border-radius: 10px;
    white-space: nowrap;
}

.mini-badge-note { background: #E0F2FE; color: #0369A1; }
.mini-badge-solution { background: #FEF3C7; color: #B45309; }
.mini-badge-question { background: #F3E1EE; color: #9C3D8B; }

.subject-card-browse {
    margin-top: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    color: var(--pine);
    border: 1px solid var(--line);
    padding: 6px 16px;
    border-radius: 20px;
    transition: background 0.15s, border-color 0.15s;
}

.subject-card:hover .subject-card-browse {
    background: var(--pine);
    border-color: var(--pine);
    color: #fff;
}

.semester-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.semester-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 20px 24px;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.semester-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--pine);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.semester-card:hover {
    transform: translateY(-4px);
    border-color: var(--pine);
    box-shadow: 0 14px 28px -16px rgba(30, 42, 34, 0.35);
}

.semester-card:hover::before {
    transform: scaleX(1);
}

.semester-card-num {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 2.4rem;
    color: var(--pine);
    line-height: 1;
    margin-bottom: 10px;
}

.semester-card-title {
    font-family: 'Work Sans', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.semester-card .post-count {
    margin-top: 0;
    margin-bottom: 18px;
}

.semester-card-browse {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    color: var(--pine);
    border: 1px solid var(--line);
    padding: 6px 16px;
    border-radius: 20px;
    transition: background 0.15s, border-color 0.15s;
}

.semester-card:hover .semester-card-browse {
    background: var(--pine);
    border-color: var(--pine);
    color: #fff;
}   

.post-count {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: #888;
    margin-top: 4px;
}

.content-section { margin-top: 36px; }
.content-section h2 { border-bottom: 1px solid #eee; padding-bottom: 8px; }
.subject-meta { color: #888; margin-top: -8px; }
.empty-state { color: #999; font-style: italic; }

.tab-toggle {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    margin: 24px 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}

.tab-btn {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    background: none;
    border: none;
    padding: 10px 4px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;

}

.tab-btn.is-active {
    color: var(--pine-dark);
    border-bottom-color: var(--pine);
    font-weight: 600;
}

.tab-count {
    display: inline-block;
    background: var(--line);
    color: var(--ink);
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 4px;
}

.tab-btn.is-active .tab-count {
    background: var(--pine);
    color: #fff;
}


.post-layout {
    display: flex;
    gap: 48px;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
}

.post-full { flex: 1; min-width: 0; }

.toc {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    padding: 16px;
    border-left: 2px solid var(--line);
}

.toc-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 12px;
}

.toc nav { display: flex; flex-direction: column; gap: 8px; }

.toc nav a {
    font-size: 0.88rem;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.4;
}

.toc nav a:hover { color: var(--pine); }

html { scroll-behavior: smooth; }

@media (max-width: 900px) {
    .post-layout { flex-direction: column; }
    .toc {
        position: static;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--line);
        order: -1;
    }
}

.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
    content: attr(data-value) !important;
}

.badge-question { background: #F3E1EE; color: #9C3D8B; }


/*dashboard filter*/
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 16px 0 20px;
    flex-wrap: wrap;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
    background: var(--paper-card);
}

/*dashboard search bar*/

.filter-search {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
    background: var(--paper-card);
    min-width: 200px;
}

/*make quill toolbar sticky*/

.ql-toolbar.ql-snow {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}

/*slug*/
.field-hint {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 400;
}

/*related posts*/

.related-posts {
    margin-top: 56px;
    padding-top: 32px;
    border-top: 1px solid var(--line);
}

.related-posts-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 18px;
}

.related-posts-viewall {
    display: inline-block;
    margin-top: 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--pine);
    text-decoration: none;
}

.related-posts-viewall:hover {
    text-decoration: underline;
}


.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 16px;
}
.table-scroll .admin-table { margin-top: 0; min-width: 640px; }

@media (max-width: 640px) {
    .post-full h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .post-full .badge {
        display: inline-block;
        margin-bottom: 8px;
    }

    .post-full time {
        display: block;
        margin-top: 4px;
    }

    .subject-meta {
        font-size: 0.85rem;
    }

    .breadcrumb {
        font-size: 0.78rem;
        line-height: 1.6;
        word-break: break-word;
    }

    .post-content {
        font-size: 1rem;
    }

    .toc {
        padding: 12px 0;
        margin-bottom: 8px;
    }

    .related-posts-label {
        font-size: 0.72rem;
    }
}


.post-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%;
}

.post-content pre {
    overflow-x: auto;
    max-width: 100%;
}

@media (max-width: 640px) {
    .site-main {
        padding: 24px 14px;
    }

    .site-main--wide {
        width: 100%;
        padding: 24px 14px;
    }

    .post-layout {
        gap: 20px;
    }
}