:root {
    --bg: #f6f7f9;
    --surface: #fff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e2e5ea;
    --accent: #2f6fed;
    --accent-soft: #e7efff;
    --code-bg: #eef0f4;
    --mark: #fff0a8;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12151c;
        --surface: #1b1f29;
        --text: #e6e9ef;
        --muted: #98a1b3;
        --border: #2b3140;
        --accent: #7aa2ff;
        --accent-soft: #232c45;
        --code-bg: #272d3b;
        --mark: #5a4b12;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #12151c;
    --surface: #1b1f29;
    --text: #e6e9ef;
    --muted: #98a1b3;
    --border: #2b3140;
    --accent: #7aa2ff;
    --accent-soft: #232c45;
    --code-bg: #272d3b;
    --mark: #5a4b12;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.bar {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: center;
}

.search {
    flex: 1;
    position: relative;
}

.search input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.search input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.search kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0 6px;
    pointer-events: none;
}

.switch {
    position: relative;
    flex: none;
    width: 64px;
    height: 36px;
    padding: 0 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
}

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

.switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.switch svg {
    width: 16px;
    height: 16px;
    position: relative;
    z-index: 1;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    transition: transform .2s;
}

:root[data-theme="dark"] .knob {
    transform: translateX(28px);
}

:root:not([data-theme="dark"]) .sun,
:root[data-theme="dark"] .moon {
    color: var(--accent);
}

main {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 4px;
}

.lead {
    color: var(--muted);
    margin: 0 0 20px;
}

.count {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 12px;
}

article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

article:target,
article.flash {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

article h2 {
    font-size: 1.1rem;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

article h2 a {
    color: inherit;
    text-decoration: none;
}

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

.anchor {
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: .6;
    margin-left: auto;
}

.anchor:hover,
article:hover .anchor {
    opacity: 1;
    color: var(--accent);
}

article p {
    margin: 6px 0;
}

code {
    background: var(--code-bg);
    border-radius: 5px;
    padding: 1px 6px;
    font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code.copy {
    cursor: pointer;
}

code.copy:hover {
    outline: 1px solid var(--accent);
}

mark {
    background: var(--mark);
    color: inherit;
    border-radius: 3px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 0;
}

[hidden] {
    display: none !important;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: .9rem;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

footer {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    padding-bottom: 30px;
}

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