/* ==========================================================================
   YBX.CC.CD - Next-Gen Olympiad & Science Platform Design System
   Top Hierarchy: [信息学 | 数学 | 化学] ->Sub-Feature Interactive Workspaces
   Includes Dynamic Table of Contents (TOC) & Adaptive Fluid Layouts
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    /* Obsidian Dark Theme */
    --bg-base: #06080e;
    --bg-surface: rgba(14, 18, 28, 0.75);
    --bg-surface-elevated: rgba(20, 26, 42, 0.85);
    --bg-surface-hover: rgba(28, 36, 58, 0.95);
    --bg-glass-input: rgba(10, 13, 22, 0.8);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-active: rgba(99, 102, 241, 0.55);
    --border-glow: rgba(99, 102, 241, 0.25);

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-inverted: #030712;

    /* Brand Accents */
    --brand-indigo: #6366f1;
    --brand-blue: #3b82f6;
    --brand-cyan: #06b6d4;
    --brand-emerald: #10b981;
    --brand-violet: #a855f7;
    --brand-amber: #f59e0b;
    --brand-rose: #f43f5e;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #3b82f6 50%, #06b6d4 100%);
    --gradient-math: linear-gradient(135deg, #c084fc 0%, #a855f7 50%, #6366f1 100%);
    --gradient-chem: linear-gradient(135deg, #34d399 0%, #10b981 50%, #06b6d4 100%);
    --gradient-mol: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow-indigo: 0 0 28px rgba(99, 102, 241, 0.35);
    --shadow-glow-emerald: 0 0 28px rgba(16, 185, 129, 0.35);

    /* Radii */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --radius-pill: 9999px;

    /* Fonts */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Light Theme Variables */
html.light-theme {
    --bg-base: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.88);
    --bg-surface-elevated: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-glass-input: #ffffff;

    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-medium: rgba(0, 0, 0, 0.14);
    --border-active: rgba(99, 102, 241, 0.6);
    --border-glow: rgba(99, 102, 241, 0.2);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverted: #ffffff;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 85% 15%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 85%, rgba(16, 185, 129, 0.08) 0px, transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}
html.light-theme body::before {
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-indigo);
}

/* ==========================================================================
   Header & 3-Discipline Navigation Dock
   ========================================================================== */
header.portal-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: center;
    pointer-events: none;
    transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}





.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 0.5rem;
}

.header-container {
    pointer-events: auto;
    width: 100%;
    max-width: 1720px;
    background: var(--bg-surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 10% Opacity Ultra-Frosted Glass When Scrolled Down */
header.portal-header.is-scrolled {
    padding: 0.65rem 1.5rem;
}

header.portal-header.is-scrolled 



.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 0.5rem;
}

.header-container {
    background: rgba(6, 8, 14, 0.10); /* 10% opacity */
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}

html.light-theme header.portal-header.is-scrolled 



.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 0.5rem;
}

.header-container {
    background: rgba(255, 255, 255, 0.10); /* 10% opacity in light mode */
    border-color: rgba(0, 0, 0, 0.07);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.06);
}

header.portal-header.is-scrolled .nav-discipline-dock {
    background: rgba(10, 13, 22, 0.25);
    backdrop-filter: blur(16px);
}
html.light-theme header.portal-header.is-scrolled .nav-discipline-dock {
    background: rgba(241, 245, 249, 0.35);
}


.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}
.brand-logo-gem {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 1.15rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand-section:hover .brand-logo-gem {
    transform: scale(1.08) rotate(4deg);
}
.brand-text-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
html.light-theme .brand-text-title {
    background: linear-gradient(135deg, #0f172a 30%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-badge-pill {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* 3-Discipline Navigation Dock */
.nav-discipline-dock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(10, 13, 22, 0.7);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
}
html.light-theme .nav-discipline-dock {
    background: rgba(241, 245, 249, 0.85);
}

.nav-discipline-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 1.4rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}
.nav-discipline-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.nav-discipline-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45);
}
.nav-discipline-btn[data-disc="math"].active {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    box-shadow: 0 4px 18px rgba(168, 85, 247, 0.45);
}
.nav-discipline-btn[data-disc="chem"].active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 18px rgba(168, 85, 247, 0.45);
}

.theme-switch-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-medium);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.theme-switch-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}

/* ==========================================================================
   Secondary Sub-Navigation Bar
   ========================================================================== */
.subnav-island-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.5rem;
    max-width: fit-content;
    margin: 0 auto 2.25rem auto;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
}

.subnav-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 1.15rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}
.subnav-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}
.subnav-tab-btn.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid var(--border-medium);
}
.discipline-info .subnav-tab-btn.active {
    background: var(--brand-indigo);
    border-color: var(--brand-indigo);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.discipline-math .subnav-tab-btn.active {
    background: var(--brand-violet);
    border-color: var(--brand-violet);
    box-shadow: 0 2px 10px rgba(168, 85, 247, 0.4);
}

.discipline-chem .subnav-tab-btn.active {
    background: var(--brand-emerald);
    border-color: var(--brand-emerald);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}

/* ==========================================================================
   Main Workspace Layout
   ========================================================================== */
main.portal-main {
    position: relative;
    z-index: 1;
    flex: 1;
    max-width: 1720px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem clamp(1rem, 2.5vw, 2.5rem) 4rem clamp(1rem, 2.5vw, 2.5rem);
}

.discipline-view {
    display: none;
    animation: fadeInView 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.discipline-view.active {
    display: block;
}

.sub-feature-view {
    display: none;
    animation: fadeInView 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.sub-feature-view.active {
    display: block;
}

@keyframes fadeInView {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Section */
.hero-stage {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0.5rem 0;
}
.hero-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.95rem;
    border-radius: var(--radius-pill);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 0.8rem;
    font-weight: 700;
    color: #818cf8;
    margin-bottom: 1.15rem;
}
.hero-headline {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.15;
    background: linear-gradient(135deg, #ffffff 20%, #cbd5e1 60%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.75rem;
}
html.light-theme .hero-headline {
    background: linear-gradient(135deg, #0f172a 20%, #334155 60%, #64748b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-desc {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.65;
}

/* Buttons */
.btn-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.btn-mesh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.35rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    text-decoration: none;
}
.btn-mesh.primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.btn-mesh.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}
.btn-mesh.emerald {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}
.btn-mesh.emerald:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}
.btn-mesh.secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}
.btn-mesh.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-active);
    transform: translateY(-1px);
}

/* ==========================================================================
   Module 1:  信竞代码格式化器 (OI Formatter)
   ========================================================================== */
.formatter-feature-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
    margin-bottom: 1.75rem;
}
.feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.formatter-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    padding: 0.9rem 1.4rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(16px);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.editor-workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    min-height: 560px;
    height: calc(100vh - 400px);
}

.editor-pane-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    overflow: hidden;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}
.editor-pane-card:focus-within {
    border-color: var(--brand-indigo);
    box-shadow: var(--shadow-glow-indigo);
}

.editor-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: rgba(10, 13, 22, 0.9);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.825rem;
    font-weight: 600;
}
html.light-theme .editor-window-header {
    background: rgba(241, 245, 249, 0.95);
}

.window-traffic-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}
.traffic-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.traffic-dot.red { background: #ef4444; }
.traffic-dot.yellow { background: #f59e0b; }
.traffic-dot.green { background: #10b981; }

.editor-text-canvas {
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 1.25rem;
    background: var(--bg-glass-input);
    border: none;
    outline: none;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.65;
    resize: none;
    tab-size: 4;
}
html.light-theme .editor-text-canvas {
    color: #0f172a;
}

/* ==========================================================================
   Module 2:  信竞算法教程库 (Tutorials Hub)
   ========================================================================== */
.tutorials-filter-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}
.filter-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.pill-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
}
.pill-filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
    background: var(--bg-surface-hover);
}
.pill-filter-btn.active {
    background: var(--brand-indigo);
    color: #ffffff;
    border-color: var(--brand-indigo);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.search-input-glowing {
    position: relative;
    min-width: 280px;
}
.search-input-glowing input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    transition: all 0.2s ease;
}
.search-input-glowing input:focus {
    border-color: var(--brand-indigo);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.search-input-glowing svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.tutorials-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
}
.tutorial-item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    backdrop-filter: blur(16px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.tutorial-item-card::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.tutorial-item-card:hover {
    transform: translateY(-4px);
    border-color: var(--brand-indigo);
    background: var(--bg-surface-hover);
    box-shadow: var(--shadow-glow-indigo);
}
.tutorial-item-card:hover::after {
    opacity: 1;
}
.card-header-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}
.category-tag-chip {
    font-size: 0.725rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.card-article-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.65rem;
    letter-spacing: -0.02em;
}
.card-article-preview {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
    flex: 1;
    margin-bottom: 1.25rem;
}
.card-footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.825rem;
    color: var(--text-tertiary);
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Reader View with Clear, Visible Table of Contents (TOC) Outline
   ========================================================================== */
.reader-container-island {
    display: none;
    width: 100%;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 2.5rem clamp(1.5rem, 3.5vw, 3.5rem);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow-lg);
}
.reader-container-island.active {
    display: block;
    animation: fadeInView 0.25s ease-out forwards;
}

.reader-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.reader-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1.15rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.reader-back-btn:hover {
    color: var(--text-primary);
    border-color: var(--brand-indigo);
    transform: translateX(-2px);
}

.reader-quick-select {
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--bg-glass-input);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

/* Split Layout: Wide Article + Floating Dot Rail (Expands to 3-column Studio Mode in Split Mode) */
.reader-split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 2rem;
    align-items: start;
    transition: grid-template-columns 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.reader-split-layout.toc-expanded,
.reader-split-layout:has(.reader-toc-sidebar:hover) {
    grid-template-columns: minmax(0, 1fr) 260px;
}

/* True Left-Right 50/50 Dual-Pane Split Screen Mode (Left: Article | Right: Live Visualizer) */
.reader-split-layout.split-vis-active {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr) !important;
    gap: 2.25rem;
}

.reader-split-layout.split-vis-active .reader-toc-sidebar {
    display: none !important;
}

.reader-main-column {
    min-width: 0;
    width: 100%;
}


/* Reader Split Live Visualizer Panel */
.reader-split-vis-panel {
    position: sticky;
    top: 85px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    backdrop-filter: blur(24px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 24px rgba(99, 102, 241, 0.15);
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    animation: fadeInView 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    z-index: 10;
}

html.light-theme .reader-split-vis-panel {
    background: #ffffff;
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1), 0 0 24px rgba(99, 102, 241, 0.1);
}

.reader-split-vis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Sleek adaptations when visualizer workbench is docked inside reader split panel */
.reader-split-vis-panel .visualizer-workbench-card {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
}

.reader-split-vis-panel .visualizer-algo-tabs,
.reader-split-vis-panel .hero-stage,
.reader-split-vis-panel [style*="图论专题算法"],
.reader-split-vis-panel [style*="经典数据结构与算法"] {
    display: none !important;
}

.reader-split-vis-panel .visualizer-screen-stage {
    min-height: auto;
    padding: 1rem;
    background: rgba(4, 6, 10, 0.5);
}
html.light-theme .reader-split-vis-panel .visualizer-screen-stage {
    background: #f8fafc;
}


/* TOC Sidebar: Consistent Modern Box with 12px Radius (NO Pill/Capsule Shape!) */
.reader-toc-sidebar {
    position: sticky;
    top: 96px;
    background: rgba(14, 18, 28, 0.75);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); /* Consistent 12px radius, NO capsule shape */
    padding: 12px 6px;
    backdrop-filter: blur(24px);
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-sm);
    transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                padding 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                background 0.3s ease, 
                border-color 0.3s ease, 
                box-shadow 0.35s ease;
    width: 40px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-self: end;
    z-index: 20;
}

.reader-toc-sidebar.is-hovered,
.reader-toc-sidebar:hover,
.reader-split-layout.toc-expanded .reader-toc-sidebar {
    width: 260px;
    border-radius: var(--radius-md); /* Keeps consistent 12px radius */
    background: var(--bg-surface-elevated);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.15);
    padding: 14px 14px;
}

html.light-theme .reader-toc-sidebar {
    background: rgba(241, 245, 249, 0.9);
}
html.light-theme .reader-toc-sidebar.is-hovered,
html.light-theme .reader-toc-sidebar:hover,
html.light-theme .reader-split-layout.toc-expanded .reader-toc-sidebar {
    background: #ffffff;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 20px rgba(99, 102, 241, 0.1);
}

/* Header Title */
.toc-header-title {
    display: flex;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-indigo);
    margin-bottom: 0;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.25s ease, 
                margin-bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.reader-toc-sidebar.is-hovered .toc-header-title,
.reader-toc-sidebar:hover .toc-header-title,
.reader-split-layout.toc-expanded .toc-header-title {
    max-height: 32px;
    opacity: 1;
    margin-bottom: 0.75rem;
}

/* Navigation List */
.toc-nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.toc-nav-list::before {
    display: none !important;
}

.toc-link-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    padding: 4px 2px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    cursor: pointer;
    min-height: 24px;
}

.toc-dot-wrap {
    width: 26px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toc-dot-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html.light-theme .toc-dot-pip {
    background: rgba(0, 0, 0, 0.35);
}

.toc-link-item:hover .toc-dot-pip,
.toc-link-item.active .toc-dot-pip {
    background: var(--brand-indigo);
    transform: scale(1.35);
    box-shadow: 0 0 12px var(--brand-indigo);
}

/* Text labels: Hidden in idle dot mode, smoothly slides out horizontally on hover */
.toc-label-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 0;
    transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.25s ease, 
                margin-left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.reader-toc-sidebar.is-hovered .toc-label-text,
.reader-toc-sidebar:hover .toc-label-text,
.reader-split-layout.toc-expanded .toc-label-text {
    opacity: 1;
    max-width: 200px;
    margin-left: 6px;
    pointer-events: auto;
}

.reader-toc-sidebar.is-hovered .toc-link-item:hover,
.reader-toc-sidebar:hover .toc-link-item:hover,
.reader-split-layout.toc-expanded .toc-link-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(3px);
}
html.light-theme .reader-toc-sidebar.is-hovered .toc-link-item:hover,
html.light-theme .reader-toc-sidebar:hover .toc-link-item:hover,
html.light-theme .reader-split-layout.toc-expanded .toc-link-item:hover {
    color: var(--brand-indigo);
    background: rgba(99, 102, 241, 0.08);
}

.reader-toc-sidebar.is-hovered .toc-link-item.active,
.reader-toc-sidebar:hover .toc-link-item.active,
.reader-split-layout.toc-expanded .toc-link-item.active {
    color: var(--brand-indigo);
    font-weight: 700;
}




.reader-toc-sidebar:hover .toc-link-item.active,
.reader-split-layout.toc-expanded .toc-link-item.active {
    color: var(--brand-indigo);
    font-weight: 700;
    background: rgba(99, 102, 241, 0.14);
}



.markdown-article {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.85;
}
.markdown-article h1,
.markdown-article h2,
.markdown-article h3,
.markdown-article h4 {
    color: var(--text-primary);
    font-weight: 800;
    margin-top: 2.5rem;
    margin-bottom: 0.85rem;
    letter-spacing: -0.025em;
    scroll-margin-top: 100px;
}
.markdown-article h1 { font-size: 1.85rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem; }
.markdown-article h2 { font-size: 1.45rem; }
.markdown-article h3 { font-size: 1.2rem; }
.markdown-article h4 { font-size: 1.05rem; }
.markdown-article p { margin-bottom: 1.35rem; color: var(--text-secondary); }
.markdown-article ul, .markdown-article ol { margin-bottom: 1.35rem; padding-left: 1.6rem; color: var(--text-secondary); }
.markdown-article blockquote {
    margin: 1.75rem 0;
    padding: 0.85rem 1.4rem;
    border-left: 4px solid var(--brand-indigo);
    background: rgba(99, 102, 241, 0.08);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-primary);
}
.markdown-article code:not(pre code) {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.2em 0.45em;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--brand-cyan);
}

.code-block-wrapper {
    margin: 1.75rem 0;
    border-radius: var(--radius-md);
    background: #080b12;
    border: 1px solid var(--border-medium);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: #0e1320;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}
.code-block-wrapper pre {
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.94rem;
    line-height: 1.65;
    background: transparent !important;
}

/* ==========================================================================
   Module 3:  可视化交互教程专区 (Expanded Algorithm Lab)
   ========================================================================== */
.visualizer-workbench-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}
.visualizer-algo-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.85rem;
    margin-bottom: 2rem;
}
.vis-card-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.15rem;
    background: rgba(10, 13, 22, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
}
html.light-theme .vis-card-tab-btn {
    background: rgba(241, 245, 249, 0.8);
}
.vis-card-tab-btn:hover {
    border-color: var(--brand-indigo);
    background: var(--bg-surface-hover);
    transform: translateY(-2px);
}
.vis-card-tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(6, 182, 212, 0.12));
    border-color: var(--brand-indigo);
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.25);
}
.vis-card-tab-btn .vis-btn-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.vis-card-tab-btn .vis-btn-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.visualizer-screen-stage {
    background: rgba(8, 10, 16, 0.75);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    min-height: 480px;
    display: flex;
    flex-direction: column;
}
html.light-theme .visualizer-screen-stage {
    background: #ffffff;
}

.vis-action-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.vis-live-status-pill {
    padding: 0.85rem 1.35rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    min-height: 46px;
    display: flex;
    align-items: center;
}

/* Binary Search Array */
.binary-array-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 2.5rem 0;
}
.array-slot-cell {
    width: 52px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}
.array-slot-cell .slot-idx {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}
.array-slot-cell.left-ptr {
    border-color: var(--brand-cyan);
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.4);
}
.array-slot-cell.right-ptr {
    border-color: var(--brand-violet);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.4);
}
.array-slot-cell.mid-ptr {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--brand-amber);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
    transform: scale(1.1);
}
.array-slot-cell.found {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--brand-emerald);
    box-shadow: 0 0 24px var(--shadow-glow-emerald);
    transform: scale(1.15);
}
.array-slot-cell.eliminated {
    opacity: 0.2;
}

/* Sorting Visualizer Bars */
.sorting-bars-canvas {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 5px;
    height: 280px;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.35);
    border-radius: var(--radius-md);
    margin: 1rem 0;
}
.sort-column-bar {
    flex: 1;
    max-width: 24px;
    background: linear-gradient(180deg, #6366f1, #3b82f6);
    border-radius: 4px 4px 0 0;
    transition: height 0.1s ease, background-color 0.15s ease;
}
.sort-column-bar.comparing {
    background: linear-gradient(180deg, #f59e0b, #d97706);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}
.sort-column-bar.swapping {
    background: linear-gradient(180deg, #ef4444, #b91c1c);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.7);
}
.sort-column-bar.sorted {
    background: linear-gradient(180deg, #10b981, #059669);
    box-shadow: 0 0 12px var(--shadow-glow-emerald);
}

/* --- New: Dijkstra & Graph General Stage --- */
.dijkstra-graph-stage {
    position: relative;
    width: 100%;
    height: 340px;
    background: rgba(4, 6, 10, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.dijkstra-node-circle {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-primary);
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    z-index: 2;
}
.dijkstra-node-circle.current {
    background: rgba(245, 158, 11, 0.3);
    border-color: var(--brand-amber);
    box-shadow: 0 0 20px var(--brand-amber);
}
.dijkstra-node-circle.visited {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--brand-emerald);
    box-shadow: 0 0 16px var(--shadow-glow-emerald);
}
.dijkstra-dist-table {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.dist-item-badge {
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dist-item-badge.updated {
    border-color: var(--brand-cyan);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

/* --- New: Kruskal Edge Table --- */
.kruskal-edge-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.kruskal-edge-pill {
    padding: 0.4rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.25s ease;
}
.kruskal-edge-pill.accepted {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--brand-emerald);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}
.kruskal-edge-pill.rejected {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #94a3b8;
    text-decoration: line-through;
}
.kruskal-edge-pill.current {
    border-color: var(--brand-amber);
    box-shadow: 0 0 14px var(--brand-amber);
}

/* --- New: TopoSort Pipeline --- */
.topo-order-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(10, 13, 22, 0.7);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-top: 1.5rem;
    min-height: 60px;
}
.topo-node-badge {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: var(--font-mono);
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- New: Hungarian Bipartite Stage --- */
.hungarian-dual-stage {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: relative;
    height: 340px;
    background: rgba(4, 6, 10, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.bipartite-col {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    z-index: 2;
}
.bipartite-node-chip {
    padding: 0.65rem 1.25rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-weight: 800;
    min-width: 90px;
    text-align: center;
    transition: all 0.25s ease;
}
.bipartite-node-chip.matched {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--brand-emerald);
    box-shadow: 0 0 14px var(--shadow-glow-emerald);
}

/* --- New: Tarjan & LCA Canvas --- */
.tarjan-stack-box {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    align-items: center;
}
.tarjan-scc-cluster {
    padding: 0.5rem 1.15rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


/* --- New: Segment Tree Visualizer --- */
.segtree-tree-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    overflow-x: auto;
    padding: 1.5rem 0;
}
.segtree-level-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}
.segtree-node-box {
    padding: 0.6rem 0.9rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    font-family: var(--font-mono);
    transition: all 0.3s ease;
}
.segtree-node-box.highlight {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--brand-indigo);
    box-shadow: 0 0 18px rgba(99, 102, 241, 0.5);
    transform: scale(1.08);
}
.segtree-node-box.lazy {
    border-color: var(--brand-amber);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
}

/* --- Advanced Segment Trees Styles --- */
/* Dynamic Segment Tree Nodes */
.dst-node-box {
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    transition: all 0.3s ease;
}
.dst-node-box.allocated {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--brand-emerald);
    color: var(--text-primary);
}
.dst-node-box.uncreated {
    opacity: 0.3;
    border-style: dashed;
    border-color: var(--border-subtle);
    background: transparent;
}
.dst-node-box.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--brand-violet);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.5);
    transform: scale(1.08);
}
.dst-node-box.query-hit {
    background: rgba(6, 182, 212, 0.25);
    border-color: var(--brand-cyan);
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.4);
}

/* Weight Segment Tree Histogram */
.wst-hist-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
}
.wst-hist-bar-fill {
    width: 100%;
    max-width: 32px;
    background: linear-gradient(180deg, var(--brand-indigo), rgba(99, 102, 241, 0.3));
    border-radius: 4px 4px 0 0;
    transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
    min-height: 4px;
}
.wst-hist-bar-col.active .wst-hist-bar-fill {
    background: linear-gradient(180deg, var(--brand-amber), rgba(245, 158, 11, 0.4));
    box-shadow: 0 0 12px var(--brand-amber);
}

/* Persistent Segment Tree (Chairman Tree) */
.pst-ver-pill {
    padding: 0.35rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.pst-ver-pill:hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}
.pst-ver-pill.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
    color: #ffffff;
    font-weight: 700;
}
.pst-node-box {
    padding: 0.55rem 0.85rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 85px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    transition: all 0.3s ease;
}
.pst-node-box.cloned {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--brand-emerald);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.4);
}
.pst-node-box.shared {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.4);
}
.pst-node-box.diff-focus {
    background: rgba(245, 158, 11, 0.25);
    border-color: var(--brand-amber);
    box-shadow: 0 0 16px var(--brand-amber);
    transform: scale(1.06);
}


/* --- New: KMP String Visualizer --- */
.kmp-track-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
    align-items: center;
}
.kmp-char-strip {
    display: flex;
    gap: 6px;
}
.kmp-char-cell {
    width: 44px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.15rem;
    transition: all 0.2s ease;
}
.kmp-char-cell.matched {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--brand-emerald);
}
.kmp-char-cell.mismatched {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

/* --- New: BFS Maze Visualizer --- */
.maze-grid-canvas {
    display: grid;
    grid-template-columns: repeat(8, 44px);
    grid-template-rows: repeat(8, 44px);
    gap: 4px;
    justify-content: center;
    margin: 1.5rem auto;
}
.maze-cell-tile {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-xs);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.maze-cell-tile.wall {
    background: #1e293b;
    border-color: #334155;
}
.maze-cell-tile.visited {
    background: rgba(6, 182, 212, 0.25);
    border-color: var(--brand-cyan);
}
.maze-cell-tile.path {
    background: rgba(16, 185, 129, 0.4);
    border-color: var(--brand-emerald);
    box-shadow: 0 0 12px var(--shadow-glow-emerald);
}
.maze-cell-tile.start {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
}
.maze-cell-tile.target {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
}

/* --- New: Sliding Window Visualizer --- */
.sliding-window-container {
    display: flex;
    justify-content: center;
    position: relative;
    margin: 3rem 0;
}
.sw-array-row {
    display: flex;
    gap: 8px;
    position: relative;
}
.sw-item-cell {
    width: 48px;
    height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-weight: 800;
}
.sw-item-cell.in-window {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--brand-indigo);
}

/* Union-Find */
.union-find-node-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    padding: 2.5rem;
}
.uf-circle-node {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--brand-indigo);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 800;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}
.uf-circle-node.root {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #34d399;
    box-shadow: var(--shadow-glow-emerald);
}

/* DP Grid */
.dp-matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}
.dp-matrix-table th, .dp-matrix-table td {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-subtle);
    text-align: center;
}
.dp-matrix-table th {
    background: rgba(10, 13, 22, 0.8);
    color: var(--brand-cyan);
}
.dp-matrix-table td.active-cell {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--brand-indigo);
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}


/* ==========================================================================
   Module 4:  数学竞赛定理库 (Math Hub)
   ========================================================================== */
.math-cards-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.75rem;
}
.math-theorem-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(16px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
}
.math-theorem-card:hover {
    transform: translateY(-4px);
    border-color: var(--brand-violet);
    box-shadow: 0 12px 32px rgba(168, 85, 247, 0.25);
}
.math-theorem-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.math-theorem-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}
.math-domain-badge {
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 0.725rem;
    font-weight: 700;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
    white-space: nowrap;
}
.math-latex-container {
    background: rgba(10, 13, 22, 0.75);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    margin: 0.85rem 0;
    text-align: center;
    overflow-x: auto;
    font-size: 1.1rem;
}
html.light-theme .math-latex-container {
    background: #f1f5f9;
}
.math-theorem-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 1rem;
    flex: 1;
}

/* ==========================================================================
   Module 5 & 6:  化学反应配平 &  3D分子结构速查
   ========================================================================== */
.chem-control-dock {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}
.chem-search-field-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.chem-text-input {
    flex: 1;
    padding: 0.85rem 1.25rem;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.05rem;
    outline: none;
    transition: all 0.2s ease;
}
.chem-text-input:focus {
    border-color: var(--brand-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}
.quick-sample-chips-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.chip-sample-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    padding: 4px 11px;
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.825rem;
    transition: all 0.2s ease;
}
.chip-sample-btn:hover {
    border-color: var(--brand-emerald);
    background: rgba(16, 185, 129, 0.15);
}

.chem-reaction-output-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}
.balanced-reaction-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.15));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    text-align: center;
    margin-bottom: 2rem;
}
.balanced-reaction-title {
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand-emerald);
    font-weight: 800;
    margin-bottom: 0.65rem;
}
.balanced-reaction-equation {
    font-size: 1.85rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #ffffff;
}
html.light-theme .balanced-reaction-equation {
    color: #0f172a;
}

/* Standalone Molecule Showcase */
.molecule-viewer-display-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    margin-top: 2rem;
}
.molecule-viewer-display-card h2 {
    color: #0f172a;
    font-family: 'Times New Roman', Times, serif;
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
}
.molecule-2d-img-asset {
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.15));
}
.molecule-3d-stage-box {
    width: 100%;
    height: 440px;
    border-radius: var(--radius-md);
    background: #090c14;
    position: relative;
    overflow: hidden;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(4, 6, 10, 0.85);
    backdrop-filter: blur(12px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.active {
    display: flex;
}
.modal-window-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 740px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.modal-top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1.75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.modal-canvas-body {
    padding: 1.75rem;
}
.modal-3dmol-canvas {
    width: 100%;
    height: 400px;
    background: #000000;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

/* Responsive Adaptations */
@media (max-width: 1100px) {
    .reader-split-layout {
        grid-template-columns: 1fr;
    }
    .reader-toc-sidebar {
        position: static;
        max-height: none;
        margin-bottom: 2rem;
    }
    .editor-workspace-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .editor-text-canvas {
        height: 360px;
    }
}

@media (max-width: 768px) {
    header.portal-header {
        padding: 0.75rem 0.5rem;
    }
    



.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 0.5rem;
}

.header-container {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    .nav-discipline-dock {
        flex-wrap: wrap;
        justify-content: center;
    }
    .nav-discipline-btn {
        padding: 0.45rem 0.95rem;
        font-size: 0.88rem;
    }
    .subnav-island-bar {
        flex-wrap: wrap;
    }
    .hero-headline {
        font-size: 2rem;
    }
    main.portal-main {
        padding: 1rem 0.75rem;
    }
}

.brand-logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(6, 182, 212, 0.4));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
    display: block;
}
.brand-section:hover .brand-logo-img {
    transform: scale(1.15) rotate(12deg);
    filter: drop-shadow(0 4px 14px rgba(245, 158, 11, 0.55));
}

/* Changelog Modal Styles */
.changelog-modal-card {
    background: var(--bg-card);
    width: 90%;
    max-width: 580px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ptable-modal-overlay.show .changelog-modal-card {
    transform: translateY(0) scale(1);
}
.changelog-modal-header {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}
.changelog-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.changelog-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 85px);
}
.changelog-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}
.changelog-timeline::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 8px;
    width: 2px;
    background: var(--border-color);
}
.changelog-item {
    position: relative;
    padding-left: 28px;
}
.changelog-item::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4f46e5;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 2px #4f46e5;
}
.changelog-item-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}
.changelog-ver-tag {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-mono, monospace);
}
.changelog-badge-current {
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.changelog-date {
    font-size: 0.75rem;
    color: var(--text-tertiary, #94a3b8);
    margin-left: auto;
}
.changelog-desc {
    background: var(--bg-body, rgba(255,255,255,0.03));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.changelog-desc strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}
.changelog-desc ul {
    margin: 0.4rem 0 0 1.2rem;
    padding: 0;
    line-height: 1.6;
    font-size: 0.82rem;
}


/* Periodic Table Styles */
.ptable-control-dock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.ptable-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    display: flex;
    align-items: center;
}
.ptable-search-wrapper svg {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary, #94a3b8);
    pointer-events: none;
}
.ptable-search-box {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 2.6rem;
    border-radius: 999px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-body, rgba(255,255,255,0.05));
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.25s ease;
}
.ptable-search-box:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
    background: var(--bg-card);
}
.ptable-search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
}
.ptable-legend-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}
.ptable-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ptable-chip:hover {
    transform: translateY(-2px);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}
.ptable-chip.active {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.35);
}

/* Category Chip Colors */
.ptable-chip.pt-c-alkali { border-color: rgba(239, 68, 68, 0.4); }
.ptable-chip.pt-c-alkali.active { background: #ef4444; border-color: #ef4444; }
.ptable-chip.pt-c-alkaline { border-color: rgba(249, 115, 22, 0.4); }
.ptable-chip.pt-c-alkaline.active { background: #f97316; border-color: #f97316; }
.ptable-chip.pt-c-transition { border-color: rgba(245, 158, 11, 0.4); }
.ptable-chip.pt-c-transition.active { background: #f59e0b; border-color: #f59e0b; }
.ptable-chip.pt-c-post-transition { border-color: rgba(16, 185, 129, 0.4); }
.ptable-chip.pt-c-post-transition.active { background: #10b981; border-color: #10b981; }
.ptable-chip.pt-c-metalloid { border-color: rgba(6, 182, 212, 0.4); }
.ptable-chip.pt-c-metalloid.active { background: #06b6d4; border-color: #06b6d4; }
.ptable-chip.pt-c-nonmetal { border-color: rgba(59, 130, 246, 0.4); }
.ptable-chip.pt-c-nonmetal.active { background: #3b82f6; border-color: #3b82f6; }
.ptable-chip.pt-c-noble { border-color: rgba(168, 85, 247, 0.4); }
.ptable-chip.pt-c-noble.active { background: #a855f7; border-color: #a855f7; }
.ptable-chip.pt-c-lanthanide { border-color: rgba(236, 72, 153, 0.4); }
.ptable-chip.pt-c-lanthanide.active { background: #ec4899; border-color: #ec4899; }
.ptable-chip.pt-c-actinide { border-color: rgba(244, 63, 94, 0.4); }
.ptable-chip.pt-c-actinide.active { background: #f43f5e; border-color: #f43f5e; }

/* 18-Column Grid Layout */
.ptable-scroll-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1.5rem;
}
.ptable-18-grid {
    display: grid;
    grid-template-columns: repeat(18, minmax(58px, 1fr));
    grid-template-rows: repeat(10, minmax(58px, 1fr));
    gap: 6px;
    max-width: 1300px;
    margin: 0 auto;
    min-width: 1100px;
}

/* Periodic Table Cell */
.ptable-cell {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-primary);
    padding: 3px 2px;
}
.ptable-cell:hover {
    transform: scale(1.18) translateY(-4px);
    z-index: 50;
    box-shadow: 0 12px 24px -6px rgba(0,0,0,0.25);
    border-color: #fff;
}
.ptable-cell.dimmed {
    opacity: 0.18;
    filter: grayscale(0.8);
    transform: scale(0.96);
    pointer-events: none;
}
.ptable-cell.highlighted {
    transform: scale(1.12);
    z-index: 40;
    box-shadow: 0 0 0 3px #fff, 0 8px 20px rgba(0,0,0,0.3);
}

.ptable-cell .el-num {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 0.62rem;
    font-family: var(--font-mono, monospace);
    opacity: 0.75;
    font-weight: 700;
}
.ptable-cell .el-sym {
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    margin: 4px 0 2px 0;
}
.ptable-cell .el-name {
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
}
.ptable-cell .el-mass {
    font-size: 0.55rem;
    opacity: 0.7;
    margin-top: 1px;
    font-family: var(--font-mono, monospace);
}

/* Category Colors */
.pt-alkali { background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(239,68,68,0.12)); border-color: rgba(239,68,68,0.5); color: #f87171; }
.pt-alkaline { background: linear-gradient(135deg, rgba(249,115,22,0.2), rgba(249,115,22,0.12)); border-color: rgba(249,115,22,0.5); color: #fb923c; }
.pt-transition { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.12)); border-color: rgba(245,158,11,0.5); color: #fbbf24; }
.pt-post-transition { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(16,185,129,0.12)); border-color: rgba(16,185,129,0.5); color: #34d399; }
.pt-metalloid { background: linear-gradient(135deg, rgba(6,182,212,0.2), rgba(6,182,212,0.12)); border-color: rgba(6,182,212,0.5); color: #22d3ee; }
.pt-nonmetal { background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(59,130,246,0.12)); border-color: rgba(59,130,246,0.5); color: #60a5fa; }
.pt-noble { background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(168,85,247,0.12)); border-color: rgba(168,85,247,0.5); color: #c084fc; }
.pt-lanthanide { background: linear-gradient(135deg, rgba(236,72,153,0.2), rgba(236,72,153,0.12)); border-color: rgba(236,72,153,0.5); color: #f472b6; }
.pt-actinide { background: linear-gradient(135deg, rgba(244,63,94,0.2), rgba(244,63,94,0.12)); border-color: rgba(244,63,94,0.5); color: #fb7185; }
.pt-unknown { background: var(--bg-card); border-color: var(--border-color); color: var(--text-secondary); }

/* In Light mode, make symbols stand out cleanly */
html.light-theme .ptable-cell { color: #1e293b; }
html.light-theme .pt-alkali { color: #dc2626; }
html.light-theme .pt-alkaline { color: #ea580c; }
html.light-theme .pt-transition { color: #d97706; }
html.light-theme .pt-post-transition { color: #059669; }
html.light-theme .pt-metalloid { color: #0891b2; }
html.light-theme .pt-nonmetal { color: #2563eb; }
html.light-theme .pt-noble { color: #9333ea; }
html.light-theme .pt-lanthanide { color: #db2777; }
html.light-theme .pt-actinide { color: #e11d48; }

/* Element Modal Card */
.element-modal-card {
    background: var(--bg-card);
    width: 90%;
    max-width: 520px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px -12px rgba(0,0,0,0.6);
    border: 1px solid var(--border-color);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}
.ptable-modal-overlay.show .element-modal-card {
    transform: translateY(0) scale(1);
}
.element-modal-header {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    color: #fff;
    position: relative;
}
.el-modal-symbol-box {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255,255,255,0.4);
    position: relative;
    flex-shrink: 0;
}
.el-modal-number-tag {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0.9;
}
.el-modal-symbol {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
}
.el-modal-name-cn {
    font-size: 0.72rem;
    font-weight: 600;
}
.el-modal-title-text {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}
.el-modal-cat-badge {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.78rem;
    font-weight: 600;
}
.el-modal-block-badge {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    font-size: 0.72rem;
    font-family: var(--font-mono, monospace);
    font-weight: 700;
}
.element-modal-body {
    padding: 1.5rem;
}
.el-prop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.el-prop-item {
    background: var(--bg-body, rgba(255,255,255,0.03));
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.el-prop-label {
    font-size: 0.72rem;
    color: var(--text-tertiary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.el-prop-val {
    font-size: 0.92rem;
    color: var(--text-primary);
}
.el-desc-box {
    background: var(--bg-body, rgba(255,255,255,0.03));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}












/* ==========================================================================
   Dual-Theme Modal System
   1. Dark Theme: Pristine Original Native Dark Design
   2. Light Theme: High-End Frosted Dark Acrylic HUD
   ========================================================================== */

/* Universal Modal Overlay */
.ptable-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.25s ease, visibility 0.25s ease !important;
}
.ptable-modal-overlay.show {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

/* --------------------------------------------------------------------------
   1. ORIGINAL DARK THEME MODAL (Restored to Pristine State)
   -------------------------------------------------------------------------- */
.element-modal-card {
    background: var(--bg-card, #1e293b);
    width: 90%;
    max-width: 520px;
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    color: var(--text-main, #f8fafc);
}
.changelog-modal-card {
    background: var(--bg-card, #1e293b);
    width: 90%;
    max-width: 580px;
    max-height: 80vh;
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--text-main, #f8fafc);
}
.ptable-modal-overlay.show .element-modal-card,
.ptable-modal-overlay.show .changelog-modal-card {
    transform: translateY(0) scale(1);
}

.element-modal-header {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    color: #fff;
    position: relative;
}
.changelog-modal-header {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.el-prop-item {
    background: var(--bg-body, rgba(255, 255, 255, 0.03));
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.el-prop-label {
    font-size: 0.72rem;
    color: var(--text-tertiary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.el-prop-val {
    font-size: 0.92rem;
    color: var(--text-primary, #f8fafc);
}
.el-desc-box {
    background: var(--bg-body, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-sm, 8px);
    padding: 0.85rem 1rem;
}

.ptable-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s ease;
}
.ptable-modal-close:hover {
    transform: scale(1.15);
}

/* --------------------------------------------------------------------------
   2. LIGHT THEME: Frosted Dark Acrylic Glass HUD (Retained)
   -------------------------------------------------------------------------- */
html.light-theme .element-modal-card,
html.light-theme .changelog-modal-card {
    background: rgba(15, 23, 42, 0.84) !important;
    backdrop-filter: blur(32px) saturate(210%) !important;
    -webkit-backdrop-filter: blur(32px) saturate(210%) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12) inset !important;
    color: #f8fafc !important;
}

html.light-theme .el-prop-item,
html.light-theme .el-desc-box,
html.light-theme .changelog-desc {
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #cbd5e1 !important;
}

html.light-theme .el-prop-label {
    color: #94a3b8 !important;
}

html.light-theme .el-prop-val {
    color: #ffffff !important;
}

html.light-theme .el-desc-box h3 {
    color: #38bdf8 !important;
}

html.light-theme .el-desc-box p {
    color: #e2e8f0 !important;
}

html.light-theme .changelog-ver-tag {
    color: #38bdf8 !important;
}
html.light-theme .changelog-date {
    color: #94a3b8 !important;
}
html.light-theme .changelog-desc strong {
    color: #ffffff !important;
}
html.light-theme .changelog-desc li {
    color: #cbd5e1 !important;
}


/* ==========================================================================
   Typing Tutor Module
   ========================================================================== */
.typing-tutor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
    gap: 2rem;
    padding: 2rem 0;
}
.typing-header {
    text-align: center;
}
.typing-header h2 {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.8rem;
    font-weight: 800;
}
.typing-header p {
    color: var(--text-tertiary);
}
.typing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3.5rem 4rem;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 95%;
    width: 900px;
    position: relative;
    outline: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.typing-card:focus-within {
    box-shadow: 0 20px 50px -5px rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
}
.typing-hint {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #fff;
    padding: 0.5rem 1.4rem;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
    white-space: nowrap;
}
.typing-content {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 2.4rem;
    line-height: 1.6;
    letter-spacing: 2px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 6px;
}
.type-char {
    color: var(--text-tertiary);
    opacity: 0.35;
    transition: color 0.1s, opacity 0.1s, text-shadow 0.1s;
    border-bottom: 4px solid transparent;
    padding: 0 1px;
    position: relative;
}
.type-char.current {
    opacity: 1;
    color: var(--text-main);
    border-bottom: 4px solid var(--brand-cyan);
    animation: blink-border 1s infinite;
}
.type-char.correct {
    color: #10b981;
    opacity: 1;
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}
.type-char.error {
    color: #ef4444;
    opacity: 1;
    border-bottom: 4px solid #ef4444;
    animation: shake-error 0.3s cubic-bezier(.36,.07,.19,.97) both;
}
.type-char.space {
    min-width: 1.4rem;
}
.type-char.space.error {
    background: rgba(239, 68, 68, 0.25);
    border-radius: 4px;
}
.typing-stats {
    display: flex;
    gap: 3rem;
    font-size: 1.15rem;
    color: var(--text-secondary);
}
.typing-stats strong {
    color: var(--brand-cyan);
    font-size: 1.8rem;
    margin-left: 0.5rem;
}
@keyframes blink-border {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--brand-cyan); }
}
@keyframes shake-error {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}
html.light-theme .typing-card {
    background: rgba(15, 23, 42, 0.84) !important;
    backdrop-filter: blur(32px) saturate(210%) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.22) !important;
}
html.light-theme .type-char.current {
    color: #f8fafc;
}




.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-medium);
    padding-bottom: 0.5rem;
}

.auth-tab {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 0.5rem;
    position: relative;
    transition: color 0.2s;
}

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

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--brand-indigo);
    border-radius: 3px;
    box-shadow: var(--shadow-glow-indigo);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.active {
    display: flex;
}

.dropdown-menu-glass {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(14, 18, 28, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 150px;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.dropdown-menu-glass.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-surface-hover);
    color: var(--brand-rose);
}


