*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f0eee6;
    --text: #1f1e1d;
    --font: 'Newsreader', Georgia, 'Times New Roman', serif;
    color-scheme: light dark;
}

[data-theme="dark"] {
    --bg: #1f1e1d;
    --text: #f0eee6;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 20px;
    line-height: 1.6;
    transition: color 0.3s ease, background-color 0.3s ease;
}

::selection {
    background: rgba(0, 100, 255, 0.26);
    color: inherit;
}

a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.3s ease;
}

a:hover {
    opacity: 0.6;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ——— Header ——— */

header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    max-width: 620px;
    margin: 0 auto;
    padding: 15px 20px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

header.scrolled {
    background: rgba(240, 238, 230, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 rgba(31, 30, 29, 0.08);
}

[data-theme="dark"] header.scrolled {
    background: rgba(31, 30, 29, 0.85);
    box-shadow: 0 1px 0 rgba(240, 238, 230, 0.08);
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
}

header h1 a {
    text-decoration: none !important;
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.char-keep {
    display: inline-block;
}

.char-collapse {
    display: inline-block;
    overflow: hidden;
    max-width: 100px;
    opacity: 1;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.char-space {
    max-width: 0.3em;
}

/* Scroll-driven animation (Chrome, Edge, Safari 18+) */
@supports (animation-timeline: scroll()) {
    .char-collapse {
        transition: none;
        animation: collapse linear both;
        animation-timeline: scroll();
        animation-range: 0px 120px;
    }
    .char-space {
        animation-name: collapseSpace;
    }
    @keyframes collapse {
        to { max-width: 0; opacity: 0; }
    }
    @keyframes collapseSpace {
        from { max-width: 0.3em; }
        to { max-width: 0; opacity: 0; }
    }
}

/* JS fallback collapsed state (Firefox, older browsers) */
.site-title.collapsed .char-collapse {
    max-width: 0;
    opacity: 0;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

/* ——— Theme Toggle (pill slider) ——— */

.toggle-wrap {
    display: flex;
    align-items: center;
}

.toggle-wrap input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.toggle-wrap input:focus-visible + label {
    outline: 2px solid var(--text);
    outline-offset: 3px;
    border-radius: 10px;
}

.toggle-wrap label {
    position: relative;
    display: block;
    width: 40px;
    height: 20px;
    background: var(--text);
    border-radius: 10px;
    cursor: pointer;
}

.toggle-wrap label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--bg);
    border-radius: 50%;
    transition: transform 0s;
}

.toggle-wrap label.has-transition::after {
    transition: transform 0.2s;
}

.toggle-wrap input:checked + label::after {
    transform: translateX(20px);
}

/* ——— Main Content ——— */

main {
    max-width: 620px;
    margin: 0 auto;
    padding: 0 20px;
}

article section {
    margin-top: 26px;
}

article section:first-child {
    margin-top: 2rem;
}

article section p {
    margin-bottom: 1rem;
}

article section p:last-child {
    margin-bottom: 0;
}

h2 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

ul {
    list-style: none;
}

ul li {
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 0.9em;
}

ul li::before {
    content: '•';
    position: absolute;
    left: 0;
}

ul li:last-child {
    margin-bottom: 0;
}

/* ——— Footer ——— */

footer {
    max-width: 620px;
    margin: 0 auto;
    padding: 3rem 20px 2rem;
}

footer p {
    font-size: 14px;
    opacity: 0.6;
}

/* ——— Responsive ——— */

@media (max-width: 768px) {
    body {
        font-size: 18px;
    }

    header h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 21px;
    }
}

/* ——— Section Entrance Animations ——— */

@media (prefers-reduced-motion: no-preference) {
    article section {
        opacity: 0;
        transform: translateY(12px);
        animation: fadeUp 0.5s ease forwards;
    }
    article section:nth-child(1) { animation-delay: 0.1s; }
    article section:nth-child(2) { animation-delay: 0.2s; }
    article section:nth-child(3) { animation-delay: 0.3s; }
    article section:nth-child(4) { animation-delay: 0.4s; }
    article section:nth-child(5) { animation-delay: 0.5s; }
    @keyframes fadeUp {
        to { opacity: 1; transform: translateY(0); }
    }
}

/* ——— Accessibility ——— */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 8px 16px;
    background: var(--text);
    color: var(--bg);
    z-index: 100;
    font-size: 14px;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* ——— Reduced Motion ——— */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
