/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root,
[data-theme="light"] {
    --text: #1a1a1a;
    --text-muted: #666;
    --bg: #fafafa;
    --bg-code: #f0f0f0;
    --bg-card: #fff;
    --border: #e2e2e2;
    --border-accent: #0055d4;
    --accent: #0055d4;
    --accent-hover: #003ea1;
    --tag-bg: #e8eef8;
    --tag-text: #3b5998;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --text: #e8e8e8;
    --text-muted: #999;
    --bg: #0d0d0d;
    --bg-code: #161616;
    --bg-card: #151515;
    --border: #272727;
    --border-accent: #6db3f2;
    --accent: #6db3f2;
    --accent-hover: #9dcbf7;
    --tag-bg: #1a2535;
    --tag-text: #8ab4e0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html {
    font-size: clamp(1.5rem, 1.8vw, 2rem);
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans",
        "Helvetica Neue", sans-serif;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: clamp(1.5rem, 4vw, 4rem) clamp(1.5rem, 5vw, 5rem);
}

/* === Header & Nav === */
header {
    margin-bottom: clamp(2rem, 4vw, 4rem);
    padding-bottom: 1.2rem;
    border-bottom: 2px solid var(--border-accent);
}

nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(0.8rem, 2vw, 2rem);
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    margin-right: auto;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(0.6rem, 1.5vw, 1.5rem);
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.15s;
}

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

.lang-switch,
.theme-switch {
    font-weight: 700;
    font-size: 0.75em;
    padding: 0.2em 0.55em;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    transition: all 0.15s;
    line-height: 1.2;
}

.lang-switch:hover,
.theme-switch:hover {
    background: var(--accent);
    color: #fff !important;
    border-color: var(--accent);
}

/* === Main === */
main {
    flex: 1;
}

/* === Headings === */
h1 {
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 0.8em;
}

h1::after {
    content: "";
    display: block;
    width: 2.5em;
    height: 3px;
    background: var(--border-accent);
    margin-top: 0.4em;
    border-radius: 2px;
}

/* === Post List === */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 2vw, 1.5rem);
}

.post-item {
    padding: clamp(1rem, 1.5vw, 1.5rem);
    background: var(--bg-card);
    border-radius: 6px;
    border-left: 3px solid var(--border-accent);
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 1rem;
}

.post-item time {
    color: var(--text-muted);
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 500;
}

.post-item > a {
    font-weight: 700;
    font-size: 1.05em;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
    transition: color 0.15s;
}

.post-item > a:hover {
    color: var(--accent);
}

.post-item .intro {
    flex-basis: 100%;
    color: var(--text-muted);
    font-size: 0.85em;
    line-height: 1.6;
    margin: 0.2em 0 0;
}

.post-item .intro p {
    margin: 0;
}

.post-item .summary {
    flex-basis: 100%;
    color: var(--text-muted);
    font-size: 0.85em;
    margin: 0.2em 0 0;
}

/* === Tags === */
.tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.tag {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--tag-text);
    padding: 0.1em 0.55em;
    border-radius: 4px;
    font-size: 0.78em;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: all 0.15s;
}

.tag:hover {
    background: var(--accent);
    color: #fff;
}

.tag-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.5rem;
}

.tag-list li {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.tag-count {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
}

/* === Article === */
article {
    max-width: none;
}

.post-header {
    margin-bottom: clamp(1.5rem, 3vw, 3rem);
}

.post-header h1 {
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    margin-bottom: 0.3em;
}

.post-meta {
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.85em;
    font-weight: 500;
}

.post-content h2,
.page-content h2 {
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 2em;
    margin-bottom: 0.6em;
}

.post-content h3,
.page-content h3 {
    font-size: clamp(1.05rem, 1.5vw, 1.4rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-top: 1.6em;
    margin-bottom: 0.5em;
}

.post-content p,
.page-content p {
    margin-bottom: 1.1em;
}

.post-content ul,
.post-content ol,
.page-content ul,
.page-content ol {
    margin-bottom: 1.1em;
    padding-left: 1.5em;
}

.post-content li,
.page-content li {
    margin-bottom: 0.3em;
}

.post-content a,
.page-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

.post-content a:hover,
.page-content a:hover {
    color: var(--accent-hover);
}

.post-content strong,
.page-content strong {
    font-weight: 700;
}

.post-content blockquote,
.page-content blockquote {
    border-left: 3px solid var(--border-accent);
    padding: 0.5em 1em;
    margin: 1em 0;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: 0 6px 6px 0;
}

.post-content hr,
.page-content hr {
    border: none;
    height: 2px;
    background: var(--border);
    margin: 2em 0;
    border-radius: 1px;
}

/* === Code === */
code {
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "SF Mono",
        Consolas, "Courier New", monospace;
    font-size: 0.85em;
    background: var(--bg-code);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

pre {
    overflow-x: auto;
    padding: clamp(1rem, 1.5vw, 1.5rem);
    margin-bottom: 1.2em;
    border-radius: 6px;
    line-height: 1.5;
}

.codehilite {
    background: var(--bg-code);
    border-radius: 6px;
    border-left: 3px solid var(--border-accent);
    overflow-x: auto;
    margin-bottom: 1.2em;
}

.codehilite pre {
    margin: 0;
    padding: clamp(1rem, 1.5vw, 1.5rem);
}

.codehilite code {
    background: none;
    padding: 0;
}

/* === Footer === */
footer {
    margin-top: clamp(3rem, 5vw, 5rem);
    padding-top: 1.2rem;
    border-top: 2px solid var(--border-accent);
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
}

/* === Pygments (light theme) === */
pre { line-height: 150%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.codehilite .hll { background-color: #ffffcc }
.codehilite .c { color: #3D7B7B; font-style: italic }
.codehilite .err { border: 1px solid #F00 }
.codehilite .k { color: #008000; font-weight: bold }
.codehilite .o { color: #666 }
.codehilite .ch { color: #3D7B7B; font-style: italic }
.codehilite .cm { color: #3D7B7B; font-style: italic }
.codehilite .cp { color: #9C6500 }
.codehilite .cpf { color: #3D7B7B; font-style: italic }
.codehilite .c1 { color: #3D7B7B; font-style: italic }
.codehilite .cs { color: #3D7B7B; font-style: italic }
.codehilite .gd { color: #A00000 }
.codehilite .ge { font-style: italic }
.codehilite .ges { font-weight: bold; font-style: italic }
.codehilite .gr { color: #E40000 }
.codehilite .gh { color: #000080; font-weight: bold }
.codehilite .gi { color: #008400 }
.codehilite .go { color: #717171 }
.codehilite .gp { color: #000080; font-weight: bold }
.codehilite .gs { font-weight: bold }
.codehilite .gu { color: #800080; font-weight: bold }
.codehilite .gt { color: #04D }
.codehilite .kc { color: #008000; font-weight: bold }
.codehilite .kd { color: #008000; font-weight: bold }
.codehilite .kn { color: #008000; font-weight: bold }
.codehilite .kp { color: #008000 }
.codehilite .kr { color: #008000; font-weight: bold }
.codehilite .kt { color: #B00040 }
.codehilite .m { color: #666 }
.codehilite .s { color: #BA2121 }
.codehilite .na { color: #687822 }
.codehilite .nb { color: #008000 }
.codehilite .nc { color: #00F; font-weight: bold }
.codehilite .no { color: #800 }
.codehilite .nd { color: #A2F }
.codehilite .ni { color: #717171; font-weight: bold }
.codehilite .ne { color: #CB3F38; font-weight: bold }
.codehilite .nf { color: #00F }
.codehilite .nl { color: #767600 }
.codehilite .nn { color: #00F; font-weight: bold }
.codehilite .nt { color: #008000; font-weight: bold }
.codehilite .nv { color: #19177C }
.codehilite .ow { color: #A2F; font-weight: bold }
.codehilite .w { color: #BBB }
.codehilite .mb { color: #666 }
.codehilite .mf { color: #666 }
.codehilite .mh { color: #666 }
.codehilite .mi { color: #666 }
.codehilite .mo { color: #666 }
.codehilite .sa { color: #BA2121 }
.codehilite .sb { color: #BA2121 }
.codehilite .sc { color: #BA2121 }
.codehilite .dl { color: #BA2121 }
.codehilite .sd { color: #BA2121; font-style: italic }
.codehilite .s2 { color: #BA2121 }
.codehilite .se { color: #AA5D1F; font-weight: bold }
.codehilite .sh { color: #BA2121 }
.codehilite .si { color: #A45A77; font-weight: bold }
.codehilite .sx { color: #008000 }
.codehilite .sr { color: #A45A77 }
.codehilite .s1 { color: #BA2121 }
.codehilite .ss { color: #19177C }
.codehilite .bp { color: #008000 }
.codehilite .fm { color: #00F }
.codehilite .vc { color: #19177C }
.codehilite .vg { color: #19177C }
.codehilite .vi { color: #19177C }
.codehilite .vm { color: #19177C }
.codehilite .il { color: #666 }

/* === Pygments (dark theme - Monokai-inspired) === */
[data-theme="dark"] .codehilite .hll { background-color: #49483e }
[data-theme="dark"] .codehilite .c { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .err { color: #f92672; border: none }
[data-theme="dark"] .codehilite .k { color: #66d9ef; font-weight: bold }
[data-theme="dark"] .codehilite .o { color: #f92672 }
[data-theme="dark"] .codehilite .ch { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .cm { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .cp { color: #75715e }
[data-theme="dark"] .codehilite .cpf { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .c1 { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .cs { color: #75715e; font-style: italic }
[data-theme="dark"] .codehilite .gd { color: #f92672 }
[data-theme="dark"] .codehilite .ge { font-style: italic }
[data-theme="dark"] .codehilite .ges { font-weight: bold; font-style: italic }
[data-theme="dark"] .codehilite .gr { color: #f92672 }
[data-theme="dark"] .codehilite .gh { color: #e6db74 }
[data-theme="dark"] .codehilite .gi { color: #a6e22e }
[data-theme="dark"] .codehilite .go { color: #75715e }
[data-theme="dark"] .codehilite .gp { color: #f92672; font-weight: bold }
[data-theme="dark"] .codehilite .gs { font-weight: bold }
[data-theme="dark"] .codehilite .gu { color: #75715e }
[data-theme="dark"] .codehilite .gt { color: #f92672 }
[data-theme="dark"] .codehilite .kc { color: #66d9ef }
[data-theme="dark"] .codehilite .kd { color: #66d9ef }
[data-theme="dark"] .codehilite .kn { color: #f92672 }
[data-theme="dark"] .codehilite .kp { color: #66d9ef }
[data-theme="dark"] .codehilite .kr { color: #66d9ef; font-weight: bold }
[data-theme="dark"] .codehilite .kt { color: #66d9ef }
[data-theme="dark"] .codehilite .m { color: #ae81ff }
[data-theme="dark"] .codehilite .s { color: #e6db74 }
[data-theme="dark"] .codehilite .na { color: #a6e22e }
[data-theme="dark"] .codehilite .nb { color: #f8f8f2 }
[data-theme="dark"] .codehilite .nc { color: #a6e22e; font-weight: bold }
[data-theme="dark"] .codehilite .no { color: #66d9ef }
[data-theme="dark"] .codehilite .nd { color: #a6e22e }
[data-theme="dark"] .codehilite .ni { color: #f8f8f2 }
[data-theme="dark"] .codehilite .ne { color: #a6e22e; font-weight: bold }
[data-theme="dark"] .codehilite .nf { color: #a6e22e }
[data-theme="dark"] .codehilite .nl { color: #f8f8f2 }
[data-theme="dark"] .codehilite .nn { color: #f8f8f2 }
[data-theme="dark"] .codehilite .nt { color: #f92672 }
[data-theme="dark"] .codehilite .nv { color: #f8f8f2 }
[data-theme="dark"] .codehilite .ow { color: #f92672 }
[data-theme="dark"] .codehilite .w { color: #f8f8f2 }
[data-theme="dark"] .codehilite .mb { color: #ae81ff }
[data-theme="dark"] .codehilite .mf { color: #ae81ff }
[data-theme="dark"] .codehilite .mh { color: #ae81ff }
[data-theme="dark"] .codehilite .mi { color: #ae81ff }
[data-theme="dark"] .codehilite .mo { color: #ae81ff }
[data-theme="dark"] .codehilite .sa { color: #e6db74 }
[data-theme="dark"] .codehilite .sb { color: #e6db74 }
[data-theme="dark"] .codehilite .sc { color: #e6db74 }
[data-theme="dark"] .codehilite .dl { color: #e6db74 }
[data-theme="dark"] .codehilite .sd { color: #e6db74; font-style: italic }
[data-theme="dark"] .codehilite .s2 { color: #e6db74 }
[data-theme="dark"] .codehilite .se { color: #ae81ff }
[data-theme="dark"] .codehilite .sh { color: #e6db74 }
[data-theme="dark"] .codehilite .si { color: #e6db74 }
[data-theme="dark"] .codehilite .sx { color: #e6db74 }
[data-theme="dark"] .codehilite .sr { color: #e6db74 }
[data-theme="dark"] .codehilite .s1 { color: #e6db74 }
[data-theme="dark"] .codehilite .ss { color: #e6db74 }
[data-theme="dark"] .codehilite .bp { color: #f8f8f2 }
[data-theme="dark"] .codehilite .fm { color: #a6e22e }
[data-theme="dark"] .codehilite .vc { color: #f8f8f2 }
[data-theme="dark"] .codehilite .vg { color: #f8f8f2 }
[data-theme="dark"] .codehilite .vi { color: #f8f8f2 }
[data-theme="dark"] .codehilite .vm { color: #f8f8f2 }
[data-theme="dark"] .codehilite .il { color: #ae81ff }
[data-theme="dark"] td.linenos .normal { color: #999 }
[data-theme="dark"] span.linenos { color: #999 }
[data-theme="dark"] td.linenos .special { color: #e0e0e0; background-color: #49483e }
[data-theme="dark"] span.linenos.special { color: #e0e0e0; background-color: #49483e }
