/* Structural tokens (always) */
:root {
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --font-sans: var(--font-mono);
    --max-width: 1100px;
    --container-padding-x: var(--space-lg);
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 2.5rem;
    --space-3xl: 3rem;
    --spacing-unit: var(--space-md);
    --spacing-section: var(--space-2xl);
    --header-height: 4.375rem;
    --site-header-offset: calc(env(safe-area-inset-top, 0px) + var(--header-height));
    --main-padding-block: var(--space-xl);
    /* Square-edge geometry â€” all radius tokens resolve to 0 */
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --border-width: 1px;
    --control-height: 2.25rem;
    --control-padding-inline: var(--space-sm);
    --cell-padding-x: var(--space-sm);
    --cell-padding-y: var(--space-xs);
    --panel-padding: var(--space-md);
    --transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1400px) {
    :root { --max-width: 1320px; }
}

@media (min-width: 1600px) {
    :root { --max-width: 1500px; }
}

/* Tokyo Night Day â€” explicit light */
html[data-theme="light"] {
    color-scheme: light;
    --bg-color: #e1e2e7;
    --bg-rgb: 225, 226, 231;
    --surface-color: #eff0f5;
    --text-color: #343b58;
    --secondary-text: #565f89;
    --accent-color: #2e7de9;
    --accent-hover: #1c6fd4;
    --accent-muted: color-mix(in srgb, var(--accent-color) 14%, transparent);
    --border-color: #c9cdd7;
    --code-bg: #d5d8e3;
    --danger-color: #8c4351;
    --shadow-sm: 0 1px 2px 0 rgb(52 59 88 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(52 59 88 / 0.08), 0 2px 4px -2px rgb(52 59 88 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(52 59 88 / 0.1), 0 4px 6px -4px rgb(52 59 88 / 0.08);
}

/* Tokyo Night â€” explicit dark */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg-color: #1a1b26;
    --bg-rgb: 26, 27, 38;
    --surface-color: #24283b;
    --text-color: #c0caf5;
    --secondary-text: #a9b1d6;
    --accent-color: #7aa2f7;
    --accent-hover: #89b4fa;
    --accent-muted: color-mix(in srgb, var(--accent-color) 18%, transparent);
    --border-color: #3b4261;
    --code-bg: #16161e;
    --danger-color: #f7768e;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.45);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.55), 0 4px 6px -4px rgb(0 0 0 / 0.45);
}

/* No JS / before theme script: follow system */
html:not([data-theme]) {
    color-scheme: light;
    --bg-color: #e1e2e7;
    --bg-rgb: 225, 226, 231;
    --surface-color: #eff0f5;
    --text-color: #343b58;
    --secondary-text: #565f89;
    --accent-color: #2e7de9;
    --accent-hover: #1c6fd4;
    --accent-muted: color-mix(in srgb, var(--accent-color) 14%, transparent);
    --border-color: #c9cdd7;
    --code-bg: #d5d8e3;
    --danger-color: #8c4351;
    --shadow-sm: 0 1px 2px 0 rgb(52 59 88 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(52 59 88 / 0.08), 0 2px 4px -2px rgb(52 59 88 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(52 59 88 / 0.1), 0 4px 6px -4px rgb(52 59 88 / 0.08);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        color-scheme: dark;
        --bg-color: #1a1b26;
        --bg-rgb: 26, 27, 38;
        --surface-color: #24283b;
        --text-color: #c0caf5;
        --secondary-text: #a9b1d6;
        --accent-color: #7aa2f7;
        --accent-hover: #89b4fa;
        --accent-muted: color-mix(in srgb, var(--accent-color) 18%, transparent);
        --border-color: #3b4261;
        --code-bg: #16161e;
        --danger-color: #f7768e;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.45);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.45);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.55), 0 4px 6px -4px rgb(0 0 0 / 0.45);
    }
}

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

html {
    overflow-x: hidden;
}

@supports (overflow: clip) {
    html {
        overflow-x: clip;
    }
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

button,
input,
textarea,
select,
optgroup {
    font-family: inherit;
}

/* Canvas node graph (site-bg-network.js); pointer-events none â€” cursor tracked on window */
.site-bg-network {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Stacked full-viewport canvases: WebGL (site-bg-webgl.js) under 2D network */
.site-bg-network canvas.site-bg-webgl {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.site-bg-network canvas.site-bg-network-2d {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.site-bg-network canvas:not(.site-bg-webgl):not(.site-bg-network-2d) {
    display: block;
    width: 100%;
    height: 100%;
    vertical-align: top;
}

/* Keep header z-index: 50 from .header rules; only lift main/footer above the canvas */
html.has-network-bg body > main,
html.has-network-bg body > footer {
    position: relative;
    z-index: 1;
}

/* Lightweight SVG backdrop (non-home pages); echoes the WebGL/2D canvas aesthetic
   with server-generated 3D isometric wireframes + random glow orbs. */
.svg-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    color: var(--secondary-text);
}

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

/* Custom per-page canvas backdrop (js/bg/<key>.js); ViewData["SiteBackground"] = "<key>" */
.site-bg-custom {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.site-bg-custom canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Wireframe breathing — subtle opacity pulse, staggered per element */
.svg-wire {
    animation: svg-breathe 10s ease-in-out infinite;
    will-change: opacity;
}
.svg-wire:nth-child(odd) { animation-delay: -2s; animation-duration: 12s; }
.svg-wire:nth-child(3n) { animation-delay: -5s; animation-duration: 14s; }
.svg-wire:nth-child(5n) { animation-delay: -8s; animation-duration: 11s; }

/* Blinking stars — subtle white dots with twinkling effect */
.svg-star {
    fill: #ffffff;
    animation: svg-star-blink 6s ease-in-out infinite;
    will-change: opacity;
}
.svg-star:nth-child(even) { animation-delay: -1.5s; animation-duration: 4.5s; }
.svg-star:nth-child(3n) { animation-delay: -3s; animation-duration: 7.5s; }
.svg-star:nth-child(5n) { animation-delay: -4.5s; animation-duration: 9s; }

@keyframes svg-breathe {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes svg-star-blink {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
    .svg-wire,
    .svg-star {
        animation: none;
        opacity: 0.85;
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-md);
    color: var(--text-color);
}

h1 { font-size: 2.75rem; margin-bottom: var(--space-md); margin-top: 0; }
h2 { font-size: 2rem; margin-top: var(--space-xl); margin-bottom: var(--space-md); }
h2:first-child { margin-top: 0; }
h3 { font-size: 1.5rem; margin-top: var(--space-lg); margin-bottom: var(--space-sm); }
h3:first-child { margin-top: 0; }

p { margin-bottom: var(--space-lg); color: var(--secondary-text); }

a {
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    border-bottom: 1px solid transparent;
}

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

/* Layout */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding-left: max(var(--container-padding-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--container-padding-x), env(safe-area-inset-right, 0px));
}

/* Header & Nav */
body > header {
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: rgba(var(--bg-rgb), 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: var(--transition);
    padding-top: env(safe-area-inset-top, 0px);
}

body > header.scrolled {
    border-bottom-color: var(--border-color);
    background-color: rgba(var(--bg-rgb), 0.95);
}

.header-shell {
    width: 100%;
}

.header-inner {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm) var(--space-md);
    width: 100%;
    min-height: var(--header-height);
    padding-block: var(--space-sm);
}

.header-end {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Checkbox-driven mobile menu (label + nav are siblings after logo) */
.header-nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.header-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
    margin: 0;
    margin-left: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    color: var(--text-color);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.header-menu-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.header-menu-icon {
    flex-shrink: 0;
}

.site-nav {
    display: block;
    margin-left: auto;
}

.site-nav ul {
    display: flex;
    gap: var(--space-xl);
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--secondary-text);
    display: inline-block;
    padding: 0.35rem 0;
    cursor: pointer;
    border: none;
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--text-color);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
}

.logo-mark {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: var(--radius-md);
}

/* Main Content â€” fade in after layout ready to avoid load glitch (no-JS: always visible) */
main {
    flex: 1;
    padding-top: var(--main-padding-block);
    padding-bottom: var(--space-2xl);
    transition: opacity 0.12s ease-out;
}
html.js main {
    opacity: 0;
}
html.js.loaded main {
    opacity: 1;
}

@media (min-width: 769px) {
    .header-inner {
        flex-wrap: nowrap;
    }

    .header-menu-btn {
        display: none;
    }

    .site-nav {
        display: block !important;
        flex-basis: auto;
        width: auto;
        order: 0;
        padding-top: 0;
        margin-top: 0;
        margin-left: auto;
        border-top: none;
    }
}

/* â€”â€”â€” Small screens: tap targets, type scale, stacking â€”â€”â€” */
@media (max-width: 768px) {
    :root {
        --container-padding-x: 1.125rem;
        --spacing-section: var(--space-xl);
        --main-padding-block: var(--space-lg);
    }

    h1 {
        font-size: clamp(1.65rem, 5.5vw, 2.75rem);
    }

    h2 {
        font-size: clamp(1.3rem, 4vw, 2rem);
        margin-top: 1.5rem;
    }

    h3 {
        font-size: clamp(1.1rem, 3.5vw, 1.5rem);
        margin-top: 1rem;
    }

    .header-menu-btn {
        display: inline-flex;
    }

    .site-nav {
        display: none;
        flex-basis: 100%;
        order: 3;
        width: 100%;
        margin-left: 0;
        padding-top: var(--space-sm);
        margin-top: var(--space-xs);
        border-top: 1px solid var(--border-color);
    }

    .header-nav-toggle:checked ~ .site-nav {
        display: block;
    }

    .header-nav-toggle:focus-visible + .header-menu-btn {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }

    .site-nav ul {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    .site-nav a {
        display: flex;
        align-items: center;
        padding: 0.65rem 0;
        min-height: 44px;
        font-size: 1rem;
    }

    main {
        padding-top: var(--main-padding-block);
        padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom, 0px));
    }

    .footer-inner {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }

    .footer-links-row {
        justify-content: center;
        width: 100%;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .section-head h2 {
        font-size: clamp(1.3rem, 4vw, 2rem);
    }

    .section-write .card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .home-title {
        font-size: clamp(1.85rem, 11vw, 3.5rem);
    }

    .home-subtitle {
        font-size: 1.05rem;
    }

    .post-header h1 {
        font-size: clamp(1.65rem, 7vw, 3rem);
    }

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

    .card-grid.home-curations-grid {
        grid-template-columns: 1fr;
    }

    .post-item h3 {
        font-size: clamp(1.15rem, 4vw, 1.5rem);
    }

    .error-wrap {
        padding: 1.5rem 0;
    }

    .error-code {
        font-size: clamp(2.75rem, 16vw, 6rem);
    }

    .lab-table-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .lab-search-input {
        max-width: none;
        width: 100%;
    }

    .markdown-body {
        font-size: 1rem;
    }

    .markdown-body pre {
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
    }

    footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
    }

    /* Avoid iOS zoom on focus (inputs below ~16px) */
    .form-input,
    .form-textarea,
    .lab-search-input,
    .synthesis-search-input,
    .filter-line-search,
    .filter-dropdown-trigger,
    .btn-filter-apply {
        font-size: 1rem;
    }
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-unit);
    margin-top: var(--spacing-unit);
}

/* Home: newest row + popular-by-views row as 4Ã—2 on wide viewports */
.card-grid.home-curations-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1024px) {
    .card-grid.home-curations-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: var(--spacing-unit);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Hover only on cards that are links (not on static cards e.g. Contact, Lab welcome) */
a.card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-lg);
}

.card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.card p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    flex-grow: 1;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--code-bg);
    color: var(--secondary-text);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

/* ==========================================================================
 * AU UI component system â€” cross-platform, non-native interactive controls
 * ========================================================================== */

/* Buttons â€” behavioral variants */
.au-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    background: transparent;
    color: inherit;
    padding: 0.45rem 0.85rem;
}
.au-btn:disabled,
.au-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.au-btn--primary,
.admin-btn-primary,
.btn-submit,
.btn-filter-apply {
    background: var(--accent-color);
    color: #fff !important;
    border-color: transparent;
}
.au-btn--primary:hover,
.admin-btn-primary:hover,
.btn-submit:hover,
.btn-filter-apply:hover {
    background: var(--accent-hover);
    color: #fff !important;
}
.au-btn--secondary {
    background: var(--surface-color);
    color: var(--text-color);
    border-color: var(--border-color);
}
.au-btn--secondary:hover {
    border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color));
    background: var(--code-bg);
}
.au-btn--ghost,
.btn-link {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.35rem;
    background: transparent;
    border-color: transparent;
    font-weight: 600;
    color: var(--accent-color);
    margin-top: 0;
}
.au-btn--ghost:hover,
.btn-link:hover {
    color: var(--accent-hover);
    transform: translateX(2px);
}
.au-btn--danger,
.admin-btn-danger {
    background: var(--danger-color);
    color: #fff !important;
    border-color: transparent;
}
.au-btn--danger:hover,
.admin-btn-danger:hover {
    filter: brightness(1.1);
}
.au-btn--icon,
.btn-icon-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--secondary-text);
    line-height: 0;
}
.au-btn--icon:hover,
.btn-icon-clear:hover {
    color: var(--text-color);
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-color));
    background: var(--code-bg);
}
.au-btn:focus-visible,
.admin-btn-primary:focus-visible,
.btn-submit:focus-visible,
.btn-filter-apply:focus-visible,
.admin-btn-danger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 35%, transparent);
}
.au-btn--danger:focus-visible,
.admin-btn-danger:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-color) 35%, transparent);
}

/* Segment / tab toggle groups */
.au-segment,
.theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}
.au-segment__btn,
.theme-switcher__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--secondary-text);
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.au-segment__btn:hover,
.theme-switcher__btn:hover {
    color: var(--text-color);
    background: var(--accent-muted);
}
.au-segment__btn[aria-pressed="true"],
.theme-switcher__btn[aria-pressed="true"] {
    color: var(--accent-color);
    background: var(--accent-muted);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-color) 35%, transparent);
}
.au-segment__btn:focus-visible,
.theme-switcher__btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Custom dropdown shell (select replacement + filter panels) */
.au-dropdown,
.filter-dropdown {
    position: relative;
}
.au-dropdown__trigger,
.filter-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    cursor: pointer;
    text-align: left;
    line-height: 1.2;
}
.au-dropdown__label,
.filter-dropdown-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.au-dropdown__chevron,
.filter-chevron {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--secondary-text);
    transition: transform 0.15s ease;
    margin-top: 1px;
}
.au-dropdown.is-open .au-dropdown__chevron,
.filter-dropdown.is-open .filter-chevron {
    transform: rotate(180deg);
}
.au-dropdown__panel,
.filter-dropdown-panel {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    min-width: min(100%, 12rem);
    max-height: 15rem;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 60;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.3rem 0;
}
.au-dropdown__option,
.filter-dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-color);
    text-align: left;
}
button.au-dropdown__option:hover,
.filter-dropdown-option:hover {
    background: var(--accent-muted);
}
.au-dropdown__option.is-selected,
.au-dropdown__option[aria-selected="true"] {
    color: var(--accent-color);
    font-weight: 600;
}
.au-select--compact .au-dropdown__trigger {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    font-family: var(--font-mono);
    min-height: auto;
    height: auto;
}
.au-select-native,
select.au-select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Custom checkbox / radio (non-native appearance) */
.au-check,
.au-radio,
label.au-check,
label.au-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: inherit;
    color: var(--text-color);
}
.au-check input[type="checkbox"],
.au-radio input[type="radio"],
.filter-dropdown-option input[type="checkbox"],
.filter-dropdown-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    transition: var(--transition);
    cursor: pointer;
}
.au-check input[type="checkbox"],
.filter-dropdown-option input[type="checkbox"] {
    border-radius: var(--radius-sm);
}
.au-check input[type="checkbox"]:checked,
.filter-dropdown-option input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='white' stroke-width='2' d='M2 6l3 3 5-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.75rem;
}
.au-radio input[type="radio"],
.filter-dropdown-option input[type="radio"] {
    border-radius: 50%;
}
.au-radio input[type="radio"]:checked,
.filter-dropdown-option input[type="radio"]:checked {
    border-color: var(--accent-color);
    background: radial-gradient(circle, var(--accent-color) 0 35%, var(--bg-color) 38% 100%);
}
.au-check input:focus-visible,
.au-radio input:focus-visible,
.filter-dropdown-option input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

/* Filter chips (admin tag picker) */
.au-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.au-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--code-bg);
    color: var(--secondary-text);
    transition: var(--transition);
    user-select: none;
}
.au-chip:has(input:checked) {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}
.au-chip:has(input:focus-visible) {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 35%, transparent);
}
.au-chip input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Toggle switch */
.au-toggle,
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}
.au-toggle input,
.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.au-toggle__slider,
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border-color);
    transition: background-color 0.25s ease;
    border-radius: 26px;
}
.au-toggle__slider::before,
.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: transform 0.25s ease;
    border-radius: 50%;
}
.au-toggle input:checked + .au-toggle__slider,
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-color);
}
.au-toggle input:checked + .au-toggle__slider::before,
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}
.au-toggle input:focus-visible + .au-toggle__slider,
.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

/* Text tabs (editor panels) */
.au-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.au-tabs__btn,
.editor-tab {
    padding: 0.5rem 1rem;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    transition: var(--transition);
}
.au-tabs__btn:hover,
.editor-tab:hover {
    border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color));
}
.au-tabs__btn.active,
.au-tabs__btn.is-active,
.editor-tab.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}
.au-tabs__btn:focus-visible,
.editor-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

/* Pagination controls */
.au-pagination__nav,
.pagination-link {
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    background: transparent;
    color: var(--accent-color);
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    font-family: inherit;
}
.au-pagination__nav:hover:not(:disabled):not(.pagination-disabled),
.pagination-link:hover:not(.pagination-disabled) {
    color: var(--accent-hover);
}
.au-pagination__nav:disabled,
.pagination-disabled {
    color: var(--border-color);
    cursor: default;
    pointer-events: none;
}
.au-pagination__current,
.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    background: var(--card-bg, rgba(128, 128, 128, 0.18));
    border: 1px solid var(--border-color);
}

/* Form inputs â€” strip OS-native chrome */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
textarea,
select:not(.au-select-native) {
    appearance: none;
    -webkit-appearance: none;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):focus-visible,
textarea:focus-visible,
select:not(.au-select-native):focus-visible,
.form-input:focus-visible,
.admin-input:focus-visible {
    outline: none;
}

/* Legacy link spacing where ghost buttons sit in content flow */
.btn-link {
    margin-top: 1rem;
}
.monitor-log-filters .au-btn--ghost,
.monitor-log-pagination .au-btn--ghost {
    margin-top: 0;
}

/* Post Meta */
.post-meta {
    font-size: 0.875rem;
    color: var(--secondary-text);
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

/* Footer */
footer {
    margin-top: auto;
    padding-block: var(--space-xl);
    border-top: 1px solid var(--border-color);
    color: var(--secondary-text);
    font-size: 0.875rem;
}

.footer-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.footer-copy {
    flex-shrink: 0;
}

.footer-copy time {
    font-weight: inherit;
}

.footer-links-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    font-size: 0.875rem;
}

.footer-links-row a {
    color: var(--secondary-text);
    border: none;
    padding: 0.25rem 0;
}

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

.footer-sep {
    color: var(--border-color);
    user-select: none;
}

/* Legal static pages */
.legal-page {
    max-width: 42rem;
}

.legal-page h2 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-sm);
    font-size: 1.1rem;
}

.legal-page h3 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-xs);
    font-size: 1rem;
}

.legal-page ul {
    margin: 0.5rem 0 0.75rem 1.25rem;
}

/* Cookie consent (GDPR-style minimal bar; state in localStorage) */
.cookie-consent {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    padding: var(--space-md);
    padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    pointer-events: none;
}

.cookie-consent__inner {
    pointer-events: auto;
    max-width: 40rem;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] .cookie-consent__inner {
    box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.45);
}

.cookie-consent__title {
    margin: 0 0 var(--space-xs);
    font-weight: 600;
    font-size: 0.95rem;
}

.cookie-consent__text {
    margin: 0 0 var(--space-md);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--secondary-text);
}

.cookie-consent__text a {
    border: none;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cookie-consent__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.cookie-consent__btn {
    min-height: 2.25rem;
    padding: 0.4rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--code-bg);
    color: var(--text-color);
}

.cookie-consent__btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.cookie-consent__btn--primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.cookie-consent__btn--primary:hover {
    filter: brightness(1.05);
    color: #fff;
}

/* Interactive controls: clear boundaries and cursor */
button,
[type="button"],
[type="submit"],
input[type="submit"] {
    cursor: pointer;
    min-height: 2.25rem;
}
button:disabled,
[disabled] {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Lab tool textarea: --lab-fill capped in Lab/_Layout; sane min/max here */
.lab-textarea-fill {
    min-height: clamp(8rem, var(--lab-fill, 240px), min(28rem, 50vh));
    resize: vertical;
}
.lab-textarea-fill-split {
    min-height: clamp(6rem, calc(var(--lab-fill, 240px) * 0.5), min(20rem, 40vh));
    resize: vertical;
}
.lab-textarea-tall {
    min-height: clamp(10rem, var(--lab-fill, 280px), min(28rem, 50vh));
    resize: vertical;
}
/* Shared lab tool layout (merged / multi-section tools) */
.lab-tool-title {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    font-weight: 600;
}
.lab-tool-lede {
    margin: 0 0 1.25rem;
    color: var(--secondary-text);
    font-size: 0.95rem;
    line-height: 1.55;
}
.lab-tool-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.lab-tool-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.lab-tool-section-title {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
    font-weight: 600;
}
.lab-tool-section-desc {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin: 0 0 0.75rem;
    line-height: 1.5;
}
.lab-tool-section-desc--warn {
    color: var(--danger-color);
    font-size: 0.85rem;
}
.lab-tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
}
.lab-tool-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}
.lab-tool-textarea--sans {
    font-family: inherit;
}
.lab-tool-textarea--sm {
    font-size: 0.85rem;
}
.lab-split-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 640px) {
    .lab-split-panes {
        grid-template-columns: 1fr;
    }
}

/* Lab Specific */
.lab-header {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-color);
    background: var(--accent-muted);
    padding: 0.2rem var(--space-xs);
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* Markdown Content */
.markdown-body {
    font-size: 1.05rem;
}

.markdown-body h2 { border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.markdown-body pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}
.markdown-body pre[class*="language-"] {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
}
.markdown-body code[class*="language-"] {
    text-shadow: none;
}
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}
.markdown-body p code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* KaTeX (Synthesis math): match body text in both themes (fraction bars, delimiters follow currentColor where supported) */
.markdown-body .katex {
    color: var(--text-color);
}

.markdown-body blockquote {
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    color: var(--secondary-text);
    font-style: italic;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
}
.markdown-body blockquote>p {
    margin-bottom: 0;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
}

/* Post detail: two-column layout */
.post-detail {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media (min-width: 1024px) {
    .post-detail {
        grid-template-columns: 1fr 260px;
        gap: 3rem;
    }
}
.post-content {
    min-width: 0;
}
.post-sidebar {
    display: none;
}
@media (min-width: 1024px) {
    .post-sidebar {
        display: block;
    }
}
.post-sidebar-sticky {
    background-color: rgba(var(--bg-rgb), 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: var(--site-header-offset);
    padding-top: 0.5rem;
    z-index: 20;
    border-radius: var(--radius-md);
}
.post-sidebar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Blog Posts & article detail: title bar stays under site header; body scrolls beneath */
.post-header h1 {
    font-size: 3rem;
    margin-bottom: 0;
    letter-spacing: -0.04em;
}

.post-detail .post-content > .post-header,
.lab-project-detail > .post-header {
    position: sticky;
    top: var(--site-header-offset);
    z-index: 25;
    margin-bottom: var(--space-lg);
    padding-top: var(--space-sm);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(var(--bg-rgb), 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.post-detail .post-content > .post-header .post-meta,
.lab-project-detail > .post-header .post-meta {
    margin-top: var(--space-sm);
}

/* Keep flowing content below the sticky title (stacking) */
.post-detail .post-content > :not(.post-header),
.lab-project-detail > :not(.post-header) {
    position: relative;
    z-index: 0;
}

/* Long-form reading: blur tint on .post-content when animated backdrop is active */
html.has-network-bg .post-detail .post-content {
    background: rgba(var(--bg-rgb), 0.76);
    backdrop-filter: blur(22px) saturate(1.12);
    -webkit-backdrop-filter: blur(22px) saturate(1.12);
}

/* Lab tools list(s): same frosted panel as posts when animated backdrop is active */
html.has-network-bg .lab-layout .lab-overview {
    background: rgba(var(--bg-rgb), 0.76);
    backdrop-filter: blur(22px) saturate(1.12);
    -webkit-backdrop-filter: blur(22px) saturate(1.12);
    border-radius: var(--radius-md);
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    margin-bottom: var(--space-lg, 1.5rem);
}

/* Aside margin notes (from ::: blocks) */
.aside-note {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--secondary-text);
}
.aside-note p:last-child {
    margin-bottom: 0;
}
.aside-note img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
}
@media (min-width: 1200px) {
    .aside-note {
        float: right;
        clear: right;
        width: 260px;
        margin: 0.25rem calc(-260px - 3rem) 1.5rem 2rem;
        font-size: 0.85rem;
        background: transparent;
        border: none;
        border-left: 2px solid var(--border-color);
        border-radius: 0;
        padding: 0.125rem 0 0.125rem 1rem;
        opacity: 0.7;
        transition: opacity 0.2s ease, border-color 0.2s ease;
    }
    .aside-note:hover {
        opacity: 1;
        border-left-color: var(--accent-color);
    }
    .aside-note img {
        margin: 0.75rem 0;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }
}

/* Synthesis search */
.synthesis-search {
    margin-top: 1.5rem;
}
.synthesis-search-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
}
.synthesis-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.synthesis-tags .tag {
    cursor: pointer;
    border: none;
    transition: var(--transition);
}
.synthesis-tags .tag:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}
.tag-active {
    background-color: var(--accent-color) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
}
.synthesis-empty {
    margin-top: 2rem;
    color: var(--secondary-text);
}

/* Synthesis / Curations: one full-width filter row + custom dropdowns */
.listing-filters {
    --filter-line-h: 2.35rem;
    margin-top: 1rem;
    width: 100%;
}
.filter-toolbar-line {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
    position: relative;
}
.filter-line-search {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
    height: var(--filter-line-h);
    padding: 0 0.65rem;
    font-size: 0.875rem;
}
.filter-dropdown {
    position: relative;
    flex-shrink: 0;
}
.filter-kind-dropdown {
    flex: 0 0 9.25rem;
    width: 9.25rem;
    max-width: 28%;
}
.filter-tag-dropdown {
    flex: 0 1 10.5rem;
    min-width: 6.75rem;
    max-width: 26%;
}
.filter-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    height: var(--filter-line-h);
    padding: 0 0.6rem;
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    background: var(--bg-color);
    line-height: 1.2;
}
.filter-dropdown-trigger:hover {
    border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color));
}
.filter-dropdown-trigger:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    border-color: var(--accent-color);
    box-shadow: none;
}
.filter-dropdown-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.filter-chevron {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--secondary-text);
    transition: transform 0.15s ease;
    margin-top: 1px;
}
.filter-dropdown.is-open .filter-chevron {
    transform: rotate(180deg);
}
.filter-dropdown-panel {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    min-width: min(100%, 12rem);
    max-height: 15rem;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 60;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.3rem 0;
}
.filter-tag-dropdown .filter-dropdown-panel {
    min-width: 11.5rem;
}
.filter-dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    margin: 0;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
}
.filter-dropdown-option:hover {
    background: var(--accent-muted);
}
.filter-dropdown-option input {
    flex-shrink: 0;
    margin: 0;
}
.filter-line-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}
.btn-filter-apply {
    height: var(--filter-line-h);
    padding: 0 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
}
.btn-filter-apply:hover {
    background: var(--accent-hover);
}
.btn-filter-apply:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    box-shadow: none;
}
/* Dimmed square control with X â€” matches filter row height inside .listing-filters */
.btn-icon-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--secondary-text);
    cursor: pointer;
    transition: var(--transition);
    line-height: 0;
}
a.btn-icon-clear {
    text-decoration: none;
    border-bottom: none;
}
.btn-icon-clear:hover {
    color: var(--text-color);
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-color));
    background: var(--code-bg);
}
.btn-icon-clear:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    border-color: var(--accent-color);
    box-shadow: none;
}
.btn-icon-clear svg {
    width: 1rem;
    height: 1rem;
    opacity: 0.72;
}
.btn-icon-clear:hover svg {
    opacity: 1;
}
.listing-filters .filter-line-actions .btn-icon-clear {
    width: var(--filter-line-h);
    height: var(--filter-line-h);
}

@media (max-width: 720px) {
    .filter-toolbar-line {
        flex-wrap: wrap;
    }
    .filter-line-search {
        flex: 1 1 100%;
        width: 100%;
    }
    .filter-kind-dropdown,
    .filter-tag-dropdown {
        flex: 1 1 calc(50% - 0.35rem);
        max-width: none;
        width: auto;
    }
    .filter-line-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        margin-left: 0;
    }
}

/* Pagination */
.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.pagination-summary {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-text);
}
.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem 1.25rem;
    width: 100%;
    max-width: 36rem;
}
.pagination-link {
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
}
.pagination-disabled {
    color: var(--border-color);
    cursor: default;
    pointer-events: none;
}
.pagination-info {
    font-size: 0.875rem;
    color: var(--secondary-text);
    font-family: var(--font-mono);
}
.pagination-numbers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.35rem;
}
.pagination-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    text-decoration: none;
    border: 1px solid transparent;
}
.pagination-num:hover {
    background: var(--card-bg, rgba(128, 128, 128, 0.12));
    border-color: var(--border-color);
}
.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    background: var(--card-bg, rgba(128, 128, 128, 0.18));
    border: 1px solid var(--border-color);
}
.pagination-ellipsis {
    padding: 0 0.2rem;
    color: var(--secondary-text);
    font-size: 0.875rem;
    user-select: none;
}

.post-list {
    list-style: none;
    margin-top: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.post-item {
    margin-bottom: 0;
    transition: var(--transition);
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-unit);
    opacity: 0.9;
}

.post-item a {
    display: block;
    border: none;
}

.post-item:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-md);
}

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

.post-item h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.post-item p {
    color: var(--secondary-text);
    margin-bottom: 0.5rem;
}

.back-link {
    margin-top: 2.5rem;
    display: inline-block;
    font-weight: 500;
    color: var(--secondary-text);
}

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

/* Curations */
.curations-surprise {
    margin-top: 0.75rem;
}
.curations-kind-filters {
    margin-top: 1rem;
}
.curation-read-progress {
    height: 3px;
    background: var(--border-color);
    border-radius: 2px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.curation-read-progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent-color);
    transition: width 0.15s ease-out;
}
.curation-poetry-body {
    white-space: pre-wrap;
    font-size: 1.05rem;
    line-height: 1.75;
}
.curation-comic-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.curation-comic-panel {
    margin: 0;
}
.curation-comic-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    vertical-align: middle;
}
.curation-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.curation-lightbox[hidden] {
    display: none !important;
}
.curation-lightbox-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}
.curation-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}
.curation-game-frame-wrap {
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}
.curation-game-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 0;
    min-height: 320px;
}
.curation-embed-unavailable {
    color: var(--secondary-text);
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.curation-external-link {
    display: inline-block;
    margin-bottom: 1rem;
    word-break: break-all;
}
.curation-link-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
@media (min-width: 640px) {
    .curation-link-preview {
        flex-direction: row;
    }
}
.curation-link-preview-image {
    flex: 0 0 200px;
    max-height: 140px;
    overflow: hidden;
    border-radius: var(--radius-md);
}
.curation-link-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.curation-link-preview-body {
    flex: 1;
    min-width: 0;
}
.curation-link-preview-site {
    font-size: 0.8rem;
    color: var(--secondary-text);
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.curation-link-preview-title {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
}
.curation-link-preview-desc {
    margin: 0;
    color: var(--secondary-text);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Home / section headings with action link */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--spacing-unit);
}
.section-head h2 {
    margin: 0;
    font-size: 2rem;
}
.section-write {
    display: grid;
    gap: var(--spacing-unit);
}
.section-write .card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}
.section-write .card h3 {
    margin: 0;
    font-size: 1.25rem;
}
.section-write .post-meta {
    margin: 0.5rem 0 0;
}
.section-write .card-arrow {
    color: var(--accent-color);
}

.home-hero {
    margin-top: 0;
    margin-bottom: var(--spacing-section);
}
@media (min-width: 1024px) {
    .home-hero {
        padding-top: var(--space-3xl);
    }
}
.home-title {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    line-height: 1.1;
    background: linear-gradient(to right, var(--text-color), var(--secondary-text));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
.home-subtitle {
    font-size: 1.25rem;
    color: var(--secondary-text);
    max-width: 100%;
    line-height: 1.6;
}
.home-section {
    margin-bottom: var(--spacing-section);
}
.home-section:last-child {
    margin-bottom: 0;
}

.contact-page {
    position: relative;
    max-width: 64rem;
    margin-inline: auto;
}
.contact-page .card {
    height: auto;
}
.contact-page .card p {
    flex-grow: 0;
}
.contact-hero {
    margin-bottom: 1.75rem;
}
.contact-page h1 {
    margin-bottom: 0.5rem;
}
.contact-lede {
    margin: 0;
    max-width: 42rem;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--secondary-text);
}
.contact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (min-width: 900px) {
    .contact-grid {
        grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem);
        gap: 2rem;
    }
}
.contact-main {
    min-width: 0;
}
.contact-form-card {
    padding: 1.25rem 1.35rem;
}
.contact-form-card-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}
.contact-aside {
    padding: 1.25rem 1.35rem;
    background: var(--surface-color);
}
.contact-aside-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}
.contact-aside-copy {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--secondary-text);
}
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
/* Honeypot: off-screen, not display:none (some bots skip hidden fields). */
.contact-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.contact-turnstile {
    margin-top: 0.25rem;
}
.contact-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 480px) {
    .contact-form-row { grid-template-columns: 1fr; }
}
.contact-validation {
    color: var(--danger-color);
    font-size: 0.9rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.contact-validation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.form-label {
    font-weight: 600;
    font-size: 0.9rem;
}
.form-optional {
    font-weight: 400;
    color: var(--secondary-text);
    font-size: 0.8rem;
}
.form-input {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
}
.form-input:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    border-color: var(--accent-color);
    box-shadow: none;
}
.form-textarea {
    resize: vertical;
    min-height: 6rem;
}
.btn-submit {
    align-self: start;
    padding: 0.55rem 1.25rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn-submit:hover {
    background: var(--accent-hover);
}
.contact-success {
    border-color: var(--accent-color);
    background: var(--accent-muted);
}
.contact-success-msg {
    margin: 0;
    color: var(--text-color);
    font-weight: 500;
}
.contact-copy-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0 0 0.75rem;
}
.contact-email {
    font-size: 1rem;
    font-weight: 600;
}
.btn-copy {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    color: var(--secondary-text);
    cursor: pointer;
}
.btn-copy:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.contact-links-inline {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.contact-links-inline a {
    font-size: 0.95rem;
    font-weight: 500;
}

.error-wrap {
    text-align: center;
    padding: 2.5rem 2rem;
}
.error-wrap .btn-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.4rem 0;
}
.error-code {
    font-size: 6rem;
    margin-bottom: 0;
    line-height: 1;
}
.error-msg {
    color: var(--secondary-text);
    margin-bottom: 1.5rem;
}
.error-request-id {
    font-size: 0.85rem;
    color: var(--secondary-text);
}

/* Lab index: high-density table */
.lab-table-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}
.lab-search-input {
    flex: 1;
    min-width: 120px;
    max-width: 280px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 0.9rem;
}
.lab-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}
.lab-filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 0.9rem;
}
.lab-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.lab-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.1rem;
    font-size: 0.875rem;
}
.lab-table th,
.lab-table td {
    padding: 0.32rem 0.55rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.lab-table tbody tr.lab-table-row td {
    border: 1px solid var(--bg-color);
    border-left-width: 0;
    border-right-width: 0;
    border-bottom: 1px solid var(--bg-color);
    background-clip: padding-box;
    vertical-align: middle;
}
.lab-table tbody tr.lab-table-row td:first-child {
    border-left-width: 1px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.lab-table tbody tr.lab-table-row td:last-child {
    border-right-width: 1px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.lab-table tbody tr.lab-table-row:hover td {
    border-color: var(--accent-color);
}
.lab-table th {
    font-weight: 600;
    color: var(--secondary-text);
    white-space: nowrap;
}
@media (prefers-reduced-motion: no-preference) {
    .lab-table tbody tr.lab-table-row td {
        transition: border-color 0.15s ease;
    }
}
.lab-table-link {
    font-weight: 500;
    border: none;
}
.lab-table-link:hover {
    color: var(--accent-color);
}
.lab-table-kind {
    color: var(--secondary-text);
    font-size: 0.8rem;
    white-space: nowrap;
    text-transform: capitalize;
}
.lab-table-desc {
    color: var(--secondary-text);
    font-size: 0.85rem;
}
.lab-table-go {
    font-weight: 500;
    white-space: nowrap;
    color: var(--accent-color);
    border: none;
}
@media (max-width: 480px) {
    .lab-table-desc { display: none; }
    .lab-table th:nth-child(3) { display: none; }
}

/* Lab chrome (_Layout) â€” sidebar + nav (no duplicate page title) */
.lab-layout {
    display: grid;
    grid-template-columns: 248px 1fr;
    gap: var(--space-lg, 1.5rem);
    margin-top: 0;
    align-items: start;
    min-height: 0;
}
.lab-sidebar {
    border-right: 1px solid var(--border-color);
    padding-right: var(--space-md, 1rem);
    position: sticky;
    top: var(--site-header-offset);
    align-self: start;
    min-height: 0;
    max-height: calc(100vh - var(--site-header-offset) - 1rem);
    overflow-y: auto;
}
.lab-sidebar-content {
    padding-top: 2.25rem;
}
.lab-content {
    min-height: 0;
    --lab-fill: min(420px, calc(100vh - var(--site-header-offset) - 14rem));
}
.lab-overview {
    max-width: none;
}

.lab-tools-section-title {
    font-size: 1.15rem;
    margin-top: 1.75rem;
    margin-bottom: 0.35rem;
}
.lab-tools-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.75rem;
    max-width: 36rem;
}
.lab-tools-search-input {
    flex: 1 1 12rem;
    min-width: 0;
}
.lab-tools-search-submit {
    flex: 0 0 auto;
}
.lab-welcome {
    margin-bottom: var(--spacing-unit, 1.25rem);
}
.lab-featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md, 1rem);
}
.lab-featured-card {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s;
}
.lab-layout .nav-group {
    margin-bottom: 0.65rem;
    border-bottom: 1px solid transparent;
}
.lab-layout .nav-group h3,
.lab-layout .nav-group summary {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--secondary-text);
    margin-bottom: 0.35rem;
    margin-top: 0;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.lab-layout .nav-group summary::-webkit-details-marker {
    display: none;
}
.lab-layout .nav-group summary::after {
    content: '+';
    font-size: 0.95rem;
    font-weight: 400;
    opacity: 0.75;
}
.lab-layout .nav-group[open] summary::after {
    content: '−';
}
.lab-layout .nav-group ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}
.lab-layout .nav-group li {
    width: 100%;
}
.lab-layout .nav-group a {
    display: block;
    padding: 0.38rem 0.55rem;
    border-radius: var(--radius-sm);
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.15s ease;
    border: 1px solid transparent;
    font-size: 0.875rem;
}
.lab-layout .nav-group a:hover {
    background-color: var(--surface-color);
    border-color: var(--accent-color);
}
.lab-layout .nav-group a.active {
    background-color: var(--surface-color);
    font-weight: 600;
    color: var(--accent-color);
    border-color: var(--accent-color);
}
.lab-layout .nav-group .disabled {
    display: block;
    padding: 0.38rem 0.55rem;
    color: var(--secondary-text);
    font-style: italic;
    font-size: 0.85rem;
    cursor: not-allowed;
    opacity: 0.6;
}
.lab-layout .mobile-sidebar-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.lab-layout .mobile-sidebar-label {
    display: none;
}
@media (max-width: 768px) {
    .lab-layout {
        grid-template-columns: 1fr;
        gap: var(--space-md, 1rem);
    }
    .lab-content {
        --lab-fill: min(50vh, 320px);
        min-width: 0;
    }
    .lab-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 0.5rem;
        position: static;
        max-height: none;
    }
    .lab-sidebar-content {
        padding-top: 0;
    }
    .lab-layout .mobile-sidebar-label {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 44px;
        padding: 0.65rem 1rem;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        font-weight: 600;
        color: var(--text-color);
        cursor: pointer;
        margin-bottom: 0.75rem;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    .lab-layout .mobile-sidebar-toggle:focus-visible + .mobile-sidebar-label {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }
    .lab-layout .mobile-sidebar-label .toggle-icon {
        transition: transform 0.2s ease;
    }
    .lab-layout .mobile-sidebar-toggle:checked ~ .mobile-sidebar-label .toggle-icon {
        transform: rotate(180deg);
    }
    .lab-layout .lab-sidebar-content {
        display: none;
    }
    .lab-layout .mobile-sidebar-toggle:checked ~ .lab-sidebar-content {
        display: block;
        margin-top: 1rem;
        animation: lab-sidebar-slide 0.2s ease-out forwards;
    }
}
@keyframes lab-sidebar-slide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

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