
/* =========================================
   COLOUR TOKENS (dark default — Obsidian palette)
   ========================================= */

:root {
    --bg:              #1e1e2e;
    --bg-raised:       #181825;
    --bg-card:         #252537;   /* card / form surface */
    --bg-stripe:       #22223a;   /* table alternating row */
    --bg-hover:        #2a2a42;   /* table row hover */
    --bg-interactive:  #313148;   /* buttons, badge backgrounds */
    --border:          #3d3d5c;
    --border-subtle:   #2e2e42;   /* soft inner borders */
    --text:            #dcdfe4;
    --text-muted:      #a9a9b7;
    --text-dim:        #6e6e8e;
    --accent:          #8ab4f8;
    /* --site-title controls the header site-name colour.
       Override this variable in your vault's custom CSS to change it. */
    --site-title:      #ffffff;
    --mark-bg:         #3d3520;
    --mark-fg:         #f9e2af;
    --code-bg:         #0d1117;
    --inline-code-bg:  #1f2933;
    --inline-code-text:var(--text-muted);
    --banner-gradient: transparent, rgba(30,30,46,0.5), #1e1e2e;
    --banner-meta-color: rgba(220, 223, 228, 0.75);
    --tag-color:       var(--text-muted);
    --callout-base-bg:     #26263a;
    --callout-base-border: #6c6cff;
    /* Heading colors — obsidian: all neutral text */
    --h1-color: var(--text);
    --h2-color: var(--text);
    --h3-color: var(--text);
    --h4-color: var(--text);
    --h5-color: var(--text);
    --h6-color: var(--text);
}

[data-theme="light"] {
    --bg:              #f5f5f0;
    --bg-raised:       #ebebe4;
    --bg-card:         #f0f0eb;
    --bg-stripe:       #e8e8e0;
    --bg-hover:        #ddddd5;
    --bg-interactive:  #e4e4dc;
    --border:          #c8c8d0;
    --border-subtle:   #d0d0da;
    --text:            #1a1a2a;
    --text-muted:      #44445a;
    --text-dim:        #77778a;
    --accent:          #1a1a2a;   /* near-black — links are bold + underlined */
    --site-title:      #1a1a2a;
    --mark-bg:         #fef08a;
    --mark-fg:         #713f12;
    --code-bg:         #0d1117;   /* code blocks stay dark in light mode */
    --inline-code-bg:  #e4e4dc;
    --inline-code-text:#1a1a2a;
    --banner-gradient: transparent, rgba(245,245,240,0.5), #f5f5f0;
    --banner-meta-color: rgba(26, 26, 42, 0.75);
    --tag-color:       var(--text-muted);
    --callout-base-bg:     #f0f0f5;
    --callout-base-border: #6c6cff;
    --h1-color: var(--text);
    --h2-color: var(--text);
    --h3-color: var(--text);
    --h4-color: var(--text);
    --h5-color: var(--text);
    --h6-color: var(--text);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    padding: 2rem;
    max-width: 900px;
    margin: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

main {
    flex: 1;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1 { color: var(--h1-color); }
h2 { color: var(--h2-color); }
h3 { color: var(--h3-color); }
h4 { color: var(--h4-color); }
h5 { color: var(--h5-color); }
h6 { color: var(--h6-color); }

blockquote {
    border-left: 4px solid var(--border);
    color: var(--text-muted);
    margin: 1em 0;
    padding-left: 1em;
    font-style: italic;
}



table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 75%;
    min-width: 320px;
}

table th, table td {
    border: 1px solid var(--border);
    padding: 0.5em;
}

/* Compress empty header row */
table thead tr:first-child:has(th:empty) {
    height: 0;
    line-height: 0;
    font-size: 0;
}

table thead tr:first-child:has(th:empty) th {
    padding: 0;
    border: none;
}


ul {
    margin: 0.5em 0;
    padding-left: 1.2em;
}

li {
    margin: 0.2em 0;
}

.checkbox-list {
    list-style: none;
    padding-left: 1.2em;
}

.checkbox-list li {
    list-style: none;
    display: flex;
    align-items: flex-start;
    gap: 0.5em;
    line-height: 1.5;
}

.checkbox-list input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    margin-top: 0.25em;
    border: 1.5px solid var(--text-dim);
    border-radius: 3px;
    background: transparent;
    cursor: default;
    position: relative;
}

.checkbox-list input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-list input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 0.18em;
    top: 0.02em;
    width: 0.35em;
    height: 0.6em;
    border: 2px solid var(--bg);
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

img{
    max-width:100%;
    height: auto;
    border-radius:8px;
}


.thumb-gallery {
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    margin:1.5em 0;
}

.thumb-gallery img,
.thumb-gallery video {
    width:160px;
    height:120px;
    object-fit:cover;
    border-radius:6px;
    cursor:pointer;
}

.thumb-gallery img:hover,
.thumb-gallery video:hover {
    transform: scale(1.05);
    transition: transform 0.2s;
}

.lightbox {
    position:fixed;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    background:rgba(0,0,0,0.92);
    z-index:9999;
}

.lightbox-inner {
    display:flex;
    flex-direction:column;
    align-items:center;
    max-width:95vw;
    max-height:95vh;
    }

.lightbox-media {
    max-width:100%;
    max-height:85vh;
    border-radius:8px;
}

.lightbox-caption {
    margin-top:12px;
    color:#ccc;
    text-align:center;
}

.slider-gallery {
    position: relative;
    overflow: hidden;
    margin: 24px 0;
}

.slides {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.slides::-webkit-scrollbar {
    display: none;
}

.slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.slide img,
.slide video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 6px;
}


.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 30px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 50%;
    z-index: 5;
}

.slider-arrow.left {
    left: 10px;
}

.slider-arrow.right {
    right: 10px;
}

.slider-arrow:hover {
    background: rgba(0,0,0,0.8);
}

/* =========================================
   HEADER + NAV
   ========================================= */

header {
    margin-bottom: 2.5rem;
}

.header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0 1rem;
}

.header-inner h1 {
    grid-column: 1;
    margin: 0;
    /* Prevent heading color tokens from bleeding into the site title */
    color: var(--site-title) !important;
}

.header-inner h1 a {
    color: var(--site-title);
    text-decoration: none;
    font-weight: 700;
}

nav {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.1rem;
    align-items: center;
    align-self: center;
}

nav a {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    padding: 0.3em 0.7em;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    text-decoration: none;
}

nav a.nav-active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    font-weight: 600;
}

/* Header controls (hamburger + toggle) grouped together */
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hamburger — hidden on desktop */
.nav-hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1.6;
}

/* =========================================
   RESPONSIVE / MOBILE NAV
   ========================================= */

@media (max-width: 600px) {
    body {
        padding: 1rem;
    }

    .header-inner {
        grid-template-columns: 1fr auto;
    }

    nav {
        display: none;
        grid-column: 1 / -1;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 0.5rem 0;
        border-top: 1px solid var(--border);
        margin-top: 0.5rem;
    }

    nav.nav-open {
        display: flex;
    }

    nav a {
        width: 100%;
        padding: 0.5em 0.75em;
        border-radius: 6px;
    }

    .nav-hamburger {
        display: block;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

    .post-nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .post-nav-next {
        margin-left: 0;
        text-align: left;
    }

    .post-nav-prev::before { content: "← "; }
    .post-nav-next::after  { content: " →"; }

    .breadcrumbs {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .breadcrumb-current {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
}

/* =========================================
   BLOG INDEX
   ========================================= */

.featured-posts {
    margin-bottom: 3rem;
}

.featured-post {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.featured-post h3 {
    margin: 0 0 0.3rem 0;
    font-size: 1.1rem;
}

.featured-post h3 a {
    color: var(--text);
}

.featured-post h3 a:hover {
    color: var(--accent);
}

.post-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.post-summary {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.55;
}

.regular-posts {
    display: flex;
    flex-direction: column;
}

.post-entry {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.post-entry:last-child {
    border-bottom: none;
}

.post-entry h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
}

.post-entry h3 a {
    color: var(--text);
}

.post-entry h3 a:hover {
    color: var(--accent);
}

/* =========================================
   PAGE BANNER
   ========================================= */

.page-banner {
    position: relative;
    width: calc(100% + 4rem);
    margin-left: -2rem;
    height: 360px;
    background-size: cover;
    background-repeat: no-repeat;
    overflow: hidden;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.page-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, var(--banner-gradient));
    pointer-events: none;
}

.page-banner-body {
    position: relative;
    z-index: 1;
    padding: 0 2rem 1.75rem;
}

.banner-title {
    color: #fff;
    font-size: 1.9rem;
    line-height: 1.2;
    margin: 0 0 0.5rem;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.banner-meta {
    color: var(--banner-meta-color);
    font-size: 0.85rem;
    margin: 0;
}

/* =========================================
   DATAVIEW TABLES
   ========================================= */

.dataview {
    margin: 1.5em 0;
    overflow-x: auto;
}

.dataview-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 320px;
    font-size: 0.9rem;
}

.dataview-table th {
    background: var(--bg-card);
    color: var(--accent);
    font-weight: 600;
    text-align: left;
    padding: 0.55em 0.8em;
    border: 1px solid var(--border);
}

.dataview-table td {
    padding: 0.5em 0.8em;
    border: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text);
}

.dataview-table tr:nth-child(even) td {
    background: var(--bg-stripe);
}

.dataview-table tr:hover td {
    background: var(--bg-hover);
}

.dataview-table img {
    display: block;
    border-radius: 4px;
}

.dataview-empty {
    color: var(--text-dim);
    font-style: italic;
}

.dataview-error {
    color: #f38ba8;
    font-size: 0.85rem;
    padding: 0.5em;
    border-left: 3px solid #f38ba8;
    margin: 1em 0;
}

/* =========================================
   PRIVATE NOTE PAGE
   ========================================= */

.private-note {
    max-width: 560px;
}

.private-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.25em 0.8em;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    letter-spacing: 0.03em;
}

.private-lock {
    font-size: 0.9em;
}

.private-message {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.private-hint {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    background: var(--bg-stripe);
}

.private-hint summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9rem;
    user-select: none;
}

.private-hint summary:hover {
    text-decoration: underline;
}

.private-hint p {
    margin: 0.75rem 0 0.4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.private-hint pre {
    margin: 0.4rem 0 0.75rem;
    background: var(--code-bg);
    border-radius: 6px;
    padding: 0.6em 0.9em;
    font-size: 0.85rem;
}

.private-hint code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85em;
    color: var(--inline-code-text);
    background: var(--bg-card);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

/* =========================================
   BOOK PAGE
   ========================================= */

.book-header {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin: 1.75rem 0 2rem;
}

.book-cover-wrap {
    flex-shrink: 0;
}

.book-cover-img {
    width: 160px;
    height: auto;
    border-radius: 6px;
    box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.5);
    display: block;
}

.book-meta {
    flex: 1;
    min-width: 0;
}

.book-title {
    margin: 0 0 0.6rem;
    font-size: 1.6rem;
    line-height: 1.25;
    color: var(--h1-color);
}

.book-status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2em 0.7em;
    border-radius: 20px;
    margin-bottom: 0.9rem;
}

.book-status--read {
    background: #1e3a2a;
    color: #a6e3a1;
    border: 1px solid #2d5c3e;
}

.book-status--reading {
    background: #1a2d42;
    color: #89dceb;
    border: 1px solid #2a4a6a;
}

.book-status--want-to-read {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.book-author {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.book-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
}

.book-detail {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.book-detail dt {
    color: var(--text-dim);
    min-width: 5.5rem;
    flex-shrink: 0;
}

.book-detail dd {
    color: var(--text);
    margin: 0;
}

.book-body {
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.5rem;
    margin-top: 0.25rem;
    color: var(--text-muted);
    line-height: 1.7;
}

@media (max-width: 520px) {
    .book-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .book-detail {
        justify-content: center;
    }
    .book-status {
        display: block;
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
    }
}

/* =========================================
   TABLE OF CONTENTS
   ========================================= */

.toc-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    max-width: 380px;
}

.toc-block summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    user-select: none;
    padding: 0.2rem 0;
    list-style: none;
}

.toc-block summary::-webkit-details-marker { display: none; }

.toc-block summary::before {
    content: "▸ ";
    font-size: 0.75em;
    transition: transform 0.15s;
}

details[open].toc-block summary::before {
    content: "▾ ";
}

.toc-block summary:hover {
    text-decoration: underline;
}

.toc-block .toc {
    margin-top: 0.5rem;
}

.toc-block .toc ul {
    margin: 0.2rem 0;
    padding-left: 1.1rem;
}

.toc-block .toc li {
    margin: 0.2rem 0;
    list-style: none;
}

.toc-block .toc a {
    color: var(--text-muted);
}

.toc-block .toc a:hover {
    color: var(--text);
    text-decoration: underline;
}

/* =========================================
   TAG BADGES
   ========================================= */

.tag-badge {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.1em 0.65em;
    font-size: 0.78rem;
    color: var(--tag-color);
    text-decoration: none;
    margin: 0.1em 0.15em;
}

.tag-badge:hover {
    background: var(--bg-interactive);
    color: var(--text);
    text-decoration: none;
}

.tag-badge--heading {
    font-size: 1rem;
    padding: 0.15em 0.75em;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin: 0.3rem 0 1.25rem;
    min-height: 0;
}

/* =========================================
   SEARCH RESULTS
   ========================================= */

.search-results {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.search-result {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result h4 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.search-result h4 a {
    color: var(--text);
}

.search-result h4 a:hover {
    color: var(--accent);
}

.search-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45em 0.75em;
    color: var(--text);
    font-size: 0.95rem;
}

.search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.search-form select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45em 0.6em;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-form select:focus {
    outline: none;
    border-color: var(--accent);
}

.search-form button {
    background: var(--bg-interactive);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45em 1.1em;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.search-form button:hover {
    background: var(--bg-hover);
}

.search-empty {
    color: var(--text-dim);
}

mark {
    background: var(--mark-bg);
    color: var(--mark-fg);
    padding: 0 0.1em;
    border-radius: 2px;
}

/* =========================================
   FOOTNOTES
   ========================================= */

.footnote {
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
    padding-top: 1rem;
    color: var(--text-muted);
}

.footnote ol {
    padding-left: 1.25rem;
    margin: 0;
}

.footnote li {
    margin-bottom: 0.4rem;
}

.footnote-ref a,
.footnote-backref {
    color: var(--accent);
    font-size: 0.75rem;
    vertical-align: super;
    text-decoration: none;
}

.footnote-ref a:hover,
.footnote-backref:hover {
    text-decoration: underline;
}

/* =========================================
   MERMAID DIAGRAMS
   ========================================= */

.mermaid {
    background: var(--bg-raised);
    border-radius: 6px;
    padding: 1rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    text-align: center;
}

.mermaid svg {
    background: transparent !important;
}

.mermaid svg rect.background {
    fill: transparent !important;
}

/* =========================================
   NOTE TRANSCLUSION
   ========================================= */

.transclusion {
    border-left: 3px solid var(--border);
    background: var(--bg-raised);
    border-radius: 0 6px 6px 0;
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
}

.transclusion-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.transclusion-title a {
    color: var(--text-dim);
}

.transclusion-title a:hover {
    color: var(--text-muted);
}

.transclusion-body {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.transclusion-body p:last-child {
    margin-bottom: 0;
}

.transclusion-missing {
    color: #f38ba8;
    font-style: italic;
}

/* =========================================
   MATH / KATEX
   ========================================= */

.math-block {
    overflow-x: auto;
    text-align: center;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-raised);
    border-radius: 6px;
}

.math-inline .katex {
    font-size: 1em;
}

/* =========================================
   AUDIO EMBEDS
   ========================================= */

audio {
    width: 100%;
    margin: 1rem 0;
    border-radius: 6px;
}

/* =========================================
   PAGINATION
   ========================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 2.5rem 0 1rem;
    font-size: 0.9rem;
}

.pagination a {
    color: var(--accent);
}

.pagination-info {
    color: var(--text-dim);
}

/* =========================================
   BREADCRUMBS
   ========================================= */

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 1.25rem;
}

.breadcrumbs a {
    color: var(--text-dim);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--text-muted);
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--border);
    user-select: none;
}

.breadcrumb-current {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

/* =========================================
   DARK / LIGHT MODE TOGGLE
   ========================================= */

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    line-height: 1.6;
    grid-column: 3;
    align-self: center;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* =========================================
   RELATED POSTS
   ========================================= */

.related-posts {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.related-title {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 1.25rem;
}

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

.related-card {
    display: block;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-decoration: none;
    transition: border-color 0.15s;
}

.related-card:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.related-card-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.related-card-meta {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.related-card-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================================
   LIGHT MODE OVERRIDES
   ========================================= */

/* --- Links: black, bold, underlined --- */
[data-theme="light"] a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

[data-theme="light"] a:hover {
    color: #000;
    text-decoration: underline;
}

/* Elements where bold+underline would look wrong */
[data-theme="light"] nav a,
[data-theme="light"] .tag-badge,
[data-theme="light"] .toc-block a,
[data-theme="light"] .breadcrumbs a,
[data-theme="light"] .related-card,
[data-theme="light"] .featured-post h3 a,
[data-theme="light"] .post-entry h3 a,
[data-theme="light"] .search-result h4 a,
[data-theme="light"] .transclusion-title a,
[data-theme="light"] .pagination a,
[data-theme="light"] .footnote-ref a,
[data-theme="light"] .footnote-backref {
    font-weight: inherit;
    text-decoration: none;
}

[data-theme="light"] nav a:hover,
[data-theme="light"] .featured-post h3 a:hover,
[data-theme="light"] .post-entry h3 a:hover,
[data-theme="light"] .search-result h4 a:hover {
    text-decoration: underline;
}

/* --- Nav --- */
[data-theme="light"] nav a       { color: #44445a; }
[data-theme="light"] nav a:hover {
    background: rgba(0, 0, 0, 0.07);
    color: #000;
    text-decoration: none;
}
[data-theme="light"] nav a.nav-active {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
    font-weight: 600;
}

/* --- Featured posts (listing page) --- */
[data-theme="light"] .featured-post {
    background: #eeeee7;
    border: 1px solid #c8c8d0;
    border-left: 4px solid #6a6a8a;
}

[data-theme="light"] .featured-post h3 a { color: #1a1a2a; }
[data-theme="light"] .featured-post h3 a:hover { color: #000; }

/* --- Post entries + search results --- */
[data-theme="light"] .post-entry { border-bottom-color: #d0d0da; }
[data-theme="light"] .post-entry h3 a { color: #1a1a2a; }
[data-theme="light"] .post-entry h3 a:hover { color: #000; }

[data-theme="light"] .search-result { border-bottom-color: #d0d0da; }
[data-theme="light"] .search-result h4 a { color: #1a1a2a; }
[data-theme="light"] .search-result h4 a:hover { color: #000; }

/* --- TOC block --- */
[data-theme="light"] .toc-block {
    background: #eeeee7;
    border-color: #c8c8d0;
}

[data-theme="light"] .toc-block summary { color: #1a1a2a; }
[data-theme="light"] .toc-block .toc a  { color: #44445a; }
[data-theme="light"] .toc-block .toc a:hover { color: #000; }

/* --- Tag badges --- */
[data-theme="light"] .tag-badge {
    background: #e4e4dc;
    border-color: #c8c8d0;
    color: #44445a;
}

[data-theme="light"] .tag-badge:hover {
    background: #d4d4cc;
    color: #1a1a2a;
    text-decoration: none;
}

/* --- Dataview tables --- */
[data-theme="light"] .dataview-table th {
    background: #d0d0c8;
    color: #44445a;
    border-color: #b8b8c0;
}

[data-theme="light"] .dataview-table td {
    background: #f0f0eb;
    color: #1a1a2a;
    border-color: #d0d0da;
}

[data-theme="light"] .dataview-table tr:nth-child(even) td {
    background: #e8e8e0;
}

[data-theme="light"] .dataview-table tr:hover td {
    background: #ddddd5;
}

[data-theme="light"] .dataview-table a {
    color: #1a1a2a;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Search form --- */
[data-theme="light"] .search-form input[type="text"],
[data-theme="light"] .search-form select {
    background: #ffffff;
    border-color: #c8c8d0;
    color: #1a1a2a;
}

[data-theme="light"] .search-form input[type="text"]:focus,
[data-theme="light"] .search-form select:focus {
    border-color: #1a1a2a;
}

[data-theme="light"] .search-form button {
    background: #e4e4dc;
    border-color: #c8c8d0;
    color: #1a1a2a;
}

[data-theme="light"] .search-form button:hover { background: #d4d4cc; }

/* --- Misc structural --- */
[data-theme="light"] hr { border-top-color: #c8c8d0; }

[data-theme="light"] .footnote {
    border-top-color: #c8c8d0;
    color: #44445a;
}

[data-theme="light"] .footnote-ref a,
[data-theme="light"] .footnote-backref { color: #44445a; }

[data-theme="light"] .pagination a { color: #1a1a2a; text-decoration: none; }

[data-theme="light"] .breadcrumbs,
[data-theme="light"] .breadcrumbs a,
[data-theme="light"] .breadcrumb-current { color: var(--text-dim); }
[data-theme="light"] .breadcrumb-sep { color: #c0c0cc; }

/* --- Transclusion --- */
[data-theme="light"] .transclusion {
    background: #eeeee7;
    border-left-color: #aaaabc;
}

[data-theme="light"] .transclusion-title,
[data-theme="light"] .transclusion-title a { color: #77778a; }
[data-theme="light"] .transclusion-body    { color: #44445a; }

/* --- Math block & Mermaid --- */
[data-theme="light"] .math-block {
    background: var(--bg-raised);
    color: var(--text);
}
[data-theme="light"] .mermaid {
    background: var(--bg-raised);
}

/* --- Private note page --- */
[data-theme="light"] .private-badge {
    background: #eeeee7;
    border-color: #c8c8d0;
    color: #44445a;
}

[data-theme="light"] .private-message { color: #44445a; }

[data-theme="light"] .private-hint {
    background: #f4f4f0;
    border-color: #c8c8d0;
}

[data-theme="light"] .private-hint summary { color: #1a1a2a; }
[data-theme="light"] .private-hint p       { color: #44445a; }

[data-theme="light"] .private-hint code {
    background: #e4e4dc;
    color: #44445a;
}

/* =========================================
   POST NAVIGATION (prev / next)
   ========================================= */

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 2.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.post-nav-prev,
.post-nav-next {
    max-width: 48%;
    color: var(--accent);
    font-size: 0.9rem;
    line-height: 1.4;
}

.post-nav-next {
    margin-left: auto;
    text-align: right;
}

[data-theme="light"] .post-nav-prev,
[data-theme="light"] .post-nav-next {
    font-weight: 700;
    text-decoration: underline;
}


/* =========================================
   FIGURE / FIGCAPTION
   ========================================= */

figure {
    margin: 1.5em 0;
    display: inline-block;
    max-width: 100%;
}

figcaption {
    margin-top: 0.4em;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}


/* =========================================
   COLLAPSIBLE CALLOUTS (details/summary)
   ========================================= */

details.callout > summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

details.callout > summary::-webkit-details-marker {
    display: none;
}

details.callout > summary::after {
    content: " ▸";
    font-size: 0.75em;
    opacity: 0.6;
}

details.callout[open] > summary::after {
    content: " ▾";
}

[data-theme="light"] details.callout > summary { color: inherit; }


/* =========================================
   LABELS INDEX PAGE
   ========================================= */

.labels-index {
    list-style: none;
    padding: 0;
    columns: 2;
    column-gap: 2rem;
    margin: 1.5rem 0;
}

.labels-index li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.25rem 0;
    break-inside: avoid;
}

.labels-index-link {
    color: var(--accent);
    font-size: 0.95rem;
}

[data-theme="light"] .labels-index-link {
    font-weight: 700;
    text-decoration: underline;
}

.labels-index-count {
    font-size: 0.78rem;
    color: var(--text-dim);
    background: var(--bg-raised);
    border-radius: 10px;
    padding: 0.1em 0.5em;
}


/* =========================================
   LABEL POST NAV (next/prev within a label)
   ========================================= */

.label-post-nav {
    display: flex;
    gap: 1rem;
    margin-top: 0.6rem;
    font-size: 0.82rem;
}

.label-nav-link {
    color: var(--text-dim);
}

.label-nav-link--next {
    margin-left: auto;
}

[data-theme="light"] .label-nav-link {
    color: #44445a;
    font-weight: 600;
    text-decoration: underline;
}


/* =========================================
   DATAVIEW LIST + GROUPED
   ========================================= */

ul.dataview-list {
    padding-left: 1.4em;
    margin: 0.75em 0;
}

ul.dataview-list li {
    margin: 0.3em 0;
    color: var(--text);
}

.dataview-grouped {
    margin: 0.75em 0;
}

.dv-group-heading {
    margin: 1.25em 0 0.4em;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.2em;
}

.dataview-grouped .dataview-table {
    margin-top: 0;
}


/* =========================================
   PRINT STYLESHEET
   ========================================= */

@media print {
    body {
        background: #fff;
        color: #000;
        max-width: none;
        padding: 0;
        margin: 0;
        font-size: 11pt;
        line-height: 1.5;
    }

    header, nav, .theme-toggle, .nav-hamburger,
    .toc-block, .related-posts, .post-nav,
    .breadcrumbs, .post-tags, .pagination,
    footer, .lightbox, .slider-gallery .slider-arrow,
    .copy-btn, .code-lang {
        display: none !important;
    }

    a { color: #000; text-decoration: none; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
    a[href^="#"]::after,
    a[href^="javascript"]::after { content: ""; }

    img { max-width: 100% !important; page-break-inside: avoid; }

    pre, blockquote { page-break-inside: avoid; }
    pre { background: #f4f4f4 !important; color: #000 !important;
          border: 1px solid #ccc; padding: 0.75em; border-radius: 4px; }
    code { background: #f4f4f4 !important; color: #000 !important; }

    .callout { border: 1px solid #ccc; background: #f9f9f9 !important;
               box-shadow: none; }

    article { max-width: none; }

    h1, h2, h3, h4 {
        page-break-after: avoid;
        color: #000;
    }
}

/* ── Site footer ─────────────────────────────────────── */
#site-footer {
    text-align: center;
    padding: 1.5rem 0 1rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-dim);
}

#site-footer a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    opacity: 0.6;
    transition: opacity 0.15s;
}

#site-footer a:hover {
    opacity: 1;
}

[data-theme="light"] #site-footer { color: var(--text-dim); }
