* {
    box-sizing: border-box;
}

:root {
    --font-body: "Montserrat", Arial, sans-serif;
    --font-code: "Fira Code", "Fira Mono", "Consolas", monospace;
    --font-header: "Lexend", Arial, sans-serif;
    --color-bg: #fff;
    --color-panel-bg: #f8f8f8;
    --color-text: #474747;
    --color-nav-text: var(--color-text);
    --color-muted: #767676;
    --color-link: #474747;
    --color-link-hover: #151515;
    --color-border: #ddd;
    --color-logo-bg: #333;
    --color-logo-text: white;
    --color-code-font: #ddd;
    --color-code-background: #2d2d2d;
    --scrollbar-thumb: #777779;
    --scrollbar-track: #201f23;
    --scrollbar-hover: #999;
    /* Paging (disabled link) colors */
    --color-paging-disabled-text: #999;
    --color-paging-disabled-border: #eee;
    --color-paging-disabled-bg: #f9f9f9;
}

html.dark {
    --color-bg: #252525;
    --color-panel-bg: #1e1e1e;
    --color-nav-text: #fff;
    --color-text: #e4e4e4;
    --color-muted: #aaa;
    --color-link: #e4e4e4;
    --color-link-hover: #ffffff;
    --color-border: #444;
    background: var(--color-bg);
    color: var(--color-text);
    --color-paging-disabled-text: #444;
    --color-paging-disabled-border: #444;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin: 0;
    transition:
        background 0.3ms,
        color 0.3ms;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-header);
    font-weight: 700;
    letter-spacing: 0.01em;
}

pre,
code {
    font-family: var(--font-code);
}

.panel {
    background-color: var(--color-panel-bg);
    border-bottom: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
}

footer {
    padding: 0.7rem;
    text-align: center;
    margin-top: 4em;
    font-size: 0.8rem;
    font-family: var(--font-header);
    color: var(--color-nav-text);
}

footer p a {
    color: var(--color-nav-text);
    text-decoration: none;
}

footer p a:hover {
    text-decoration: underline;
}

.footer-links a {
    margin: 0 0.5rem;
}

footer svg {
    display: inline-block;
    vertical-align: middle;
}

header {
    padding: 0.4rem;
    text-align: center;
    font-family: var(--font-header);
}

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

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

a.button {
    color: var(--color-link);
    font-family: var(--font-header);
    text-wrap-mode: nowrap;
    padding: 0.28em 0.95em;
    background: none;
    font-weight: 700;
    border: 1.5px solid var(--color-link);
    border-radius: 0.35em;
    text-decoration: none;
    transition:
        background 0.18s,
        color 0.18s,
        border 0.18s;
    font-size: 1em;
    letter-spacing: 0.01em;
}

a.button:hover {
    color: var(--color-panel-bg);
    background: var(--color-text);
}

a.link {
    transition: border 0.18s;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0);
}

a.link:hover {
    text-decoration: none;
    border-bottom: 1px solid var(--color-nav-text);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 690px;
    margin: 0 auto;
}

nav a {
    color: var(--color-nav-text);
    margin: 0 0.5rem;
    font-family: var(--font-header);
    font-weight: 400;
}

.nav-logo {
    font-size: 2rem;
    background: var(--color-logo-bg);
    color: var(--color-logo-text) !important;
    padding: 0.02em 0.3em;
    border-radius: 0.4em;
    text-decoration: none;
    margin: 0;
}

.nav-logo:hover {
    text-decoration: none;
}

.nav-logo strong {
    font-weight: bold;
}

.toggle-icon {
    font-size: 1.3em;
    margin-left: 0.5rem;
    margin-right: 0.2rem;
    width: 1.5rem;
    color: var(--color-nav-text);
    display: inline-block;
    text-align: center;
    transition: border 0.18s;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0);
}

.toggle-icon:hover {
    border-bottom: 1px solid var(--color-nav-text);
    cursor: pointer;
}

main {
    max-width: 720px;
    margin: auto;
    padding: 1em;
}

.hero {
    padding-bottom: 1rem;
    padding-top: 1rem;
}

.hero h1 {
    font-size: 2.3rem;
    margin-top: 0.5em;
    margin-bottom: 0.7em;
    font-size: 2em;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-left: 5px solid var(--color-text);
    padding-left: 0.4em;
    background: none;
}

.hero p {
    margin: 1rem auto;
}

.toc {
    margin: 0.9rem 0;
    padding: 0.7rem 1rem;
    background: var(--color-panel-bg);
    border-radius: 8px;
    max-width: 350px;
    display: inline-block;
}

.toctitle {
    font-size: 1.05rem;
    font-weight: 600;
    font-family: var(--font-header);
    margin-bottom: 0.7rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.toc ul {
    list-style: disc;
    padding: 0.3rem 0 0 1rem;
    margin: 0;
    font-size: 0.9rem;
}

.toc li {
    padding-left: 0.1rem;
}

.toc a {
    transition: border 0.18s;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0);
}

.toc a:hover {
    text-decoration: none;
    border-bottom: 1px solid var(--color-nav-text);
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.6rem;
}

h3 {
    font-size: 1.4rem;
}

h1 a,
h2 a,
h3 a {
    text-decoration: none;
    color: var(--color-text);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.6em;
}

.section-title h2 {
    margin-top: 1em;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-bottom: 1.2px solid var(--color-text);
    padding-bottom: 0.08em;
    display: inline-block;
}

.post-preview {
    padding: 0.8em;
    border: 1px solid var(--color-border);
    border-radius: 0.35em;
    margin-bottom: 2rem;
}

.post-title {
    display: block;
    text-decoration: none;
}

.post-title h3 {
    font-weight: 600;
    margin-bottom: 0;
    margin-top: 0;
    display: inline-block;
    border-bottom: 1px solid rgba(0, 0, 0, 0);
}

.post-title:hover h3 {
    text-decoration: none;
    border-bottom: 1px solid var(--color-text);
}

.post-footer {
    margin-top: 0.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.post-meta span {
    margin-right: 0.5em;
}

.tag {
    background: rgba(0, 0, 0, 0);
    color: var(--color-muted);
    font-weight: 400;
    border-radius: 0.3em;
    padding: 0.1em 0.3em;
    margin-right: 0.05em;
    margin-bottom: 0.05em;
    text-decoration: none;
    border: 1px solid var(--color-border);
    transition:
        background 0.18s,
        color 0.18s;
}

.tag:hover {
    text-decoration: none;
    background: var(--color-link);
    color: var(--color-border);
}

.tags {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    list-style: none;
    padding: 0;
    white-space: nowrap;
    flex-wrap: wrap;
}

.tags li {
    padding: 0.3rem;
}

.paging {
    list-style: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    margin: 2rem 0;
}

.paging li {
    display: inline-block;
}

.paging a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.paging a[aria-disabled="true"] {
    pointer-events: none;
    color: var(--color-paging-disabled-text);
    border-color: var(--color-paging-disabled-border);
}

.paging li:nth-child(2) {
    font-weight: 500;
    color: #666;
}

.highlight {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

div.highlight > button {
    font-size: 0.8rem;
    align-self: flex-end;
    color: var(--color-code-font);
    font-family: var(--font-code);
    background-color: var(--color-code-background);
    border-radius: 5px 5px 0px 0px;
    border: 0;
    padding-bottom: 10px;
    margin-bottom: -20px;
}

div.highlight > button:hover,
div.highlight > button:focus {
    text-decoration: underline;
    cursor: pointer;
}

.wrap > pre {
    text-wrap: wrap;
}

code {
    color: var(--color-code-font);
    background-color: var(--color-code-background);
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 300;
    padding: 1px 2px;
}

pre code {
    background-color: transparent;
}

pre {
    line-height: 1.1;
    display: block;
    overflow-x: auto;
    position: relative;
    padding: 15px 10px !important;
    background-color: var(--color-code-background);
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    scrollbar-width: auto;
}

/* Webkit properties for Chrome, Safari, Edge */
pre::-webkit-scrollbar {
    height: 12px;
}

pre::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

pre::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border: 2px solid var(--scrollbar-track);
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-hover);
}

article table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
    margin-bottom: 1.5rem;
    border-collapse: collapse;
}

article table tr {
    border-bottom: var(--color-border) solid 2px;
}

article table thead,
article table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
}

article table td,
article table th {
    padding: 0.3rem 0.5rem;
    white-space: nowrap;
}

article table td + td {
    border-left-color: inherit;
    border-left-style: solid;
    border-left-width: 1px;
}

@media print {
    body {
        font-family: "Arial", "Times New Roman", serif !important;
        font-size: 13pt !important;
        line-height: 1.6;
        color: #000 !important;
        background: #fff !important;
    }

    @page {
        margin: 1cm;
        /* Standard margins to prevent content clipping */
    }

    header,
    footer,
    .hero,
    .toc {
        display: none !important;
    }

    h2,
    h3,
    h4,
    ul,
    p {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    a.toclink {
        color: inherit;
        text-decoration: none;
        pointer-events: none;
    }

    h2 {
        page-break-before: always;
        break-before: page;
        margin-top: 0.2rem;
        margin-bottom: 0.3rem;
    }

    h2:first-of-type {
        page-break-before: auto;
        break-before: auto;
    }

    h3 {
        margin-top: 0.4rem;
        margin-bottom: 0.4rem;
        page-break-before: always;
        break-before: page;
    }

    h4 {
        margin: 0.3rem auto 0.3rem;
    }

    h1,
    h2,
    h3,
    h4 {
        text-decoration: none;
        break-after: avoid;
        page-break-after: avoid;
        color: #000;
    }

    p {
        margin-top: 0.1rem;
    }

    ul {
        list-style-type: disc;
        padding-left: 18px;
        margin-top: 0;
        margin-bottom: 0;
    }

    article table td,
    article table th {
        padding: 0.2rem 0.5rem;
        white-space: normal;
    }

    section,
    p,
    blockquote {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }

    img {
        max-width: 100% !important;
        height: auto !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        /* Append URL so reader knows where link goes */
        font-size: 90%;
        color: #333;
    }

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
        /* Don't show internal anchors or scripts */
    }
}
