:root,
:root[data-theme="light"] {
    --bg-color: #f4f6fb;
    --sidebar-bg: #ebeff7;
    --surface-color: #ffffff;
    --surface-subtle: #eef2fa;
    --text-color: #343b58;
    --muted-color: #6c7393;
    --heading-color: #161822;
    --accent-color: #2e7de9;
    --accent-hover: #1d64c8;
    --accent-soft: rgba(46, 125, 233, 0.11);
    --green-color: #0f9d76;
    --green-soft: rgba(15, 157, 118, 0.12);
    --border-color: #d8dfee;
    --border-hover: #bcc7de;
    --code-bg: #eef2fa;
    --code-text: #b15c00;
    --btn-bg: #ffffff;
    --shadow-sm: 0 1px 2px rgba(22, 24, 34, 0.05);
    --shadow-md: 0 6px 16px rgba(22, 24, 34, 0.08);

    --note-color: #2e7de9;
    --tip-color: #0f9d76;
    --warn-color: #b15c00;
    --danger-color: #d22f4d;

    --tok-comment: #6c7393;
    --tok-keyword: #9854f1;
    --tok-string: #0f9d76;
    --tok-number: #b15c00;
    --tok-func: #2e7de9;
    --tok-type: #007197;
    --tok-del: #d22f4d;
    --tok-ins: #0f9d76;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg-color: #1a1b26;
    --sidebar-bg: #16161e;
    --surface-color: #24283b;
    --surface-subtle: #1f2335;
    --text-color: #c0caf5;
    --muted-color: #787c99;
    --heading-color: #e0e6ff;
    --accent-color: #7aa2f7;
    --accent-hover: #89b4fa;
    --accent-soft: rgba(122, 162, 247, 0.14);
    --green-color: #73daca;
    --green-soft: rgba(115, 218, 202, 0.14);
    --border-color: #2f3549;
    --border-hover: #414868;
    --code-bg: #16161e;
    --code-text: #ff9e64;
    --btn-bg: #1f2335;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.48);

    --note-color: #7aa2f7;
    --tip-color: #9ece6a;
    --warn-color: #e0af68;
    --danger-color: #f7768e;

    --tok-comment: #565f89;
    --tok-keyword: #bb9af7;
    --tok-string: #9ece6a;
    --tok-number: #ff9e64;
    --tok-func: #7aa2f7;
    --tok-type: #2ac3de;
    --tok-del: #f7768e;
    --tok-ins: #9ece6a;
    color-scheme: dark;
}

:root {
    --sidebar-width: 270px;
    --content-max: none;
    --reading-width: none;
    --img-min-width: 720px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-pill: 9999px;
    --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --body-font: var(--sans);
    --heading-font: var(--sans);
    --base-size: 0.98rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    background-color: var(--bg-color);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 28px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

body {
    min-height: 100vh;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--body-font);
    font-size: var(--base-size);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
    overflow-x: clip;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.no-scroll { overflow: hidden; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

a { color: var(--accent-color); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

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

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 300;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent-color);
    color: #1a1b26;
    font-size: 0.85rem;
    font-weight: 600;
}

.skip-link:focus { top: 12px; text-decoration: none; }

#read-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-color);
    transform: scaleX(0);
    transform-origin: left;
    z-index: 120;
}

.docs-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.docs-sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 26px 20px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: width 0.22s ease, padding 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
    z-index: 110;
}

html.sidebar-collapsed .docs-sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-color: transparent;
}

html.sidebar-collapsed .docs-sidebar > * {
    opacity: 0;
    pointer-events: none;
}

.sidebar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    white-space: nowrap;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--heading-color);
}

.site-logo:hover { text-decoration: none; color: var(--heading-color); }

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 700;
}

.sidebar-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.theme-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    background: var(--btn-bg);
    color: var(--muted-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.theme-btn {
    padding: 0 9px;
    font-family: var(--mono);
    font-size: 0.74rem;
    font-weight: 500;
}

.icon-btn {
    width: 28px;
    padding: 0;
}

.theme-btn:hover,
.icon-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.topbar-toggle-wrap {
    margin-bottom: 18px;
    display: none;
}

html.sidebar-collapsed .topbar-toggle-wrap {
    display: block;
}

.sidebar-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-color);
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, color 0.15s ease;
}

.sidebar-open-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.garden-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    padding: 3px 10px;
    margin-bottom: 12px;
    border-radius: var(--radius-pill);
    background: var(--green-soft);
    color: var(--green-color);
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--green-color);
}

.sidebar-bio {
    margin: 0 0 22px;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--muted-color);
}

.sidebar-label {
    margin: 0 0 8px;
    padding: 0 8px;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 24px;
}

.sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-color);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    background: var(--surface-subtle);
    color: var(--heading-color);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--accent-soft);
    color: var(--accent-color);
    font-weight: 600;
}

.sidebar-count {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted-color);
}

.sidebar-link.active .sidebar-count,
.sidebar-tag.active .sidebar-count {
    color: var(--accent-color);
}

.sidebar-topics { margin-bottom: 24px; }

.sidebar-tag-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-tag {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted-color);
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-tag:hover {
    background: var(--surface-subtle);
    color: var(--heading-color);
    text-decoration: none;
}

.sidebar-tag.active {
    background: var(--accent-soft);
    color: var(--accent-color);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted-color);
    white-space: nowrap;
}

.sidebar-footer a { color: var(--muted-color); text-decoration: none; }
.sidebar-footer a:hover { color: var(--accent-color); text-decoration: none; }

.docs-main-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 40px 48px 32px;
}

.docs-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--content-max);
}

html.sidebar-collapsed .docs-main,
html.sidebar-collapsed .site-footer {
    max-width: var(--content-max);
    margin-left: 0;
    margin-right: 0;
}

.post-content { min-width: 0; }

.docs-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.docs-breadcrumb {
    margin-bottom: 8px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent-color);
}

.docs-title {
    margin: 0 0 6px;
    font-size: clamp(1.65rem, 1.4rem + 1.1vw, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.25;
    color: var(--heading-color);
}

.docs-subtitle {
    margin: 0;
    font-size: 0.96rem;
    color: var(--muted-color);
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 0 22px;
}

.search input {
    width: 100%;
    padding: 11px 42px 11px 16px;
    font-family: var(--sans);
    font-size: 0.92rem;
    color: var(--heading-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input::placeholder { color: var(--muted-color); }

.search input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

.search-kbd {
    position: absolute;
    right: 12px;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--surface-subtle);
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted-color);
    pointer-events: none;
}

mark {
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--heading-color);
    background: var(--accent-soft);
    border-bottom: 1px solid var(--accent-color);
}

.post-content .search-empty {
    margin: 20px 0;
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    text-align: center;
    font-size: 0.92rem;
    color: var(--muted-color);
}

.topic-row { margin: 0 0 20px; }

@media (min-width: 861px) {
    html:not(.sidebar-collapsed) .topic-row { display: none; }
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

.topic-row .tag-list { margin-top: 0; }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    background: var(--surface-subtle);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-color);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.tag .count { margin-left: 5px; opacity: 0.75; }

.tag:hover,
.tag.active {
    border-color: var(--accent-color);
    background: var(--accent-soft);
    color: var(--accent-color);
    text-decoration: none;
}

.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-item {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 22px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.post-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.post-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.post-link {
    font-family: var(--heading-font);
    font-size: 1.14rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.38;
    color: var(--heading-color);
}

.post-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.post-link:focus-visible { outline: none; }
.post-link:focus-visible::after { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.post-link:hover,
.post-item:hover .post-link { color: var(--accent-color); text-decoration: none; }

.post-arrow {
    font-family: var(--mono);
    font-size: 0.95rem;
    color: var(--muted-color);
    transition: transform 0.18s ease, color 0.18s ease;
}

.post-item:hover .post-arrow {
    color: var(--accent-color);
    transform: translateX(3px);
}

.post-item .tag { position: relative; z-index: 1; }

.post-content .post-excerpt {
    margin: 10px 0 0;
    font-size: 0.91rem;
    line-height: 1.62;
    color: var(--muted-color);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted-color);
}

.card-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--green-color);
    font-weight: 500;
}

.mini-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--green-color);
}

.tag-group {
    margin-top: 20px;
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
    scroll-margin-top: 24px;
}

.tag-group h3 {
    margin: 0 0 10px;
    font-family: var(--mono);
    font-size: 1.02rem;
    color: var(--heading-color);
}

.tag-group:target { border-color: var(--accent-color); }
.tag-group .count { color: var(--muted-color); font-weight: 400; font-size: 0.85rem; }

.tag-posts { list-style: none; margin: 0; padding: 0; }
.tag-posts li {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}
.tag-posts li:first-child { border-top: none; padding-top: 0; }
.post-date { font-family: var(--mono); font-size: 0.8rem; color: var(--muted-color); }

.post-header {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border-color);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted-color);
}

.status-pill {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--green-soft);
    color: var(--green-color);
    font-weight: 600;
}

.post-title {
    margin: 0 0 10px;
    font-family: var(--heading-font);
    font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.3rem);
    font-weight: 700;
    line-height: 1.24;
    letter-spacing: -0.025em;
    color: var(--heading-color);
}

.post-content .section-label {
    margin: 0 0 12px;
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
}

.post-content h1,
.post-content h2,
.post-content h3 {
    font-family: var(--heading-font);
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--heading-color);
    line-height: 1.32;
}

.post-content h2 {
    margin: 2.1em 0 0.7em;
    font-size: 1.42rem;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    scroll-margin-top: 24px;
}

.post-content h3 {
    margin: 1.7em 0 0.5em;
    font-size: 1.16rem;
    scroll-margin-top: 24px;
}

.post-content p { margin: 0 0 1.25em; }

.entry-body > p,
.entry-body > ul:not([class]),
.entry-body > ol,
.entry-body > blockquote { max-width: var(--reading-width); }

.post-content ul,
.post-content ol { margin: 0 0 1.25em; padding-left: 1.45em; }
.post-content li { margin-bottom: 0.42em; }

.post-content ul.post-list,
.post-content ul.tag-posts,
.post-content ul.related-list,
.post-content ul.sidebar-tag-list { margin: 0; padding: 0; list-style: none; }
.post-content ul.tag-list { margin: 10px 0 0; padding: 0; list-style: none; }
.post-content .topic-row ul.tag-list { margin: 0; }
.post-content .post-list li,
.post-content .tag-list li,
.post-content .tag-posts li,
.post-content .related-list li { margin: 0; }

.post-content a:not([class]) {
    text-decoration: underline;
    text-decoration-color: var(--accent-soft);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}
.post-content a:not([class]):hover { text-decoration-color: var(--accent-color); }

.anchor {
    margin-left: 0.45em;
    font-family: var(--mono);
    font-size: 0.8em;
    font-weight: 400;
    color: var(--muted-color);
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--accent-color); text-decoration: none; }

.post-content img {
    display: block;
    max-width: 100%;
    min-width: min(100%, var(--img-min-width));
    height: auto;
    margin: 1.75em auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.post-content img.zoomable { cursor: zoom-in; }

.zoom-hint {
    display: block;
    margin: -1.1em 0 1.75em;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted-color);
}

hr { border: 0; border-top: 1px solid var(--border-color); margin: 2.4em 0; }

.post-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.75em 0;
    font-size: 0.92rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.post-content th,
.post-content td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.post-content th {
    background: var(--surface-subtle);
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--heading-color);
}

.post-content tbody tr:last-child td { border-bottom: none; }

.back-link { margin-top: 2.2em; font-size: 0.9rem; font-weight: 500; }

.ctf-card {
    margin: 18px 0 0;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
}

.ctf-card dl { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0; }
.ctf-card dt { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-color); }
.ctf-card dd { margin: 2px 0 0; font-family: var(--mono); font-size: 0.9rem; font-weight: 600; color: var(--heading-color); }
.ctf-card dd.diff-easy   { color: var(--tip-color); }
.ctf-card dd.diff-medium { color: var(--warn-color); }
.ctf-card dd.diff-hard,
.ctf-card dd.diff-insane { color: var(--danger-color); }

.toc {
    margin: 0 0 2em;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.toc summary {
    cursor: pointer;
    padding: 11px 16px;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--heading-color);
}

.toc ul { list-style: none; margin: 0; padding: 4px 16px 14px; }
.toc li { margin: 0; padding: 3px 0; line-height: 1.5; }
.toc li.toc-sub { padding-left: 1.2em; }
.toc li.toc-sub::before { content: "└ "; color: var(--muted-color); font-family: var(--mono); font-size: 0.82em; }
.toc a { text-decoration: none; color: var(--text-color); }
.toc a:hover { color: var(--accent-color); text-decoration: none; }

blockquote {
    margin: 1.6em 0;
    padding: 0.3em 1.25em;
    border-left: 3px solid var(--border-hover);
    color: var(--muted-color);
}

blockquote p:last-child { margin-bottom: 0; }

blockquote.note,
blockquote.tip,
blockquote.warning,
blockquote.todo {
    --c: var(--note-color);
    padding: 1em 1.25em;
    font-style: normal;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--c);
    border-radius: var(--radius-md);
    background: var(--surface-color);
}

blockquote.tip     { --c: var(--tip-color); }
blockquote.warning { --c: var(--warn-color); }
blockquote.todo    { --c: var(--danger-color); }

blockquote.note::before,
blockquote.tip::before,
blockquote.warning::before,
blockquote.todo::before {
    display: block;
    margin-bottom: 5px;
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--c);
}

blockquote.note::before    { content: "NOTE"; }
blockquote.tip::before     { content: "TIP"; }
blockquote.warning::before { content: "WARNING"; }
blockquote.todo::before    { content: "TODO"; }

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

code {
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 0.85em;
    color: var(--code-text);
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
}

pre {
    max-width: 100%;
    margin: 1.65em 0;
    padding: 16px 18px;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    font-size: 0.86rem;
    line-height: 1.65;
}

pre code {
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: inherit;
    color: var(--text-color);
    background-color: transparent;
}

div.highlighter-rouge {
    max-width: 100%;
    margin: 1.65em 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--code-bg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

div.highlighter-rouge .highlight { margin: 0; }
div.highlighter-rouge pre { margin: 0; border: 0; border-radius: 0; }

.code-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--muted-color);
}

.code-lang { text-transform: lowercase; font-weight: 500; }

.copy-btn {
    background: var(--surface-color);
    color: var(--muted-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 2px 8px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.74rem;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.copy-btn:hover { color: var(--accent-color); border-color: var(--accent-color); text-decoration: none; }

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp, .highlight .ch { color: var(--tok-comment); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kc, .highlight .nt, .highlight .ow { color: var(--tok-keyword); }
.highlight .kt, .highlight .nc, .highlight .nn, .highlight .no, .highlight .nv, .highlight .vi, .highlight .vg, .highlight .vc { color: var(--tok-type); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss { color: var(--tok-string); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: var(--tok-number); }
.highlight .nf, .highlight .fm, .highlight .nb, .highlight .na, .highlight .bp { color: var(--tok-func); }
.highlight .gd { color: var(--tok-del); }
.highlight .gi { color: var(--tok-ins); }
.highlight .err { color: inherit; background: none; }

.spoiler {
    filter: blur(6px);
    cursor: pointer;
    user-select: none;
    transition: filter 0.2s ease;
}

.spoiler.revealed { filter: none; user-select: text; }
.spoiler:hover:not(.revealed) { filter: blur(5px); }

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    padding: 24px;
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y pinch-zoom;
    background: rgba(22, 22, 30, 0.92);
    backdrop-filter: blur(6px);
    cursor: zoom-out;
}

.lightbox[hidden] { display: none; }

.lightbox img {
    flex: none;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.post-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin: 3em 0 0;
    padding-top: 2em;
    border-top: 1px solid var(--border-color);
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.post-nav-link:hover {
    border-color: var(--accent-color);
    transform: translateY(-1px);
    text-decoration: none;
}
.post-nav-link.next { text-align: right; }

.post-nav-label { font-family: var(--mono); font-size: 0.76rem; color: var(--muted-color); }
.post-nav-title { font-weight: 600; font-size: 0.95rem; line-height: 1.4; color: var(--heading-color); overflow-wrap: anywhere; }

.related {
    margin-top: 2.4em;
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
}
.related[hidden] { display: none; }

.related-list li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 7px 0;
    border-top: 1px solid var(--border-color);
}
.related-list li:first-child { border-top: none; padding-top: 0; }

.related-list time {
    flex: 0 0 6.5rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted-color);
}

.post-content .related-list a { text-decoration: none; font-weight: 600; color: var(--heading-color); }
.post-content .related-list a:hover { color: var(--accent-color); text-decoration: none; }

#to-top {
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 90;
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--heading-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#to-top.show { opacity: 1; pointer-events: auto; }
#to-top:hover { color: var(--accent-color); border-color: var(--accent-color); text-decoration: none; }

.site-footer {
    margin-top: 72px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    width: 100%;
    max-width: var(--content-max);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.84rem;
    color: var(--muted-color);
}

.site-footer p { margin: 0; }
.site-footer a { color: var(--muted-color); font-weight: 500; text-decoration: none; }
.site-footer a:hover { color: var(--accent-color); text-decoration: none; }
.footer-links { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 0.8rem; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 105;
    background: rgba(22, 22, 30, 0.65);
    backdrop-filter: blur(2px);
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 980px) {
    .post-list { grid-template-columns: 1fr; }
    .docs-main-wrap { padding: 32px 32px 28px; }
}

@media (max-width: 860px) {
    .topbar-toggle-wrap { display: block; }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 270px;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }

    html.sidebar-mobile-open .docs-sidebar {
        transform: translateX(0);
    }

    html.sidebar-collapsed .docs-sidebar {
        width: 270px;
        padding: 26px 20px;
        border-right-color: var(--border-color);
    }

    html.sidebar-collapsed .docs-sidebar > * {
        opacity: 1;
        pointer-events: auto;
    }

    .docs-main-wrap { padding: 20px 20px 28px; }
    .post-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tag-posts li,
    .related-list li { flex-direction: column; gap: 2px; }
    .related-list time { flex-basis: auto; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav-link.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}

@media print {
    :root[data-theme] {
        --bg-color: #fff; --text-color: #111; --heading-color: #000;
        --muted-color: #555; --accent-color: #000; --border-color: #ccc;
        --code-bg: #f6f6f6; --code-text: #111;
    }
    .docs-shell { display: block; }
    .docs-sidebar, .topbar-toggle-wrap, .sidebar-backdrop, .skip-link, #read-progress, #to-top, .toc,
    .post-nav, .related, .copy-btn, .back-link, .search, .topic-row { display: none !important; }
    .docs-main-wrap { padding: 0; }
    .post-item { break-inside: avoid; box-shadow: none; }
    .spoiler { filter: none; }
    a { color: inherit; }
}
