:root {
    --bg: #ffffff;
    --text: #24292f;
    --text-secondary: #57606a;
    --accent: #0969da;
    --border: #d0d7de;
    --code-bg: #f6f8fa;
    --hover-bg: #f3f4f6;

    /* Alert Colors */
    --alert-note-bg: #ddf4ff;
    --alert-note-border: #54aeff;
    --alert-note-text: #0969da;

    --alert-info-bg: #dafbe1;
    --alert-info-border: #41ae60;
    --alert-info-text: #145226;

    --alert-warning-bg: #fff8c5;
    --alert-warning-border: #d4a72c;
    --alert-warning-text: #9a6700;
    --alert-danger-bg: #ffebe9;
    --alert-danger-border: #ff8182;
    --alert-danger-text: #cf222e;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    width: 100%;
    padding: 32px 0;
}


.article-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    margin: 0 auto;
}

.article-layout>.toc,
.article-layout>#sidebar {
    flex: 1 1 auto;
    min-width: 280px;
}

.article-layout>article {
    flex: 2 1 auto;
    min-width: 800px;
 
}

@media (max-width: 1200px) {
    .article-layout {
        flex-direction: column;
        gap: 24px;
    }

    .article-layout>.toc {
        flex: 1;
        min-width: 0;
        max-width: 100%;
    }

    .article-layout>#sidebar {
        display: none;
    }

    .article-layout>article {
        flex: 1;
        max-width: 100%;
    }
}

#sidebar {
    position: sticky;
    top: 32px;
    align-self: flex-start;
    height: calc(100vh - 100px);
    overflow-y: auto;
    width: 100%;
}

#sidebar:has(.toc) {
    border-left: 1px solid var(--border);
}
#sidebar:has(.more_articles) {
    border-right: 1px solid var(--border);
}
/* more_articles */

.more_articles {
    background-color: var(--bg);
    /* border: 1px solid var(--border); */
    border-radius: 6px;
    /* padding: 16px; */
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    float: inline-end;
}

.more_articles h3 {
    font-size: 16px;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.more_articles ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.more_articles li {
    margin-bottom: 6px;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--border);
}

.more_articles li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.more_articles a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    display: block;
    line-height: 1.4;
}

.more_articles a:hover {
    color: var(--accent);
}

.more_articles-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}


/* Links */
a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
}

h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border);
}

h2 {
    font-size: 1.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 1.25em;
}

h4 {
    font-size: 1em;
}

p {
    margin-top: 0;
    margin-bottom: 16px;
}

blockquote {
    padding: 0 1em;
    color: var(--text-secondary);
    border-left: 0.25em solid var(--border);
    margin: 0 0 16px 0;
}

/* Lists */
ul,
ol {
    margin: 0 0 16px;
    padding-left: 2em;
}

ul {
    list-style-type: disc;
}

ol {
    list-style-type: decimal;
}

li {
    word-wrap: break-word;
}

li+li {
    margin-top: 0.25em;
}

/* Code */
code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    white-space: break-spaces;
    background-color: var(--code-bg);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

pre {
    background-color: var(--code-bg);
    padding: 16px 2rem 16px 16px;
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 85%;
    line-height: 1.45;
    /* max-width: fit-content; */
    overflow-x: auto;
    min-width: 200px;
}

pre code {
    background-color: transparent;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    white-space: pre;
    font-size: 100%;
}

/* Tables */
table {
    border-spacing: 0;
    border-collapse: collapse;
    margin: 0 0 16px;
    width: 100%;
    display: block;
    overflow: auto;
}

table th,
table td {
    padding: 6px 13px;
    border: 1px solid var(--border);
}

table tr {
    background-color: #ffffff;
    border-top: 1px solid var(--border);
}

table tr:nth-child(2n) {
    background-color: var(--code-bg);
}

table th {
    font-weight: 600;
}

/* Images */
img:not(.profile-img) {
    max-width: 100%;
    box-sizing: content-box;
    background-color: transparent;
    border-style: none;
}

/* Task lists */
ul.contains-task-list {
    list-style-type: none;
    padding-left: 0;
}

li.task-list-item {
    list-style-type: none;
}

input.task-list-item-checkbox {
    margin: 0 0.2em 0.25em -1.6em;
    vertical-align: middle;
    cursor: default;
}

/* Fix nested lists indentation inside task lists */
.article-content li.task-list-item ul,
.article-content li.task-list-item ol {
    margin-left: 2rem;
    list-style-type: disc !important;
    display: block !important;
}

.article-content li.task-list-item ol {
    list-style-type: decimal !important;
}

/* Custom content blocks / Alerts */
.warning-block,
.info-block,
.tip-block,
.danger-block {
    padding: 8px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    /* width: fit-content; */
}

.warning-block {
    background-color: var(--alert-warning-bg);
    border-color: var(--alert-warning-border);
    color: var(--alert-warning-text);
}

.danger-block {
    background-color: var(--alert-danger-bg);
    border-color: var(--alert-danger-border);
    color: var(--alert-danger-text);
}

.info-block {
    background-color: var(--alert-info-bg);
    border-color: var(--alert-info-border);
    color: var(--alert-info-text);
}

.tip-block {
    background-color: var(--alert-note-bg);
    border-color: var(--alert-note-border);
    color: var(--alert-note-text);
}

.warning-title,
.info-title,
.tip-title,
.danger-title {
    font-weight: 600;
    margin-bottom: 4px;
}

/* Reduced spacing for content inside alerts */
.warning-content p,
.info-content p,
.tip-content p,
.danger-content p {
    margin-bottom: 8px;
}

.warning-content p:last-child,
.info-content p:last-child,
.tip-content p:last-child,
.danger-content p:last-child {
    margin-bottom: 0;
}

/* Tighter lists inside alerts */
.warning-content ul,
.warning-content ol,
.info-content ul,
.info-content ol,
.tip-content ul,
.tip-content ol,
.danger-content ul,
.danger-content ol {
    margin-bottom: 8px;
    padding-left: 1.5em;
}

.warning-content li+li,
.info-content li+li,
.tip-content li+li,
.danger-content li+li {
    margin-top: 4px;
}

/* Specific component styles */
.site-footer {
    padding: 5px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: auto;
}
.site-footer p {
    margin-bottom: 0px;
}
.article-header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
    padding-bottom: 16px;
}

.article-header h1 {
    font-size: 2em;
    margin-bottom: 8px;
    border-bottom: none;
    padding-bottom: 0;
}

.article-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.author-link {
    color: var(--accent);
    text-decoration: none;
}

.author-link:hover {
    text-decoration: underline;
}

.author-role {
    color: var(--text-secondary);
    font-style: italic;
}

/* TOC */
.toc {
    position: sticky;
    top: 32px;
    align-self: flex-start;
    float: inline-start;
    background-color: var(--bg);
    border-radius: 6px;
    padding: 12px;
    padding-right: 20px;
    font-size: 13px;
    width: fit-content;
    max-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 1200px) {
    .toc {
        position: static;
        max-width: 100%;
        width: 100%;
    }
}

.toc h2 {
    font-size: 1em;
    margin: 0 0 8px 0;
    padding: 0;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}

/* Hide/Show toggle */
.toc h2::after {
    content: "[hide]";
    font-size: 11px;
    font-weight: normal;
    color: var(--accent);
    margin-left: 8px;
}

.toc.collapsed h2::after {
    content: "[show]";
}

.toc.collapsed ul {
    display: none;
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc-counter;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.toc>ul>li {
    counter-increment: toc-counter;
    margin: 4px 0;
    line-height: 1.4;
}

.toc>ul>li::before {
    content: counter(toc-counter) ". ";
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 4px;
}

.toc>ul>li>ul {
    counter-reset: toc-sub-counter;
    padding-left: 16px;
    margin-top: 4px;
}

.toc>ul>li>ul>li {
    counter-increment: toc-sub-counter;
    margin: 2px 0;
}

.toc>ul>li>ul>li::before {
    content: counter(toc-counter) "." counter(toc-sub-counter) " ";
    color: var(--text-secondary);
    margin-right: 4px;
}

.toc a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.toc a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.toc a.active {
    color: var(--accent);
    font-weight: 600;
}

/* Breadcrumb navigation */
.breadcrumb {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Article Navigation (Next/Prev) */
.article-nav {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.back-link {
    color: var(--text-secondary);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
}

.back-link:hover {
    color: var(--accent);
}

/* Listing/Home */
.listing {
    max-width: 800px;
    margin: 0 auto;
}

.listing-header {
    margin-bottom: 24px;
}

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

.post-list li {
    display: flex;
    align-items: baseline;
    padding: 2px 0;
    border-bottom: 1px solid var(--border);
}

.post-list time {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 100px;
}

.post-list a {
    font-weight: 600;
    color: var(--accent);
}

.post-list a:hover {
    text-decoration: underline;
}

.listing-count {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.list-reading-time {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: auto;
}

.list-modified {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 12px;
}

/* Tags and Badges */
.modified-tag {
    display: inline-block;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    border: 1px solid var(--border);
    border-radius: 2em;
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    margin-left: 8px;
}

.new-tag {
    display: inline-block;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    border: 1px solid transparent;
    border-radius: 2em;
    background-color: #2da44e;
    color: #ffffff;
    margin-left: 8px;
}

.modified-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.separator {
    margin: 0 4px;
    color: var(--text-secondary);
}

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

/* Share Section */
.share-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.share-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}

.share-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    text-decoration: none;
}

.share-button:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-secondary);
    text-decoration: none;
}

.share-button svg {
    flex-shrink: 0;
}

.share-button.copy-link.copied {
    background-color: #2da44e;
    border-color: #2da44e;
    color: #ffffff;
}

/* Sponsor Block */
.sponsor-block {
    margin-top: 32px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Syntax Highlighting - GitHub Light */
.hljs {
    background: var(--code-bg);
    color: var(--text);
}

.hljs-comment,
.hljs-quote,
.hljs-meta {
    color: #6e7781;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
    color: #cf222e;
}

.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
    color: #0550ae;
}

.hljs-section,
.hljs-name {
    color: #0550ae;
    font-weight: bold;
}

.hljs-variable,
.hljs-template-variable {
    color: #953800;
}

.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-regexp,
.hljs-link {
    color: #0550ae;
}

.hljs-string {
    color: #0a3069;
}

.hljs-title,
.hljs-attr,
.hljs-selector-pseudo,
.hljs-number,
.hljs-inserted,
.hljs-addition {
    color: #116329;
}

.hljs-deletion {
    color: #82071e;
    background-color: #ffebe9;
}

/* Home profile adjustments */
.home {
    max-width: fit-content;
    margin: 0 auto;
    text-align: center;
}

.profile-wrap {
    width: 170px;
    height: 240px;
    overflow: hidden;
    border-radius: 14px;
    position: relative;
    margin: 0 auto;
    border: 1px solid var(--border);
}

.profile-img {
  
    width: 100%;
    height: auto;
    display: block;
}

.profile-name {
    font-size: 26px;
    line-height: 1;
    margin-bottom: 8px;
    color: var(--text);
}

.profile-title {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-weight: 300;
}


.sections ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sections li {
    border: 1px solid var(--border);
    padding: 7px;
    border-radius: 6px;
    background: #ffffff;
    transition: background-color 0.2s, border-color 0.2s;
    text-align: center;
}

.sections li:hover {
    background-color: var(--hover-bg);
    border-color: var(--accent);
}

.sections a {
    display: block;
    font-weight: 600;
    font-size: 16px;
    color: var(--accent);
}

.social-links {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.social-links a {
    color: var(--text-secondary);
    font-size: 14px;
}

.social-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}