@font-face {
    font-family: 'Sansation';
    src: url('../Sansation-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-primary-dark: linear-gradient(135deg, #445b54 0%, #324641 50%, #223330 100%);
    --bg-primary-light: linear-gradient(135deg, #f5fdfb 0%, #d8ede6 50%, #a1b7ae 100%);

    --text-primary-dark: #ffffff;
    --text-primary-light: #2c3e50;

    --text-secondary-dark: #e8e8e8;
    --text-secondary-light: #555555;

    --bg-content-dark: #1a1a1a;
    --bg-content-light: #ffffff;

    --border-dark: #333333;
    --border-light: #ecf0f1;

    --link-dark: #b8d8d8;
    --link-light: #2d7a6f;

    --accent-dark: #1e3932;
    --accent-light: #dceae6;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    background: var(--bg-primary-dark);
    background-attachment: fixed;
    color: var(--text-primary-dark);
    padding: 20px;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

html[data-theme="light"] body {
    background: var(--bg-primary-light);
    color: var(--text-primary-light);
}

/* ── Site header ─────────────────────────────────────────────────── */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;  /* now just: logo | right-group */
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-dark);
    transition: border-color 0.3s ease;
}

html[data-theme="light"] .site-header {
    border-bottom-color: var(--border-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-link {
    display: flex;
    flex-shrink: 0;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo-link:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.logo {
    width: 50px;
    height: 50px;
    display: block;
}

/* ── Language selector ───────────────────────────────────────────── */

.language-selector {
    display: flex;
    align-items: center;
    gap: 4px;
}

.language-selector a {
    color: var(--link-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9em;
    letter-spacing: 0.05em;
    padding: 0 4px;
    transition: color 0.3s ease;
    white-space: nowrap;
}

html[data-theme="light"] .language-selector a {
    color: var(--link-light);
}

.language-selector a:hover {
    text-decoration: underline;
}

.language-selector a.active {
    color: var(--text-primary-dark);
    font-weight: bold;
}

html[data-theme="light"] .language-selector a.active {
    color: var(--text-primary-light);
}

.language-selector a + a::before {
    content: '|';
    margin-right: 8px;
    color: var(--border-dark);
    font-weight: normal;
}

html[data-theme="light"] .language-selector a + a::before {
    color: var(--border-light);
}

/* ── Theme toggle ────────────────────────────────────────────────── */

.theme-toggle button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: var(--text-primary-dark);
    -webkit-appearance: none;
    appearance: none;
}

html[data-theme="light"] .theme-toggle button {
    color: var(--text-primary-light);
}

.theme-toggle button:hover {
    transform: scale(1.15);
}

.theme-toggle button:focus {
    outline: none;
}

.theme-toggle button span {
    display: none;
}

.theme-toggle button span.active {
    display: inline;
}

.theme-toggle button svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Container ───────────────────────────────────────────────────── */

.container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    background: rgba(26, 26, 26, 0.85);
    padding: 20px 40px 40px 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(2px);
}

html[data-theme="light"] .container {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ── Typography ──────────────────────────────────────────────────── */

h1 {
    color: var(--text-primary-dark);
    font-size: 2em;
    margin-bottom: 10px;
    border-bottom: 3px solid var(--link-dark);
    padding-bottom: 10px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

html[data-theme="light"] h1 {
    color: var(--text-primary-light);
    border-bottom-color: var(--link-light);
}

h2 {
    color: var(--text-primary-dark);
    font-size: 1.5em;
    margin-top: 30px;
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

html[data-theme="light"] h2 {
    color: var(--text-primary-light);
}

h3 {
    color: var(--text-secondary-dark);
    font-size: 1.2em;
    margin-top: 20px;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

html[data-theme="light"] h3 {
    color: var(--text-secondary-light);
}

p {
    margin-bottom: 15px;
    text-align: left;
    color: var(--text-secondary-dark);
    transition: color 0.3s ease;
}

html[data-theme="light"] p {
    color: var(--text-secondary-light);
}

ul, ol {
    margin-left: 0;
    padding-left: 1.5em;
    margin-bottom: 15px;
}

li {
    margin-bottom: 5px;
    color: var(--text-secondary-dark);
    transition: color 0.3s ease;
}

html[data-theme="light"] li {
    color: var(--text-secondary-light);
}

strong {
    color: var(--text-primary-dark);
    transition: color 0.3s ease;
}

html[data-theme="light"] strong {
    color: var(--text-primary-light);
}

a {
    color: var(--link-dark);
    text-decoration: none;
    transition: color 0.3s ease;
}

html[data-theme="light"] a {
    color: var(--link-light);
}

a:hover {
    text-decoration: underline;
}

/* ── Shared components ───────────────────────────────────────────── */

.header-subtitle {
    color: var(--text-secondary-dark);
    font-size: 1.2em;
    margin-bottom: 30px;
    transition: color 0.3s ease;
}

html[data-theme="light"] .header-subtitle {
    color: var(--text-secondary-light);
}

.info-box {
    background: var(--accent-dark);
    padding: 20px;
    border-left: 4px solid var(--link-dark);
    margin: 20px 0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

html[data-theme="light"] .info-box {
    background: var(--accent-light);
    border-left-color: var(--link-light);
}

.info-box p {
    margin-bottom: 8px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.info-box ul {
    margin-top: 10px;
}

.footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-dark);
    color: var(--text-secondary-dark);
    font-size: 0.9em;
    transition: border-color 0.3s ease, color 0.3s ease;
}

html[data-theme="light"] .footer {
    border-top-color: var(--border-light);
    color: var(--text-secondary-light);
}

/* ── Document meta bar ───────────────────────────────────────────── */

.doc-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9em;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-dark);
    color: var(--text-secondary-dark);
    transition: border-color 0.3s ease, color 0.3s ease;
}

html[data-theme="light"] .doc-meta-bar {
    border-bottom-color: var(--border-light);
    color: var(--text-secondary-light);
}

.doc-version {
    font-weight: 500;
}

.doc-meta-sep {
    color: var(--border-dark);
    transition: color 0.3s ease;
}

html[data-theme="light"] .doc-meta-sep {
    color: var(--border-light);
}

.pdf-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: var(--link-dark);
    font-weight: 500;
    transition: color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

html[data-theme="light"] .pdf-btn {
    color: var(--link-light);
}

.pdf-btn:hover {
    text-decoration: underline;
}

/* ── Page layout (two-column when TOC is present) ───────────────── */

.page-layout {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.page-layout:has(.toc-sidebar) {
    overflow: visible;
}

@media (max-width: 1100px) {
    .toc-sidebar {
        display: none;
    }
}

/* ── TOC sidebar ─────────────────────────────────────────────────── */

.toc-sidebar {
    position: absolute;
    left: calc(100% + 32px);
    top: 48px;                  /* ① push below the header area */
    width: 220px;
    height: 100%;
}

.toc-sticky {
    position: sticky;
    top: 68px;    /* 20px body padding + 48px toc-sidebar offset */
    padding-top: 4px;
}

.toc-title {
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary-dark);
    margin-bottom: 12px;
    padding-left: 10px;
    transition: color 0.3s ease;
}

html[data-theme="light"] .toc-title {
    color: var(--text-secondary-light);
}

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

.toc-item {
    margin: 0;
    line-height: 1;
}

.toc-item a {
    display: block;
    padding: 4px 8px;
    border-left: 2px solid transparent;
    color: var(--text-secondary-dark);
    text-decoration: none;
    font-size: 0.82em;
    line-height: 1.45;
    transition: color 0.15s ease, border-color 0.15s ease;
}

html[data-theme="light"] .toc-item a {
    color: var(--text-secondary-light);
}

.toc-item a:hover {
    color: var(--text-primary-dark);
    text-decoration: none;
}

html[data-theme="light"] .toc-item a:hover {
    color: var(--text-primary-light);
}

.toc-item a.toc-active {
    color: var(--link-dark);
    border-left-color: var(--link-dark);
}

html[data-theme="light"] .toc-item a.toc-active {
    color: var(--link-light);
    border-left-color: var(--link-light);
}

.toc-level-1 > a { padding-left: 10px; font-weight: 500; }  /* ① was 600 */
.toc-level-2 > a { padding-left: 18px; }
.toc-level-3 > a { padding-left: 28px; font-size: 0.78em; }
.toc-level-4 > a { padding-left: 38px; font-size: 0.75em; }

/* ── Heading anchor links ─────────────────────────────────────────── */

#content h1[id],
#content h2[id],
#content h3[id],
#content h4[id] {
    position: relative;
}

.heading-anchor {
    position: absolute;
    left: -1.2em;
    opacity: 0;
    color: var(--link-dark);
    text-decoration: none;
    font-weight: normal;
    font-size: 0.9em;
    transition: opacity 0.15s ease;
}

html[data-theme="light"] .heading-anchor {
    color: var(--link-light);
}

.heading-anchor:hover {
    text-decoration: none;
}

#content h1:hover .heading-anchor,
#content h2:hover .heading-anchor,
#content h3:hover .heading-anchor,
#content h4:hover .heading-anchor {
    opacity: 1;
}

/* ── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.5em;
    }

    h2 {
        font-size: 1.3em;
    }

    .doc-meta-bar {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px 12px;
    }

    .doc-meta-sep {
        display: none;
    }

    .pdf-btn {
        display: none;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.3em;
    }

    h2 {
        font-size: 1.1em;
    }
}

/* ── Print ───────────────────────────────────────────────────────── */

@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
        padding: 20px;
    }

    .site-header,
    .doc-meta-bar {
        display: none;
    }
    .toc-sidebar {
        display: none;
    }

    .heading-anchor {
        display: none;
    }
}