:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --muted: #555555;
    --light: #888888;
    --border: #dddddd;
    --code-bg: #f5f5f5;
    --accent: #0c5c2c;
    --green: #2e7d32;
    --red: #c62828;
    --orange: #e65100;
    --blue: #1565c0;
    --purple: #6a1b9a;
    --teal: #00695c;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --text: #e8e8e4;
        --muted: #9a9a96;
        --light: #6b6b67;
        --border: #333333;
        --code-bg: #2d2d2d;
        --purple: #9c27b0;
        --teal: #00897b;
    }
}

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

body {
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    
}
*{
    scroll-behavior: smooth;
}
/* ── Navigation ── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.site-nav a {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    transition: all 0.15s;
}

.site-nav a:hover {
    color: var(--text);
    background: var(--code-bg);
    border-color: var(--light);
}

/* ── Headings ── */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 36px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
    scroll-margin-top: 60px;
}

h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 24px 0 8px;
}

.subtitle {
    color: var(--light);
    font-size: 14px;
    margin-bottom: 32px;
    font-style: italic;
}

/* ── Text ── */
p {
    margin-bottom: 10px;
    color: var(--muted);
}

strong {
    color: var(--text);
}

/* ── Code ── */
pre {
    overflow-x: scroll;
}

pre code {
    display: block;
    white-space: pre;
    word-wrap: normal;
}

code {
    padding: 12px;
    border-radius: 4px;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 14px;
    font-size: 14px;
    overflow-x: auto;
    display: block;
}

th {
    background: var(--code-bg);
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--border);
    font-weight: 700;
}

td {
    padding: 8px 10px;
    border: 1px solid var(--border);
    color: var(--muted);
    vertical-align: top;
}

/* ── Lists ── */
ul,
ol {
    margin: 8px 0 14px 24px;
    color: var(--muted);
}

li {
    margin-bottom: 4px;
}

/* ── Blockquotes & note blocks ── */
blockquote,
.note,
.tip,
.warn {
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
    border-left: 4px solid;
    border-radius: 4px;
}

blockquote p,
.note p,
.tip p,
.warn p {
    margin-bottom: 0;
}

blockquote {
    border-left-color: var(--border);
    background: var(--code-bg);
    color: var(--muted);
}

.note,
blockquote.note {
    background: #fff8e1;
    border-left-color: #e65100;
    color: #633806;
}

.tip,
blockquote.tip {
    background: #e8f5e9;
    border-left-color: #2e7d32;
    color: #1b5e20;
}

.warn,
blockquote.warn {
    background: #fce4ec;
    border-left-color: #c62828;
    color: #b71c1c;
}

.important,
blockquote.important {
    background: #e3f2fd;
    border-left-color: #1565c0;
    color: #0d47a1;
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 4px;
}

.success,
blockquote.success {
    background: #e8f5e9;
    border-left-color: #2e7d32;
    color: #1b5e20;
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 4px;
}

blockquote code {
    background: rgba(0, 0, 0, 0.1);
    border: none;
}

@media (prefers-color-scheme: dark) {

    .note,
    blockquote.note {
        background: #3e2a1f;
        border-left-color: #e65100;
        color: #ffcc80;
    }

    .tip,
    blockquote.tip {
        background: #1b3a1f;
        border-left-color: #4caf50;
        color: #a5d6a7;
    }

    .warn,
    blockquote.warn {
        background: #3a1a1a;
        border-left-color: #ef5350;
        color: #ef9a9a;
    }

    .important,
    blockquote.important {
        background: #1a2a3a;
        border-left-color: #42a5f5;
        color: #90caf9;
    }
}

/* ── Card grid ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.card {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.card h2 {
    margin-top: 0;
    border-bottom: none;
}

.card h2 a {
    color: var(--text);
    text-decoration: none;
}

.card h2 a:hover {
    color: var(--accent);
}

.card p {
    margin-bottom: 0;
}

/* ── Book cards ── */
.books {
    display: grid;
    gap: 2px;
}

.book-card {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.book-card:hover {
    border-color: var(--light);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

.book-card+.book-card {
    margin-top: -1px;
}

.book-spine {
    width: 6px;
    flex-shrink: 0;
}

.book-body {
    flex: 1;
    padding: 18px 22px 18px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.book-left {
    flex: 1;
}

.book-num {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--light);
    margin-bottom: 5px;
}

.book-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 5px;
    line-height: 1.3;
}

.book-subtitle {
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 10px;
}

.topics {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.topic {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--light);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 7px;
}

.book-right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.book-badge {
    font-family: 'Courier New', monospace;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.book-arrow {
    font-size: 18px;
    color: var(--light);
    margin-top: auto;
}

.book-card:hover .book-arrow {
    color: var(--text);
}

/* ── Spine colors ── */
.spine-green {
    background: var(--green);
}

.spine-blue {
    background: var(--blue);
}

.spine-orange {
    background: var(--orange);
}

.spine-purple {
    background: var(--purple);
}

.spine-teal {
    background: var(--teal);
}

.spine-red {
    background: var(--red);
}

.spine-rust {
    background: var(--accent);
}

/* ── Badge colors ── */
.badge-green {
    background: #e8f5e9;
    color: var(--green);
}

.badge-blue {
    background: #e3f2fd;
    color: var(--blue);
}

.badge-orange {
    background: #fff3e0;
    color: var(--orange);
}

.badge-purple {
    background: #f3e5f5;
    color: var(--purple);
}

.badge-teal {
    background: #e0f2f1;
    color: var(--teal);
}

.badge-red {
    background: #fce4ec;
    color: var(--red);
}

.badge-rust {
    background: #fbe9e7;
    color: var(--accent);
}

@media (prefers-color-scheme: dark) {
    .badge-green {
        background: #1b3a1f;
        color: #81c784;
    }

    .badge-blue {
        background: #1a2a3a;
        color: #90caf9;
    }

    .badge-orange {
        background: #3e2a1f;
        color: #ffb74d;
    }

    .badge-purple {
        background: #2a1a3a;
        color: #ce93d8;
    }

    .badge-teal {
        background: #1a2a2a;
        color: #80cbc4;
    }

    .badge-red {
        background: #3a1a1a;
        color: #ef9a9a;
    }

    .badge-rust {
        background: #3a1f1a;
        color: #ffab91;
    }
}

/* ── Hero ── */
.hero {
    max-width: 1280px;
    margin: 0 auto;
    padding: 72px 24px 56px;
    border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
    font-family: 'Courier New', monospace;
    font-size: 11.5px;
    color: var(--light);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 16px;
}

.hero h1 span {
    color: var(--accent);
}

.hero-desc {
    font-size: 17px;
    color: var(--muted);
    max-width: 580px;
    line-height: 1.75;
    margin-bottom: 32px;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--light);
}

.hero-meta span::before {
    content: '— ';
}

/* ── How-to grid ── */
.how-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 4px;
}

.how-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px 18px;
}

.how-card h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.how-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
    .how-card {
        background: var(--code-bg);
    }
}

/* ── Quote ── */
.quote {
    margin: 56px 0 0;
    padding: 24px 28px;
    border-left: 3px solid var(--border);
}

.quote p {
    font-size: 18px;
    color: var(--muted);
    font-style: italic;
    line-height: 1.7;
    margin-bottom: 0;
}

.quote cite {
    display: block;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--light);
    font-style: normal;
}

/* ── Section label ── */
.section-label {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--light);
    margin: 56px 0 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Stats ── */
.stats {
    text-align: center;
    padding: 24px;
    background: var(--code-bg);
    border-radius: 8px;
    margin-top: 32px;
    color: var(--muted);
    font-size: 14px;
}

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

/* ── Book filter input ── */
#book-filter {
    width: 100%;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.15s;
}

#book-filter:focus {
    border-color: var(--light);
}

#book-filter::placeholder {
    color: var(--light);
}

/* ── Layout: index (no sidebar) ── */
.index-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.index-layout .main-content {
    width: 100%;
    min-width: 0;
}

/* ── Layout: sidebar + content ── */
.layout-container {
    display: flex;
    gap: 2.5rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.sidebar {
    position: sticky;
    top: 1.5rem;
    height: fit-content;
    width: 220px;
    flex-shrink: 0;
}

.main-content {
    flex-grow: 1;
    min-width: 0;
}

.sidebar-label {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--light);
    margin-bottom: 0.75rem;
}

.toc-link {
    display: block;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.toc-link:hover {
    color: var(--accent);
    border-left-color: var(--accent);
}

/* ── Mobile TOC tag strip ── */

/* ── Responsive ── */
@media (max-width: 700px) {
    body {
        font-size: 14px;
    }

    pre {
        font-size: 11px;
        padding: 10px;
    }

    td,
    th {
        font-size: 12px;
    }

    .card-grid,
    .how-grid {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 32px;
    }

    .book-body {
        flex-direction: column;
    }

    .book-right {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        align-items: center;
    }

    .book-arrow {
        margin-top: 0;
    }

    .sidebar {
        display: none;
    }

    .layout-container {
        flex-direction: column;
        padding: 1rem;
    }



    .tag-label {
        font-family: 'Courier New', monospace;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--light);
        align-self: center;
        flex-shrink: 0;
        margin-right: 0.25rem;
    }




}

/* ── Print ── */
@media print {
    body {
        font-size: 12px;
        background: white;
        color: black;
    }

    .site-nav,
    .sidebar {
        display: none;
    }

    pre {
        font-size: 11px;
        padding: 10px;
        background: #f5f5f5;
        border: 1px solid #ccc;
    }

    a {
        text-decoration: none;
        color: black;
    }

    .book-card {
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .book-arrow {
        display: none;
    }

    .hero-meta span::before {
        content: '• ';
    }
}

.page-inner .hero-desc,
.page-inner .hero-meta {
    display: none;
}