:root {
    --ink: #111827;
    --ink-light: #374151;
    --muted: #6b7280;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-light: #eef2ff;
    --paper: #ffffff;
    --bg: #f8fafc;
    --border: #e2e8f0;
    --code-bg: #f8fafc;
    --code-ink: #1e293b;
    --code-border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 19px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== Navigation ===== */
.top-nav {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: var(--ink);
    text-decoration: none;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 24px;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--brand);
}

/* ===== Content Wrapper ===== */
.content-wrapper {
    max-width: 85%;
    margin: 56px auto 100px;
    padding: 0 24px;
}

/* ===== Article Card ===== */
.markdown-content {
    background: var(--paper);
    padding: 56px 64px 64px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.1);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    margin-bottom: 20px;
}

.breadcrumb a {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--brand-dark);
}

/* ===== Article Header ===== */
.article-header {
    margin-bottom: 2.5em;
    padding-bottom: 2em;
    border-bottom: 1px solid var(--border);
}

.article-title {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--ink);
    margin: 0 0 0.5em 0;
    letter-spacing: -0.03em;
}

.article-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    border-radius: 2px;
    margin-top: 20px;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}

.meta-item {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Article Body ===== */
.article-body {
    font-size: inherit;
}

.article-body > *:first-child {
    margin-top: 0;
}

.article-body > p:first-of-type {
    font-size: 1.2em;
    color: var(--ink);
    line-height: 1.7;
}

/* ===== Article Footer ===== */
.article-footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.share-prompt {
    background: linear-gradient(135deg, var(--brand-light), #f8fafc);
    padding: 24px 28px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.share-prompt p {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}

.share-prompt a {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    color: var(--paper);
    background: var(--brand);
    padding: 10px 20px;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
}

.share-prompt a:hover {
    background: var(--brand-dark);
    transform: translateY(-2px);
}

.back-link {
    display: inline-block;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
}

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

/* ===== Typography ===== */
.markdown-content h1,
.article-body h1,
.markdown-content h2,
.article-body h2,
.markdown-content h3,
.article-body h3,
.markdown-content h4,
.article-body h4,
.markdown-content h5,
.article-body h5,
.markdown-content h6,
.article-body h6 {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--ink);
    line-height: 1.25;
    margin-top: 2em;
    margin-bottom: 0.6em;
    letter-spacing: -0.02em;
}

.markdown-content h1,
.article-body h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 0.8em;
    line-height: 1.15;
}

.markdown-content h1::after,
.article-body h1::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    border-radius: 2px;
    margin-top: 16px;
}

.markdown-content h2,
.article-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
    padding-top: 0.5em;
    border-top: 1px solid var(--border);
}

.markdown-content h3,
.article-body h3 {
    font-size: 1.35rem;
    font-weight: 600;
}

.markdown-content h4,
.article-body h4 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink-light);
}

.markdown-content p,
.article-body p {
    margin-bottom: 1.4em;
    color: var(--ink-light);
}

.markdown-content > p:first-of-type,
.article-body > p:first-of-type {
    font-size: 1.15em;
    color: var(--ink);
}

/* ===== Links ===== */
.markdown-content a,
.article-body a {
    color: var(--brand);
    text-decoration: none;
    background-image: linear-gradient(var(--brand), var(--brand));
    background-size: 0% 2px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.25s ease-out;
}

.markdown-content a:hover,
.article-body a:hover {
    color: var(--brand-dark);
    background-size: 100% 2px;
}

/* ===== Lists ===== */
.markdown-content ul,
.markdown-content ol,
.article-body ul,
.article-body ol {
    padding-left: 1.5em;
    margin-bottom: 1.4em;
}

.markdown-content ul,
.article-body ul {
    list-style: none;
}

.markdown-content ul li,
.article-body ul li {
    position: relative;
    padding-left: 0.2em;
}

.markdown-content ul li::before,
.article-body ul li::before {
    content: '';
    position: absolute;
    left: -1.3em;
    top: 0.65em;
    width: 6px;
    height: 6px;
    background: var(--brand);
    border-radius: 50%;
}

.markdown-content ol li,
.article-body ol li {
    padding-left: 0.3em;
}

.markdown-content li,
.article-body li {
    margin-bottom: 0.6em;
    color: var(--ink-light);
}

.markdown-content li p,
.article-body li p {
    margin-bottom: 0.4em;
}

/* ===== Code ===== */
.markdown-content code,
.article-body code {
    background: var(--brand-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
    color: var(--brand-dark);
    font-weight: 500;
}

.markdown-content pre,
.article-body pre {
    background: var(--code-bg);
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--code-border);
    overflow-x: auto;
    margin: 0.8em 0;
    line-height: 1.45;
}

.markdown-content pre code,
.article-body pre code {
    background: transparent;
    color: var(--code-ink);
    padding: 0;
    font-size: 0.92em;
    font-weight: 400;
}

/* ===== Syntax Highlighting (Light Theme - GitHub-style) ===== */
.highlight { background: var(--code-bg); }
.highlight .c { color: #6a737d; font-style: italic; } /* Comment */
.highlight .err { color: #cb2431; } /* Error */
.highlight .k { color: #d73a49; } /* Keyword */
.highlight .l { color: #005cc5; } /* Literal */
.highlight .n { color: #24292e; } /* Name */
.highlight .o { color: #d73a49; } /* Operator */
.highlight .p { color: #24292e; } /* Punctuation */
.highlight .ch { color: #6a737d; font-style: italic; } /* Comment.Hashbang */
.highlight .cm { color: #6a737d; font-style: italic; } /* Comment.Multiline */
.highlight .cp { color: #6a737d; } /* Comment.Preproc */
.highlight .cpf { color: #6a737d; font-style: italic; } /* Comment.PreprocFile */
.highlight .c1 { color: #6a737d; font-style: italic; } /* Comment.Single */
.highlight .cs { color: #6a737d; font-style: italic; } /* Comment.Special */
.highlight .kc { color: #005cc5; } /* Keyword.Constant */
.highlight .kd { color: #d73a49; } /* Keyword.Declaration */
.highlight .kn { color: #d73a49; } /* Keyword.Namespace */
.highlight .kp { color: #d73a49; } /* Keyword.Pseudo */
.highlight .kr { color: #d73a49; } /* Keyword.Reserved */
.highlight .kt { color: #6f42c1; } /* Keyword.Type */
.highlight .ld { color: #032f62; } /* Literal.Date */
.highlight .m { color: #005cc5; } /* Literal.Number */
.highlight .s { color: #032f62; } /* Literal.String */
.highlight .na { color: #6f42c1; } /* Name.Attribute */
.highlight .nb { color: #005cc5; } /* Name.Builtin */
.highlight .nc { color: #6f42c1; } /* Name.Class */
.highlight .no { color: #005cc5; } /* Name.Constant */
.highlight .nd { color: #6f42c1; } /* Name.Decorator */
.highlight .ni { color: #24292e; } /* Name.Entity */
.highlight .ne { color: #6f42c1; } /* Name.Exception */
.highlight .nf { color: #6f42c1; } /* Name.Function */
.highlight .nl { color: #24292e; } /* Name.Label */
.highlight .nn { color: #24292e; } /* Name.Namespace */
.highlight .nx { color: #6f42c1; } /* Name.Other */
.highlight .py { color: #005cc5; } /* Name.Property */
.highlight .nt { color: #22863a; } /* Name.Tag */
.highlight .nv { color: #e36209; } /* Name.Variable */
.highlight .ow { color: #d73a49; } /* Operator.Word */
.highlight .w { color: #24292e; } /* Text.Whitespace */
.highlight .mb { color: #005cc5; } /* Literal.Number.Bin */
.highlight .mf { color: #005cc5; } /* Literal.Number.Float */
.highlight .mh { color: #005cc5; } /* Literal.Number.Hex */
.highlight .mi { color: #005cc5; } /* Literal.Number.Integer */
.highlight .mo { color: #005cc5; } /* Literal.Number.Oct */
.highlight .sa { color: #032f62; } /* Literal.String.Affix */
.highlight .sb { color: #032f62; } /* Literal.String.Backtick */
.highlight .sc { color: #032f62; } /* Literal.String.Char */
.highlight .dl { color: #032f62; } /* Literal.String.Delimiter */
.highlight .sd { color: #032f62; } /* Literal.String.Doc */
.highlight .s2 { color: #032f62; } /* Literal.String.Double */
.highlight .se { color: #005cc5; } /* Literal.String.Escape */
.highlight .sh { color: #032f62; } /* Literal.String.Heredoc */
.highlight .si { color: #005cc5; } /* Literal.String.Interpol */
.highlight .sx { color: #032f62; } /* Literal.String.Other */
.highlight .sr { color: #032f62; } /* Literal.String.Regex */
.highlight .s1 { color: #032f62; } /* Literal.String.Single */
.highlight .ss { color: #005cc5; } /* Literal.String.Symbol */
.highlight .bp { color: #005cc5; } /* Name.Builtin.Pseudo */
.highlight .fm { color: #6f42c1; } /* Name.Function.Magic */
.highlight .vc { color: #e36209; } /* Name.Variable.Class */
.highlight .vg { color: #e36209; } /* Name.Variable.Global */
.highlight .vi { color: #e36209; } /* Name.Variable.Instance */
.highlight .vm { color: #e36209; } /* Name.Variable.Magic */
.highlight .il { color: #005cc5; } /* Literal.Number.Integer.Long */

/* JSON specific highlighting */
.highlight .language-json .k { color: #005cc5; } /* JSON keys */
.highlight .language-json .s2 { color: #032f62; } /* JSON strings */
.highlight .language-json .mi { color: #005cc5; } /* JSON numbers */
.highlight .language-json .kc { color: #d73a49; } /* JSON booleans/null */

/* ===== Mermaid Diagrams ===== */
.mermaid {
    display: flex;
    justify-content: center;
    margin: 2em 0;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ===== Blockquote ===== */
.markdown-content blockquote,
.article-body blockquote {
    border-left: 4px solid var(--brand);
    padding: 1em 1.5em;
    margin: 1.8em 0;
    background: linear-gradient(135deg, var(--brand-light), #f8fafc);
    border-radius: 0 12px 12px 0;
    color: var(--ink-light);
    font-style: italic;
}

.markdown-content blockquote p:last-child,
.article-body blockquote p:last-child {
    margin-bottom: 0;
}

/* ===== Images ===== */
.markdown-content img,
.article-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em auto;
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.markdown-content img + em,
.markdown-content figure figcaption,
.article-body img + em,
.article-body figure figcaption {
    display: block;
    text-align: center;
    font-size: 0.9em;
    color: var(--muted);
    margin-top: -1em;
    margin-bottom: 1.5em;
}

/* ===== Tables ===== */
.markdown-content table,
.article-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.8em 0;
    font-size: 0.95em;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.markdown-content th,
.markdown-content td,
.article-body th,
.article-body td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.markdown-content th,
.article-body th {
    background: var(--brand);
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.markdown-content tr:last-child td,
.article-body tr:last-child td {
    border-bottom: none;
}

.markdown-content tr:nth-child(even),
.article-body tr:nth-child(even) {
    background: #f8fafc;
}

.markdown-content tr:hover,
.article-body tr:hover {
    background: var(--brand-light);
}

/* ===== Horizontal Rule ===== */
.markdown-content hr,
.article-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 3em 0;
}

/* ===== Definition Lists ===== */
.markdown-content dl,
.article-body dl {
    margin: 1.5em 0;
}

.markdown-content dt,
.article-body dt {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    color: var(--ink);
    margin-top: 1em;
}

.markdown-content dd,
.article-body dd {
    margin-left: 1.5em;
    color: var(--ink-light);
}

/* ===== Task Lists ===== */
.markdown-content ul.task-list,
.markdown-content ul:has(input[type="checkbox"]),
.article-body ul.task-list,
.article-body ul:has(input[type="checkbox"]) {
    list-style: none;
    padding-left: 0;
}

.markdown-content ul.task-list li::before,
.markdown-content ul:has(input[type="checkbox"]) li::before,
.article-body ul.task-list li::before,
.article-body ul:has(input[type="checkbox"]) li::before {
    display: none;
}

.markdown-content input[type="checkbox"],
.article-body input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    margin-right: 10px;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
}

.markdown-content input[type="checkbox"]:checked,
.article-body input[type="checkbox"]:checked {
    background: var(--brand);
    border-color: var(--brand);
}

.markdown-content input[type="checkbox"]:checked::after,
.article-body input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: #fff;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ===== Alerts / Admonitions ===== */
.markdown-content .note,
.markdown-content .tip,
.markdown-content .warning,
.markdown-content .info,
.article-body .note,
.article-body .tip,
.article-body .warning,
.article-body .info {
    padding: 1em 1.25em;
    border-radius: 12px;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.markdown-content .note,
.article-body .note {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
}

.markdown-content .tip,
.article-body .tip {
    background: #d1fae5;
    border-left: 4px solid var(--success);
}

.markdown-content .warning,
.article-body .warning {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}

.markdown-content .info,
.article-body .info {
    background: #dbeafe;
    border-left: 4px solid var(--info);
}

/* ===== Keyboard Keys ===== */
.markdown-content kbd,
.article-body kbd {
    display: inline-block;
    padding: 4px 8px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85em;
    color: var(--ink);
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 2px 0 var(--border);
}

/* ===== Abbr ===== */
.markdown-content abbr[title],
.article-body abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 40px 24px 56px;
    color: var(--muted);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
}

.site-footer p {
    margin-bottom: 8px;
}

.site-footer a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ===== Reading Progress ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    z-index: 1001;
    transition: width 0.1s;
}

/* ===== Copy Button ===== */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.markdown-content pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
}

/* ===== Responsive ===== */
/* Large screens */
@media (min-width: 1400px) {
    .content-wrapper {
        max-width: 75%;
    }
    
    .nav-container {
        max-width: 1300px;
    }
}

/* Tablet landscape */
@media (max-width: 1024px) {
    .content-wrapper {
        max-width: 90%;
        padding: 0 20px;
    }
    
    .markdown-content {
        padding: 40px 32px 48px;
    }
}

/* Tablet portrait */
@media (max-width: 900px) {
    .content-wrapper {
        margin: 40px auto 80px;
    }
    
    .markdown-content {
        padding: 32px 24px 40px;
    }
    
    .markdown-content h1 {
        font-size: 2.2rem;
    }
    
    .markdown-content h2 {
        font-size: 1.8rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    body {
        font-size: 17px;
    }

    .content-wrapper {
        max-width: 95%;
        margin: 32px auto 60px;
        padding: 0 16px;
    }

    .markdown-content {
        padding: 24px 20px 32px;
        font-size: 17px;
        border-radius: 16px;
    }

    .markdown-content h1 {
        font-size: 1.9rem;
        line-height: 1.2;
    }
    
    .markdown-content h2 {
        font-size: 1.6rem;
    }
    
    .markdown-content h3 {
        font-size: 1.4rem;
    }

    .nav-container {
        flex-direction: column;
        gap: 10px;
        padding: 0 16px;
    }

    .nav-links a {
        margin-left: 12px;
    }
    
    /* Code blocks mobile optimization */
    .markdown-content pre,
    .article-body pre {
        padding: 8px 12px;
        border-radius: 4px;
        font-size: 0.82rem;
        overflow-x: auto;
    }
    
    .markdown-content code,
    .article-body code {
        font-size: 0.82rem;
        padding: 1px 4px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 0 12px;
    }
    
    .markdown-content {
        padding: 20px 16px 28px;
    }
    
    .markdown-content h1 {
        font-size: 1.7rem;
    }
    
    .breadcrumb {
        margin-bottom: 16px;
    }
    
    .breadcrumb a {
        font-size: 0.9rem;
    }
}
