
:root {
    --bg: #fafaf9;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #1d4ed8;
    --border: #e5e7eb;
    --code-bg: #f3f4f6;
    --surface-bg: rgba(255, 255, 255, 0.95);
    --surface-border: rgba(15, 23, 42, 0.08);
    --surface-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
    --divider-color: rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0f;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --accent: #60a5fa;
        --accent-hover: #93c5fd;
        --border: #334155;
        --code-bg: #1e293b;
        --surface-bg: rgba(17, 24, 39, 0.95);
        --surface-border: rgba(255, 255, 255, 0.1);
        --surface-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
        --divider-color: rgba(255, 255, 255, 0.08);
    }
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    max-width: 48rem;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.site-title {
    font-size: 1.5rem;
    margin: 0;
}

.site-title a {
    color: var(--text);
    text-decoration: none;
}

.site-title a:hover {
    color: var(--accent);
}

.breadcrumb {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ── Content typography ── */

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

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

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.content h1 { font-size: 2rem; margin-top: 0; }
.content h2 { font-size: 1.5rem; }
.content h3 { font-size: 1.25rem; }

.content p {
    margin: 1rem 0;
}

.content ul, .content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.content li {
    margin: 0.25rem 0;
}

.content pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    line-height: 1.5;
}

.content code {
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
}

.content pre code {
    background: none;
    padding: 0;
}

.content blockquote {
    border-left: 3px solid var(--accent);
    margin: 1.5rem 0;
    padding-left: 1.25rem;
    color: var(--text-muted);
    font-style: italic;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.content th, .content td {
    border: 1px solid var(--border);
    padding: 0.5rem;
    text-align: left;
}

.content th {
    background: var(--code-bg);
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

.content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* ── Floating metadata pill ── */

.metadata-pill {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    max-width: 420px;
}

.pill-collapsed {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.125rem;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.metadata-pill:hover .pill-collapsed {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 12px 32px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.pill-text {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}

.pill-expanded {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 0.25rem;
    width: 380px;
    max-width: calc(100vw - 5rem);
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.pill-expanded::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
    background: transparent;
}

.metadata-pill:hover .pill-expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.pill-header {
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--divider-color);
}

.pill-header-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pill-content {
    padding: 0.875rem 1.25rem 1.125rem;
    max-height: 60vh;
    overflow-y: auto;
}

.pill-content dl {
    margin: 0;
}

.pill-row {
    margin: 0 0 0.75rem 0;
}

.pill-row:last-child {
    margin-bottom: 0;
}

.pill-content dt {
    margin: 0 0 0.25rem 0;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: capitalize;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.pill-content dd {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text);
    padding: 0.4rem 0.65rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0.375rem;
    border: 1px solid var(--divider-color);
}

.pill-content dd a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.pill-content dd a:hover {
    text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
    .metadata-pill:hover .pill-collapsed {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
    }
    .pill-content dd {
        background: rgba(255, 255, 255, 0.03);
    }
}

/* Touch devices: tap to toggle */
@media (hover: none) and (pointer: coarse) {
    .pill-expanded {
        display: none;
    }
    .metadata-pill.is-active .pill-expanded {
        display: block;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }
}

/* Mobile: full-width pill */
@media (max-width: 48rem) {
    .metadata-pill {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    .pill-collapsed {
        padding: 0.625rem 1rem;
    }
    .pill-text {
        font-size: 0.8125rem;
    }
    .pill-expanded {
        position: fixed;
        bottom: 4.5rem;
        left: 1rem;
        right: 1rem;
        margin-bottom: 0;
        width: auto;
    }
    .pill-content {
        max-height: 50vh;
    }
}

@media print {
    .metadata-pill { display: none; }
}

/* ── Single-file details fallback ── */

.metadata-details {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.metadata-details summary {
    padding: 0.625rem 1rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}

.metadata-details summary:hover {
    color: var(--accent);
}

.metadata-details dl {
    margin: 0;
    padding: 0.5rem 1rem 1rem;
    border-top: 1px solid var(--divider-color);
}

.metadata-details .pill-row {
    margin: 0 0 0.5rem;
}

.metadata-details dt {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: capitalize;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
}

.metadata-details dd {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text);
}

.metadata-details dd a {
    color: var(--accent);
}

/* ── Layout misc ── */

nav.toc {
    background: var(--code-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

nav.toc h2 {
    margin-top: 0;
}

nav.toc ul {
    margin: 0;
    padding-left: 1.5rem;
}

nav.toc li {
    margin: 0.5rem 0;
}

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

section {
    margin-bottom: 2rem;
}

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

footer a {
    color: var(--text-muted);
}

footer a:hover {
    color: var(--accent);
}

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

/* ── Colored highlights ── */

.highlight-mark {
    background: none;
    padding: 0.1em 0.2em;
    border-radius: 0.2em;
}

.highlight-red { background: oklch(0.92 0.12 25); }
.highlight-orange { background: oklch(0.93 0.1 60); }
.highlight-yellow { background: oklch(0.95 0.12 95); }
.highlight-green { background: oklch(0.92 0.08 145); }
.highlight-cyan { background: oklch(0.92 0.08 195); }
.highlight-blue { background: oklch(0.88 0.1 250); }
.highlight-violet { background: oklch(0.9 0.1 300); }
.highlight-pink { background: oklch(0.93 0.1 350); }
.highlight-brown { background: oklch(0.88 0.06 60); }
.highlight-grey { background: oklch(0.9 0 0); }

@media (prefers-color-scheme: dark) {
    .highlight-red { background: oklch(0.35 0.12 25); }
    .highlight-orange { background: oklch(0.38 0.1 60); }
    .highlight-yellow { background: oklch(0.42 0.12 95); }
    .highlight-green { background: oklch(0.38 0.08 145); }
    .highlight-cyan { background: oklch(0.38 0.08 195); }
    .highlight-blue { background: oklch(0.35 0.1 250); }
    .highlight-violet { background: oklch(0.38 0.1 300); }
    .highlight-pink { background: oklch(0.4 0.1 350); }
    .highlight-brown { background: oklch(0.38 0.06 60); }
    .highlight-grey { background: oklch(0.4 0 0); }
}

/* ── Spoilers ── */

.spoiler-mark {
    cursor: pointer;
    border-radius: 0.2em;
    padding: 0.1em 0.3em;
    transition: background 0.2s, color 0.2s;
}

.spoiler-hidden {
    background: var(--text);
    color: transparent;
    user-select: none;
}

.spoiler-revealed {
    background: var(--code-bg);
    color: var(--text);
}

/* ── Footnotes ── */

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

.footnotes ol {
    padding-left: 1.5rem;
}

.footnotes li {
    margin: 0.5rem 0;
}

.footnote-ref a, .footnotes a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

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

sup.footnote-ref {
    font-size: 0.75em;
    line-height: 0;
    vertical-align: super;
}
