:root {
    color-scheme: dark;
    --bg: #151413;
    --surface: #1c1b18;
    --border: #2c2a26;
    --text: #e3ded6;
    --heading: #ffffff;
    --quote-text: #ccc5b9;
    --muted: #8c857b;
    --accent: #d4975c;
    --ok: #6fbf45;
    --bad: #e2788f;

    --serif: "Charter", "Bitstream Charter", "Sitka Text", "Cambria", Georgia, serif;
    --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --ease: cubic-bezier(0.22, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --bg: #f6f2ea;
        --surface: #ece6da;
        --border: #d9d1c2;
        --text: #2b2824;
        --heading: #14110d;
        --quote-text: #4a443b;
        --muted: #6f675b;
        --accent: #a85f1a;
        --ok: #3f8a1f;
        --bad: #c2476a;
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f2ea;
    --surface: #ece6da;
    --border: #d9d1c2;
    --text: #2b2824;
    --heading: #14110d;
    --quote-text: #4a443b;
    --muted: #6f675b;
    --accent: #a85f1a;
    --ok: #3f8a1f;
    --bad: #c2476a;
}

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

html { scroll-padding-top: 4.5rem; }

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.7;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body::before {
    content: "";
    position: fixed;
    top: -45vmax;
    left: 50%;
    width: 90vmax;
    height: 90vmax;
    margin-left: -45vmax;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 11%, transparent), transparent);
    pointer-events: none;
    z-index: -1;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0 1.25rem;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.bar {
    max-width: 580px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 1.2rem;
}

.brand {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    padding: 0.85rem 0;
}

.brand:hover { color: var(--heading); }

.hush { color: var(--muted); }

.hush-z {
    display: none;
    font-size: 9px;
    vertical-align: super;
    margin-left: 1px;
}

[data-night] .brand-name { display: none; }

.nav {
    display: flex;
    gap: 1.3rem;
    font-family: var(--sans);
    font-size: 0.85rem;
}

.nav a {
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    padding: 0.85rem 0 calc(0.85rem - 2px);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

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

.theme-toggle {
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: none;
    padding: 0.5rem 0.15rem;
    cursor: pointer;
}

.theme-toggle:hover { color: var(--accent); }

.nav a[aria-current] {
    color: var(--heading);
    border-bottom-color: var(--accent);
}

@media (max-width: 560px) {

    .brand-name { display: none; }
    .hush-word { display: none; }
    .hush-z { display: inline; }
    .bar { gap: 0 0.6rem; }
    .nav {
        flex: 1;
        justify-content: space-between;
        gap: 0.5rem;
        font-size: 0.78rem;
        padding-left: 0.4rem;
    }
    .nav a { padding: 0.8rem 0 calc(0.8rem - 2px); }
}

@media (max-width: 380px) {
    .site-header { padding: 0 0.8rem; }
    .nav { font-size: 0.74rem; }
}

@media (max-width: 340px) {
    .site-header { padding: 0 0.6rem; }
    .bar { gap: 0 0.35rem; }
    .brand { font-size: 12px; }
    .nav {
        font-size: 0.68rem;
        gap: 0.3rem;
        padding-left: 0.15rem;
    }
}

.layout {
    max-width: calc(580px + 2.5rem);
    margin: 0 auto;
    padding: 2.8rem 1.25rem 3rem;
}

h1 {
    font-size: 1.6rem;
    font-weight: normal;
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin-bottom: 0.25rem;
    color: var(--heading);
}

.subtitle {
    font-style: italic;
    color: var(--muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

p { margin-bottom: 1.3rem; }

h2 {
    font-family: var(--sans);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 1.2rem;
    font-weight: 600;
}

h3 {
    font-family: var(--sans);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin: 1.6rem 0 0.9rem;
    font-weight: 600;
}

section + section { margin-top: 2.4rem; }

a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.note {
    font-size: 0.92rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.dash-list {
    list-style: none;
    margin-bottom: 0.5rem;
}

.dash-list > li {
    margin-bottom: 0.9rem;
    padding-left: 1.2rem;
    position: relative;
}

.dash-list > li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.dash-list .note { margin-top: -0.2rem; }

.quote {
    position: relative;
    background: var(--surface);
    padding: 1rem 1.2rem 1rem calc(1.2rem + 2px);
    margin: 1.8rem 0 2.2rem;
    font-style: italic;
    color: var(--quote-text);
}

.quote::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.8rem 1rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
}

.card[hidden] { display: none; }

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

.glyph {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    white-space: pre;
}

.card-title { color: var(--heading); }

.card .note {
    margin: 0;
    line-height: 1.45;
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    -webkit-appearance: none;
    appearance: none;
}

select {
    padding-right: 1.8rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 0.95rem) 55%, calc(100% - 0.65rem) 55%;
    background-size: 0.3rem 0.3rem;
    background-repeat: no-repeat;
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
    display: block;
    width: 100%;
}

textarea {
    min-height: 7.5rem;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    outline: none;
}

input[type="number"] { width: 5rem; }

input[type="range"],
input[type="checkbox"] {
    accent-color: var(--accent);
}

::placeholder { color: var(--muted); opacity: 0.8; }

.search {
    font-family: var(--sans);
    font-size: 16px;
    margin-bottom: 2.2rem;
}

label,
.meta {
    font-family: var(--sans);
    font-size: 0.82rem;
    color: var(--muted);
}

.field {
    display: block;
    margin-top: 1.1rem;
}

.field > input,
.field > textarea {
    margin-top: 0.3rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.6rem;
    margin: 0.7rem 0;
}

.btn {
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0.3rem 1rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--accent);
    color: var(--bg);
}

.btn[disabled] {
    opacity: 0.5;
    cursor: default;
}

.btn.quiet {
    color: var(--muted);
    border-color: var(--border);
}

.btn.quiet:hover {
    color: var(--text);
    background: transparent;
    border-color: var(--muted);
}

.btn.danger {
    color: var(--bad);
    border-color: var(--bad);
}

.btn.danger:hover {
    background: var(--bad);
    color: var(--bg);
}

.err {
    font-size: 0.92rem;
    color: var(--bad);
    margin-top: 0.6rem;
}

.okmsg {
    font-size: 0.92rem;
    color: var(--ok);
    margin-top: 0.6rem;
}

@media (max-width: 520px) {
    input[type="text"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

.prose { overflow-wrap: break-word; }

.prose h2,
.prose h3,
.prose h4 {
    font-family: var(--serif);
    font-weight: normal;
    text-transform: none;
    letter-spacing: -0.01em;
    color: var(--heading);
    line-height: 1.35;
    margin: 2.2rem 0 0.7rem;
}

.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.12rem; }
.prose h4 { font-size: 1rem; font-style: italic; }

.prose ul,
.prose ol {
    margin: 0 0 1.3rem 1.4rem;
}

.prose li { margin-bottom: 0.35rem; }
.prose li::marker { color: var(--accent); }

.prose code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.08em 0.35em;
}

.prose pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.3rem;
    overflow-x: auto;
    line-height: 1.5;
}

.prose pre code {
    font-size: 13px;
    background: none;
    border: none;
    padding: 0;
}

.prose img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0.4rem 0;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.prose .code {
    position: relative;
    margin-bottom: 1.3rem;
}

.prose .code pre { margin-bottom: 0; }

.code-copy {
    position: absolute;
    top: 0.4rem;
    right: 0.45rem;
    font-family: var(--sans);
    font-size: 0.7rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    cursor: pointer;
    opacity: 0;
}

.code:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }

.code-copy:hover {
    color: var(--accent);
    border-color: var(--accent);
}

@media (hover: none) {
    .code-copy { opacity: 1; }
}

.hl-c { color: var(--muted); font-style: italic; }
.hl-s { color: var(--ok); }
.hl-k { color: var(--accent); }
.hl-n { color: var(--bad); }

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.6rem;
}

.tags a {
    font-family: var(--sans);
    font-size: 0.78rem;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.6rem;
}

.tags a span { opacity: 0.7; }

.tags a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.tags a[aria-current] {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
}

.tag-link {
    font-family: var(--sans);
    font-size: 0.82em;
    font-style: normal;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.tag-link:hover { color: var(--accent); }

.prose blockquote {
    border-left: 2px solid var(--accent);
    background: var(--surface);
    padding: 0.8rem 1.2rem;
    margin-bottom: 1.3rem;
    font-style: italic;
    color: var(--quote-text);
}

.prose blockquote > :last-child { margin-bottom: 0; }

.prose hr {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 2rem 0;
}

.prose > :last-child { margin-bottom: 0; }

footer {
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background-color: var(--ok);
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
}

@media (prefers-reduced-motion: no-preference) {
    body::before { animation: drift 26s ease-in-out infinite alternate; }

    .rise > * { animation: rise 0.8s var(--ease) both; }
    .rise > :nth-child(2) { animation-delay: 0.08s; }
    .rise > :nth-child(3) { animation-delay: 0.16s; }
    .rise > :nth-child(4) { animation-delay: 0.24s; }
    .rise > :nth-child(n+5) { animation-delay: 0.32s; }

    a, .btn, .nav a, .tags a, .theme-toggle, .code-copy {
        transition: color 0.25s ease, background-color 0.25s ease, border-color 0.25s ease,
                    text-underline-offset 0.25s ease, text-decoration-thickness 0.25s ease;
    }

    a:hover {
        text-underline-offset: 5px;
        text-decoration-thickness: 2px;
    }

    input, select, textarea { transition: border-color 0.25s ease; }

    .card {
        transition: translate 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.25s ease;
    }

    .card:hover { translate: 0 -2px; }

    .code-copy { transition-property: color, border-color, opacity; }

    .dash-list > li::before { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }

    .dash-list > li:hover::before,
    .dash-list > li:focus-within::before {
        transform: translateX(4px);
    }
}

@keyframes drift {
    from { transform: translate(-6vmax, 0) scale(1); }
    to { transform: translate(6vmax, 4vmax) scale(1.12); }
}

@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
