:root {
    --bg: #F5F4F0;
    --bg-elevated: #FEFDFB;
    --text-primary: #2B2B2A;
    --text-secondary: #555552;
    --text-tertiary: #6E6E6A;
    --accent: #4A6741;
    --accent-hover: #3A5233;
    --border: #DEDDD8;
    --focus-ring: #4A6741;

    --code-bg: #1E1E1E;
    --code-text: #D4D4D4;
    --code-comment: #6A9955;
    --code-keyword: #569CD6;
    --code-string: #CE9178;
    --code-function: #DCDCAA;
    --code-number: #B5CEA8;
    --code-type: #4EC9B0;
    --code-variable: #9CDCFE;
    --code-operator: #D4D4D4;
    --code-property: #9CDCFE;

    --theme-icon-light: none;
    --theme-icon-dark: block;

    /* Responsive embed sizing knobs */
    --embed-min-h: 420px;     /* never smaller than this (desktop) */
    --embed-ideal-h: 68vh;    /* “feels full” but still scroll-friendly */
    --embed-max-h: 860px;     /* avoid absurdly tall embeds on huge screens */
}

[data-theme="dark"] {
    --bg: #0A0F0C;
    --bg-elevated: #0F1612;
    --text-primary: #B8E0C8;
    --text-secondary: #8ABF9A;
    --text-tertiary: #5C8A6C;
    --accent: #5EEAD4;
    --accent-hover: #99F6E4;
    --border: #1A2A20;
    --focus-ring: #5EEAD4;

    --code-bg: #0D1117;

    --theme-icon-light: block;
    --theme-icon-dark: none;
}

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

.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--text-primary);
    color: var(--bg);
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 500;
    z-index: 1000;
    border-radius: 0 0 4px 4px;
}

.skip-link:focus {
    top: 0;
}

html {
    font-size: 18px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.75;
    letter-spacing: 0.01em;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 72px 24px;
}

.container-wide {
    max-width: none;
    padding: 72px 24px 24px 24px;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
    border-radius: 2px;
}

header {
    margin-bottom: 56px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border);
    position: relative;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.container-wide header {
    margin-bottom: 24px;
    padding-bottom: 24px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.identity {
    flex: 1;
}

.name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 2.2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.title {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cyrillic-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    color: var(--text-tertiary);
    font-size: 1rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.icon-sun {
    display: var(--theme-icon-light);
}

.icon-moon {
    display: var(--theme-icon-dark);
}

/* Hamburger button - hidden on desktop */
.hamburger-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
    align-items: center;
    justify-content: center;
}

.hamburger-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.hamburger-btn svg {
    width: 20px;
    height: 20px;
}

.hamburger-btn .icon-close {
    display: none;
}

.hamburger-btn.active .icon-hamburger {
    display: none;
}

.hamburger-btn.active .icon-close {
    display: block;
}

nav {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 28px;
}

nav a {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1.5px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

nav a:hover {
    color: var(--text-primary);
}

nav a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

section {
    margin-bottom: 48px;
}

h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
}

p {
    color: var(--text-secondary);
    margin-bottom: 14px;
}

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

.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.skill {
    font-size: 0.82rem;
    font-weight: 500;
    padding: 8px 14px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 3px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.contact-list {
    list-style: none;
}

.contact-list li {
    margin-bottom: 12px;
}

.contact-list a,
.content-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.contact-list a:hover,
.content-link:hover {
    color: var(--accent-hover);
    text-decoration-color: var(--accent);
}

.project {
    margin-bottom: 48px;
    padding-bottom: 48px;
    border-bottom: 1px solid var(--border);
}

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

.project h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.project-tech {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.code-block {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--code-bg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-lang {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #858585;
}

.code-actions {
    display: flex;
    gap: 8px;
}

.code-btn {
    background: none;
    border: none;
    color: #858585;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s, background 0.2s;
}

.code-btn:hover {
    color: #D4D4D4;
    background: rgba(255, 255, 255, 0.08);
}

.code-btn svg {
    width: 14px;
    height: 14px;
}

.code-content {
    padding: 20px;
    overflow-x: auto;
}

.code-content pre {
    margin: 0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--code-text);
}

.code-content code {
    font-family: inherit;
}

.hl-keyword { color: var(--code-keyword); }
.hl-string { color: var(--code-string); }
.hl-comment { color: var(--code-comment); font-style: italic; }
.hl-function { color: var(--code-function); }
.hl-number { color: var(--code-number); }
.hl-type { color: var(--code-type); }
.hl-variable { color: var(--code-variable); }
.hl-property { color: var(--code-property); }
.hl-operator { color: var(--code-operator); }
.hl-punctuation { color: #808080; }

/* ===========================
   Embed (responsive + correct)
   =========================== */

/* The wrapper must have a REAL height (not just min-height) so the iframe can be 100% */
.embed-wrapper {
    position: relative;
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;

    /* This is the fix: a definite, responsive height */
    height: clamp(var(--embed-min-h), var(--embed-ideal-h), var(--embed-max-h));
}

/* If you want the embed to “feel” less tall on very short viewports,
   you can also cap it to viewport height minus some breathing room: */
@supports (height: min(1px, 2px)) {
    .embed-wrapper {
        height: min(
            clamp(var(--embed-min-h), var(--embed-ideal-h), var(--embed-max-h)),
            calc(100vh - 220px)
        );
    }
}

.embed-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    gap: 8px;
}

.embed-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.embed-btn:hover {
    opacity: 1;
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.embed-btn svg {
    width: 16px;
    height: 16px;
}

/* Let the container simply fill the wrapper */
.embed-container {
    width: 100%;
    height: 100%;
}

/* Iframe fills container */
.app-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: transparent;
}

/* Fullscreen still wins */
.embed-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    border-radius: 0;
    border: none;
    height: 100vh;     /* definite */
    min-height: 100vh; /* keep */
}

.embed-wrapper.fullscreen .embed-container {
    height: 100%;
}

.embed-wrapper.fullscreen .embed-btn {
    opacity: 0.6;
}

.embed-wrapper.fullscreen .embed-btn:hover {
    opacity: 1;
}

footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

.container-wide footer {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.a11y-note {
    margin-top: 16px;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.a11y-note abbr {
    text-decoration: none;
    border-bottom: 1px dotted var(--text-tertiary);
    cursor: help;
}

[data-theme="dark"] .name {
    text-shadow: 0 0 30px rgba(184, 224, 200, 0.15);
}

[data-theme="dark"] .skill {
    border-color: #1A3D28;
}

[data-theme="dark"] nav {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Mobile styles */
@media (max-width: 600px) {
    html { font-size: 17px; }
    .container { padding: 48px 20px; }
    .container-wide { padding: 48px 16px 16px 16px; }
    .name { font-size: 1.8rem; }
    .code-content { padding: 16px; }
    .code-content pre { font-size: 0.75rem; }

    /* Embed sizing on mobile */
    :root {
        --embed-min-h: 360px;
        --embed-ideal-h: 62vh;
        --embed-max-h: 720px;
    }

    /* Show hamburger button on mobile */
    .hamburger-btn {
        display: flex;
    }

    /* Mobile nav styles */
    nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-top: 16px;
        padding: 12px 0;
        flex-direction: column;
        gap: 0;
        z-index: 100;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    }

    nav.open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    nav a {
        padding: 12px 20px;
        border-bottom: none;
        display: block;
    }

    nav a:hover {
        background: var(--bg-elevated);
    }

    nav a.active {
        background: var(--bg-elevated);
        border-bottom: none;
        position: relative;
    }

    nav a.active::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 20px;
        background: var(--accent);
        border-radius: 0 2px 2px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}