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

:root {
    --bg-color: #ffffff;
    --text-color: #2d2d2d;
    --text-secondary: #6b6b6b;
    --link-color: #2d2d2d;
    --link-hover-color: #000000;
    --border-color: #e5e5e5;
    --lang-btn-active: #2d2d2d;
    --lang-btn-active-text: #ffffff;
    --code-block-bg: var(--bg-color);
    --inline-code-bg: #f7f7f7;
    --code-text: var(--text-color);
    /* Muted "editor-like" syntax palette (light) */
    --code-keyword: #2f6f9f;
    --code-string: #2f7a5a;
    --code-number: #6b4ca6;
    --code-comment: #7a7a7a;
    --code-operator: #3b3b3b;
    --code-func: #6a5d00;
    --header-control-height: 32px;
}

body.dark {
    --bg-color: #0a0a0a;
    --text-color: #e5e5e5;
    --text-secondary: #a0a0a0;
    --link-color: #e5e5e5;
    --link-hover-color: #ffffff;
    --border-color: #2a2a2a;
    --lang-btn-active: #e5e5e5;
    --lang-btn-active-text: #0a0a0a;
    --code-block-bg: #0f0f0f;
    --inline-code-bg: #131313;
    --code-text: #e5e5e5;
    /* Muted "editor-like" syntax palette (dark, Cursor-ish) */
    /* slightly desaturated to avoid "neon" on dark background */
    --code-keyword: #7b96c7;
    --code-string: #88a96a;
    --code-number: #a38ad1;
    --code-comment: #5b647f;
    --code-operator: #7aa8bf;
    --code-func: #c19a69;
}

@media (prefers-color-scheme: dark) {
    body:not(.light):not(.dark) {
        --bg-color: #0a0a0a;
        --text-color: #e5e5e5;
        --text-secondary: #a0a0a0;
        --link-color: #e5e5e5;
        --link-hover-color: #ffffff;
        --border-color: #2a2a2a;
        --lang-btn-active: #e5e5e5;
        --lang-btn-active-text: #0a0a0a;
        --code-block-bg: #0f0f0f;
        --inline-code-bg: #131313;
        --code-text: #e5e5e5;
        --code-keyword: #7b96c7;
        --code-string: #88a96a;
        --code-number: #a38ad1;
        --code-comment: #5b647f;
        --code-operator: #7aa8bf;
        --code-func: #c19a69;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 700px;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text-color);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-btn {
    width: var(--header-control-height);
    height: var(--header-control-height);
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    color: var(--text-color);
    border-color: var(--text-color);
}

.theme-icon {
    display: block;
    line-height: 1;
}

.lang-switcher {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    height: var(--header-control-height);
}

.lang-btn {
    height: 100%;
    padding: 0 0.9rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1;
    border-right: 1px solid var(--border-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:last-child {
    border-right: none;
}

.lang-btn:hover {
    color: var(--text-color);
    background-color: transparent;
}

.lang-btn.active {
    background-color: var(--lang-btn-active);
    color: var(--lang-btn-active-text);
    border-color: var(--lang-btn-active);
}

.lang-btn.active:hover {
    color: var(--lang-btn-active-text);
}

.content-section {
    animation: fadeIn 0.2s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.bio {
    margin-bottom: 4rem;
}

.bio p {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    color: var(--text-color);
    line-height: 1.8;
    font-weight: 400;
}

.bio p:last-child {
    margin-bottom: 0;
}

.links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.link-card {
    display: block;
    padding: 1.75rem 0;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.link-card:last-child {
    border-bottom: none;
}

.link-card:hover {
    opacity: 0.7;
    color: var(--link-hover-color);
}

.link-card h3 {
    font-size: 0.95rem;
    font-weight: 400;
    margin-bottom: 0.4rem;
    color: inherit;
    letter-spacing: -0.01em;
    transition: color 0.3s ease;
}

.link-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 400;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.link-card:hover p {
    opacity: 0.8;
}

.articles-section {
    margin-top: 4rem;
    padding-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.articles-section h2 {
    font-size: 0.875rem;
    font-weight: 400;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.articles {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.article-card {
    display: block;
    padding: 1.75rem 0;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.article-card:last-child {
    border-bottom: none;
}

.article-card:hover {
    opacity: 0.7;
    color: var(--link-hover-color);
}

.article-card h3 {
    font-size: 0.95rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    color: inherit;
    letter-spacing: -0.01em;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.article-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-weight: 400;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.article-card:hover p {
    opacity: 0.8;
}

.article-source {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

@media (max-width: 600px) {
    body {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 3rem;
        gap: 1rem;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .bio {
        margin-bottom: 3rem;
    }

    .bio p {
        font-size: 0.95rem;
    }

    .links {
        grid-template-columns: 1fr;
    }

    .articles-section {
        margin-top: 3rem;
        padding-top: 3rem;
    }
}

/* Post/Article page styles */
.post {
    animation: fadeIn 0.2s ease;
}

.post-header {
    margin-bottom: 3rem;
}

.post-title {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text-color);
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-meta span:not(:last-child)::after {
    content: '';
}

.video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    margin-bottom: 3rem;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-color);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.post-content {
    line-height: 1.8;
}

.post-intro {
    margin-bottom: 3rem;
}

.post-intro p {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 1.25rem;
}

.post-intro p:last-child {
    margin-bottom: 0;
}

.post-body {
    margin-top: 3rem;
}

.post-body h2 {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-color);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.post-body h3 {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-color);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.post-body p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 1.25rem;
}

.post-body ul,
.post-body ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.post-body li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.post-body a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.post-body a:hover {
    opacity: 0.7;
    color: var(--link-hover-color);
}

.post-body blockquote {
    margin: 1.5rem 0;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.post-body blockquote p {
    margin-bottom: 0.75rem;
}

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

.post-body pre {
    margin: 1.5rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--code-block-bg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    tab-size: 4;
}

.post-body .highlight {
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--code-block-bg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.post-body .highlight pre {
    margin: 0;
    padding: 0.9rem 1rem;
    border: none;
    border-radius: 0;
    background: transparent !important; /* перебить inline chroma background */
    color: var(--code-text) !important; /* перебить inline chroma base color */
    overflow: visible;
    tab-size: 4;
}

.post-body .highlight code {
    background: transparent !important;
}

.post-body .highlight code,
.post-body .highlight pre code {
    color: var(--code-text) !important;
}

/* Chroma uses inline colors; remap them to a muted editor-like palette */
.post-body .highlight [style*="color:#66d9ef"] { color: var(--code-keyword) !important; } /* keywords (monokai cyan) */
.post-body .highlight [style*="color:#ae81ff"] { color: var(--code-number) !important; } /* numbers (monokai purple) */
.post-body .highlight [style*="color:#e6db74"] { color: var(--code-string) !important; } /* strings (monokai yellow) */
.post-body .highlight [style*="color:#75715e"] { color: var(--code-comment) !important; } /* comments (monokai gray) */
.post-body .highlight [style*="color:#f92672"] { color: var(--code-operator) !important; } /* operators (monokai pink) */
.post-body .highlight [style*="color:#fd971f"] { color: var(--code-func) !important; } /* functions/types (monokai orange) */
.post-body .highlight [style*="color:#a6e22e"] { color: var(--code-string) !important; } /* identifiers (monokai green) */

.post-body pre code {
    display: block;
    padding: 0;
    background: transparent;
    border-radius: 0;
    color: var(--code-text);
    font-size: 0.85rem;
    line-height: 1.55;
}

.post-body :not(pre) > code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    background: var(--inline-code-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

.post-body strong {
    font-weight: 500;
    color: var(--text-color);
}

.raw-transcript-section {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
}

.raw-transcript-section .raw-transcript-details {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.raw-transcript {
    white-space: pre-wrap;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.transcript-section {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
}

.transcript-section h2 {
    font-size: 0.875rem;
    font-weight: 400;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#transcript-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-color);
}

#transcript-content p {
    margin-bottom: 1.25rem;
}

#transcript-content p:last-child {
    margin-bottom: 0;
}

.raw-transcript-details {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.raw-transcript-details summary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.raw-transcript-details summary:hover {
    color: var(--text-color);
}

.raw-transcript-details pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow-x: auto;
}

.post-footer {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
}

.back-link {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

@media (max-width: 600px) {
    .post-title {
        font-size: 1.5rem;
    }

    .post-header {
        margin-bottom: 2rem;
    }

    .video-embed {
        margin-bottom: 2rem;
    }

    .post-intro {
        margin-bottom: 2rem;
    }

    .transcript-section {
        margin-top: 3rem;
        padding-top: 2rem;
    }

    .post-footer {
        margin-top: 3rem;
        padding-top: 2rem;
    }
}
