/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #c0392b;
    --accent-hover: #e74c3c;
    --accent-glow: rgba(192, 57, 43, 0.3);
    --border: #2a2a2a;
    --border-hover: #3a3a3a;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Cinzel', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --max-width: 1200px;
    --transition: 0.2s ease;
}

/* ===== GLOBAL SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #333 var(--bg-primary);
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(13, 13, 13, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font);
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.nav-logo span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-badge {
    font-size: 0.65rem;
    font-family: var(--font-body);
    font-weight: 500;
    padding: 0.2em 0.5em;
    background: rgba(192, 57, 43, 0.15);
    color: var(--accent);
    border: 1px solid rgba(192, 57, 43, 0.3);
    border-radius: 4px;
    letter-spacing: 0;
}

@media (max-width: 640px) {
    .version-badge {
        display: inline;
    }
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    transition: color var(--transition), background var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-search {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    flex-shrink: 0;
}

.nav-search:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.nav-mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
}

.nav-mobile-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ===== HERO ===== */
.hero {
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 7rem 2rem 3rem;
    animation: fadeIn 0.5s ease;
}

.hero-emblem {
    width: 300px;
    height: 300px;
    margin-bottom: 1.5rem;
    animation: float 6s ease-in-out infinite;
}

.hero-emblem svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 20px rgba(192, 192, 192, 0.3)) drop-shadow(0 0 40px rgba(192, 57, 43, 0.15));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.ring-rotate {
    transform-origin: 150px 150px;
    animation: spinSlow 60s linear infinite;
}

.ring-rotate-reverse {
    transform-origin: 150px 150px;
    animation: spinSlow 45s linear infinite reverse;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pulse-ring {
    animation: pulse 3s ease-in-out infinite;
    transform-origin: 150px 150px;
}

@keyframes pulse {
    0%, 100% { opacity: 0.15; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(1.03); }
}

.hero-title {
    font-size: 4.5rem;
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 1.5rem;
    font-weight: 300;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 1rem;
    border: none;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.hero-cta svg {
    transition: transform var(--transition);
}

.hero-cta:hover svg {
    transform: translateX(3px);
}

.hero-cta:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

/* ===== HOME CONTENT ===== */
.home-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 2rem 6rem;
    animation: fadeIn 0.6s ease 0.1s both;
}

.home-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

.home-section h2 {
    font-family: var(--font);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

/* What's New */
.whats-new {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.update-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.update-item {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.update-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.update-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 0.75rem;
}

.update-tag {
    font-size: 0.7rem;
    padding: 0.15em 0.5em;
    background: rgba(192, 57, 43, 0.15);
    color: var(--accent);
    border-radius: 3px;
    font-weight: 500;
}

.update-item p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Stats Panel */
.stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    align-self: start;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-meta {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.stat-meta p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.stat-meta p:last-child {
    margin-bottom: 0;
}

.stat-cta {
    display: block;
    text-align: center;
    padding: 0.75rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    transition: background var(--transition), transform var(--transition);
}

.stat-cta:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.stat-cta-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.stat-cta-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .home-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== FEATURES (legacy, keep for compatibility) ===== */
.features {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 2rem 6rem;
    animation: fadeIn 0.6s ease 0.1s both;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.feature-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-4px);
}

.feature-icon {
    width: 72px;
    height: 72px;
    margin-bottom: 1.25rem;
}

.feature-icon svg {
    width: 100%;
    height: 100%;
}

.feature-card h3 {
    font-size: 1.4rem;
    font-family: var(--font);
    font-weight: 600;
    margin-bottom: 0;
    letter-spacing: -0.01em;
}

.feature-card p {
    display: none;
}

.feature-link {
    display: none;
}

/* ===== FOOTER ===== */
.footer {
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== SEARCH OVERLAY ===== */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.search-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.search-modal {
    width: 100%;
    max-width: 560px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.search-overlay.active .search-modal {
    transform: translateY(0);
}

.search-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
}

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

.search-results {
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.search-hint {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== CONTENT PAGES ===== */
.page-wrapper {
    display: flex;
    padding-top: 64px;
    min-height: 100vh;
}

.page-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    overflow-y: auto;
    z-index: 10;
}

.page-sidebar h4 {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
    transition: color var(--transition);
}

.page-sidebar h4:first-child {
    margin-top: 0;
}

.page-sidebar a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--transition), background var(--transition);
    border-left: 2px solid transparent;
}

.page-sidebar a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.page-sidebar a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(192, 57, 43, 0.05);
}

.page-sidebar a svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.page-layout {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
    padding-left: 240px;
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 3rem;
    animation: fadeIn 0.4s ease;
}

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

/* Page icon - removed, icons are now inline in sidebar */

.page-content {
    min-width: 0;
    overflow-x: auto;
}

.page-content > :not(table) {
    overflow-wrap: anywhere;
}

.page-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.page-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.page-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.page-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.7;
}

.page-content ul, .page-content ol {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.page-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.page-content li:has(input[type="checkbox"]) {
    list-style: none;
    padding-left: 0;
    margin-left: -1.5rem;
}

.page-content li input[type="checkbox"] {
    margin-right: 0.5rem;
    vertical-align: middle;
    accent-color: var(--accent);
}

.page-content code {
    background: var(--bg-card);
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 0.875em;
    color: var(--accent-hover);
}

.page-content pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    position: relative;
}

.page-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* Tables */
.page-content table {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    display: table;
    table-layout: fixed;
    table-layout: auto;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: visible;
}

.page-content table th,
.page-content table td {
    overflow-wrap: normal;
    word-break: normal;
    vertical-align: top;
}

.page-content table th:first-child,
.page-content table td:first-child {
    width: auto;
}

.page-content table th:nth-child(2):not(:last-child),
.page-content table td:nth-child(2):not(:last-child) {
    width: auto;
}

.page-content table.table-field-reference th:first-child,
.page-content table.table-field-reference td:first-child {
    width: 24%;
}

.page-content table.table-field-reference th:nth-child(2),
.page-content table.table-field-reference td:nth-child(2) {
    width: 14%;
}

.page-content table.table-field-reference th:nth-child(3),
.page-content table.table-field-reference td:nth-child(3) {
    width: 62%;
}

.page-content table.table-phase-actions th:first-child,
.page-content table.table-phase-actions td:first-child {
    width: 30%;
}

.page-content table.table-phase-actions th:nth-child(2),
.page-content table.table-phase-actions td:nth-child(2) {
    width: 38%;
}

.page-content table.table-phase-actions th:nth-child(3),
.page-content table.table-phase-actions td:nth-child(3) {
    width: 32%;
}

.page-content table td code {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.page-content table th {
    white-space: nowrap;
}

.page-content th,
.page-content td {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.page-content th {
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.page-content td {
    color: var(--text-secondary);
}

.page-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.page-content tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Callout blocks */
.callout {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    border-left: 3px solid;
}

.callout-info {
    background: rgba(192, 57, 43, 0.08);
    border-color: var(--accent);
}

.callout-warning {
    background: rgba(241, 196, 15, 0.1);
    border-color: #f1c40f;
}

.callout-danger {
    background: rgba(192, 57, 43, 0.1);
    border-color: var(--accent);
}

.callout p {
    color: var(--text-primary);
    margin: 0;
    font-size: 0.9rem;
}

/* Table of contents sidebar */
.page-toc {
    position: sticky;
    top: 5rem;
    align-self: start;
    height: calc(100vh - 6rem);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    padding-bottom: 3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
    min-width: 0;
}

.page-toc::-webkit-scrollbar {
    width: 4px;
}

.page-toc::-webkit-scrollbar-track {
    background: transparent;
}

.page-toc::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.page-toc::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.page-toc h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.page-toc ul {
    list-style: none;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
}

.page-toc li {
    margin-bottom: 0.5rem;
}

.page-toc li.toc-category {
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    font-weight: 600;
    border-left: 2px solid var(--accent);
    margin-left: -1rem;
    padding-left: calc(1rem - 2px);
}

.page-toc li.toc-category a {
    font-size: inherit;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color var(--transition), font-weight var(--transition);
}

.page-toc li.toc-category a:hover {
    color: var(--accent-hover);
}

.page-toc li.toc-category a.active {
    color: var(--text-primary);
    font-weight: 700;
    border-left-color: var(--text-primary);
}

.page-toc a {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: color var(--transition);
    overflow-wrap: anywhere;
    word-break: normal;
}

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

/* Page navigation (prev/next) */
.page-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.page-nav a {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.page-nav a:hover {
    border-color: var(--accent);
    background: rgba(192, 57, 43, 0.05);
    transform: translateY(-1px);
}

.page-nav a:only-child {
    grid-column: 1 / -1;
    max-width: min(420px, 100%);
}

.page-nav-next {
    text-align: right;
    align-items: flex-end;
    justify-self: end;
}

.page-nav-prev {
    justify-self: start;
}

.page-nav .nav-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.page-nav .nav-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* Copy button for code blocks */
.copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.6rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}

.page-content pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    color: var(--text-primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-sidebar {
        display: none;
    }

    .page-layout {
        grid-template-columns: 1fr;
        padding-left: 2rem;
    }

    .page-toc {
        display: none;
    }

    .nav-links {
        display: none;
    }

    .nav-mobile-toggle {
        display: flex;
    }

    .nav-container {
        padding: 0 1rem;
        gap: 0.5rem;
    }

    .nav-search {
        margin-left: auto;
        width: 42px;
        height: 42px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .search-overlay {
        align-items: flex-end;
        justify-content: stretch;
        padding: 0;
        background: rgba(0, 0, 0, 0.68);
    }

    .search-modal {
        max-width: none;
        width: 100%;
        max-height: min(78vh, 620px);
        border-width: 1px 0 0;
        border-radius: 18px 18px 0 0;
        padding: 1rem;
        transform: translateY(100%);
        box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.45);
    }

    .search-modal::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        margin: 0 auto 0.9rem;
        border-radius: 999px;
        background: var(--border-hover);
    }

    .search-results {
        max-height: calc(78vh - 150px);
    }

    .search-hint {
        display: none;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-emblem {
        width: 120px;
        height: 120px;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: 70vh;
        padding-top: 6rem;
    }

    .nav-logo span:first-child {
        font-size: 0.9rem;
    }

    .page-layout {
        padding: 1.25rem 1rem 3rem;
        width: 100%;
        max-width: 100%;
    }

    .page-content h1 {
        font-size: 2rem;
    }

    .page-nav {
        grid-template-columns: 1fr;
        margin-top: 3rem;
    }

    .page-nav a,
    .page-nav a:only-child {
        width: 100%;
        max-width: none;
        justify-self: stretch;
    }

    .page-nav-next {
        text-align: left;
        align-items: flex-start;
    }
}

@media (max-width: 420px) {
    .nav-container {
        padding: 0 0.75rem;
    }

    .version-badge {
        display: none;
    }

    .nav-logo span:first-child {
        max-width: calc(100vw - 140px);
    }
}


/* ===== SEARCH RESULTS ===== */
.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

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

.search-result-title {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.search-result-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.search-result-desc mark {
    background: rgba(192, 57, 43, 0.25);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 1px;
}

.search-no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
    font-size: 0.85rem;
}

/* ===== SCROLL TO TOP ===== */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s, color 0.2s, border-color 0.2s;
    z-index: 50;
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ===== CARD HOVER GLOW ===== */
.feature-card:hover {
    box-shadow: 0 0 20px rgba(192, 57, 43, 0.15), 0 4px 12px rgba(0,0,0,0.3);
}

/* ===== ACTIVE NAV UNDERLINE ===== */
.nav-links a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    position: relative;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* ===== MOBILE MENU ===== */
.nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    gap: 0.25rem;
}

.nav-mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.nav-mobile-toggle.active span:nth-child(2) {
    opacity: 0;
}
.nav-mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== HIGHLIGHT.JS OVERRIDES ===== */
.page-content pre code.hljs {
    background: transparent;
    padding: 0;
}


/* ===== MERMAID DIAGRAMS ===== */
.mermaid {
    margin-bottom: 1.5rem;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
}

/* Force mermaid nodes to match site style */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node polygon,
.mermaid .node path {
    stroke: var(--border) !important;
    stroke-width: 1px !important;
}

.mermaid .node .label,
.mermaid .nodeLabel {
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
}

.mermaid .edgeLabel {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-radius: 4px !important;
    padding: 2px 6px !important;
    font-family: var(--font-body) !important;
    font-size: 0.8rem !important;
}

.mermaid .edge-thickness-normal {
    stroke: var(--text-muted) !important;
}

.mermaid .edge-pattern-solid {
    stroke: var(--text-muted) !important;
}

/* ===== READING TIME ===== */
.reading-time {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* ===== VERSION BADGE ===== */
.since-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-family: var(--font-body);
    font-weight: 500;
    padding: 0.15em 0.5em;
    background: rgba(192, 57, 43, 0.12);
    color: var(--accent);
    border: 1px solid rgba(192, 57, 43, 0.25);
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.5rem;
    letter-spacing: 0;
}

/* ===== HEADING ANCHORS ===== */
.heading-anchor {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 0.5rem;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.2s;
}

.page-content h2:hover .heading-anchor,
.page-content h3:hover .heading-anchor {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent);
}
