
:root {
    --primary: #1565c0;
    --primary-dark: #0d47a1;
    --accent: #ff6f00;
    --text: #1a1a1a;
    --text-light: #444;
    --bg: #fff;
    --bg-alt: #f8f8f8;
    --border: #ccc;
    --shadow: 0 2px 8px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    margin: 0;
    padding: 0;
    background: var(--bg-alt);
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Sidebar / TOC */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 20px 0;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.sidebar-header h1 {
    font-size: 1.2em;
    margin: 0 0 5px;
    color: var(--primary);
}

.sidebar-header .subtitle {
    font-size: 0.85em;
    color: var(--text-light);
}

.toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li {
    margin: 0;
}

.toc a {
    display: block;
    padding: 8px 20px;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.toc a:hover {
    background: var(--bg-alt);
    border-left-color: var(--primary);
}

.toc a.active {
    background: #e3f2fd;
    border-left-color: var(--primary);
    font-weight: 600;
}

.toc .chapter { font-weight: 600; color: var(--text); }
.toc .section { padding-left: 35px; font-size: 0.95em; color: var(--text); }
.toc .subsection { padding-left: 50px; font-size: 0.9em; color: var(--text-light); }

/* Main content */
.main {
    padding: 40px;
    max-width: 900px;
}

/* Page anchors */
.page-anchor {
    position: relative;
    top: -80px;
    visibility: hidden;
}

.page-marker {
    font-size: 0.8em;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 40px;
}

/* Typography */
h1 {
    font-size: 2em;
    color: var(--primary-dark);
    margin: 0 0 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary);
}

h2 {
    font-size: 1.5em;
    color: var(--primary);
    margin: 40px 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 1.2em;
    color: var(--text);
    margin: 30px 0 15px;
}

p { margin: 0 0 15px; }

/* Lists */
ul, ol {
    margin: 0 0 20px;
    padding-left: 25px;
}

li { margin: 5px 0; }

/* Chapter TOC */
.chapter-toc {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 30px;
    margin: 20px 0 40px;
}

.chapter-toc h2 {
    margin: 0 0 15px;
    padding: 0;
    border: none;
    font-size: 1.2em;
    color: var(--primary);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

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

.toc-list a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dotted var(--border);
}

.toc-list a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.toc-list ul {
    list-style: none;
    padding-left: 25px;
    margin: 5px 0;
}

.toc-page {
    color: var(--text-light);
    font-size: 0.9em;
    margin-left: 8px;
}

/* Schematics */
.schematic-section {
    margin: 40px 0;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border);
}

.schematic-section h3 {
    color: var(--primary);
    margin-bottom: 20px;
}

.schematic-figure {
    margin: 20px 0;
    text-align: center;
}

.schematic-img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: zoom-in;
    transition: box-shadow 0.2s;
}

.schematic-img:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.schematic-figure figcaption {
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--text-light);
}

/* Procedure steps */
.procedure {
    counter-reset: step;
    list-style: none;
    padding: 0;
}

.procedure li {
    position: relative;
    padding-left: 50px;
    margin: 15px 0;
}

.procedure li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Callout boxes */
.note, .warning, .caution {
    padding: 15px 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid;
}

.note {
    background: #e3f2fd;
    border-color: var(--primary);
}

.note::before {
    content: 'NOTE: ';
    font-weight: 600;
    color: var(--primary);
}

.warning {
    background: #fff3e0;
    border-color: #ff9800;
}

.warning::before {
    content: 'WARNING: ';
    font-weight: 600;
    color: #e65100;
}

.caution {
    background: #ffebee;
    border-color: #f44336;
}

.caution::before {
    content: 'CAUTION: ';
    font-weight: 600;
    color: #c62828;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.95em;
}

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

th {
    background: var(--bg-alt);
    font-weight: 600;
}

tr:nth-child(even) { background: #fafafa; }
tr:hover { background: #f0f7ff; }

/* Parts table specific */
.parts-table {
    font-size: 0.9em;
}

.parts-table .part-number {
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 600;
}

.parts-table .ref-des {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

/* Figures / Diagrams */
figure {
    margin: 30px 0;
    text-align: center;
}

figure img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: var(--shadow);
}

figcaption {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--text);
    font-style: italic;
}

/* Code / monospace */
code {
    font-family: 'Consolas', 'Monaco', monospace;
    background: #e8e8e8;
    color: #1a1a1a;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background: #263238;
    color: #fff;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
}

/* Search */
.search-container {
    padding: 10px 20px 20px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.95em;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 20px;
    right: 20px;
    margin-top: 5px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    z-index: 1000;
}

.search-results-header {
    padding: 10px 15px;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-light);
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9em;
}

.search-results-chapter {
    border-bottom: 1px solid var(--border);
}

.search-results-chapter:last-child {
    border-bottom: none;
}

.search-results-chapter-title {
    padding: 8px 15px;
    background: var(--bg-alt);
    font-weight: 600;
    font-size: 0.85em;
    color: var(--primary);
}

.search-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-result-item {
    margin: 0;
}

.search-result-link {
    display: block;
    padding: 8px 15px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s;
}

.search-result-link:hover {
    background: #e3f2fd;
}

.search-result-main {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.search-result-icon {
    margin-right: 8px;
    font-size: 0.9em;
    flex-shrink: 0;
}

.search-result-text {
    font-size: 0.9em;
    font-weight: 500;
}

.search-result-snippet {
    font-size: 0.8em;
    color: var(--text-light);
    margin-left: 24px;
    line-height: 1.4;
}

.search-match {
    background: #ffeb3b;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* Navigation buttons */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.nav-button {
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s;
}

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

.nav-button.prev::before { content: '\2190\00a0'; }
.nav-button.next::after { content: '\00a0\2192'; }

/* Responsive */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: relative;
        height: auto;
    }
    .main {
        padding: 20px;
    }
}

/* Print styles */
@media print {
    .sidebar { display: none; }
    .layout { grid-template-columns: 1fr; }
    .main { max-width: none; padding: 0; }
    a { color: inherit; text-decoration: none; }
}
