html {
    scrollbar-gutter: stable;
}

:root {
    --bg: #f8f9fa;
    --text: #1a1a1a;
    --text-secondary: #555;
    --border: #d0d0d0;
    --border-light: #e8e8e8;
    --code-bg: #f0f0f0;
    --link: #0645ad;
    --link-visited: #0b0080;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro",
        Menlo, Consolas, "DejaVu Sans Mono", monospace;

    --fs: 0.9375rem;
    --fs-small: 0.8125rem;
    --lh: 1.5;
}

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

body {
    font-family: var(--font);
    font-size: var(--fs);
    line-height: var(--lh);
    max-width: 72ch;
    color: var(--text);
    background: var(--bg);
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

a {
    color: var(--link);
    transition: color 0.2s ease;
}

a:visited {
    color: var(--link-visited);
}

a[href^="http"]:not(.buttons-container a)::after {
    content: " \29C9";
    font-size: 0.75em;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    margin: 1rem 0 0.5rem;
}

h1 {
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

h2 {
    font-size: 1.15rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.2rem;
    margin-top: 1.25rem;
}

h3 {
    font-size: 1rem;
    margin-top: 1rem;
}

h4 {
    font-size: 0.9375rem;
    margin-top: 0.75rem;
}

p {
    margin-bottom: 0.6rem;
}

small {
    font-size: var(--fs-small);
}

abbr {
    cursor: help;
}

ul, ol {
    margin: 0.4rem 0;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.15rem;
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.1em 0.3em;
    border-radius: 2px;
}

pre {
    background: var(--code-bg);
    padding: 0.5rem 0.75rem;
    border-left: 2px solid var(--border);
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: var(--fs-small);

    code {
        background: none;
        padding: 0;
        border-radius: 0;
    }
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #909090;
}

.token.punctuation {
    color: #008000;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
    color: #000080;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
    color: #008000;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string {
    color: #008080;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #0000dd;
}

.token.function,
.token.class-name {
    color: #1a1a1a;
}

.token.regex,
.token.variable {
    color: #000080;
}

.token.important {
    color: #ff0000;
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

table {
    width: auto;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: var(--fs-small);
}

th, td {
    padding: 0.25rem 0.6rem;
    text-align: left;
    border: 1px solid var(--border-light);
}

th {
    font-weight: bold;
    background: var(--code-bg);
    border-bottom: 2px solid var(--border);
}

blockquote {
    margin: 0.5rem 0;
    padding: 0.4rem 0.75rem;
    background: var(--code-bg);
    border-left: 2px solid var(--border);

    p {
        margin-bottom: 0.4rem;

        &:last-child {
            margin-bottom: 0;
        }
    }

    & blockquote {
        background: var(--border-light);
    }
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.4rem 0;
}

.float-right {
    float: right;
    max-width: 45%;
    margin: 0.25rem 0 0.5rem 0.75rem;
}

figure {
    margin: 0;
    text-align: center;

    &.float-right {
        img { margin: 0; }
        figcaption { text-align: right; }
    }
}

figcaption {
    font-size: var(--fs-small);
    margin-top: 0.2rem;
    font-style: italic;
    color: var(--text-secondary);
}

.site-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.site-header .site-title {
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    margin-right: 0.5rem;
}

.site-header nav {
    display: flex;
    gap: 0.1rem;
    font-size: var(--fs-small);
}

.site-header nav a {
    padding: 0 0.3rem;

    &:visited {
        color: var(--link);
    }
}

.site-header nav a:first-child {
    padding-left: 0;
}

.site-header nav .sep {
    color: var(--border);
    user-select: none;
}

.site-header .spacer {
    flex: 1;
}

.site-header .header-right {
    font-size: var(--fs-small);
    color: var(--text-secondary);
}

footer {
    margin-top: 1.5rem;
    padding-top: 0.5rem;
    text-align: center;
    font-size: var(--fs-small);
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);

    a, a:visited {
        color: var(--text-secondary);
    }
}

.footer-logo {
    display: inline-block;
    width: auto;
    height: 0.9em;
    vertical-align: -0.1em;
    margin: 0 0.4em 0 0;
}


.year-heading {
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.9375rem;

    &.first-year {
        margin-top: 0.25rem;
    }

    &.hidden {
        display: none;
    }
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.filter-legend {
    font-size: var(--fs-small);
    color: var(--text-secondary);
}

.category-filter {
    font-family: var(--font);
    font-size: var(--fs-small);
    padding: 0.15rem 0.4rem;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;

    &:hover {
        border-color: var(--border);
    }

    &.active {
        border-color: var(--text);
        color: var(--text);
        background: var(--code-bg);
    }
}

h4.year-heading + ul {
    margin-top: 0;
}

.text-small {
    font-size: var(--fs-small);
}

.text-muted {
    color: var(--text-secondary);
}

.post-list + p {
    margin-top: 0.4rem;
    font-size: var(--fs-small);
}

.post-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.post-item {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.2rem;
    font-size: var(--fs-small);

    &.hidden {
        display: none;
    }
}

.dot-leader {
    flex: 1;
    border-bottom: 1px dotted var(--border);
    margin: 0 0.4rem;
    min-width: 1rem;
    position: relative;
    bottom: 0.2em;
}

.post-link {
    position: relative;

    &[data-description]:hover::after {
        content: attr(data-description);
        position: absolute;
        left: 0;
        top: 100%;
        margin-top: 4px;
        z-index: 1;
        width: 280px;
        background: var(--bg);
        padding: 0.4rem 0.5rem;
        border: 1px solid var(--border);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        color: var(--text-secondary);
        font-size: var(--fs-small);
        line-height: 1.35;
        pointer-events: none;
    }
}

.favorite {
    color: var(--text-secondary);
    margin-left: 0.15em;
    font-size: var(--fs-small);
}

.post-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: var(--fs-small);
}

.post-meta {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    margin-bottom: 0.4rem;

    a, a:visited {
        color: var(--text-secondary);
    }
}

.post-description {
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 0.1rem;
    margin-bottom: 0.75rem;
}

article {
    position: relative;
}

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

.the-end {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    clear: both;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    font-size: var(--fs-small);
}

.nav-prev, .nav-next {
    flex: 1;
    min-width: 180px;
}

.nav-next {
    text-align: right;
}

.toc-wrapper {
    background: var(--code-bg);
    border: 1px solid var(--border-light);
    padding: 0.4rem;
    margin-bottom: 0.5rem;
    font-size: var(--fs-small);

    summary {
        cursor: pointer;
        font-weight: bold;
        list-style-position: outside;
        margin-left: 1em;
    }
}

.toc {
    list-style: none;
    padding-left: 0;
    margin: 0.3rem 0 0 1em;

    li.toc-h2 {
        margin-top: 0.3rem;
        margin-bottom: 0.1rem;
        line-height: 1.35;

        &:first-child {
            margin-top: 0;
        }
    }

    li.toc-h3 {
        margin-bottom: 0.1rem;
        padding-left: 0.75rem;
        line-height: 1.35;
        color: var(--text-secondary);
    }
}

.authors-note {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border-light);
    padding: 0.4rem;

    summary {
        cursor: pointer;
        font-weight: bold;
        list-style-position: outside;
        margin-left: 1em;
    }
}

.authors-note-content {
    margin: 0.3rem 0 0 1em;

    p {
        margin-bottom: 0.3rem;

        &:last-child {
            margin-bottom: 0;
        }
    }
}

sup.fnref {
    vertical-align: baseline;
    position: relative;
    font-size: 0.8em;
    bottom: 1.25ex;

    a {
        &:hover, &.hover {
            border: 1px solid var(--text-secondary);
            padding: 2px 3px 0 3px;
            margin: -2px -4px 0 -4px;
        }
    }
}

a.fnref, .fnref a {
    color: var(--text);
    text-decoration: none;
}

.footnote {
    float: right;
    clear: right;
    width: 200px;
    margin-right: -230px;
    margin-bottom: 0.3rem;
    font-size: var(--fs-small);
    line-height: 1.35;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    padding: 0.3rem;
    background: var(--bg);

    &:hover, &.hover {
        border-color: var(--border);
        background: var(--code-bg);
    }

    &:target {
        background: var(--code-bg);
    }
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 3px;
}

.friend-info {
    display: flex;
    flex-direction: column;
    font-size: var(--fs-small);
}

.about-intro {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.button-88x31 {
    width: 88px;
    height: 31px;
    margin: 0;
}

.side-by-side {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: 0.3rem 0.6rem;
    background: var(--text);
    color: var(--bg);
    font-size: var(--fs-small);
    text-decoration: none;
    z-index: 100;

    &:focus {
        top: 0;
    }
}

.status-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
}

:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

@media (min-width: 1100px) {
    .toc-wrapper {
        position: absolute;
        left: -240px;
        width: 210px;
        top: 0;
    }

    .authors-note {
        position: absolute;
        left: -240px;
        width: 210px;
    }
}

@media (max-width: 1100px) {
    .footnote {
        float: none;
        display: block;
        width: auto;
        margin: 0.2rem 0 0.3rem 1.5rem;
        border-left: 2px solid var(--border-light);
        border-top: none;
        border-right: none;
        border-bottom: none;
        background: none;
        padding: 0.1rem 0 0.1rem 0.5rem;
    }
}

@media (max-width: 640px) {
    .site-header {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .site-header .spacer {
        display: none;
    }

    .toc-wrapper {
        position: static;
        width: auto;
        margin-bottom: 0.75rem;
    }

    .toc-wrapper[open] {
        margin-bottom: 0.75rem;
    }

    .side-by-side {
        gap: 0.25rem;
    }
}

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