:root {
    --primary: #e30613;
    --primary-dark: #b8050f;
    --primary-light: #ff1a2a;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --border-color: #e8eaed;
    --border-light: #f1f3f4;
    --sidebar-width: 280px;
    --header-height: 64px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --border-color: #3c4043;
    --border-light: #2d2d2d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(255,255,255,0.95);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    backdrop-filter: blur(8px);
}

[data-theme="dark"] .header {
    background: rgba(26,26,26,0.95);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.header-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.header-title { font-weight: 600; font-size: 18px; }

.header-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.menu-toggle:hover { background: var(--bg-tertiary); }

.theme-toggle {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 16px 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-section { padding: 0 12px; margin-bottom: 8px; }

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
}

.nav-item {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--radius-sm);
    margin: 2px 0;
    transition: var(--transition);
}

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

.nav-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.nav-item.active:hover { background: var(--primary-dark); }

/* Main Content */
.main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

.content {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 48px;
    animation: fadeIn 0.3s ease;
}

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

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

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

.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-separator { color: var(--text-muted); }

/* Typography */
h1, .heading {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--text-primary) !important;
}

h2, .subheading {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 48px 0 16px 0;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
    color: var(--text-primary);
}

h2:first-of-type, .subheading:first-of-type {
    margin-top: 32px;
    border-top: none;
    padding-top: 0;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 32px 0 12px 0;
    color: var(--text-primary);
}

p { margin-bottom: 16px; color: var(--text-secondary); }
strong { font-weight: 600; color: var(--text-primary); }

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

a:hover { text-decoration: underline; }

/* Lists */
ol, ul, .list { margin: 16px 0; padding-left: 24px; }
li { margin-bottom: 12px; color: var(--text-secondary); }
li::marker { color: var(--primary); font-weight: 600; }

/* Images & Figures */
figure, .figure, .img_original {
    margin: 32px 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

figure img, .figure img, .img_original img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: block;
}

figcaption, .figure-caption {
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

tr:hover { background: var(--bg-tertiary); }

/* Code */
code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary);
}

pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    overflow-x: auto;
    margin: 16px 0;
}

pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

/* Callouts & Notes */
.callout, .note, .warning, .tip {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin: 24px 0;
    border-left: 4px solid;
}

.callout-info, .note {
    background: #eff6ff;
    border-color: #3b82f6;
}

.callout-warning, .warning {
    background: #fffbeb;
    border-color: #f59e0b;
}

.tip {
    background: #f0fdf4;
    border-color: #22c55e;
}

[data-theme="dark"] .callout-info,
[data-theme="dark"] .note { background: rgba(59, 130, 246, 0.1); }

[data-theme="dark"] .callout-warning,
[data-theme="dark"] .warning { background: rgba(245, 158, 11, 0.1); }

[data-theme="dark"] .tip { background: rgba(34, 197, 94, 0.1); }

/* Title page styles */
.schema-titlepage-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.schema-titlepage-img {
    max-width: 300px;
    margin: 0 auto 32px;
    display: block;
}

.schema-titlepage-additionalinfo,
.schema-titlepage-versioninfo,
.schema-titlepage-produrl {
    color: var(--text-secondary);
    margin: 8px 0;
}

/* Footer */
.footer {
    margin-top: 64px;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

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

/* TOC */
.toc {
    position: fixed;
    right: 24px;
    top: calc(var(--header-height) + 40px);
    width: 200px;
    font-size: 13px;
}

.toc-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid var(--border-color);
    padding-left: 12px;
}

.toc-list li { margin: 8px 0; }

.toc-list a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.toc-list a:hover,
.toc-list a.active { color: var(--primary); }

/* Version badge */
.version-badge {
    display: inline-block;
    font-size: 12px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-muted);
    margin-left: 12px;
    font-weight: 500;
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
}

.sidebar-overlay.open { display: block; }

/* Responsive */
@media (max-width: 1400px) {
    .toc { display: none; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: flex; }
    .header-subtitle { display: none; }
}

@media (max-width: 640px) {
    .content { padding: 24px 16px; }
    h1, .heading { font-size: 1.75rem; }
    h2, .subheading { font-size: 1.25rem; }
    
    figure, .figure, .img_original {
        padding: 12px;
        margin: 16px -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Clean up legacy styles */
.textmodule, .text-module { margin-bottom: 32px; }
.linklist { display: none; }
.procedural-instructions { margin: 24px 0; }
.instructions dd { margin-bottom: 16px; }
