/*
 * GLOBAL DESIGN SYSTEM
 * Centralized styles for mb-2025
 */

/* VIEW TRANSITIONS API - Cross-document page transitions */
@view-transition {
    navigation: auto;
}

/* Custom view transition animations - simple fade */
::view-transition-old(root) {
    animation: vt-fade-out 0.3s ease-out forwards;
}

::view-transition-new(root) {
    animation: vt-fade-in 0.3s ease-out forwards;
}

@keyframes vt-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes vt-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Hide content during initial translation load for non-English users */
html.translation-loading .content-wrapper {
    opacity: 0 !important;
    transition: opacity 0.3s ease-out;
}

/* 1. FONTS - Primary (English/Latin) */
@font-face {
    font-family: 'Axis Std';
    src: local('Axis Std Light'),
         url('/fonts/AxisStd-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Andale Mono';
    src: local('Andale Mono'),
         url('/fonts/AndaleMono.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Fira Code';
    src: url('/fonts/FiraCode-Light.woff2') format('woff2'),
         url('/fonts/FiraCode-Light.woff') format('woff');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* 1b. FONTS - International (lazy loaded on language menu open) */
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/IBMPlexMono-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/IBMPlexSans-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/IBMPlexSans-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* 2. VARIABLES */
:root {
    --font-body: 'Axis Std', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Andale Mono', 'IBM Plex Mono', ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
    --font-fira: 'Fira Code', monospace;
    --text-primary: #F2F2F2;
    --text-body: #BEBEBE;
    --text-secondary: #888888;
    --text-muted: #767676;
    --text-inactive: #555555;
    --bg-color: #000000;
    --border-color: #333333;
    --transition-base: 0.3s ease;
    --container-padding: 2rem;
}

@media (max-width: 768px) {
    :root {
        --container-padding: 1.5rem;
    }
}

/* 3. CORE RESET & BASE STYLES */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: calc(var(--vh, 1vh) * 100);
}

img, video, canvas, svg, iframe {
    max-width: 100%;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Fallback for languages with extended character requirements */
body.font-fallback h1,
body.font-fallback .breadcrumb-demo,
body.font-fallback .language-search,
body.font-fallback .button-meta,
body.font-fallback .menu-item,
body.font-fallback .btn-cancel,
body.font-fallback .btn-send,
body.font-fallback .toast-title,
body.font-fallback .checkpoint-content p,
body.font-fallback .checkpoint-button,
body.font-fallback .modal-title,
body.font-fallback .breadcrumb-link,
body.font-fallback .breadcrumb-current,
body.font-fallback .skip-link,
body.font-fallback .contact-links,
body.font-fallback #contact-form input,
body.font-fallback #contact-form textarea,
body.font-fallback #generate-audio-button,
body.font-fallback #pre-translate-button,
body.font-fallback .content-changed::after,
body.font-fallback .ds-header-title,
body.font-fallback .ds-section-title,
body.font-fallback .ds-label,
body.font-fallback .hamburger-label,
body.font-fallback .attractor-title,
body.font-fallback .viz-anatomy-label-title,
body.font-fallback .talk p,
body.font-fallback .container h1 {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body.font-fallback h2,
body.font-fallback h3,
body.font-fallback h4,
body.font-fallback p,
body.font-fallback .button-text,
body.font-fallback .footer-text {
    font-family: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 300;
}

::selection {
    background: white;
    color: black;
}

/* 4. TYPOGRAPHY */
h1 {
    font-family: 'Andale Mono', monospace;
    font-variant: small-caps;
    font-size: 2rem;
    line-height: 1.4;
    word-spacing: -0.4em;
    text-transform: lowercase;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

h2 {
    font-family: 'Axis Std', sans-serif;
    font-size: 1.5rem;
    font-weight: 300;
    line-height: 1.6;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

h3 {
    font-family: 'Axis Std', sans-serif;
    font-size: 1.2rem;
    font-weight: 300;
    line-height: 1.4;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    color: #C0C0C0;
}

h4 {
    font-family: 'Axis Std', sans-serif;
    font-size: 0.9rem;
    font-weight: 300;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

p {
    font-family: 'Axis Std', sans-serif;
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    letter-spacing: 0.01em;
    color: var(--text-body);
    max-width: 70ch;
}

p strong {
    color: var(--text-primary);
}

a {
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    display: inline-block;
    transition: color var(--transition-base);
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

a::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: white;
    transition: height 0.2s, bottom 0.2s;
    z-index: -1;
}

@media (hover: hover) {
    a:hover {
        color: black;
    }
    
    a:hover::after {
        height: 100%;
        bottom: 0;
        background-color: white;
    }
}

/* Breadcrumb / Subpage Header */
.breadcrumb-header {
    width: 100%;
    margin-bottom: 1rem;
    padding-top: 2rem;
}

@media (max-width: 768px) {
    .breadcrumb-header {
        padding-top: 0;
    }
}

.breadcrumb-header h1 {
    max-width: 38rem;
    margin: 0 auto 1rem auto;
    padding: 0 var(--container-padding);
    font-size: 0.9rem;
    word-spacing: -0.4em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .breadcrumb-header h1 {
        font-size: 0.85rem;
    }
}

/* Constrain header media on desktop, full bleed on mobile via media query */
.breadcrumb-header .header-media-wrapper {
    max-width: 38rem;
    margin: 0 auto;
}

.breadcrumb-header .image-caption {
    max-width: 38rem;
    margin: 1rem auto 2.5rem auto;
}

.breadcrumb-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 0 0.2em;
    display: inline-block;
    flex-shrink: 0;
}

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

.breadcrumb-link::after {
    display: none !important;
}

.breadcrumb-current {
    flex-shrink: 0;
}

.breadcrumb-slash {
    margin-right: 0.25em;
}

#back-button {
    position: relative;
    margin-right: 0.25rem;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

#back-button svg {
    transform: translateY(1px);
}

#back-button::before {
    content: 'Home';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.85rem;
    padding: 0.35rem 0.65rem;
    background-color: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    font-family: 'Axis Std', sans-serif;
    font-size: 0.75rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 20;
}

#back-button::after {
    content: '';
    position: absolute;
    top: -0.85rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #444;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 21;
}

@media (hover: hover) {
    #back-button:hover::before,
    #back-button:hover::after {
        opacity: 1;
        visibility: visible;
    }
}

#back-button:focus-visible::before,
#back-button:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

ul, ol {
    font-family: 'Axis Std', sans-serif;
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    color: var(--text-body);
}

li {
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

blockquote {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 6px 6px 0;
}

blockquote p {
    margin: 0;
    color: var(--text-body);
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 3rem 0;
}

#header-container {
    transition: opacity 0.3s ease-out;
}

/* 5. LAYOUT COMPONENTS */
.content-wrapper {
    position: relative;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
}

.content-wrapper.visible { 
    opacity: 1; 
}

.container, .content-section {
    max-width: 38rem;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.content-section {
    margin-bottom: 2rem;
}

/* Full-bleed elements (inside a container) */
.full-bleed {
    position: relative;
    width: calc(100% + (2 * var(--container-padding)));
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    border-radius: 0;
    overflow: hidden;
}

/* Header media (outside container) */
.header-media-wrapper {
    position: relative;
    width: 100%;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
}

.header-image,
.header-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
    transition: opacity 0.5s ease-in-out;
}

.header-image.placeholder {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 1;
    z-index: 1;
}

.header-video {
    position: relative;
    opacity: 0;
    z-index: 2;
}

.header-video.loaded {
    opacity: 1;
}

.header-image.placeholder.fade-out {
    opacity: 0;
}

.image-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin: 1rem 0 2.5rem 0;
    font-style: italic;
}

.embed-container {
    position: relative;
    width: min(80vw, 768px);
    max-width: 768px;
    aspect-ratio: 16/9;
    margin: 4rem auto;
    background: #000;
    overflow: hidden;
}

/* Full-width embed inside header media wrapper */
.header-media-wrapper .embed-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-bottom: 56.25%;
    height: 0;
    aspect-ratio: unset;
}

/* 6. AUDIO & NARRATION */
#listen-container {
    margin-top: 0;
    margin-bottom: 0;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}

/* Show container when language has narration support */
html.lang-narration #listen-container {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    opacity: 1;
    max-height: 200px; /* Generous max to accommodate button */
}

/* Reduce first heading margin when narration container is hidden */
html:not(.lang-narration) #listen-container + h2 {
    margin-top: 1.5rem;
}

/* Listen button styles */
.listen-button {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: transparent;
    color: white;
    border: none;
    padding: 0;
    transition: all 0.3s ease;
    font-family: 'Axis Std', sans-serif;
    font-size: 0.8rem;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.listen-button:hover .button-icon-container {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.button-icon-container {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.button-meta {
    display: flex;
    align-items: center;
    color: rgba(242, 242, 242, 0.7);
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.button-meta:not(:empty) {
    opacity: 1;
}

.button-meta::before {
    content: '•';
    margin-right: 0.5rem;
    color: rgba(255, 255, 255, 0.4);
}

.button-text-wrapper {
    display: flex;
    align-items: center;
}

.button-text-wrapper .button-text {
    display: inline;
    color: var(--text-primary);
}

.button-text-wrapper .shortcut-text {
    color: rgba(242, 242, 242, 0.7);
}

.button-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-icon svg {
    position: absolute;
    width: 100%;
    height: 100%;
    display: none;
}

.button-icon .play-svg { display: block; }
.is-playing .button-icon .play-svg { display: none; }
.is-playing .button-icon .pause-svg { display: block; }

.fixed-audio-button {
    background: black;
    color: white;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    line-height: 1;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.fixed-audio-button:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.fixed-audio-button .button-icon {
    width: 14px;
    height: 14px;
}

/* Wrapper for fixed-bottom controls on iOS Safari */
.ios-bottom-anchor {
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    height: 100dvh;
    height: -webkit-fill-available;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    pointer-events: none;
    z-index: 48;
}

@media (max-width: 768px) {
    .ios-bottom-anchor {
        padding: 0.25rem;
    }
}

.ios-bottom-anchor > * {
    pointer-events: auto;
}

#fixed-audio-controls {
    z-index: 48;
}

#fixed-audio-controls.initial-state {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#fixed-audio-controls.hidden { display: none; }

/* Narration Highlighting */
body.is-playing [data-narration] {
    color: var(--text-inactive);
    transition: color 0.3s ease, border-color 0.3s ease, filter 0.3s ease;
}

body.is-playing [data-narration] strong,
body.is-playing [data-narration] b {
    color: var(--text-inactive);
    transition: color 0.3s ease;
}

body.is-playing p[data-narration] {
    padding-left: calc(var(--container-padding) - 2px);
    margin-left: calc(-1 * var(--container-padding));
    border-left: 2px solid transparent;
}

body.is-playing [data-narration].reading-active {
    color: var(--text-primary);
    filter: brightness(1) !important;
}

body.is-playing [data-narration].reading-active strong,
body.is-playing [data-narration].reading-active b {
    color: var(--text-primary);
}

body.is-playing p[data-narration].reading-active {
    border-color: white;
}

body.is-playing [data-narration] a {
    color: var(--text-inactive);
    transition: color 0.3s ease;
}

body.is-playing [data-narration].reading-active a {
    color: white;
}

body.is-playing [data-narration] a::after {
    background-color: #777;
    transition: background-color 0.3s ease;
}

body.is-playing [data-narration].reading-active a::after {
    background-color: white;
}

/* Playback Dimming */
body.is-playing .strange-img,
body.is-playing .content-image,
body.is-playing .header-image,
body.is-playing .tech-stack-icons img,
body.is-playing .tech-stack,
body.is-playing .carousel,
body.is-playing .punk-band-icons,
body.is-playing .embed-container,
body.is-playing .ds-header,
body.is-playing .swatch-grid,
body.is-playing .component-demo,
body.is-playing .viz-grid,
body.is-playing .recent-work,
body.is-playing .table-container,
body.is-playing .ds-section-title,
body.is-playing .ds-label,
body.is-playing .type-sample,
body.is-playing .exclude-folders-wrapper,
body.is-playing .pro-tip-wrapper,
body.is-playing .breadcrumb-header,
body.is-playing .ds-note,
body.is-playing .equation-block,
body.is-playing .code-block-wrapper,
body.is-playing .tanh-viz-container,
body.is-playing .tantara-viz,
body.is-playing #attractor-container,
body.is-playing .meta-info,
body.is-playing .section-nav,
body.is-playing h1,
body.is-playing h2,
body.is-playing h3,
body.is-playing h4,
body.is-playing p,
body.is-playing li,
body.is-playing code,
body.is-playing pre,
body.is-playing table,
body.is-playing .katex,
body.is-playing .math,
body.is-playing ul,
body.is-playing ol,
body.is-playing blockquote,
body.is-playing hr,
body.checkpoint-active .strange-img,
body.checkpoint-active .content-image,
body.checkpoint-active .header-image,
body.checkpoint-active .tech-stack-icons img,
body.checkpoint-active .tech-stack,
body.checkpoint-active .carousel,
body.checkpoint-active .punk-band-icons,
body.checkpoint-active .embed-container,
body.checkpoint-active .ds-header,
body.checkpoint-active .swatch-grid,
body.checkpoint-active .component-demo,
body.checkpoint-active .viz-grid,
body.checkpoint-active .recent-work,
body.checkpoint-active .table-container,
body.checkpoint-active .ds-section-title,
body.checkpoint-active .ds-label,
body.checkpoint-active .type-sample,
body.checkpoint-active .exclude-folders-wrapper,
body.checkpoint-active .pro-tip-wrapper,
body.checkpoint-active .breadcrumb-header,
body.checkpoint-active .ds-note,
body.checkpoint-active .equation-block,
body.checkpoint-active .code-block-wrapper,
body.checkpoint-active .tanh-viz-container,
body.checkpoint-active .tantara-viz,
body.checkpoint-active #attractor-container,
body.checkpoint-active .meta-info,
body.checkpoint-active .section-nav,
body.checkpoint-active h1,
body.checkpoint-active h2,
body.checkpoint-active h3,
body.checkpoint-active h4,
body.checkpoint-active p,
body.checkpoint-active li,
body.checkpoint-active code,
body.checkpoint-active pre,
body.checkpoint-active table,
body.checkpoint-active .katex,
body.checkpoint-active .math,
body.checkpoint-active ul,
body.checkpoint-active ol,
body.checkpoint-active blockquote,
body.checkpoint-active hr {
    filter: brightness(0.6);
    transition: filter 0.3s ease;
}

/* Brighten elements near active paragraph */
.narration-highlight,
body.is-playing *:has(> .reading-active),
body.is-playing *:has(> * > .reading-active),
body.is-playing *:has(> * > * > .reading-active),
body.is-playing *:has(> * > * > * > .reading-active) {
    filter: brightness(1) !important;
}

/* Specific brightness overrides for internal elements when active */
body.is-playing .reading-active,
body.is-playing .reading-active *,
body.is-playing .narration-highlight,
body.is-playing .narration-highlight * {
    filter: brightness(1) !important;
}

/* Specific brightness overrides for internal elements */
.narration-highlight img,
.narration-highlight iframe,
.narration-highlight .swatch-color {
    filter: brightness(1) !important;
}

/* Sibling and parent selectors for brightening */
.ds-label.narration-highlight,
.ds-section-title.narration-highlight,
.ds-note.narration-highlight {
    filter: brightness(1);
}

body.is-playing .chicago-stars {
    color: var(--text-inactive);
    transition: color 0.3s ease;
}

.chicago-stars.narration-highlight {
    color: var(--text-primary) !important;
    filter: brightness(1) !important;
}

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

.section-divider {
    text-align: center;
    color: var(--text-primary);
    margin: 2rem 0;
    letter-spacing: 0.5em;
}

/* 6. NAVIGATION */
.section-nav {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 42;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body .content-wrapper.nav-fixed .section-nav {
    position: fixed;
    top: 2rem;
    opacity: 1;
    visibility: visible;
}

.menu-toggle,
.flag-toggle {
    position: relative;
    z-index: 50;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    border: none !important;
    padding: 0;
    flex-shrink: 0;
}

.menu-toggle:focus,
.flag-toggle:focus {
    outline: none !important;
}

.menu-toggle:hover,
.flag-toggle:hover {
    transform: translateY(-1px);
    background: rgba(0, 0, 0, 0.6);
}

.menu-icon {
    width: 24px;
    height: 24px;
    transition: fill var(--transition-base);
}

.flag-toggle {
    font-size: 1.5rem;
    line-height: 1;
}

.hamburger-line {
    transition: all var(--transition-base);
    transform-origin: center;
}

.hamburger-line.top { transform: translateY(-5px); }
.hamburger-line.bottom { transform: translateY(5px); }

.menu-toggle.active .hamburger-line.top { transform: translateY(0) rotate(45deg); }
.menu-toggle.active .hamburger-line.middle { opacity: 0; }
.menu-toggle.active .hamburger-line.bottom { transform: translateY(0) rotate(-45deg); }

/* Ensure toggle buttons stay above menu content when menu is open */
.section-nav:has(.menu-toggle.active) {
    z-index: 43;
}

/* Hide language selector when hamburger menu is open */
.section-nav:has(.menu-toggle.active) .language-selector {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    z-index: 41;
}

.menu-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
    outline: none;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.95);
    pointer-events: none;
    z-index: 42;
}

.menu-content::-webkit-scrollbar {
    display: none;
}

.menu-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 2vh, 1.25rem);
    width: 100%;
    max-width: 500px;
    height: auto;
    max-height: 80dvh;
    pointer-events: auto;
    scrollbar-width: none;
}

.menu-content ul::-webkit-scrollbar {
    display: none;
}

.menu-content li {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.menu-content li.menu-divider-li {
    margin: 1rem 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.menu-content li::before {
    content: none !important;
}

.menu-content.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

.menu-item {
    display: inline-block;
    text-align: center;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border-radius: 0.25rem;
    font-size: clamp(1.0rem, 4vh, 1.2rem);
    user-select: none;
    text-decoration: none;
    font-family: 'Andale Mono', monospace;
    text-transform: lowercase;
    font-variant: small-caps;
    word-spacing: -0.4em;
    line-height: 1.2;
}

.menu-item::after {
    display: none !important;
}

.menu-divider {
    height: 1px;
    background-color: var(--border-color);
    width: 100%;
    max-width: 25vw;
    opacity: 1;
}

.menu-item:hover {
    color: var(--text-primary);
}

.menu-item:active {
    color: white;
    transform: scale(0.98);
}

/* 7. FOOTER & LOGO */
footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4rem 0;
    margin-top: 4rem;
}

.logo {
    display: inline-block;
    margin-bottom: 0.5rem;
    width: 27px;
    height: 30px;
    position: relative;
    cursor: pointer;
}

.logo::after {
    display: none !important;
}

.logo .mb-path {
    fill: #FFFFFF;
}

.logo svg {
    width: 100%;
    height: 100%;
    display: block;
}

.footer-text {
    font-size: 0.65rem;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

.logo-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.85rem;
    padding: 0.35rem 0.65rem;
    background-color: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    font-family: 'Axis Std', sans-serif;
    font-size: 0.75rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 20;
}

.logo-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #444;
}

@media (hover: hover) {
    .logo:hover .logo-tooltip {
        opacity: 1;
        visibility: visible;
    }
}

.logo:focus-visible .logo-tooltip {
    opacity: 1;
    visibility: visible;
}

/* 8. CONTACT MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100svh;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem 2rem 2rem 2rem;
    width: 90%;
    max-width: 420px;
    position: relative;
    transform: translateY(20px);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: 'Andale Mono', monospace;
    font-variant: small-caps;
    font-size: 1.5rem;
    line-height: 1.4;
    word-spacing: -0.4em;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.7;
}

#contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#contact-form input,
#contact-form textarea {
    font-family: 'Andale Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    outline: none;
    word-spacing: -0.4em;
    transition: border-color 0.2s ease;
    resize: vertical;
    width: 100%;
}

#contact-form input::placeholder,
#contact-form textarea::placeholder {
    color: var(--text-inactive);
}

#contact-form input:focus,
#contact-form textarea:focus {
    border-color: #666;
}

.form-field {
    position: relative;
    z-index: 1;
}

.form-field.error {
    z-index: 10;
}

.form-field.error input,
.form-field.error textarea {
    border-color: #a44;
}

.field-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    padding: 0.35rem 0.65rem;
    background-color: #1a1a1a;
    border: 1px solid #a44;
    border-radius: 4px;
    font-family: 'Axis Std', sans-serif;
    font-size: 0.75rem;
    color: #e88;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 20;
}

.field-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0.75rem;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #a44;
}

.form-field.error .field-tooltip {
    opacity: 1;
    visibility: visible;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.modal-buttons button {
    flex: 1;
}

.btn-cancel, .btn-send {
    font-family: 'Andale Mono', monospace;
    font-size: 0.85rem;
    padding: 0.85rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    word-spacing: -0.4em;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    outline: none;
}

.btn-small {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-cancel {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-secondary);
}

.btn-cancel:hover {
    border-color: #555;
    color: var(--text-primary);
}

.btn-send {
    background: #1a1a1a;
    border: 1px solid #444;
    color: var(--text-primary);
}

.btn-send:hover {
    background: #252525;
    border-color: #555;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-success {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    text-align: center;
    padding: 2rem 0;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.modal-success.animate-in {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.success-checkmark {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #4ade80;
    stroke-miterlimit: 10;
}

.success-checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: #4ade80;
    fill: none;
}

.success-checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: #4ade80;
    stroke-width: 3;
    stroke-linecap: round;
    fill: none;
}

.modal-success.animate-in .success-checkmark__circle {
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.modal-success.animate-in .success-checkmark__check {
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

/* 10. CODE BLOCKS */
code {
    font-family: 'Fira Code', 'Andale Mono', monospace;
    font-size: 0.85em;
    background-color: #1a1a1a;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: #e0e0e0;
}

.code-block-wrapper {
    position: relative;
    margin: 1.5rem 0;
}

pre {
    font-family: 'Fira Code', 'Andale Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 1.5rem;
    margin: 0;
    overflow-x: auto;
    color: #e0e0e0;
}

pre code {
    padding: 0;
    background: none;
}

/* Scrollable code block */
.code-block-wrapper.code-block-scrollable pre {
    max-height: 400px;
    overflow-y: auto;
}

.copy-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    opacity: 1;
    color: #e3e3e3;
    transition: opacity 0.2s, background-color 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-button:hover {
    background-color: #3a3a3a;
}

.copy-button:active {
    background-color: #4a4a4a;
    transform: scale(0.95);
}

.copy-button svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: fill 0.2s;
}

.copy-button::before {
    content: 'Copy Code';
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 0.5rem;
    padding: 0.35rem 0.65rem;
    background-color: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    font-family: 'Axis Std', sans-serif;
    font-size: 0.75rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 20;
}

.copy-button::after {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 0.75rem;
    margin-bottom: 0.25rem;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #444;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 21;
}

@media (hover: hover) {
    .copy-button:hover::before,
    .copy-button:hover::after {
        opacity: 1;
        visibility: visible;
    }
}

.copy-button:focus-visible::before,
.copy-button:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.copy-button.copied {
    opacity: 1;
    background-color: #3a3a3a;
    border-color: #555;
}

.copy-button.copied svg {
    fill: var(--text-primary);
}

.copy-button.copied::before {
    content: 'Copied!';
    background-color: #1a1a1a;
    border-color: #555;
    color: var(--text-primary);
    opacity: 1;
    visibility: visible;
}

.copy-button.copied::after {
    border-top-color: #555;
    opacity: 1;
    visibility: visible;
}

.copy-button.fading-out::before,
.copy-button.fading-out::after {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.copy-button.fading-out::before {
    content: 'Copied!';
}

/* 11. TABLES */
.table-container {
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.table-container table {
    margin: 0;
    border-bottom: none;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.85rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    color: var(--text-primary);
    font-weight: 300;
    background-color: #1a1a1a;
}

td {
    color: var(--text-body);
}

@media (max-width: 768px) {
    .table-container {
        margin: 1.5rem 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 4px;
    }

    .table-container table {
        min-width: 480px;
    }

    th, td {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .table-container table {
        min-width: 420px;
    }

    th, td {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

/* 12. ACCESSIBILITY & UTILS */
.nowrap {
    white-space: nowrap;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #f2f2f2;
    color: #000;
    padding: 8px;
    z-index: 10000;
    font-family: 'Andale Mono', monospace;
    font-size: 14px;
    text-decoration: none;
    transition: top 0.2s;
}

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

:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 2px black, 0 0 0 4px var(--text-primary) !important;
    border-radius: 2px !important;
    transition: box-shadow 0.2s ease !important;
}

/* Hide debug UI */
.lil-gui {
    display: none !important;
}

/* 13. SOCIAL & CONTACT LINKS */
.contact-links {
    font-family: 'Andale Mono', monospace;
    font-size: 0.75rem;
    word-spacing: -0.4em;
    margin-top: 5rem;
}

.contact-links a {
    margin-right: 1.0rem;
    display: inline-block;
}

.contact-links a:last-child {
    margin-right: 0;
}

/* 14. RESPONSIVE UTILS */
@media (max-width: 768px) {
    .container, 
    .content-section,
    .breadcrumb-header h1,
    .breadcrumb-header .image-caption,
    .breadcrumb-header .header-media-wrapper {
        width: 100%;
        max-width: none;
    }
    
    h1 { font-size: 1.2rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1.0rem; }

    .menu-divider {
        max-width: 50vw;
    }
    
    .breadcrumb-header .header-media-wrapper {
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
    }

    /* Full-width embed on mobile */
    .embed-container {
        width: 100vw;
        max-width: none;
        padding-bottom: 56.25%;
        aspect-ratio: unset;
        height: 0;
        margin: 3rem 0;
    }

    .section-nav {
        top: 1rem;
        right: 1rem;
    }

    footer {
        padding: 4rem 0 calc(4rem + env(safe-area-inset-bottom));
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }

    /* Prevent auto-zoom on mobile browsers */
    #contact-form input,
    #contact-form textarea,
    .language-search,
    .exclude-folders-wrapper input {
        font-size: 16px !important;
    }
}

/* 15. CALLOUTS & WRAPPERS */
.exclude-folders-wrapper {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 200, 50, 0.08) 0%, rgba(255, 150, 50, 0.04) 100%);
    border: 1px solid rgba(255, 180, 50, 0.3);
    border-left: 3px solid rgba(255, 180, 50, 0.6);
    border-radius: 6px;
}

.exclude-folders-wrapper label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: rgba(255, 200, 100, 0.9);
}

.exclude-folders-wrapper input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #f2f2f2;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 180, 50, 0.25);
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.exclude-folders-wrapper input:focus {
    border-color: rgba(255, 180, 50, 0.5);
    box-shadow: 0 0 0 2px rgba(255, 180, 50, 0.1);
}

.exclude-folders-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.exclude-folders-hint {
    margin: 0.5rem 0 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

.exclude-folders-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}

.pro-tip-wrapper {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(100, 180, 255, 0.08) 0%, rgba(80, 140, 200, 0.04) 100%);
    border: 1px solid rgba(100, 180, 255, 0.25);
    border-left: 3px solid rgba(100, 180, 255, 0.5);
    border-radius: 6px;
}

.pro-tip-label {
    margin: 0 0 0.75rem 0 !important;
    font-size: 0.9rem;
    color: rgba(140, 200, 255, 0.9);
}

.pro-tip-wrapper p {
    margin-bottom: 0.75rem;
    color: var(--text-body);
}

.pro-tip-wrapper p:last-child {
    margin-bottom: 0;
}

.pro-tip-wrapper code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}

/* 16. TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    height: 100dvh;
    height: -webkit-fill-available;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0.75rem;
    z-index: 2000;
    pointer-events: none;
}

@media (max-width: 768px) {
    .toast-container {
        padding: 0.25rem;
    }
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 400px;
    padding: 1rem 1.25rem;
    background: #0a0a0a;
    border: 1px solid #333;
    border-left: 3px solid var(--text-secondary);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-family: 'Andale Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.toast-message {
    font-family: 'Axis Std', sans-serif;
    font-size: 0.8rem;
    color: var(--text-body);
    line-height: 1.4;
    margin: 0 !important;
}

.toast-success { border-left-color: #4ade80; }
.toast-error { border-left-color: #ff6b6b; }
.toast-warning { border-left-color: #ffb432; }
.toast-info { border-left-color: #64b4ff; }
/* 17. MATHEMATICAL EQUATIONS (KaTeX) */
.equation-block {
    margin: 2rem 0;
    padding: 1.75rem 2rem;
    border-radius: 8px;
    overflow-x: auto;
}

.equation-block .katex-display {
    margin: 0;
    padding: 0;
}

.equation-block .katex-display > .katex {
    text-align: center;
}

/* KaTeX global overrides for dark theme */
.katex {
    font-size: 1.15em;
    color: var(--text-primary);
}

.katex-display {
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.katex-display > .katex {
    white-space: normal;
}

/* Inline math styling */
.katex-inline, p .katex, li .katex {
    font-size: 1.05em;
    padding: 0 0.1em;
}

.katex .mord.mtight, .katex .minner {
    color: var(--text-primary);
}

.katex .mop {
    color: #a0a0a0;
}

.katex .base {
    margin-top: 0.1em;
    margin-bottom: 0.1em;
}

.katex .frac-line {
    border-bottom-color: var(--text-secondary);
}

.katex .delimsizing {
    color: var(--text-secondary);
}

/* 19. LANGUAGE SELECTOR */
.language-selector {
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease 0.15s; /* Slight delay for sequence effect */
    opacity: 1;
}

.nav-fixed .language-selector {
    opacity: 1;
}

.language-dropdown {
    position: fixed;
    top: 5.5rem;
    right: 2rem;
    width: 300px;
    max-height: calc(100dvh - 7rem);
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 100; /* High z-index to stay above the menu backdrop (41) */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.language-dropdown.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.language-search-container {
    padding: 1rem;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    background: #0a0a0a;
    z-index: 2;
    border-radius: 8px 8px 0 0;
}

.language-search {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: 'Andale Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.language-search:focus {
    border-color: #666;
}

.language-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.language-list::-webkit-scrollbar {
    width: 6px;
}

.language-list::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.language-item {
    width: 100%;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: none;
    text-align: left;
    color: var(--text-body);
    font-family: 'Axis Std', sans-serif;
    font-size: 0.85rem;
}

.language-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.language-item.selected {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.language-item.has-narration {
    /* Subtle highlight for narration-enabled languages */
}

.narration-indicator {
    margin-left: auto;
    font-size: 0.9rem;
    opacity: 0.7;
}

.language-item:hover .narration-indicator,
.language-item.selected .narration-indicator {
    opacity: 1;
}

.language-flag {
    font-size: 1.1rem;
    line-height: 1;
}

.language-name-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.language-name-native {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

@media (max-width: 768px) {
    .language-dropdown {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(10px);
        width: min(320px, calc(100vw - 2rem));
    }

    .language-dropdown.active {
        transform: translateX(-50%) translateY(0);
    }
}

/* Demo language selectors should not escape their container */
.component-demo-preview .language-dropdown,
.component-demo-preview .flag-toggle {
    position: relative;
    top: auto;
    right: auto;
    z-index: 1;
    transform: none;
}

.component-demo-preview .language-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body:not(.is-dev) #generate-audio-button,
body:not(.is-dev) #pre-translate-button {
    display: none !important;
}

#generate-audio-button,
#pre-translate-button {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    padding: 1rem 2rem;
    background-color: #f2f2f2;
    border: 1px solid #333;
    border-radius: 8px;
    color: #000;
    cursor: pointer;
    z-index: 9999;
    font-family: 'Andale Mono', monospace;
    font-size: 0.85rem;
    font-weight: bold;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 240px;
}

#pre-translate-button {
    bottom: 8.5rem; /* Stack above the narration button */
}

#generate-audio-button:hover,
#pre-translate-button:hover {
    transform: translateY(-4px);
    background-color: #ffffff;
    border-color: #000;
}

#generate-audio-button:disabled,
#pre-translate-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#generate-audio-button .button-title,
#pre-translate-button .button-title {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9rem;
}

#generate-audio-button .button-command,
#pre-translate-button .button-command {
    font-size: 10px;
    opacity: 0.7;
    font-family: 'Fira Code', monospace;
    font-weight: normal;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
}

.content-changed {
    position: relative;
    outline: 1px dashed #ffb432;
    outline-offset: 4px;
}

.content-changed::after {
    content: 'MODIFIED';
    position: absolute;
    top: -1.5rem;
    left: 0;
    font-family: 'Andale Mono', monospace;
    font-size: 10px;
    color: #ffb432;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    border: 1px solid #ffb432;
    border-radius: 3px;
    pointer-events: none;
    z-index: 5;
}

/* Hide modified badges when toggle is off */
.hide-modified-badges .content-changed {
    outline: none;
}

.hide-modified-badges .content-changed::after {
    display: none;
}

.hide-modified-badges #pre-translate-button,
.hide-modified-badges #generate-audio-button {
    display: none;
}

/* Badge toggle button */
#badge-toggle-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #555;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 9999;
    font-family: 'Andale Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    transition: border-color 0.2s, color 0.2s;
}

#badge-toggle-button:hover {
    border-color: #888;
    color: #ccc;
}

#badge-toggle-button.badges-hidden {
    border-color: #ffb432;
    color: #ffb432;
}

#badge-toggle-button .shortcut {
    opacity: 0.5;
    margin-left: 6px;
}

#badge-toggle-button .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: #ffb432;
    color: #000;
    font-size: 10px;
    font-weight: bold;
    border-radius: 9px;
    margin-left: 8px;
    padding: 0 5px;
}

/* Narration Checkpoint UI */
.narration-checkpoint-container {
    margin: 2.5rem 0;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
    filter: brightness(1) !important;
}

.narration-checkpoint-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.checkpoint-content p {
    font-family: 'Andale Mono', monospace;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.checkpoint-button {
    background: var(--text-primary);
    color: var(--bg-color);
    border: none;
    padding: 0.75rem 2rem;
    font-family: 'Andale Mono', monospace;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.checkpoint-button:hover {
    transform: scale(1.05);
    background: #fff;
}

body.is-playing .narration-checkpoint-container,
body.is-playing .narration-checkpoint-container *,
body.checkpoint-active .narration-checkpoint-container,
body.checkpoint-active .narration-checkpoint-container * {
    filter: brightness(1) !important;
}
