/**
 * The Metaphysics of Product Management
 * ======================================
 * Design System: Encyclopedic / Wikipedia-inspired
 * 
 * Principles:
 * - Text-first, modular knowledge portal
 * - Near-monochrome with blue links
 * - Serif body, sans-serif UI
 * - Dense but scannable
 * - Calm, academic, timeless
 */

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
    /* Typography */
    --font-body: 'Georgia', 'Times New Roman', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Consolas', monospace;

    /* Type Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Colors - Near Monochrome */
    --color-bg: #ffffff;
    --color-bg-alt: #f8f9fa;
    --color-bg-highlight: #eaecf0;

    --color-text: #202122;
    --color-text-secondary: #54595d;
    --color-text-muted: #72777d;

    --color-border: #a2a9b1;
    --color-border-light: #c8ccd1;
    --color-border-subtle: #eaecf0;

    /* Links - Blue only */
    --color-link: #3366cc;
    --color-link-visited: #795cb2;
    --color-link-hover: #447ff5;
    --color-link-red: #ba0000;
    /* Missing articles, Wikipedia style */

    /* Rainbow gradient for accents */
    --gradient-rainbow: linear-gradient(90deg,
            #e63946 0%,
            #f4a261 20%,
            #e9c46a 40%,
            #2a9d8f 60%,
            #264653 80%,
            #023047 100%);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Layout */
    --nav-width: 200px;
    --content-max-width: 960px;
    --header-height: 3rem;

    /* Responsive Breakpoints (per responsive-design-rules.md) */
    /* Phone: 0-639, Tablet: 640-1023, Desktop: 1024-1279, Wide: 1280-1535, XL: 1536+ */
    --bp-phone-max: 639px;
    --bp-tablet-max: 1023px;
    --bp-desktop-max: 1279px;
    --bp-wide-max: 1535px;

    /* Missing Tokens for Modern Page Design */
    --max-width-content: 65ch;
    --color-bg-surface: #ffffff;
    --color-bg-elevated: #ffffff;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --tracking-wide: 0.025em;
    --tracking-widest: 0.1em;

    /* Motion / Animation (per design-system-rules.md) */
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);

    /* Z-Index Scale */
    --z-base: 0;
    --z-dropdown: 50;
    --z-sticky: 100;
    --z-fixed: 200;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-toast: 1100;

    /* Opacity */
    --opacity-disabled: 0.5;
    --opacity-hover: 0.8;
    --opacity-backdrop: 0.4;

    /* Focus Ring */
    --focus-ring-color: var(--color-link);
    --focus-ring-width: 2px;
    --focus-ring-offset: 2px;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--color-text);
    background-color: var(--color-bg);
}

/* ==========================================================================
   Links - Blue Only (Wikipedia style)
   ========================================================================== */

a {
    color: var(--color-link);
    text-decoration: none;
}

a:visited {
    color: var(--color-link-visited);
}

a:hover {
    text-decoration: underline;
}

a:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Reduced Motion Support (Accessibility)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-body);
    font-weight: normal;
    line-height: var(--leading-tight);
    color: var(--color-text);
}

h1 {
    font-size: var(--text-3xl);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-4);
}

h2 {
    font-size: var(--text-xl);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: var(--space-1);
    margin-top: var(--space-8);
    margin-bottom: var(--space-3);
}

h3 {
    font-size: var(--text-lg);
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
}

p {
    margin-bottom: var(--space-3);
}

ul,
ol {
    margin-left: var(--space-6);
    margin-bottom: var(--space-4);
}

li {
    margin-bottom: var(--space-1);
}

blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: var(--space-4);
    margin: var(--space-4) 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border-light);
    margin: var(--space-6) 0;
}

/* ==========================================================================
   Skip Link (Accessibility)
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: var(--space-4);
    background: var(--color-text);
    color: var(--color-bg);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    z-index: var(--z-modal);
}

.skip-link:focus {
    top: var(--space-2);
}

/* ==========================================================================
   Site Shell
   ========================================================================== */

.site-shell {
    display: grid;
    grid-template-columns: var(--nav-width) 1fr;
    grid-template-rows: var(--header-height) 1fr auto;
    grid-template-areas:
        "header header"
        "nav main"
        "footer footer";
    min-height: 100vh;
}

@media (max-width: 1023px) {
    .site-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "footer";
    }
}

/* ==========================================================================
   Top Utility Bar
   ========================================================================== */

.utility-bar {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-4);
    background-color: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border-light);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
}

.utility-bar__left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.utility-bar__right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.utility-bar a {
    color: var(--color-text-secondary);
}

.utility-bar a:hover {
    color: var(--color-link);
}

/* Search in utility bar (deprecated for central search) */
.search-form {
    display: flex;
    align-items: center;
    visibility: hidden;
    /* Hide in utility bar if central is present */
}

@media (max-width: 1023px) {
    .search-form {
        visibility: visible;
    }
}

/* ==========================================================================
   Command Palette & Central Search
   ========================================================================== */

.command-container {
    padding: var(--space-8) 0;
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.command-bar {
    position: relative;
    padding: 3px;
    background: var(--gradient-rainbow);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.command-bar:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.command-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--color-bg);
    border-radius: 6px;
    padding: var(--space-3) var(--space-4);
}

.command-input {
    flex: 1;
    border: none;
    font-family: var(--font-ui);
    font-size: var(--text-lg);
    color: var(--color-text);
    background: transparent;
    outline: none;
}

.command-key-hint {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    margin-left: var(--space-2);
}

/* Results Overlay / Palette Result List */
.palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 5vh var(--space-4) 5vh;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.palette-overlay--open {
    display: flex;
}

/* Rainbow gradient variables */
:root {
    --gradient-rainbow: linear-gradient(90deg,
            #667eea 0%,
            #764ba2 25%,
            #f093fb 50%,
            #4facfe 75%,
            #00f2fe 100%);
    --gradient-rainbow-subtle: linear-gradient(90deg,
            rgba(102, 126, 234, 0.1) 0%,
            rgba(118, 75, 162, 0.1) 25%,
            rgba(240, 147, 251, 0.1) 50%,
            rgba(79, 172, 254, 0.1) 75%,
            rgba(0, 242, 254, 0.1) 100%);
}

@keyframes rainbow-shimmer {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

.palette-modal {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}

.palette-header {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg-surface);
}

.palette-tabs {
    display: flex;
    gap: 0;
    padding: var(--space-3) var(--space-4) 0;
    border-bottom: 1px solid var(--color-border-light);
}

.palette-tab {
    padding: var(--space-2) var(--space-4);
    background: none;
    border: none;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.palette-tab:hover {
    color: var(--color-text);
}

.palette-tab.active {
    color: var(--color-text);
}

.palette-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-rainbow);
    border-radius: 3px 3px 0 0;
}

.palette-input-wrapper {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    gap: var(--space-3);
}

.palette-input {
    flex: 1;
    border: none;
    font-family: var(--font-ui);
    font-size: 18px;
    outline: none;
    background: transparent;
    color: var(--color-text);
}

.palette-input::placeholder {
    color: var(--color-text-muted);
}

.palette-input:focus {
    outline: none;
}

.command-key-hint {
    padding: 2px 8px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono, monospace);
    color: var(--color-text-muted);
}

.palette-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s ease;
}

.palette-close-btn:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.palette-results {
    overflow-y: auto;
    padding: var(--space-3);
    max-height: calc(75vh - 180px);
}

.palette-results::-webkit-scrollbar {
    width: 8px;
}

.palette-results::-webkit-scrollbar-track {
    background: var(--color-bg-alt);
}

.palette-results::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.palette-group {
    padding: var(--space-3) 0;
}

.palette-group:not(:last-child) {
    border-bottom: 1px solid var(--color-border-subtle);
}

.palette-group-title {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: var(--space-2) var(--space-3) var(--space-3);
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.palette-group-count {
    background: var(--color-bg-alt);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
}

.palette-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-3);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text);
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    transition: all 0.15s ease;
    border: 2px solid transparent;
}

.palette-item:hover {
    background-color: var(--color-bg-highlight);
    text-decoration: none;
    transform: translateX(2px);
}

.palette-item--active {
    background: var(--gradient-rainbow-subtle);
    border-color: transparent;
    border-left: 3px solid;
    border-image: var(--gradient-rainbow) 1;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.palette-item--active .palette-item-meta {
    color: var(--color-text-secondary);
}

.palette-item-icon {
    font-size: 20px;
    opacity: 0.8;
    flex-shrink: 0;
}

.palette-item-content {
    flex: 1;
    min-width: 0;
}

.palette-item-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.palette-item-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.palette-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.palette-shortcuts {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.palette-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kbd {
    padding: 2px 6px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    font-weight: 500;
}

/* Loading state */
.palette-loading {
    padding: var(--space-8);
    text-align: center;
}

.palette-loading-shimmer {
    width: 100%;
    height: 60px;
    background: linear-gradient(90deg,
            var(--color-bg-alt) 0%,
            var(--color-bg-highlight) 50%,
            var(--color-bg-alt) 100%);
    background-size: 200% 100%;
    animation: rainbow-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
    margin-bottom: var(--space-2);
}

/* Empty state */
.palette-empty {
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.palette-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.palette-empty-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.palette-empty-text {
    font-size: 14px;
    color: var(--color-text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* AI Chat Styles */
.palette-chat {
    display: flex;
    flex-direction: column;
    max-height: calc(75vh - 280px);
    padding: var(--space-4);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.palette-chat.hidden {
    display: none;
}

.chat-message {
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    border-radius: 8px;
    max-width: 85%;
    line-height: 1.6;
}

.chat-message--user {
    background: var(--gradient-rainbow-subtle);
    border-left: 3px solid;
    border-image: var(--gradient-rainbow) 1;
    margin-left: auto;
}

.chat-message--bot {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-light);
}

.chat-status {
    padding: var(--space-3);
    text-align: center;
    font-size: 13px;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Full-page AI Chat Mode */
.ai-chat-fullpage {
    position: fixed;
    top: 0;
    left: 260px;
    /* Account for side nav */
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    z-index: var(--z-modal-backdrop);
    display: none;
    flex-direction: column;
}

.ai-chat-fullpage.active {
    display: flex;
}

.ai-chat-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    background: var(--gradient-rainbow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.model-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--space-2) var(--space-6);
    font-size: 12px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border-light);
}

.model-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    animation: pulse 1.5s ease-in-out infinite;
}

.model-indicator.model-loaded .model-indicator-dot {
    background: #22c55e;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.ai-chat-input-container {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-surface);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.ai-chat-input {
    width: 100%;
    min-height: 60px;
    padding: var(--space-3);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 15px;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.ai-chat-input:focus {
    outline: none;
    border-color: transparent;
    border-image: var(--gradient-rainbow) 1;
}

.ai-chat-send {
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: var(--gradient-rainbow);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.ai-chat-send:hover {
    opacity: 0.9;
}

/* Mobile responsive */
@media (max-width: 639px) {
    .palette-modal {
        max-width: 100%;
        border-radius: 0;
        max-height: 100vh;
    }

    .palette-overlay {
        padding: 0;
    }

    .ai-chat-fullpage {
        left: 0;
    }

    .palette-item {
        padding: var(--space-3) var(--space-2);
    }
}


/* ==========================================================================
   Left Navigation
   ========================================================================== */

.site-nav {
    grid-area: nav;
    background-color: var(--color-bg-alt);
    border-right: 1px solid var(--color-border-light);
    padding: var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    overflow-y: auto;
}

@media (max-width: 1023px) {
    .site-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: min(280px, 85vw);
        height: calc(100vh - var(--header-height));
        z-index: var(--z-sticky);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .site-nav--open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* Backdrop overlay */
    .nav-backdrop {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: calc(var(--z-sticky) - 1);
    }

    .nav-backdrop--visible {
        display: block;
    }
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
}

.mobile-menu-toggle:hover {
    color: var(--color-text);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 1023px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

.nav-group {
    margin-bottom: var(--space-6);
}

.nav-group__title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.nav-group__list {
    list-style: none;
    margin: 0;
}

.nav-group__list li {
    margin-bottom: var(--space-1);
}

.nav-group__list a {
    display: block;
    padding: var(--space-1) 0;
    color: var(--color-link);
}

.nav-group__list a:hover {
    text-decoration: underline;
}

/* Rainbow accent line */
.nav-accent {
    height: 3px;
    background: var(--gradient-rainbow);
    margin: var(--space-4) 0;
    border-radius: 2px;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main-content {
    grid-area: main;
    padding: var(--space-6);
    max-width: var(--content-max-width);
}

/* ==========================================================================
   Article Tabs (Read / View Source / History)
   ========================================================================== */

.article-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
}

.article-tab {
    padding: var(--space-2) var(--space-4);
    background-color: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--color-link);
    cursor: pointer;
    position: relative;
    bottom: -1px;
}

.article-tab:hover {
    text-decoration: underline;
}

.article-tab--active {
    background-color: var(--color-bg);
    border-color: var(--color-border-light);
    color: var(--color-text);
    cursor: default;
}

.article-tab--active:hover {
    text-decoration: none;
}

/* ==========================================================================
   Module System (Smart Brevity)
   ========================================================================== */

.module {
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border-subtle);
}

.module:last-child {
    border-bottom: none;
}

.module__headline {
    font-size: var(--text-xl);
    font-weight: normal;
    margin-bottom: var(--space-2);
    border-bottom: none;
    padding-bottom: 0;
}

.module__lede {
    font-size: var(--text-base);
    color: var(--color-text);
    margin-bottom: var(--space-3);
}

.module__why {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-3);
}

.module__bullets {
    margin-left: var(--space-5);
    margin-bottom: var(--space-3);
}

.module__bullets li {
    margin-bottom: var(--space-2);
}

.module__more {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
}

/* ==========================================================================
   Table of Contents
   ========================================================================== */

.toc {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    display: inline-block;
    min-width: 200px;
}

.toc__title {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-2);
    text-align: center;
}

.toc__list {
    list-style: decimal;
    margin-left: var(--space-6);
    font-size: var(--text-sm);
}

.toc__list li {
    margin-bottom: var(--space-1);
}

/* ==========================================================================
   Info Box (Wikipedia style)
   ========================================================================== */

.infobox {
    float: right;
    width: 280px;
    margin-left: var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid var(--color-border-light);
    background-color: var(--color-bg-alt);
    font-size: var(--text-sm);
}

.infobox__title {
    background-color: var(--color-bg-highlight);
    padding: var(--space-2) var(--space-3);
    font-weight: 600;
    text-align: center;
    font-family: var(--font-ui);
}

.infobox__row {
    display: flex;
    border-top: 1px solid var(--color-border-light);
}

.infobox__label {
    width: 40%;
    padding: var(--space-2) var(--space-3);
    background-color: var(--color-bg-alt);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.infobox__value {
    width: 60%;
    padding: var(--space-2) var(--space-3);
    background-color: var(--color-bg);
}

@media (max-width: 639px) {
    .infobox {
        float: none;
        width: 100%;
        margin-left: 0;
        margin-bottom: var(--space-4);
    }
}

/* ==========================================================================
   Statistics Grid
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-4);
    margin: var(--space-4) 0;
}

.stat-item {
    text-align: center;
    padding: var(--space-3);
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
}

.stat-item__value {
    font-size: var(--text-2xl);
    font-weight: normal;
    color: var(--color-text);
    display: block;
}

.stat-item__label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Horizontal List (inline navigation)
   ========================================================================== */

.hlist {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: var(--text-sm);
}

.hlist li::after {
    content: " · ";
    color: var(--color-text-muted);
}

.hlist li:last-child::after {
    content: "";
}

/* ==========================================================================
   Categories (bottom of article)
   ========================================================================== */

.categories {
    margin-top: var(--space-8);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
}

.categories__label {
    font-weight: 600;
    color: var(--color-text-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    grid-column: 1 / -1;
    background-color: var(--color-bg-alt);
    border-top: 1px solid var(--color-border-light);
    padding: var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
}

.site-footer a {
    color: var(--color-text-secondary);
}

/* Rainbow footer accent */
.footer-accent {
    height: 3px;
    background: var(--gradient-rainbow);
    margin-bottom: var(--space-4);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

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

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-small {
    font-size: var(--text-sm);
}

.font-ui {
    font-family: var(--font-ui);
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Filter Components (Usability-First Design)
   ========================================================================== */

.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-subtle);
    border-radius: 8px;
    margin-bottom: var(--space-6);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 140px;
}

.filter-group--search {
    flex: 1;
    min-width: 200px;
}

/* Labels above inputs (A2 rule: persistent, visible labels) */
.filter-label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

/* Search input with icon */
.filter-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.filter-search-icon {
    position: absolute;
    left: 12px;
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color 0.2s ease;
}

.filter-input {
    width: 100%;
    height: 44px;
    /* Touch target minimum */
    padding: var(--space-3) var(--space-4);
    padding-left: 40px;
    /* Space for icon */
    font-family: var(--font-ui);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.filter-input:hover {
    border-color: var(--color-border);
}

.filter-input:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.15);
}

.filter-input:focus+.filter-search-icon,
.filter-input-wrapper:focus-within .filter-search-icon {
    color: var(--color-link);
}

.filter-input::placeholder {
    color: var(--color-text-muted);
}

/* Helper text below input */
.filter-hint {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-style: italic;
}

/* Select dropdowns */
.filter-select {
    height: 44px;
    padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

/* Alphabet Nav Bar */
.alphabet-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--color-bg-alt);
    padding: 8px;
    border-radius: 8px;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border-subtle);
}

.alphabet-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    text-decoration: none;
    font-weight: 600;
    color: var(--color-text-muted);
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 12px;
    font-family: var(--font-ui);
}

.alphabet-link:hover {
    background: var(--color-bg-surface);
    color: var(--color-link);
}

.alphabet-link--disabled {
    opacity: 0.2;
    pointer-events: none;
}

/* Concept Group Headers */
.concept-group-header {
    font-family: var(--font-display);
    font-size: 2rem;
    margin: 4rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-border-light);
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    scroll-margin-top: 60px;
}

.concept-group-header::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--color-border-subtle);
}

/* Touch target minimum */
padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4);
font-family: var(--font-ui);
font-size: var(--text-sm);
color: var(--color-text);
background: var(--color-bg);
border: 1px solid var(--color-border-light);
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
-webkit-appearance: none;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2372777d'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
background-size: 16px;
}

.filter-select:hover {
    border-color: var(--color-border);
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.15);
}

/* Clear filters button */
.filter-clear {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    align-self: flex-end;
    height: 44px;
    padding: 0 var(--space-4);
    margin-bottom: 0;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-link);
    background: transparent;
    border: 1px solid var(--color-link);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-clear:hover {
    background: var(--color-link);
    color: white;
}

.filter-clear:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.15);
}

.filter-clear svg {
    flex-shrink: 0;
}

/* Results bar */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
}

.results-count {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.results-count__number {
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--text-lg);
}

.results-count__label {
    margin-left: var(--space-1);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sort-label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sort-btn {
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.sort-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(51, 102, 204, 0.2);
}

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

.sort-btn--active:hover {
    background: var(--color-text-secondary);
    border-color: var(--color-text-secondary);
    color: var(--color-bg);
}

/* Loading state */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-16) 0;
    color: var(--color-text-muted);
    font-family: var(--font-ui);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border-light);
    border-top-color: var(--color-link);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.6;
}

.empty-state__title {
    font-family: var(--font-ui);
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.empty-state__text {
    font-family: var(--font-ui);
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
}

.empty-state__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-link);
    background: transparent;
    border: 1px solid var(--color-link);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.empty-state__btn:hover {
    background: var(--color-link);
    color: white;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-10);
    padding: var(--space-4) 0;
}

/* Responsive adjustments */
@media (max-width: 639px) {
    .filter-container {
        flex-direction: column;
        gap: var(--space-4);
    }

    .filter-group {
        width: 100%;
        min-width: 0;
    }

    .filter-group--search {
        min-width: 0;
    }

    .filter-clear {
        width: 100%;
        justify-content: center;
    }

    .results-bar {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }

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

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {

    .site-nav,
    .utility-bar,
    .article-tabs,
    .search-form {
        display: none;
    }

    .site-shell {
        display: block;
    }

    .main-content {
        max-width: none;
        padding: 0;
    }

    a {
        color: var(--color-text);
    }

    a::after {
        content: " (" attr(href) ")";
        font-size: var(--text-sm);
        color: var(--color-text-muted);
    }
}

/* ==========================================================================
   Portal Components (Site-wide)
   ========================================================================== */

/* Page Header & Tabs */
.article-tabs {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border-subtle);
}

.article-tab {
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.article-tab--active {
    color: var(--color-text);
    border-bottom-color: var(--color-link);
    font-weight: 600;
}

/* Grids */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
    margin: var(--space-6) 0;
}

/* Cards */
.portal-card {
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    transition: box-shadow 0.2s ease;
}

.portal-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: var(--color-border);
}

.portal-card__thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background-color: var(--color-bg-alt);
}

.portal-card__content {
    padding: var(--space-4);
    flex: 1;
}

.portal-card__guest {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-link);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-1);
}

.portal-card__title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    color: var(--color-text);
    line-height: var(--leading-snug);
    margin-bottom: var(--space-3);
}

/* Hero Sections (Wikipedia-style) */
.portal-hero {
    margin-bottom: var(--space-8);
}

.portal-hero h1 {
    margin-bottom: var(--space-2);
}

.portal-hero__desc {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    max-width: 800px;
}

/* Legendary Guests */
.legendary-guests {
    margin-bottom: var(--space-8);
}

.legendary-card {
    display: flex;
    flex-direction: column;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.legendary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-rainbow);
}

.legendary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--color-border);
}

.legendary-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.legendary-role {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   Command Palette
   ========================================================================== */

.palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: none;
    /* Hidden by default */
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.palette-overlay--open {
    display: flex;
}

.palette-modal {
    width: 100%;
    max-width: 600px;
    background-color: var(--color-bg);
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.palette-header {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
}

.palette-input {
    flex: 1;
    border: none;
    background: none;
    font-family: var(--font-ui);
    font-size: var(--text-lg);
    color: var(--color-text);
    outline: none;
}

.palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-2) 0;
}

.palette-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    text-decoration: none;
    color: var(--color-text-secondary);
    transition: background-color 0.1s ease;
}

.palette-item:hover,
.palette-item--active {
    background-color: var(--color-bg-alt);
    color: var(--color-link);
}

.palette-item-icon {
    margin-right: var(--space-4);
    font-size: 1.25rem;
}

.palette-item-content {
    flex: 1;
}

.palette-item-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.palette-item-meta {
    font-size: var(--text-xs);
    opacity: 0.7;
}

.palette-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    background-color: var(--color-bg-alt);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.palette-shortcuts {
    display: flex;
    gap: var(--space-4);
}

.palette-shortcut {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.kbd {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 1px 4px;
    font-family: monospace;
}

/* ==========================================================================
   Command Palette Chat Interface
   ========================================================================== */
.palette-tabs {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-4) 0;
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-bg-surface);
}

.palette-tab {
    background: none;
    border: none;
    padding: var(--space-2) var(--space-1);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.palette-tab:hover {
    color: var(--color-text);
}

.palette-tab.active {
    color: var(--color-link);
    border-bottom-color: var(--color-link);
}

.palette-chat {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-height: 300px;
}

.palette-chat.hidden {
    display: none;
}

.chat-message {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: 1.6;
    max-width: 90%;
    animation: fadeIn 0.3s ease;
}

.chat-message--user {
    align-self: flex-end;
    background: var(--color-bg-highlight);
    color: var(--color-text);
    border-bottom-right-radius: 2px;
}

.chat-message--bot {
    align-self: flex-start;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-bottom-left-radius: 2px;
}

.chat-status {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
    padding: var(--space-2);
    background: var(--color-bg-highlight);
    border-radius: var(--radius-md);
    margin-top: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AI Expert CTA Button */
.ai-expert-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 9999px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

/* AI Expert CTA Button */
.ai-expert-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    min-height: 48px;
    background: #000000;
    /* Hardcoded Black */
    color: #ffffff !important;
    /* Hardcoded White */
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    margin: 1.5rem 0;
    position: relative;
    z-index: var(--z-base);
}

.ai-expert-cta:visited {
    color: #ffffff !important;
}

.ai-expert-cta:hover {
    background: #ffffff;
    /* Hardcoded White */
    color: #000000 !important;
    /* Hardcoded Black */
    border-color: #000000;
    /* Hardcoded Black */
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

.ai-expert-cta:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
    .ai-expert-cta {
        width: 100%;
    }
}

/* Chat System Message (Context) */
.chat-message--system {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.chat-message--system strong {
    color: var(--text-main);
    font-weight: 600;
}

/* ==========================================================================
   Container Queries - Component-level Responsiveness
   (per responsive-design-rules.md Section 3)
   ========================================================================== */

/* Enable container queries on grid wrappers */
.portal-grid,
.episodes-grid,
.guests-grid {
    container-type: inline-size;
}

/* Card adaptations based on container width */
@container (max-width: 400px) {
    .portal-card {
        padding: var(--space-3);
    }

    .portal-card__title {
        font-size: var(--text-base);
    }

    .portal-card__meta {
        font-size: var(--text-xs);
    }
}

@container (min-width: 600px) {
    .portal-card {
        padding: var(--space-5);
    }
}

/* ==========================================================================
   Reading Width Constraints
   (per responsive-design-rules.md Section 4.1: 60-80 chars)
   ========================================================================== */

/* Apply max-width to prose content areas */
.main-content p,
.main-content .concept-definition,
.main-content .dd-content,
.main-content blockquote,
.theme-main p,
.engine-main p,
.archetype-main p {
    max-width: var(--max-width-content);
}

/* Ensure article-level text doesn't disperse on wide screens */
.concept-main,
.theme-main,
.engine-main,
.archetype-main {
    max-width: 75ch;
}

/* ==========================================================================
   Utility Classes (per development-rules.md - replacing inline styles)
   ========================================================================== */

/* Nav footer link spacing */
.nav-link--spaced {
    margin-top: var(--space-4);
}

/* Subtle link (inherits color, no decoration) */
.link--subtle {
    text-decoration: none;
    color: inherit;
}

.link--subtle:hover {
    text-decoration: underline;
}

/* Footer attribution */
.footer-attribution {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    opacity: 0.8;
}

.footer-attribution a {
    color: inherit;
    text-decoration: underline;
}

/* Hidden by default (JS controlled) */
.u-hidden {
    display: none;
}

/* Flex row with gap */
.u-flex-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}