:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #f8fafc;

    --text: #1f2933;
    --heading: #111827;
    --muted: #667085;

    --border: #d9e2ec;
    --border-strong: #c6d0dc;

    /* CoCoS-inspired blue */
    --primary: #2476a8;
    --primary-dark: #155a82;
    --primary-deep: #0f3f5f;
    --primary-soft: #e7f2f8;

    --link: #1d6f9f;
    --link-hover: #0f4f73;

    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 6px;
    --header-height: 72px;

    --font-main:
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-main);
    color: var(--text);
    background: var(--bg);
    line-height: 1.62;
    font-size: 15.5px;
}

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

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 0 28px;
    background: #1F6EA6;
    border-bottom: 1px solid var(--border-strong);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
    min-width: 0;
    color: #1F6EA6;
}

.brand::before {
    content: none;
}

.brand img {
    display: block;
    width: 200px;
    height: 42px;
    object-fit: cover;
    object-position: center;
    border-radius: 4px;
    background: var(--primary);
}

.brand span {
    white-space: nowrap;
}

.brand:hover {
    color: #1F6EA6;
    text-decoration: none;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    width: min(460px, 44vw);
}

.search-form input,
.large-search input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    border-radius: var(--radius);
    padding: 0 0.85rem;
    font: inherit;
    outline: none;
}

.search-form input:focus,
.large-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 74, 124, 0.12); 
}

button {
    height: 40px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    padding: 0 1rem;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Page shell */

.content {
    max-width: none;
    width: 100%;
    padding: 0;
}

/* Home */

.home-hero,
.search-page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 52px 28px 24px;
}

.home-hero {
    border-bottom: 1px solid var(--border);
}

.home-hero h1,
.search-page h1 {
    margin: 0;
    color: var(--heading);
    font-size: clamp(2rem, 3vw, 3.1rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.035em;
}

.home-hero p {
    max-width: 760px;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 1.08rem;
}

.card-grid {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 28px 56px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.book-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow); 
    padding: 22px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.book-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.09);
}

.book-card h2 {
    margin: 0 0 0.65rem;
    color: var(--heading);
    font-size: 1.12rem;
    line-height: 1.3;
}

.book-card h2 a {
    color: var(--heading);
}

.book-card h2 a:hover {
    color: var(--primary);
}

.book-card p {
    margin: 0;
    color: var(--muted);
}

.card-meta {
    display: block;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.88rem;
}

/* Documentation split */

.doc-split {
    --doc-nav-width: min(25vw, 380px);

    display: grid;
    grid-template-columns: var(--doc-nav-width) 8px minmax(0, 1fr);
    min-height: calc(100vh - var(--header-height));
    width: 100%;
}

.doc-tree {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow: auto;
    padding: 18px 16px;
    background: linear-gradient(180deg, var(--primary-deep), #0b3048);
    border-right: 1px solid #08283d;
    color: #d8e8f2;
}

.doc-tree::-webkit-scrollbar {
    width: 10px;
}

.doc-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    border: 3px solid var(--primary-deep);
}

.doc-resizer {
    cursor: col-resize;
    background: #0b3048;
    border-right: 1px solid var(--border);
}

.doc-resizer:hover,
.resizing-doc-nav .doc-resizer {
    background: var(--primary);
}

.resizing-doc-nav {
    cursor: col-resize;
    user-select: none;
}

.doc-view {
    min-width: 0;
    padding: 32px;
    overflow: auto;
}

.doc-page {
    max-width: 1040px;
    margin: 0 auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(24px, 3vw, 44px);
}

.doc-page h1 {
    margin: 0.35rem 0 0.8rem;
    color: var(--heading);
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.035em;
}

.lead {
    color: var(--muted);
    font-size: 1.05rem;
}

/* Tree */

.tree-title {
    margin-bottom: 16px;
    padding: 12px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-left: 4px solid #ffffff;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 700;
    line-height: 1.25;
}

.tree-title a {
    color: #ffffff;
}

.tree-title a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.tree-root,
.tree-pages,
.tree-headings {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-chapter {
    margin-bottom: 14px;
}

.tree-chapter-title {
    display: block;
    margin: 18px 0 7px;
    color: #b8d7e8;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.075em;
}

.tree-page {
    margin: 2px 0;
    border-radius: var(--radius);
}

.tree-page > a {
    display: block;
    padding: 7px 9px;
    color: #e5f3fb;
    border-radius: var(--radius);
    font-size: 0.91rem;
    line-height: 1.28;
}

.tree-page > a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none;
}

.tree-page.active > a {
    background: #ffffff;
    color: var(--primary-deep);
    font-weight: 700;
}

.tree-headings {
    margin: 7px 0 10px 10px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.tree-heading {
    margin: 2px 0;
    line-height: 1.25;
}

.tree-heading a {
    display: block;
    padding: 3px 0;
    color: #bad6e6;
    font-size: 0.83rem;
}

.tree-heading a:hover {
    color: #ffffff;
    text-decoration: none;
}

.tree-heading.level-1 {
    margin-left: 0;
}

.tree-heading.level-2 {
    margin-left: 6px;
}

.tree-heading.level-3 {
    margin-left: 12px;
}

.tree-heading.level-4,
.tree-heading.level-5,
.tree-heading.level-6 {
    margin-left: 18px;
}

/* Content */

.breadcrumb-line {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.breadcrumb-line a {
    color: var(--muted);
}

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

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 0.75rem 0 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.92rem;
}

.page-meta a {
    padding: 0.32rem 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--panel-soft);
    color: var(--primary);
    font-weight: 600;
}

.page-meta a:hover {
    background: var(--primary-soft);
    text-decoration: none;
}

.doc-body {
    font-size: 1rem;
}

.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5,
.doc-body h6 {
    scroll-margin-top: calc(var(--header-height) + 1rem);
    color: var(--heading);
    margin-top: 2rem;
    letter-spacing: -0.02em;
    line-height: 1.24;
}

.doc-body h2 {
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.doc-body p {
    margin: 1rem 0;
}

.doc-body ul,
.doc-body ol {
    padding-left: 1.4rem;
}

.doc-body li {
    margin: 0.35rem 0;
}

.doc-body blockquote {
    margin: 1.5rem 0;
    padding: 0.8rem 1rem;
    border-left: 4px solid var(--primary);
    background: var(--primary-soft);
    color: #344054;
}

.doc-body img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.doc-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
}

.doc-body th,
.doc-body td {
    border: 1px solid var(--border);
    padding: 0.7rem;
    vertical-align: top;
}

.doc-body th {
    background: var(--panel-soft);
    color: var(--heading);
    font-weight: 700;
}

.doc-body pre {
    overflow-x: auto;
    padding: 1rem;
    border-radius: var(--radius);
    background: #1f2937;
    color: #f9fafb;
}

.doc-body code {
    background: #eef2f6;
    border-radius: 4px;
    padding: 0.12rem 0.32rem;
}

.doc-body pre code {
    background: transparent;
    padding: 0;
}

/* Book overview */

.page-overview {
    display: grid;
    gap: 10px;
    margin-top: 1.5rem;
}

.overview-link {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.overview-link:hover {
    border-color: var(--primary);
    background: #ffffff;
    text-decoration: none;
}

.overview-link strong {
    display: block;
    color: var(--heading);
}

.overview-link span {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
}

/* Search */

.search-page {
    max-width: 940px;
}

.large-search {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0 2rem;
}

.search-results {
    display: grid;
    gap: 1rem;
    padding: 0;
    list-style: none;
}

.search-results li,
.empty-state {
    padding: 1.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-results h3 {
    margin: 0 0 0.4rem;
    color: var(--heading);
}

/* Footer */

.site-footer {
    padding: 1rem;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid var(--border);
    background: #ffffff;
    font-size: 0.88rem;
}

/* Responsive */

@media (max-width: 980px) {
    .doc-split {
        display: block;
    }

    .doc-tree {
        position: relative;
        top: auto;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .doc-resizer {
        display: none;
    }

    .doc-view {
        padding: 16px;
    }

    .doc-page {
        border-radius: var(--radius);
        box-shadow: none;
        padding: 22px;
    }

    .site-header {
        height: auto;
        align-items: stretch;
        flex-direction: column;
        padding: 14px;
        gap: 12px;
    }

    .search-form {
        width: 100%;
    }

    .large-search {
        flex-direction: column;
    }

    button {
        width: 100%;
    }
}

/* Soft registration wall */

.access-locked .page-shell {
    filter: blur(7px);
    pointer-events: none;
    user-select: none;
}

.access-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 31, 47, 0.72);
    backdrop-filter: blur(4px);
}

.access-card {
    width: min(440px, 100%);
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    padding: 28px;
    text-align: left;
}

.access-logo {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
}

.access-logo img {
    width: 92px;
    height: 58px;
    object-fit: cover;
    object-position: center;
    border-radius: 4px;
}

.access-card h2 {
    margin: 0 0 8px;
    color: #111827;
    font-size: 1.55rem;
    line-height: 1.15;
}

.access-intro {
    margin: 0 0 20px;
    color: #667085;
}

.access-form {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.access-form label {
    color: #344054;
    font-weight: 700;
    font-size: 0.92rem;
}

.access-form input {
    height: 42px;
    border: 1px solid #c6d0dc;
    border-radius: 6px;
    padding: 0 0.75rem;
    font: inherit;
}

.access-form input:focus {
    border-color: #2476a8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(36, 118, 168, 0.15);
}

.access-form button {
    margin-top: 4px;
}

.hidden {
    display: none !important;
}

.access-message {
    min-height: 1.3em;
    margin: 16px 0 0;
    font-size: 0.92rem;
}

.access-message.error {
    color: #b42318;
}

.access-message.success {
    color: #0f766e;
}

.access-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.secondary-button {
    background: #ffffff;
    color: #2476a8;
    border: 1px solid #c6d0dc;
}

.secondary-button:hover {
    background: #e7f2f8;
    border-color: #2476a8;
}

.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #f4f6f8;
    color: #667085;
}

@media (max-width: 520px) {
    .access-actions {
        grid-template-columns: 1fr;
    }
}

