/* ══════════════════════════════════════════════════════════════════════════════
   TOME Knowledge Base
   Industrial Terminal Design System
   JetBrains Mono + Brand Colors
   ══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   Typography
   ───────────────────────────────────────────────────────────────────────────── */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('fonts/jetbrains-mono-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('fonts/jetbrains-mono-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Cinzel - Warcraft theme (display only — headings, logo) */
@font-face { font-family: 'Cinzel'; src: url('fonts/cinzel-latin.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cinzel'; src: url('fonts/cinzel-latin-ext.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Inter — sans-serif body for warcraft theme. Cinzel kept on display only.
   Cormorant Garamond was tried first and rejected as still hard to read on
   dense tables; sans-serif is the right call for an information surface. */
@font-face { font-family: 'Inter'; src: url('https://i.sub-net.at/fonts/inter-variable.woff2') format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }

/* IBM Plex Sans - Corporate theme */
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-300.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('https://i.sub-net.at/fonts/ibm-plex-sans-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* IBM Plex Mono - Corporate theme */
@font-face { font-family: 'IBM Plex Mono'; src: url('https://i.sub-net.at/fonts/ibm-plex-mono-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('https://i.sub-net.at/fonts/ibm-plex-mono-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('https://i.sub-net.at/fonts/ibm-plex-mono-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }

/* Orbitron - Synthwave theme */
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-800.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('https://i.sub-net.at/fonts/orbitron-900.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }

/* Rajdhani - Synthwave theme */
@font-face { font-family: 'Rajdhani'; src: url('https://i.sub-net.at/fonts/rajdhani-300.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('https://i.sub-net.at/fonts/rajdhani-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('https://i.sub-net.at/fonts/rajdhani-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('https://i.sub-net.at/fonts/rajdhani-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('https://i.sub-net.at/fonts/rajdhani-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* Fira Code - Synthwave theme */
@font-face { font-family: 'Fira Code'; src: url('https://i.sub-net.at/fonts/fira-code-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fira Code'; src: url('https://i.sub-net.at/fonts/fira-code-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fira Code'; src: url('https://i.sub-net.at/fonts/fira-code-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }

/* ─────────────────────────────────────────────────────────────────────────────
   Design Tokens
   ───────────────────────────────────────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────────────────────────────
   Shared Tokens (all themes)
   ───────────────────────────────────────────────────────────────────────────── */
:root {
    /* Brand Colors */
    --brand-dark: #2C3E50;
    --brand-accent: #27AE60;
    --brand-accent-bright: #2ECC71;
    --brand-accent-dim: rgba(39, 174, 96, 0.15);
    --brand-accent-glow: rgba(39, 174, 96, 0.4);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Transitions */
    --transition-fast: 0.1s;
    --transition-base: 0.15s;
    --transition-slow: 0.3s;
}

/* ─────────────────────────────────────────────────────────────────────────────
   THEME: Terminal (default)
   JetBrains Mono · Dark industrial · Green accent
   ───────────────────────────────────────────────────────────────────────────── */
.terminal-theme {
    /* Backgrounds */
    --bg-deep: #0a0e12;
    --bg-base: #0f1419;
    --bg-surface: #151c24;
    --bg-elevated: #1a232e;
    --bg-hover: #1f2937;

    /* Borders */
    --border-subtle: #1e2832;
    --border-default: #2a3744;
    --border-strong: #3d4f5f;

    /* Text */
    --text-primary: #e8eef4;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-disabled: #4b5563;

    /* Accent */
    --accent: var(--brand-accent);
    --accent-bright: var(--brand-accent-bright);
    --accent-dim: var(--brand-accent-dim);
    --accent-glow: var(--brand-accent-glow);

    /* Status */
    --status-error: #ef4444;
    --status-warning: #f59e0b;
    --status-info: #3b82f6;

    /* Typography */
    --font-body: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-heading: 'JetBrains Mono', 'SF Mono', monospace;
    --font-nav: 'JetBrains Mono', 'SF Mono', monospace;

    /* Radii */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Effects */
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ─────────────────────────────────────────────────────────────────────────────
   THEME: Corporate
   IBM Plex Sans + IBM Plex Mono · Navy sidebar, white content · Blue accent
   ───────────────────────────────────────────────────────────────────────────── */
.theme-corporate {
    /* Palette */
    --navy: #0F1B2D;
    --navy-mid: #162338;
    --navy-light: #1C2D45;

    /* Backgrounds */
    --bg-deep: #F8FAFC;
    --bg-base: #FFFFFF;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F1F5F9;
    --bg-hover: #E2E8F0;

    /* Sidebar (dark navy — overridden in selectors below) */
    --sidebar-bg: var(--navy);
    --sidebar-text: #CBD5E1;
    --sidebar-text-dim: #94A3B8;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-hover: rgba(255, 255, 255, 0.05);

    /* Borders */
    --border-subtle: #E2E8F0;
    --border-default: #CBD5E1;
    --border-strong: #94A3B8;

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-disabled: #CBD5E1;

    /* Accent */
    --accent: #3B82F6;
    --accent-bright: #2563EB;
    --accent-dim: rgba(59, 130, 246, 0.1);
    --accent-glow: rgba(59, 130, 246, 0.2);

    /* Status */
    --status-error: #EF4444;
    --status-warning: #F59E0B;
    --status-info: #3B82F6;

    /* Typography */
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', 'Monaco', monospace;
    --font-heading: 'IBM Plex Sans', -apple-system, sans-serif;
    --font-nav: 'IBM Plex Sans', -apple-system, sans-serif;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 10px;

    /* Effects */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ─────────────────────────────────────────────────────────────────────────────
   THEME: Synthwave
   Orbitron + Rajdhani + Fira Code · Neon on deep purple · Retro-futuristic
   ───────────────────────────────────────────────────────────────────────────── */
.theme-synthwave {
    /* Palette */
    --neon-pink: #FF2D95;
    --neon-cyan: #00F0FF;
    --neon-purple: #A855F7;
    --neon-yellow: #FFE14D;

    /* Backgrounds */
    --bg-deep: #0D0221;
    --bg-base: #110428;
    --bg-surface: #150535;
    --bg-elevated: #1A0940;
    --bg-hover: #1F0D4D;

    /* Sidebar */
    --sidebar-bg: rgba(13, 2, 33, 0.95);
    --sidebar-text: #E8E0F0;
    --sidebar-text-dim: #9B94A8;
    --sidebar-border: rgba(168, 85, 247, 0.15);
    --sidebar-hover: rgba(168, 85, 247, 0.08);

    /* Borders */
    --border-subtle: rgba(168, 85, 247, 0.1);
    --border-default: rgba(168, 85, 247, 0.2);
    --border-strong: rgba(168, 85, 247, 0.35);

    /* Text */
    --text-primary: #E8E0F0;
    --text-secondary: #B0A8C0;
    --text-muted: #7A7490;
    --text-disabled: #5A5470;

    /* Accent */
    --accent: #00F0FF;
    --accent-bright: #33F5FF;
    --accent-dim: rgba(0, 240, 255, 0.1);
    --accent-glow: rgba(0, 240, 255, 0.3);

    /* Status */
    --status-error: #FF4D6A;
    --status-warning: var(--neon-yellow);
    --status-info: var(--neon-cyan);

    /* Typography */
    --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;
    --font-heading: 'Orbitron', 'Rajdhani', sans-serif;
    --font-nav: 'Rajdhani', sans-serif;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Effects */
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Synthwave Font Size Overrides
   Rajdhani (proportional) needs larger sizes than JetBrains Mono (monospace 13px)
   Orbitron (display) headings need scaling too
   ───────────────────────────────────────────────────────────────────────────── */
.theme-synthwave {
    font-size: 15px;
}

.theme-synthwave .sidebar .nav-item,
.theme-synthwave .sidebar .nav-group-header {
    font-size: 14px;
}

.theme-synthwave .page-meta {
    font-size: 13px;
}

.theme-synthwave .page-content h1 {
    font-size: 34px;
}

.theme-synthwave .markdown-body {
    font-size: 15px;
}

.theme-synthwave .markdown-body h1 { font-size: 28px; }
.theme-synthwave .markdown-body h2 { font-size: 23px; }
.theme-synthwave .markdown-body h3 { font-size: 18px; }
.theme-synthwave .markdown-body h4 { font-size: 16px; }

.theme-synthwave .markdown-body code {
    font-size: 14px;
}

.theme-synthwave .markdown-body pre {
    font-size: 14px;
}

.theme-synthwave .markdown-body table {
    font-size: 14px;
}

.theme-synthwave .tag {
    font-size: 10px;
}

.theme-synthwave .search-box input {
    font-size: 14px;
}

.theme-synthwave .breadcrumb {
    font-size: 12px;
}

.theme-synthwave .btn {
    font-size: 13px;
}

.theme-synthwave .btn-small {
    font-size: 10px;
}

.theme-synthwave .welcome h1 {
    font-size: 36px;
}

.theme-synthwave .modal-title {
    font-size: 16px;
}

.theme-synthwave .toast {
    font-size: 14px;
}

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

/* Terminal theme: disable all transitions for snappy UI */
.terminal-theme *,
.terminal-theme *::before,
.terminal-theme *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}

::selection {
    background: var(--accent-dim);
    color: var(--accent-bright);
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.6;
    font-feature-settings: 'liga' 1, 'calt' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.terminal-theme,
.theme-corporate,
.theme-synthwave,
.theme-warcraft {
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}

/* ─────────────────────────────────────────────────────────────────────────────
   App Layout
   ───────────────────────────────────────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    background: var(--bg-deep);
    position: relative;
}

.terminal-theme .app {
    background:
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(39, 174, 96, 0.02) 2px,
            rgba(39, 174, 96, 0.02) 4px
        );
}

.theme-synthwave .app {
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%);
}

/* Synthwave grid overlay */
.theme-synthwave .app::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(168, 85, 247, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(168, 85, 247, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Sidebar
   ───────────────────────────────────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.theme-corporate .sidebar {
    background: var(--sidebar-bg);
    border-right-color: var(--sidebar-border);
}

.theme-corporate .sidebar .search-box input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
}

.theme-corporate .sidebar .search-box input::placeholder {
    color: var(--sidebar-text-dim);
}

.theme-corporate .sidebar .search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.theme-corporate .sidebar-header {
    border-bottom-color: var(--sidebar-border);
}

.theme-corporate .sidebar-footer {
    background: rgba(15, 27, 45, 0.8);
    border-top-color: var(--sidebar-border);
}

.theme-corporate .nav-tree .loading {
    color: var(--sidebar-text-dim);
}

.theme-corporate .nav-group-header {
    color: var(--sidebar-text-dim);
}

.theme-corporate .nav-group-header:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
}

.theme-corporate .nav-group.expanded > .nav-group-header {
    color: #60A5FA;
}

.theme-corporate .nav-item {
    color: var(--sidebar-text);
}

.theme-corporate .nav-item:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
}

.theme-corporate .nav-item.active {
    color: #60A5FA;
    background: rgba(59, 130, 246, 0.15);
}

.theme-corporate .nav-children {
    border-left-color: rgba(255, 255, 255, 0.08);
}

.theme-corporate .user-name {
    color: var(--sidebar-text-dim);
}

.theme-corporate .settings-btn {
    color: var(--sidebar-text-dim);
}

.theme-corporate .settings-btn:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
    border-color: var(--sidebar-border);
}

.theme-synthwave .sidebar {
    background: var(--sidebar-bg);
    border-right-color: var(--sidebar-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.theme-synthwave .sidebar-header {
    border-bottom-color: var(--sidebar-border);
}

.theme-synthwave .sidebar-footer {
    background: rgba(17, 4, 40, 0.8);
    border-top-color: var(--sidebar-border);
}

.theme-synthwave .nav-group-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.theme-synthwave .nav-item.active {
    text-shadow: 0 0 8px var(--accent-glow);
    border: 1px solid rgba(0, 240, 255, 0.15);
}

/* Glow line on sidebar edge */
.terminal-theme .sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(
        180deg,
        var(--accent) 0%,
        transparent 30%,
        transparent 70%,
        var(--accent) 100%
    );
    opacity: 0.3;
}

.theme-synthwave .sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, #00F0FF 0%, #A855F7 50%, #FF2D95 100%);
    opacity: 0.4;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    position: relative;
}

.sidebar-header .btn {
    width: 100%;
}

/* Collapse toggle: pinned top-right of the sidebar header. Two SVGs swap
   based on .sidebar.collapsed so the chevron points the right way. */
.sidebar-collapse-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    z-index: 2;
}

.sidebar-collapse-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
    border-color: var(--border-subtle);
}

.sidebar-collapse-btn .collapse-icon-collapsed { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .collapse-icon-expanded { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .collapse-icon-collapsed { display: block; }

/* Collapsed sidebar: 64px wide, icons only, hide labels/separators/sub-children. */
.sidebar.collapsed {
    width: 64px;
}
.sidebar.collapsed .sidebar-collapse-btn {
    position: static;
    margin: 0 auto;
}
.sidebar.collapsed .sidebar-header {
    padding: 8px 4px;
    align-items: center;
}
.sidebar.collapsed .logo,
.sidebar.collapsed .sidebar-actions,
.sidebar.collapsed .sidebar-instances,
.sidebar.collapsed .search-box,
.sidebar.collapsed .nav-children,
.sidebar.collapsed .nav-separator,
.sidebar.collapsed .nav-toggle,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info,
.sidebar.collapsed .login-btn {
    display: none !important;
}
.sidebar.collapsed .nav-tree {
    padding: 6px 0;
}
.sidebar.collapsed .nav-group {
    margin: 0 !important;
    padding: 0 !important;
}
.sidebar.collapsed .nav-group-header,
.sidebar.collapsed .nav-item.root-item,
.sidebar.collapsed .nav-tree > .nav-item {
    width: 48px;
    height: 48px;
    margin: 4px auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border-left: 0;
    text-transform: none;
    font-size: 0;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-footer {
    padding: 8px 0;
    justify-content: center;
}

/* Nav icons (visible only in collapsed mode by default; force-shown under
   the warcraft theme so class icons sit beside the label too). */
.nav-icon {
    display: none;
    flex-shrink: 0;
}
.sidebar.collapsed .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 16px;
}
.nav-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    image-rendering: pixelated;
}
.nav-icon-mono {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0;
    border: 1px solid var(--border-default);
}

/* Warcraft theme: show class icons in expanded mode too, sized down.
   Spacing is handled by the parent's flex `gap`, so no margin-right here. */
.theme-warcraft .nav-tree > .nav-group > .nav-group-header .nav-icon,
.theme-warcraft .nav-tree > .nav-item .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}
.theme-warcraft .nav-tree > .nav-group > .nav-group-header .nav-icon-img,
.theme-warcraft .nav-tree > .nav-item .nav-icon-img {
    width: 20px;
    height: 20px;
}
.theme-warcraft .nav-tree > .nav-group > .nav-group-header .nav-icon-mono,
.theme-warcraft .nav-tree > .nav-item .nav-icon-mono {
    width: 20px;
    height: 20px;
    font-size: 11px;
}

.sidebar-actions {
    display: flex;
    gap: var(--space-sm);
}

.sidebar-actions .btn {
    width: auto;
    flex: 1;
}

.sidebar-instances {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.sidebar-instances:empty {
    display: none;
}

.btn-instance {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    flex: 1 1 auto;
    text-align: center;
    text-decoration: none;
}

.btn-instance:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

/* Logo */
.logo {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.logo-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.logo-text {
    color: var(--text-primary);
}

.theme-corporate .logo-icon {
    color: #94A3B8;
}

.theme-corporate .logo-text {
    color: #FFFFFF;
}

.theme-synthwave .logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.theme-synthwave .logo-text {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 16px rgba(0, 240, 255, 0.25));
}

/* Search */
.search-box {
    padding: var(--space-md) var(--space-lg);
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-nav);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-base);
}

.theme-synthwave .search-box input:focus {
    box-shadow: 0 0 0 3px var(--accent-dim), 0 0 20px var(--accent-dim);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim), 0 0 20px var(--accent-dim);
}

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

.search-clear {
    position: absolute;
    right: calc(var(--space-lg) + 10px);
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: transparent;
    border: 1px solid var(--status-error);
    border-radius: var(--radius-sm);
    color: var(--status-error);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.search-box:has(input:not(:placeholder-shown)) .search-clear {
    opacity: 1;
    visibility: visible;
}

.search-clear:hover {
    background: var(--status-error);
    color: white;
}

/* Navigation Tree */
.nav-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-sm);
}

/* Drawn between adjacent nav items whose nav_order crosses a 100-bucket
   boundary (e.g. order 30 → 100). Authors use this to lift "basics" above
   the default-100 mass without introducing a second concept. */
.nav-separator {
    height: 1px;
    margin: var(--space-sm) var(--space-sm);
    background: var(--border-default);
    opacity: 0.6;
}

.nav-tree .loading {
    padding: var(--space-lg);
    color: var(--text-muted);
    text-align: center;
    font-size: 12px;
}

.nav-tree .loading::after {
    content: '';
    animation: loading-dots 1.4s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Navigation Groups */
.nav-group {
    margin-bottom: 2px;
    opacity: 0;
    transform: translateX(-8px);
    animation: slide-in 0.3s ease-out forwards;
}

.nav-group[data-depth="1"] { margin-left: 12px; }
.nav-group[data-depth="2"] { margin-left: 24px; }
.nav-group[data-depth="3"] { margin-left: 36px; }
.nav-group[data-depth="4"] { margin-left: 48px; }

.nav-group-header {
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    user-select: none;
    border-left: 2px solid transparent;
    margin-top: var(--space-sm);
}

.nav-group-header:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-left-color: var(--accent);
}

.nav-group.expanded > .nav-group-header {
    color: var(--accent);
    border-left-color: var(--accent);
}

/* Headers that ARE their own page (e.g. /classic/druid is both a page and
   the parent of feral/, guardian/) lose the all-caps folder treatment and
   read like a nav-item, but keep the toggle/expand affordance. */
.nav-group-header.has-page {
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0.9;
}
.nav-group-header.has-page:hover {
    opacity: 1;
}
.nav-group-header.has-page.active {
    color: var(--accent-bright);
    background: var(--accent-dim);
    border-left-color: var(--accent);
}

.nav-toggle {
    font-size: 10px;
    width: 14px;
    text-align: center;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.nav-group.expanded > .nav-group-header .nav-toggle {
    color: var(--accent);
}

.nav-toggle-spacer {
    width: 12px;
}

.nav-children {
    display: none;
    padding-left: 8px;
    border-left: 1px solid var(--border-default);
    margin-left: 6px;
    margin-top: 2px;
}

.nav-group.expanded > .nav-children {
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    font-size: 13px;
    opacity: 0.85;
}

.nav-item .nav-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item.root-item {
    margin-bottom: 2px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    opacity: 1;
}

.nav-item.active {
    color: var(--accent-bright);
    background: var(--accent-dim);
}

.nav-item.active::before {
    content: '>';
    position: absolute;
    left: 4px;
    color: var(--accent);
    font-weight: 700;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; text-shadow: 0 0 4px var(--accent-glow); }
    50% { opacity: 0.7; text-shadow: 0 0 8px var(--accent-glow); }
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
    min-width: 0;
}

.user-name {
    flex: 1;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Settings */
.settings-wrapper {
    position: relative;
}

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

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

.settings-btn.active {
    color: var(--accent);
    background: var(--bg-hover);
    border-color: var(--accent-dim);
}

.settings-btn svg {
    transition: transform 0.25s ease;
}

.settings-btn:hover svg,
.settings-btn.active svg {
    transform: rotate(30deg);
}

.settings-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 170px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 1000;
}

.settings-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-menu-section {
    padding: 6px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-nav);
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

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

.settings-menu-item.active {
    color: var(--accent);
}

.theme-preview {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border-default);
    flex-shrink: 0;
}

.theme-preview--terminal {
    background: linear-gradient(135deg, #0f1419 50%, #27AE60 50%);
    border-color: #2a3744;
}

.theme-preview--corporate {
    background: linear-gradient(135deg, #0F1B2D 50%, #F8FAFC 50%);
    border-color: #334155;
}

.theme-preview--synthwave {
    background: linear-gradient(135deg, #0D0221 50%, #00F0FF 25%, #FF2D95 75%);
    border-color: #4A1D6A;
}

.theme-label {
    flex: 1;
}

.theme-check {
    font-size: 11px;
    opacity: 0;
    color: var(--accent);
    transition: opacity 0.15s;
}

.settings-menu-item.active .theme-check {
    opacity: 1;
}

.theme-synthwave .settings-btn.active {
    box-shadow: 0 0 8px var(--accent-glow);
}

.theme-synthwave .settings-menu {
    border-color: rgba(0, 240, 255, 0.15);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(0, 240, 255, 0.06);
}

.theme-corporate .settings-btn.active {
    color: var(--accent);
    background: var(--sidebar-hover);
    border-color: rgba(59, 130, 246, 0.3);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Main Content
   ───────────────────────────────────────────────────────────────────────────── */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-base);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    position: relative;
}

.theme-corporate .content-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Synthwave glow line under topbar */
.theme-synthwave .content-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--neon-cyan) 20%,
        var(--neon-purple) 50%,
        var(--neon-pink) 80%,
        transparent 100%
    );
    opacity: 0.4;
}

/* Corporate: no terminal cursor on active nav item */
.theme-corporate .nav-item.active::before {
    content: '';
}

.content-header.animate {
    animation: fade-in 0.4s ease-out;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-base);
}

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

.breadcrumb .home-indicator {
    color: var(--accent);
}

.breadcrumb .separator {
    color: var(--border-strong);
}

.theme-synthwave .breadcrumb {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.actions {
    display: flex;
    gap: var(--space-sm);
}

.action-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 12px;
    user-select: none;
    cursor: pointer;
}

.action-flag:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.action-flag input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Page Content */
.page-content {
    flex: 1;
    overflow-y: auto;
    /* No vertical padding on the scroll container itself — sticky elements
       (like .markdown-body thead th) pin from the scrollport's padding
       edge, so any padding-top here would create a "dead zone" above the
       sticky element where body content visibly scrolls past. The vertical
       inset is moved onto the first/last child below. */
    padding: 0 var(--space-xl);
}
.page-content > article,
.page-content > .welcome {
    margin-block: var(--space-xl);
}

.page-content.graph-mode {
    padding: 0;
    overflow: hidden;
}

.graph-canvas-wrap {
    position: relative;
    width: 100%;
    height: 100%;
}

#graph-canvas {
    position: absolute;
    inset: 0;
}

.graph-search {
    width: 260px;
    max-width: 40vw;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
}

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

.graph-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.graph-hint {
    position: absolute;
    left: var(--space-md);
    bottom: var(--space-md);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: color-mix(in srgb, var(--bg-deep) 60%, transparent);
    color: var(--text-secondary);
    font-size: 12px;
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Welcome Screen */
.welcome {
    max-width: 600px;
    margin: 80px auto;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    animation: fade-up 0.4s ease-out 0.1s forwards;
}

.welcome h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.theme-synthwave .welcome h1 {
    font-size: 32px;
    font-family: var(--font-heading);
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-corporate .welcome h1 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

.welcome p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: var(--space-lg);
}

.welcome .btn {
    margin-top: var(--space-md);
}

.welcome-terminal {
    font-size: 14px;
    margin-bottom: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    display: inline-flex;
    gap: var(--space-sm);
}

.theme-corporate .welcome-terminal {
    background: #0F1B2D;
    border-color: rgba(255, 255, 255, 0.1);
}

.theme-corporate .welcome-terminal .command {
    color: #E2E8F0;
}

.welcome-terminal .prompt {
    color: var(--accent);
}

.welcome-terminal .command {
    color: var(--text-primary);
}

.welcome-hint {
    margin-top: var(--space-xl);
    font-size: 12px;
    color: var(--text-muted);
}

.welcome-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    box-shadow: 0 2px 0 var(--border-subtle);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Article & Markdown
   ───────────────────────────────────────────────────────────────────────────── */
.page-content article {
    max-width: 100%;
}

.page-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.theme-corporate .page-content h1,
.theme-synthwave .page-content h1 {
    font-family: var(--font-heading);
}

.theme-synthwave .page-content h1 {
    font-size: 34px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 12px;
}

.page-tags {
    display: flex;
    gap: 6px;
}

.tag {
    padding: 3px 10px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--accent-bright);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theme-synthwave .tag {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 0.1em;
}

/* Markdown Content */
.markdown-body {
    color: var(--text-primary);
    line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    font-family: var(--font-heading);
}

.theme-synthwave .markdown-body h2 {
    color: var(--neon-cyan);
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
    border-bottom-color: rgba(0, 240, 255, 0.15);
}

.theme-synthwave .markdown-body h3 {
    color: var(--neon-purple);
}

.markdown-body h1 { font-size: 24px; }
.markdown-body h2 {
    font-size: 20px;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}
.markdown-body h3 { font-size: 16px; }
.markdown-body h4 { font-size: 14px; color: var(--text-secondary); }

.markdown-body p {
    margin-bottom: var(--space-md);
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-base);
}

.markdown-body a:hover {
    color: var(--accent-bright);
    border-bottom-color: var(--accent);
}

.theme-synthwave .markdown-body a:hover {
    text-shadow: 0 0 8px var(--accent-glow);
}

/* Wiki-style internal links [[page]] */
.markdown-body a.wiki-link {
    color: var(--accent);
    background: var(--accent-dim);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    font-weight: 500;
}

.theme-synthwave .markdown-body a.wiki-link:hover {
    color: var(--bg-deep);
}

.markdown-body a.wiki-link:hover {
    background: var(--accent);
    color: var(--bg-deep);
    border-color: var(--accent-bright);
}

.markdown-body code {
    padding: 2px 6px;
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--accent-bright);
    font-family: var(--font-mono);
}

.theme-corporate .markdown-body code {
    background: #F1F5F9;
    color: #B45309;
    border-color: #E2E8F0;
}

/* Color swatch for hex codes */
.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border-radius: 2px;
    border: 1px solid var(--border-default);
    vertical-align: middle;
}

.markdown-body pre {
    padding: var(--space-md);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: var(--space-md);
    position: relative;
    max-width: 100%;
    width: fit-content;
}

.theme-corporate .markdown-body pre {
    background: #0F1B2D;
    border-color: #1C2D45;
}

.theme-corporate .markdown-body pre code {
    background: transparent;
    color: #CBD5E1;
}

.markdown-body pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.markdown-body pre code {
    padding: 0;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
}

.theme-synthwave .markdown-body pre {
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.04);
}

.markdown-body ul,
.markdown-body ol {
    padding-left: var(--space-lg);
    margin-bottom: var(--space-md);
}

.markdown-body li {
    margin-bottom: var(--space-sm);
}

.markdown-body li::marker {
    color: var(--accent);
}

.theme-synthwave .markdown-body li::marker {
    color: var(--neon-pink);
}

.markdown-body blockquote {
    padding: var(--space-md) var(--space-lg);
    margin: 0 0 var(--space-md);
    border-left: 3px solid var(--accent);
    background: var(--accent-dim);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
}

.markdown-body table {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-md);
    font-size: 13px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    /* No `overflow: hidden` here: it would make the table the sticky
       scroll-port for its own thead, defeating the sticky thead rule
       below. The visible corner bleed past --radius-sm (2px) is
       imperceptible against the bordered table. */
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    text-align: left;
    color: var(--text-primary);
    max-width: 400px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Block-level content inside a table cell (lists, paragraphs) renders
   left-aligned regardless of the column's text-align. Otherwise a
   center- or right-aligned column with bullets inside the cell scatters
   each <li> text relative to its bullet, which looks broken. The cell
   itself keeps its column alignment for any inline content (icons, plain
   text), so single-line center/right columns still work as expected. */
.markdown-body td ul,
.markdown-body td ol,
.markdown-body td > p {
    text-align: left;
}
.markdown-body td ul,
.markdown-body td ol {
    margin: 0;
    padding-left: 1.2em;
}

.markdown-body thead tr {
    background: var(--bg-elevated);
    border-left: 3px solid var(--accent);
}

.markdown-body th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-default);
    /* Sticky inside the .page-content scroll container so column names stay
       visible on long tables. Per-theme thead backgrounds must be opaque
       (or layered over a solid base) so rows don't bleed through when
       scrolling underneath — see .theme-warcraft .markdown-body thead th. */
    position: sticky;
    top: 0;
    z-index: 2;
}

.theme-synthwave .markdown-body thead tr {
    border-bottom: 2px solid rgba(168, 85, 247, 0.3);
    border-left: none;
}

.theme-synthwave .markdown-body th {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--neon-purple);
}

.markdown-body th.sortable-with-btn {
    padding: 0;
}

.markdown-body th.sortable-with-btn .table-sort-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    user-select: none;
}

.markdown-body th.sortable-with-btn:hover .table-sort-btn {
    background: var(--bg-hover);
}

.markdown-body th.sortable-with-btn .table-sort-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.markdown-body th.sortable .table-sort-indicator {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.65;
}

.markdown-body th.sortable-direct {
    cursor: pointer;
    position: relative;
    padding-right: 32px;
}

.markdown-body th.sortable-direct:hover {
    background: var(--bg-hover);
}

.markdown-body th.sortable-direct:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.markdown-body th.sortable-direct > .table-sort-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.markdown-body th.sortable[data-sort-dir="asc"] .table-sort-indicator {
    border-bottom: 6px solid var(--text-secondary);
}

.markdown-body th.sortable[data-sort-dir="desc"] .table-sort-indicator {
    border-top: 6px solid var(--text-secondary);
}

.markdown-body tbody tr:nth-child(odd) {
    background: var(--bg-surface);
}

.markdown-body tbody tr:nth-child(even) {
    background: var(--bg-base);
}

.markdown-body tbody tr:hover {
    background: var(--bg-hover);
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.markdown-body .kroki-diagram {
    margin: var(--space-lg) 0;
}

.markdown-body figure.kroki-diagram {
    margin: var(--space-lg) 0;
}

.markdown-body .kroki-diagram img {
    /* Some Kroki renderers (notably d2) can emit very tall SVG viewboxes.
       Cap height to keep pages readable while preserving aspect ratio. */
    max-height: 65vh;
    max-width: 100%;
    width: auto;
    height: auto;
    display: block;
    /* Left-align by default to match typical Markdown image layout. */
    margin: 0;
    object-fit: contain;
}

.markdown-body .kroki-diagram.align-left img,
.markdown-body figure.kroki-diagram.align-left img {
    margin-left: 0;
    margin-right: auto;
}

.markdown-body .kroki-diagram.align-center img,
.markdown-body figure.kroki-diagram.align-center img {
    margin-left: auto;
    margin-right: auto;
}

.markdown-body .kroki-diagram.align-right img,
.markdown-body figure.kroki-diagram.align-right img {
    margin-left: auto;
    margin-right: 0;
}

.markdown-body figure.kroki-diagram figcaption {
    margin-top: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.trash-banner {
    margin: var(--space-md) 0 var(--space-lg) 0;
    padding: 10px 12px;
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

.trash-view h1 {
    margin-top: 0;
}

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

.trash-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: var(--space-lg);
}

.trash-row {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.trash-link {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 14px;
    text-decoration: none;
}

.trash-meta {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.markdown-body hr {
    border: none;
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-xl) 0;
}

.theme-synthwave .markdown-body hr {
    background: linear-gradient(90deg, transparent, var(--neon-purple), transparent);
    opacity: 0.4;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-nav);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.theme-synthwave .btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 0.08em;
}

.theme-synthwave .btn-small { font-size: 10px; }

.btn-primary {
    background: var(--accent);
    color: var(--bg-deep);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
    box-shadow: 0 0 20px var(--accent-dim), 0 0 40px var(--accent-dim);
}

.theme-corporate .btn-primary {
    color: white;
}

.theme-synthwave .btn-primary {
    color: var(--bg-deep);
}

.theme-synthwave .btn-primary:hover {
    box-shadow: 0 0 24px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}

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

.btn.active {
    color: var(--text-primary);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.btn-danger {
    background: var(--status-error);
    color: white;
    border-color: var(--status-error);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 11px;
}

/* Focus states */
.btn:focus-visible,
.nav-item:focus-visible,
.search-box input:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Modal
   ───────────────────────────────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 18, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.theme-corporate .modal {
    background: rgba(15, 23, 42, 0.6);
}

.theme-synthwave .modal {
    background: rgba(13, 2, 33, 0.85);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in 0.25s ease-out;
    box-shadow: 0 0 60px var(--accent-dim);
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-base);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
}

.modal-content-history {
    max-width: 920px;
}

/* Edit modal: page editor needs density and a tall textarea, not a heavy
   ornamental frame. Override the generic modal sizing and let the body
   stretch so the markdown textarea fills the available height. */
#edit-modal .modal-content {
    width: 95vw;
    max-width: 1400px;
    height: 95vh;
    max-height: 95vh;
}

#edit-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
}

#edit-modal .form-group {
    margin-bottom: 0;
}

#edit-modal .form-group:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#edit-modal #edit-content {
    flex: 1;
    min-height: 0;
    resize: none;
}

.history-modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.history-modal-subtitle {
    color: var(--text-secondary);
    font-size: 12px;
    word-break: break-all;
}

.history-status {
    min-height: 42px;
}

.history-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-base);
    color: var(--text-secondary);
    font-size: 12px;
}

.history-state-loading::before {
    content: '$ ';
    color: var(--accent);
}

.history-state-error {
    border-color: var(--status-error);
    color: var(--status-error);
}

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

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: 0;
    padding: 0;
}

.history-entry {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-base);
    padding: var(--space-md);
}

.history-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: 10px;
}

.history-entry-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 11px;
}

.history-entry-index {
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.history-entry-note {
    color: var(--text-muted);
    font-size: 11px;
}

.history-entry-preview {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group .label-hint {
    font-weight: 400;
    text-transform: none;
    color: var(--text-disabled);
    font-size: 10px;
    letter-spacing: normal;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-base);
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-disabled);
}

.form-group textarea {
    resize: vertical;
    line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Search Results
   ───────────────────────────────────────────────────────────────────────────── */
.search-results {
    position: absolute;
    top: 100%;
    left: var(--space-lg);
    right: var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-base);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.search-result-path {
    font-size: 11px;
    color: var(--text-muted);
}

.search-result-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.search-result-snippet mark {
    background: var(--accent-dim);
    color: var(--accent-bright);
    padding: 0 2px;
    border-radius: 2px;
}

/* Search Results List (in nav tree) */
.search-results-list {
    padding: var(--space-sm);
    max-width: 100%;
    overflow: hidden;
}

.search-results-hint {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid transparent;
}

.search-result-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.result-number {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.search-result-item:hover .result-number {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-deep);
}

.theme-synthwave .search-result-item:hover .result-number {
    box-shadow: 0 0 8px var(--accent-glow);
}

.result-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.result-title {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-path {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-shortcut {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--text-disabled);
    padding: 2px 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Animations
   ───────────────────────────────────────────────────────────────────────────── */
@keyframes slide-in {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes detail-in {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Staggered entrance */
.nav-group:nth-child(1) { animation-delay: 0.02s; }
.nav-group:nth-child(2) { animation-delay: 0.04s; }
.nav-group:nth-child(3) { animation-delay: 0.06s; }
.nav-group:nth-child(4) { animation-delay: 0.08s; }
.nav-group:nth-child(5) { animation-delay: 0.1s; }
.nav-group:nth-child(6) { animation-delay: 0.12s; }
.nav-group:nth-child(7) { animation-delay: 0.14s; }
.nav-group:nth-child(8) { animation-delay: 0.16s; }

/* ─────────────────────────────────────────────────────────────────────────────
   Toast Notifications
   ───────────────────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 2000;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-top: var(--space-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.3s ease;
    font-size: 12px;
}

.toast.success {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-dim);
}

.toast.error {
    border-color: var(--status-error);
}

.toast.info {
    border-color: var(--status-info);
}

.theme-synthwave .toast.success {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 16px var(--accent-dim);
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Mobile Menu
   ───────────────────────────────────────────────────────────────────────────── */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 1100;
    width: 44px;
    height: 44px;
    padding: var(--space-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-base);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
    background: var(--accent);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
    background: var(--accent);
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 18, 0.8);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.theme-corporate .mobile-overlay {
    background: rgba(15, 23, 42, 0.6);
}

.theme-synthwave .mobile-overlay {
    background: rgba(13, 2, 33, 0.85);
}

.mobile-overlay.active {
    opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Gitea Embed
   ───────────────────────────────────────────────────────────────────────────── */
.gitea-embed {
    margin: var(--space-lg) 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-deep);
    max-width: 100%;
    width: fit-content;
}

.theme-corporate .gitea-embed {
    background: #0F1B2D;
    border-color: #1C2D45;
}

.theme-corporate .gitea-embed-header {
    background: #162338;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.theme-corporate .gitea-embed code {
    color: #CBD5E1;
}

.gitea-embed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--space-md);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
}

.gitea-embed-path {
    color: var(--accent);
    font-weight: 500;
    font-family: var(--font-mono);
}

.theme-synthwave .gitea-embed-header {
    background: rgba(168, 85, 247, 0.08);
}

.theme-synthwave .gitea-embed-link:hover {
    color: var(--bg-deep);
}

.gitea-embed-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.gitea-embed-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-deep);
}

.gitea-embed pre {
    margin: 0;
    padding: var(--space-md);
    overflow-x: auto;
    background: transparent;
    border: none;
    border-radius: 0;
}

.gitea-embed pre::before {
    display: none;
}

.gitea-embed code {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
}

/* Embedded README/.md rendered as markdown (not as a code listing).
   Takes the full embed width and gets its own padding so headings and
   paragraphs breathe; inner code blocks still pick up the .sy-code
   syntect styles from the page-wide highlighter. */
.gitea-embed.gitea-embed-markdown {
    width: 100%;
    max-width: 100%;
}

.gitea-embed-markdown .markdown-body {
    padding: var(--space-md);
    background: transparent;
}

.gitea-embed-markdown .markdown-body > :first-child {
    margin-top: 0;
}

.gitea-embed-markdown .markdown-body > :last-child {
    margin-bottom: 0;
}

.gitea-embed-error {
    border-color: var(--status-error);
}

.gitea-embed-error .gitea-embed-header {
    background: rgba(239, 68, 68, 0.1);
}

.gitea-embed-error .gitea-embed-path {
    color: var(--status-error);
}

.gitea-embed-error pre {
    color: var(--status-error);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Expandable Code Blocks
   ───────────────────────────────────────────────────────────────────────────── */
.code-block-wrapper {
    position: relative;
    margin-bottom: var(--space-md);
    width: fit-content;
    max-width: 100%;
}

.code-block-wrapper.collapsed pre {
    max-height: 300px;
    overflow: hidden;
}

.code-block-wrapper.collapsed::after {
    display: none;
}

.code-expand-btn {
    display: none;
    width: 100%;
    padding: 10px var(--space-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.code-block-wrapper.expandable .code-expand-btn {
    display: block;
}

.code-expand-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.code-block-wrapper.expanded pre {
    max-height: none;
}

.code-block-wrapper.expanded::after {
    display: none;
}

/* Adjust pre in wrapper */
.code-block-wrapper pre {
    margin-bottom: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.code-block-wrapper.expanded pre,
.code-block-wrapper:not(.expandable) pre {
    border-radius: var(--radius-md);
}

/* Gitea embed expandable */
.gitea-embed.expandable.collapsed pre {
    max-height: 300px;
    overflow: hidden;
}

.gitea-embed.expandable.collapsed::after {
    display: none;
}

.gitea-embed.expandable {
    position: relative;
}

.gitea-embed.expandable .code-expand-btn {
    display: block;
}

.gitea-embed .code-expand-btn {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border: none;
    border-top: 1px solid var(--border-subtle);
}

.gitea-embed.expanded pre {
    max-height: none;
}

.gitea-embed.expanded::after {
    display: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
        pointer-events: none;
    }

    .mobile-overlay.active {
        pointer-events: auto;
    }

    .sidebar {
        width: 240px;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .content {
        margin-left: 0;
    }

    .content-header {
        padding: var(--space-md);
        padding-left: 68px;
    }

    .page-content {
        padding: var(--space-md);
    }

    .welcome {
        margin: var(--space-2xl) auto;
    }

    .welcome h1 {
        font-size: 24px;
    }

    .modal-content-history {
        width: calc(100% - 24px);
        max-height: calc(100vh - 24px);
    }

    .history-entry-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Print Styles
   ───────────────────────────────────────────────────────────────────────────── */
@media print {
    .sidebar,
    .mobile-menu-btn,
    .actions,
    .toast-container,
    .settings-wrapper {
        display: none !important;
    }

    .content {
        margin: 0;
    }

    .page-content {
        padding: 0;
    }

    .markdown-body pre {
        white-space: pre-wrap;
        word-wrap: break-word;
    }
}

/* ============================================================
   Syntax Highlighting — CSS class-based (syntect sy- prefix)
   Three theme variants scoped under body theme classes.
   Generated from syntect themes; do not hand-edit colors.
   ============================================================ */

/* --- Terminal theme: Breeze Dark --- */
.terminal-theme .sy-code { color: #cfcfc2; }
.terminal-theme .sy-meta.sy-group, .terminal-theme .sy-meta.sy-method-call.sy-source, .terminal-theme .sy-meta.sy-method.sy-body, .terminal-theme .sy-none, .terminal-theme .sy-source, .terminal-theme .sy-text { color: #cfcfc2; }
.terminal-theme .sy-keyword.sy-operator.sy-accessor, .terminal-theme .sy-meta.sy-brace, .terminal-theme .sy-meta.sy-delimiter, .terminal-theme .sy-meta.sy-separator, .terminal-theme .sy-punctuation { color: #cfcfc2; }
.terminal-theme .sy-comment, .terminal-theme .sy-comment .sy-text, .terminal-theme .sy-punctuation.sy-definition.sy-comment, .terminal-theme .sy-string.sy-comment { color: #7a7c7d; font-style: italic; }
.terminal-theme .sy-comment.sy-block.sy-documentation, .terminal-theme .sy-storage.sy-type.sy-class.sy-jsdoc, .terminal-theme .sy-keyword.sy-other.sy-documentation { color: #3daee9; }
.terminal-theme .sy-keyword, .terminal-theme .sy-keyword.sy-control, .terminal-theme .sy-keyword.sy-other, .terminal-theme .sy-storage.sy-modifier, .terminal-theme .sy-storage.sy-type { color: #fdbc4b; font-weight: bold; }
.terminal-theme .sy-keyword.sy-control.sy-conditional, .terminal-theme .sy-keyword.sy-control.sy-loop, .terminal-theme .sy-keyword.sy-control.sy-flow, .terminal-theme .sy-keyword.sy-control.sy-return, .terminal-theme .sy-keyword.sy-control.sy-break, .terminal-theme .sy-keyword.sy-control.sy-continue { color: #fdbc4b; font-weight: bold; }
.terminal-theme .sy-keyword.sy-operator, .terminal-theme .sy-keyword.sy-operator.sy-arithmetic, .terminal-theme .sy-keyword.sy-operator.sy-assignment, .terminal-theme .sy-keyword.sy-operator.sy-comparison, .terminal-theme .sy-keyword.sy-operator.sy-logical { color: #3f8058; }
.terminal-theme .sy-entity.sy-name.sy-function, .terminal-theme .sy-meta.sy-function-call, .terminal-theme .sy-support.sy-function, .terminal-theme .sy-variable.sy-function { color: #8e44ad; }
.terminal-theme .sy-entity.sy-name.sy-class, .terminal-theme .sy-entity.sy-name.sy-type, .terminal-theme .sy-entity.sy-name.sy-struct, .terminal-theme .sy-entity.sy-name.sy-enum, .terminal-theme .sy-entity.sy-name.sy-trait, .terminal-theme .sy-entity.sy-name.sy-interface, .terminal-theme .sy-support.sy-class, .terminal-theme .sy-support.sy-type { color: #2980b9; }
.terminal-theme .sy-variable, .terminal-theme .sy-variable.sy-other, .terminal-theme .sy-variable.sy-parameter { color: #cfcfc2; }
.terminal-theme .sy-constant, .terminal-theme .sy-constant.sy-other, .terminal-theme .sy-variable.sy-other.sy-constant, .terminal-theme .sy-support.sy-constant { color: #27aeae; }
.terminal-theme .sy-string, .terminal-theme .sy-string.sy-quoted, .terminal-theme .sy-string.sy-template { color: #f44f4f; }
.terminal-theme .sy-constant.sy-character.sy-escape, .terminal-theme .sy-string .sy-variable, .terminal-theme .sy-string.sy-interpolated, .terminal-theme .sy-punctuation.sy-definition.sy-template-expression, .terminal-theme .sy-punctuation.sy-section.sy-embedded { color: #27aeae; }
.terminal-theme .sy-constant.sy-numeric { color: #f67400; }
.terminal-theme .sy-constant.sy-language.sy-boolean { color: #27aeae; }
.terminal-theme .sy-constant.sy-language.sy-null, .terminal-theme .sy-constant.sy-language.sy-undefined, .terminal-theme .sy-constant.sy-language.sy-none { color: #27aeae; }
.terminal-theme .sy-keyword.sy-control.sy-import, .terminal-theme .sy-keyword.sy-control.sy-from, .terminal-theme .sy-keyword.sy-control.sy-export, .terminal-theme .sy-keyword.sy-other.sy-import, .terminal-theme .sy-meta.sy-preprocessor, .terminal-theme .sy-keyword.sy-control.sy-directive { color: #27ae60; }
.terminal-theme .sy-entity.sy-name.sy-module, .terminal-theme .sy-entity.sy-name.sy-namespace, .terminal-theme .sy-support.sy-other.sy-module { color: #27ae60; }
.terminal-theme .sy-entity.sy-name.sy-tag.sy-attribute, .terminal-theme .sy-meta.sy-attribute, .terminal-theme .sy-meta.sy-decorator, .terminal-theme .sy-punctuation.sy-definition.sy-annotation { color: #3daee9; }
.terminal-theme .sy-entity.sy-name.sy-tag, .terminal-theme .sy-punctuation.sy-definition.sy-tag { color: #2980b9; }
.terminal-theme .sy-entity.sy-other.sy-attribute-name { color: #27aeae; }
.terminal-theme .sy-support.sy-type.sy-property-name.sy-css, .terminal-theme .sy-meta.sy-property-name.sy-css { color: #3daee9; }
.terminal-theme .sy-support.sy-constant.sy-property-value.sy-css, .terminal-theme .sy-meta.sy-property-value.sy-css { color: #f67400; }
.terminal-theme .sy-entity.sy-name.sy-tag.sy-css, .terminal-theme .sy-entity.sy-other.sy-attribute-name.sy-class.sy-css, .terminal-theme .sy-entity.sy-other.sy-attribute-name.sy-id.sy-css { color: #27ae60; }
.terminal-theme .sy-meta.sy-structure.sy-dictionary.sy-key .sy-string, .terminal-theme .sy-support.sy-type.sy-property-name.sy-json { color: #3daee9; }
.terminal-theme .sy-entity.sy-name.sy-tag.sy-yaml { color: #3daee9; }
.terminal-theme .sy-markup.sy-heading, .terminal-theme .sy-entity.sy-name.sy-section.sy-markdown, .terminal-theme .sy-punctuation.sy-definition.sy-heading.sy-markdown { color: #2980b9; font-weight: bold; }
.terminal-theme .sy-markup.sy-bold { color: #f67400; font-weight: bold; }
.terminal-theme .sy-markup.sy-italic { color: #fdbc4b; font-style: italic; }
.terminal-theme .sy-markup.sy-underline.sy-link, .terminal-theme .sy-string.sy-other.sy-link { color: #27ae60; }
.terminal-theme .sy-markup.sy-raw, .terminal-theme .sy-markup.sy-inline.sy-raw, .terminal-theme .sy-markup.sy-fenced_code { color: #27aeae; }
.terminal-theme .sy-markup.sy-list, .terminal-theme .sy-punctuation.sy-definition.sy-list { color: #f44f4f; }
.terminal-theme .sy-markup.sy-inserted { color: #27ae60; }
.terminal-theme .sy-markup.sy-deleted { color: #da4453; }
.terminal-theme .sy-markup.sy-changed { color: #f67400; }
.terminal-theme .sy-invalid, .terminal-theme .sy-invalid.sy-illegal { color: #da4453; }
.terminal-theme .sy-invalid.sy-deprecated { color: #da4453; text-decoration: underline; font-style: italic; }
.terminal-theme .sy-support.sy-function.sy-builtin, .terminal-theme .sy-support.sy-variable.sy-magic, .terminal-theme .sy-variable.sy-language { color: #609ca0; }
.terminal-theme .sy-string.sy-regexp { color: #8e44ad; }
.terminal-theme .sy-variable.sy-other.sy-normal.sy-shell, .terminal-theme .sy-variable.sy-other.sy-positional.sy-shell, .terminal-theme .sy-variable.sy-other.sy-bracket.sy-shell { color: #27aeae; }
.terminal-theme .sy-keyword.sy-other.sy-sql, .terminal-theme .sy-keyword.sy-other.sy-DML.sy-sql, .terminal-theme .sy-keyword.sy-other.sy-DDL.sy-sql { color: #fdbc4b; font-weight: bold; }

/* --- Corporate theme: Base16 Ocean Dark --- */
.theme-corporate .sy-code { color: #c0c5ce; }
.theme-corporate .sy-variable.sy-parameter.sy-function { color: #c0c5ce; }
.theme-corporate .sy-comment, .theme-corporate .sy-punctuation.sy-definition.sy-comment { color: #65737e; }
.theme-corporate .sy-keyword.sy-operator { color: #c0c5ce; }
.theme-corporate .sy-keyword { color: #b48ead; }
.theme-corporate .sy-variable, .theme-corporate .sy-variable.sy-other.sy-dollar.sy-only.sy-js { color: #bf616a; }
.theme-corporate .sy-entity.sy-name.sy-function, .theme-corporate .sy-meta.sy-require, .theme-corporate .sy-support.sy-function.sy-any-method, .theme-corporate .sy-variable.sy-function { color: #8fa1b3; }
.theme-corporate .sy-support.sy-class, .theme-corporate .sy-entity.sy-name.sy-class, .theme-corporate .sy-entity.sy-name.sy-type.sy-class { color: #ebcb8b; }
.theme-corporate .sy-meta.sy-class { color: #eff1f5; }
.theme-corporate .sy-keyword.sy-other.sy-special-method { color: #8fa1b3; }
.theme-corporate .sy-storage { color: #b48ead; }
.theme-corporate .sy-support.sy-function { color: #96b5b4; }
.theme-corporate .sy-string, .theme-corporate .sy-constant.sy-other.sy-symbol, .theme-corporate .sy-entity.sy-other.sy-inherited-class { color: #a3be8c; }
.theme-corporate .sy-constant.sy-numeric { color: #d08770; }
.theme-corporate .sy-constant { color: #d08770; }
.theme-corporate .sy-entity.sy-name.sy-tag { color: #bf616a; }
.theme-corporate .sy-entity.sy-other.sy-attribute-name { color: #d08770; }
.theme-corporate .sy-entity.sy-other.sy-attribute-name.sy-id, .theme-corporate .sy-punctuation.sy-definition.sy-entity { color: #8fa1b3; }
.theme-corporate .sy-meta.sy-selector { color: #b48ead; }
.theme-corporate .sy-markup.sy-heading .sy-punctuation.sy-definition.sy-heading, .theme-corporate .sy-entity.sy-name.sy-section { color: #8fa1b3; }
.theme-corporate .sy-keyword.sy-other.sy-unit { color: #d08770; }
.theme-corporate .sy-markup.sy-bold, .theme-corporate .sy-punctuation.sy-definition.sy-bold { color: #ebcb8b; font-weight: bold; }
.theme-corporate .sy-markup.sy-italic, .theme-corporate .sy-punctuation.sy-definition.sy-italic { color: #b48ead; font-style: italic; }
.theme-corporate .sy-markup.sy-raw.sy-inline { color: #a3be8c; }
.theme-corporate .sy-string.sy-other.sy-link { color: #bf616a; }
.theme-corporate .sy-markup.sy-list { color: #bf616a; }
.theme-corporate .sy-markup.sy-inserted { color: #a3be8c; }
.theme-corporate .sy-markup.sy-deleted { color: #bf616a; }
.theme-corporate .sy-markup.sy-changed { color: #b48ead; }
.theme-corporate .sy-constant.sy-other.sy-color { color: #96b5b4; }
.theme-corporate .sy-string.sy-regexp { color: #96b5b4; }
.theme-corporate .sy-constant.sy-character.sy-escape { color: #96b5b4; }
.theme-corporate .sy-punctuation.sy-section.sy-embedded, .theme-corporate .sy-variable.sy-interpolation { color: #ab7967; }
.theme-corporate .sy-invalid.sy-illegal { color: #2b303b; background-color: #bf616a; }

/* --- Synthwave theme: Neon (based on Base16 Eighties Dark, neon-ified) --- */
.theme-synthwave .sy-code { color: #e2e0f0; }
.theme-synthwave .sy-variable.sy-parameter.sy-function { color: #e2e0f0; }
.theme-synthwave .sy-comment, .theme-synthwave .sy-punctuation.sy-definition.sy-comment { color: #6c6783; font-style: italic; }
.theme-synthwave .sy-keyword.sy-operator { color: #e2e0f0; }
.theme-synthwave .sy-keyword { color: #ff79c6; }
.theme-synthwave .sy-variable, .theme-synthwave .sy-variable.sy-other.sy-dollar.sy-only.sy-js { color: #ff6e96; }
.theme-synthwave .sy-entity.sy-name.sy-function, .theme-synthwave .sy-meta.sy-require, .theme-synthwave .sy-support.sy-function.sy-any-method, .theme-synthwave .sy-variable.sy-function { color: #00e5ff; }
.theme-synthwave .sy-support.sy-class, .theme-synthwave .sy-entity.sy-name.sy-class, .theme-synthwave .sy-entity.sy-name.sy-type.sy-class { color: #bd93f9; }
.theme-synthwave .sy-meta.sy-class { color: #f8f0ff; }
.theme-synthwave .sy-keyword.sy-other.sy-special-method { color: #00e5ff; }
.theme-synthwave .sy-storage { color: #ff79c6; }
.theme-synthwave .sy-support.sy-function { color: #50fa7b; }
.theme-synthwave .sy-string, .theme-synthwave .sy-constant.sy-other.sy-symbol, .theme-synthwave .sy-entity.sy-other.sy-inherited-class { color: #f1fa8c; }
.theme-synthwave .sy-constant.sy-numeric { color: #ffb86c; }
.theme-synthwave .sy-constant { color: #ffb86c; }
.theme-synthwave .sy-entity.sy-name.sy-tag { color: #ff6e96; }
.theme-synthwave .sy-entity.sy-other.sy-attribute-name { color: #ffb86c; }
.theme-synthwave .sy-entity.sy-other.sy-attribute-name.sy-id, .theme-synthwave .sy-punctuation.sy-definition.sy-entity { color: #00e5ff; }
.theme-synthwave .sy-meta.sy-selector { color: #ff79c6; }
.theme-synthwave .sy-markup.sy-heading .sy-punctuation.sy-definition.sy-heading, .theme-synthwave .sy-entity.sy-name.sy-section { color: #00e5ff; }
.theme-synthwave .sy-keyword.sy-other.sy-unit { color: #ffb86c; }
.theme-synthwave .sy-markup.sy-bold, .theme-synthwave .sy-punctuation.sy-definition.sy-bold { color: #bd93f9; font-weight: bold; }
.theme-synthwave .sy-markup.sy-italic, .theme-synthwave .sy-punctuation.sy-definition.sy-italic { color: #ff79c6; font-style: italic; }
.theme-synthwave .sy-markup.sy-raw.sy-inline { color: #50fa7b; }
.theme-synthwave .sy-string.sy-other.sy-link { color: #ff6e96; }
.theme-synthwave .sy-markup.sy-list { color: #ff6e96; }
.theme-synthwave .sy-markup.sy-inserted { color: #50fa7b; }
.theme-synthwave .sy-markup.sy-deleted { color: #ff6e96; }
.theme-synthwave .sy-markup.sy-changed { color: #ff79c6; }
.theme-synthwave .sy-constant.sy-other.sy-color { color: #50fa7b; }
.theme-synthwave .sy-string.sy-regexp { color: #50fa7b; }
.theme-synthwave .sy-constant.sy-character.sy-escape { color: #50fa7b; }
.theme-synthwave .sy-punctuation.sy-section.sy-embedded, .theme-synthwave .sy-variable.sy-interpolation { color: #ff6e40; }
.theme-synthwave .sy-invalid.sy-illegal { color: #0a0015; background-color: #ff6e96; }

/* ─────────────────────────────────────────────────────────────────────────────
   THEME: Warcraft — Obsidian & Bronze
   Stone-cold substrate + warm parchment text + bronze trim. The temperature
   contrast (warm fg on cool bg) is the whole move; an all-brown bg fights
   with the parchment text instead of staging it. Border-image button frames
   are still adapted from warcraftcn-ui (MIT, fan-made).
   ───────────────────────────────────────────────────────────────────────────── */
.theme-warcraft {
    /* Backgrounds: near-black obsidian with a faint warm tint (8% red shift)
       so the page doesn't read as sterile UI gray. Cool enough to make the
       parchment text glow against it. */
    --bg-deep:     #0c0d10;
    --bg-base:     #14161b;
    --bg-surface:  #1c1f25;
    --bg-elevated: #252830;
    --bg-hover:    #2e323c;

    /* Borders graduate from charcoal to bronze. The "default" weight is the
       hairline used on tables, code, and panel edges. */
    --border-subtle:  #262932;
    --border-default: #3a3e48;
    --border-strong:  #6b5028;   /* bronze, used for emphasis only */

    /* Aged-parchment text. Same hue as before, retuned for cool substrate. */
    --text-primary:   #ece1c4;
    --text-secondary: #b8a684;
    --text-muted:     #786a52;
    --text-disabled:  #4a443a;

    /* Bronze accent — slightly redder than the previous gold so it reads
       "polished bronze" rather than "yellow highlighter" against obsidian. */
    --accent:        #c89058;
    --accent-bright: #e8a868;
    --accent-dim:    rgba(200, 144, 88, 0.15);
    --accent-glow:   rgba(200, 144, 88, 0.4);

    --status-error:   #c54a3f;
    --status-warning: #d4a853;
    --status-info:    #5aaaa5;

    /* Body / nav / tables use Inter — these pages are mostly tables and
       talent grids; Cinzel/Cormorant lost word recognition at small sizes.
       Cinzel stays on display surfaces (h1/h2/h3, logo). */
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-heading: 'Cinzel', 'Inter', serif;
    --font-nav: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.75);
}

/* Per-instance accent variants — intentionally none. Both instance-coa and
   instance-classic share the bronze-gold accent so the Exiles guild wikis
   match db.exil.es (coa-db-exiles.css uses --gold: #c89058). Reintroduce a
   per-instance override here only if a future instance needs to diverge. */

/* Heading polish — Cinzel reads better with extra letter-spacing at small sizes */
.theme-warcraft h1,
.theme-warcraft h2,
.theme-warcraft h3,
.theme-warcraft .logo-text {
    letter-spacing: 0.04em;
    font-weight: 700;
}

/* Reading surface — candlelit library, not fluorescent panel.
   The radial gradient warms the center of the viewport ~6% above bg-deep,
   so prose reads inside a soft pool of light and the table edges fade
   into stone. Fixed attachment so it doesn't streak on long pages. */
.theme-warcraft body {
    background:
        radial-gradient(ellipse 90% 70% at 50% 25%, rgba(200, 144, 88, 0.06), transparent 70%),
        var(--bg-deep);
    background-attachment: fixed;
}

.theme-warcraft .markdown-body { font-family: var(--font-body); line-height: 1.6; }
.theme-warcraft .markdown-body code,
.theme-warcraft .markdown-body pre { font-family: var(--font-mono); }

/* Tables — the dominant element on class/comparison pages. Bronze hairlines,
   gold-tinted header row, restrained zebra. Header keeps its uppercase tone
   from the underlying base styles; we just give it a substrate and a rule. */
.theme-warcraft .markdown-body table {
    font-size: 0.92rem;
    border-collapse: collapse;
    border: 1px solid var(--border-default);
    background: var(--bg-base);
    box-shadow: var(--shadow-sm);
}
.theme-warcraft .markdown-body th,
.theme-warcraft .markdown-body td {
    border: 1px solid var(--border-subtle);
    padding: 0.5em 0.75em;
}
.theme-warcraft .markdown-body thead th {
    /* Gold tint layered over a solid obsidian base — the base layer is
       required because thead is sticky (see .markdown-body th) and the
       tint alone would let rows scroll through visibly. */
    background:
        linear-gradient(180deg, rgba(200, 144, 88, 0.14), rgba(200, 144, 88, 0.04)),
        var(--bg-base);
    color: var(--accent-bright);
    border-bottom: 1px solid var(--accent);
    font-family: var(--font-heading);
    letter-spacing: 0.04em;
    font-weight: 700;
}
.theme-warcraft .markdown-body tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.012);   /* almost imperceptible — depth, not stripe */
}
.theme-warcraft .markdown-body tbody tr:hover td {
    background: rgba(200, 144, 88, 0.05);
}

/* Inline code — bronze tint on a slate-ink chip. Not the same as block code. */
.theme-warcraft .markdown-body :not(pre) > code {
    background: var(--bg-elevated);
    color: var(--accent-bright);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.05em 0.4em;
    font-size: 0.92em;
}

/* Block code — stone slab. Bronze hairline matches the table treatment. */
.theme-warcraft .markdown-body pre {
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 1em 1.15em;
    box-shadow: var(--shadow-sm);
}

/* Blockquotes — bronze rule + faint warm wash. Reads as a parchment cite. */
.theme-warcraft .markdown-body blockquote {
    border-left: 3px solid var(--accent);
    background: rgba(200, 144, 88, 0.06);
    color: var(--text-secondary);
    padding: 0.6em 1em;
    margin: 1em 0;
    font-style: italic;
}

/* Section rules under headings — subtle bronze underline so h1/h2 anchor
   their sections without a thick separator. h3 stays clean. */
.theme-warcraft .markdown-body h1,
.theme-warcraft .markdown-body h2 {
    border-bottom: 1px solid var(--border-default);
    padding-bottom: 0.25em;
    margin-top: 1.6em;
}
.theme-warcraft .markdown-body h1 { border-bottom-color: var(--accent); }

/* Page links — bronze, underlined on hover. Default underline is the
   "magic ink" that marks them, hover brightens. */
.theme-warcraft .markdown-body a {
    color: var(--accent-bright);
    text-decoration: underline;
    text-decoration-color: var(--accent-dim);
    text-underline-offset: 0.18em;
    transition: text-decoration-color 0.12s ease, color 0.12s ease;
}
.theme-warcraft .markdown-body a:hover {
    color: #f6c084;
    text-decoration-color: var(--accent);
}

/* Horizontal rule — twin bronze lines, like a chapter break in a tome. */
.theme-warcraft .markdown-body hr {
    border: 0;
    height: 3px;
    margin: 2em 0;
    background:
        linear-gradient(180deg, var(--accent-dim), transparent 50%, var(--accent-dim)),
        linear-gradient(90deg, transparent, var(--border-strong), transparent);
    background-size: 100% 3px, 100% 1px;
    background-position: 0 0, 0 1px;
    background-repeat: no-repeat;
}

/* Buttons — flat bronze-bordered panel that lights up gold on hover.
   Mirrors db.exil.es's .btn / .home-chip treatment (coa-db.css §10,
   coa-db-exiles.css .home-chip). No border-image; the warcraftcn-ui
   webp frames were the wrong scale for Tome's nav buttons and carried
   a baked-in blue tint that fought the bronze theme. */
.theme-warcraft .btn,
.theme-warcraft .btn-small,
.theme-warcraft .btn-primary,
.theme-warcraft .btn-secondary,
.theme-warcraft .btn-instance,
.theme-warcraft .btn-danger {
    background: rgba(20, 22, 27, 0.85);
    color: var(--text-secondary);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.78rem;
    padding: 0.4rem 0.9rem;
    text-decoration: none;
    transition: color 120ms ease, border-color 120ms ease,
                background-color 120ms ease, box-shadow 240ms ease;
}
.theme-warcraft .btn:hover,
.theme-warcraft .btn:focus-visible,
.theme-warcraft .btn-small:hover,
.theme-warcraft .btn-small:focus-visible,
.theme-warcraft .btn-secondary:hover,
.theme-warcraft .btn-instance:hover {
    color: var(--accent-bright);
    border-color: var(--accent);
    background: rgba(20, 22, 27, 0.92);
    box-shadow:
        0 0 0 1px rgba(200, 144, 88, 0.20),
        0 0 18px rgba(200, 144, 88, 0.15);
}
.theme-warcraft .btn:active,
.theme-warcraft .btn-small:active { transform: translateY(1px); }

/* Primary button — solid bronze, dark text. The "go" affordance. */
.theme-warcraft .btn-primary {
    background: var(--accent);
    color: #1a1410;
    border-color: var(--accent-bright);
}
.theme-warcraft .btn-primary:hover,
.theme-warcraft .btn-primary:focus-visible {
    background: var(--accent-bright);
    color: #1a1410;
    border-color: var(--accent-bright);
    box-shadow:
        0 0 0 1px rgba(232, 168, 104, 0.30),
        0 0 22px rgba(232, 168, 104, 0.25);
}

/* Active sibling instance — dim gold rule so the current site reads as
   "you are here", matching the breadcrumb/current-page treatment. */
.theme-warcraft .btn-instance.active {
    color: var(--accent-bright);
    border-color: var(--accent);
    background: rgba(200, 144, 88, 0.10);
}

/* Danger (delete) — keep the red signal but in the bronze frame so it
   visually belongs to the same button family. */
.theme-warcraft .btn-danger { color: var(--status-error); }
.theme-warcraft .btn-danger:hover,
.theme-warcraft .btn-danger:focus-visible {
    color: #f0786b;
    border-color: var(--status-error);
    background: rgba(197, 74, 63, 0.08);
    box-shadow:
        0 0 0 1px rgba(197, 74, 63, 0.25),
        0 0 18px rgba(197, 74, 63, 0.18);
}

/* TheTable knowledge-card flag (tt_card) is a tome.sub-net.at-only
   concept; the Exiles guild wikis don't surface it. Hide the action-bar
   toggle on instance-coa / instance-classic regardless of theme. */
.instance-coa .action-flag,
.instance-classic .action-flag { display: none; }

/* Text inputs (search, form fields) and textarea — flat bronze panel
   matching the buttons and the db.exil.es .site-search treatment. The
   warcraftcn-ui input-frame.webp/textarea-bg.webp wood frames were too
   ornamental for a working editor and the border-image bled past the
   modal padding box. */
.theme-warcraft .search-box input,
.theme-warcraft .form-group input,
.theme-warcraft input[type="text"],
.theme-warcraft input[type="search"],
.theme-warcraft textarea {
    background: rgba(20, 22, 27, 0.85);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-body);
    transition: border-color 120ms ease, box-shadow 240ms ease;
}
.theme-warcraft textarea { font-family: var(--font-mono); line-height: 1.55; }
.theme-warcraft .search-box input:focus,
.theme-warcraft .form-group input:focus,
.theme-warcraft input[type="text"]:focus,
.theme-warcraft input[type="search"]:focus,
.theme-warcraft textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow:
        0 0 0 1px rgba(200, 144, 88, 0.25),
        0 0 18px rgba(200, 144, 88, 0.15);
}

/* Modals use the same flat translucent panel as .page-content > article.
   The card-bg.webp ornamental frame was scaled wrong on tall content
   modals and the 24px border-image inset broke the modal's max-height
   accounting (textarea got cropped). */
.theme-warcraft .modal-content {
    background: var(--panel-bg-strong);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    box-shadow: 0 0 60px var(--accent-dim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Settings dropdown — flat bronze panel, same family as the buttons /
   inputs / modal so the warcraft chrome reads as one design language. */
.theme-warcraft .settings-menu {
    background: var(--panel-bg-strong);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}

/* Theme switcher swatch — obsidian → stone → bronze. */
.theme-preview--warcraft {
    background: linear-gradient(135deg, #14161b 0%, #252830 50%, #c89058 100%);
    border: 1px solid #3a3e48;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Warcraft theme — db.exil.es alignment overlay
   ────────────────────────────────────────────────────────────────────────────
   These rules pull the Warcraft theme visually closer to db.exil.es (the
   coa-db site) without porting its biome backdrop / particle canvas. The
   moves are:
     - translucent panels with a backdrop-blur so the warm radial pool of
       light on body bleeds through subtly (matches the .spell-page,
       .item-page, etc. treatment in coa-db-exiles.css)
     - gold-tinted borders rather than charcoal hairlines
     - Cinzel-uppercase nav group headers, matching db.exil.es's
       .site-nav__link
     - gold-glow search focus matching .site-search:focus-within
   ───────────────────────────────────────────────────────────────────────── */

/* db.exil.es-style bronze border tokens, exposed alongside the existing
   --border-* tokens so we can opt panels in without touching all sites that
   read the originals. */
.theme-warcraft {
    --panel-bg:        rgba(20, 22, 27, 0.78);
    --panel-bg-strong: rgba(12, 13, 16, 0.84);
    --panel-border:    rgba(140, 100, 60, 0.42);
    --panel-border-hi: rgba(200, 144, 88, 0.65);
}

/* .app sets its own bg-deep over the body — make it transparent so the
   .theme-warcraft body radial gradient (the candlelit pool of light) can
   show through the translucent sidebar / content panels below. */
.theme-warcraft .app { background: transparent; }

/* Sidebar — frosted obsidian with a bronze hairline on the right edge. */
.theme-warcraft .sidebar {
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.theme-warcraft .sidebar-header { border-bottom-color: var(--panel-border); }
.theme-warcraft .sidebar-footer {
    background: rgba(12, 13, 16, 0.62);
    border-top-color: var(--panel-border);
}

/* Nav group headers — Cinzel uppercase, like db.exil.es .site-nav__link.
   Individual nav-items (page titles) stay in Inter for word recognition. */
.theme-warcraft .nav-group-header {
    font-family: var(--font-heading);
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.theme-warcraft .nav-group-header:hover { color: var(--accent-bright); }
.theme-warcraft .nav-group.expanded > .nav-group-header { color: var(--accent); }

/* Active nav item — gold tint + tinted left rule, mirrors db.exil.es's
   listview row hover wash. */
.theme-warcraft .nav-item.active {
    color: var(--accent-bright);
    background: rgba(200, 144, 88, 0.08);
}

/* Search box — match .site-search from coa-db-exiles.css: translucent
   panel + bronze focus ring with soft outer glow. */
.theme-warcraft .search-box input {
    background: rgba(20, 22, 27, 0.85);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
}
.theme-warcraft .search-box input:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 1px rgba(200, 144, 88, 0.25),
        0 0 24px rgba(200, 144, 88, 0.18);
}

/* Content shell — let the body gradient through, then re-establish a
   subtle bronze rule under the header. */
.theme-warcraft .content { background: transparent; }
.theme-warcraft .content-header {
    background: rgba(12, 13, 16, 0.62);
    border-bottom-color: var(--panel-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Page article wraps the rendered markdown in a translucent obsidian
   panel with a bronze hairline — mirrors db.exil.es's .spell-page,
   .item-page, .quest-page, .listing treatment. */
.theme-warcraft .page-content > article,
.theme-warcraft .page-content > .welcome {
    background: var(--panel-bg-strong);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 1.4rem 1.6rem 1.8rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
/* Graph mode is full-bleed by design — don't wrap it in a panel. */
.theme-warcraft .page-content.graph-mode > article {
    background: transparent;
    border: 0;
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
