:root {
    --color-bg: #ffffff;
    --color-text: #1a1a1a;
    --color-text-light: #666666;
    --color-border: #e5e5e5;
    --color-accent: #0066cc;
    --color-accent-hover: #0052a3;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    line-height: 1.6;
    font-size: 16px;
}

.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== Боковое меню ========== */
.sidebar {
    width: 280px;
    padding: 40px 30px;
    border-right: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: #fafafa;
}

.sidebar-header {
    margin-bottom: 30px;
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-light);
}

.toc-list {
    list-style: none;
}

.toc-list li {
    margin-bottom: 12px;
}

.toc-list a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toc-list a:hover {
    background-color: var(--color-border);
    color: var(--color-accent);
    padding-left: 16px;
}

/* ========== Основной контент ========== */
.content {
    flex: 1;
    padding: 60px 80px;
    max-width: 900px;
}

/* Header */
.document-header {
    margin-bottom: 50px;
}

.document-header h1 {
    font-family: var(--font-serif);
    font-size: 42px;
    line-height: 1.2;
    margin-bottom: 8px;
    font-weight: 700;
}

.subtitle {
    font-size: 20px;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-weight: 400;
}

.metadata {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-light);
}

.metadata p {
    margin: 0;
}

.metadata a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.metadata a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* Горизонтальные разделители */
hr {
    border: none;
    height: 1px;
    background-color: var(--color-border);
    margin: 40px 0;
}

/* Преамбула */
.preamble {
    font-style: italic;
    color: var(--color-text-light);
    margin-bottom: 20px;
    line-height: 1.8;
    background-color: #f9f9f9;
    padding: 20px;
    border-left: 3px solid var(--color-accent);
    border-radius: 4px;
}

.preamble a {
    color: var(--color-accent);
    text-decoration: none;
}

.preamble a:hover {
    text-decoration: underline;
}

/* Разделы */
section {
    margin-bottom: 50px;
}

section h2 {
    font-family: var(--font-serif);
    font-size: 28px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
}

/* Пункты */
.clause {
    margin-bottom: 30px;
    scroll-margin-top: 100px;
}

.clause h3 {
    font-size: 18px;
    margin-bottom: 12px;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.clause-number {
    display: inline-block;
    min-width: 50px;
    color: var(--color-accent);
    font-weight: 700;
    font-family: var(--font-sans);
}

.clause p {
    margin-bottom: 12px;
    line-height: 1.8;
    color: var(--color-text);
}

.clause ul,
.clause ol {
    margin: 16px 0 16px 40px;
    line-height: 1.8;
}

.clause li {
    margin-bottom: 8px;
    color: var(--color-text);
}

/* Ссылки-якоря */
.anchor-ref {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted var(--color-accent);
}

.anchor-ref:hover {
    border-bottom-style: solid;
    color: var(--color-accent-hover);
}

/* Код */
code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #d32f2f;
}

.clause code {
    color: #d32f2f;
}

/* Footer */
.document-footer {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text-light);
    font-style: italic;
}

/* ========== Копирование якорей при клике ========== */
.clause {
    position: relative;
}

.clause::before {
    content: '🔗';
    position: absolute;
    left: -30px;
    top: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 18px;
    transition: opacity 0.2s ease;
}

.clause:hover::before {
    opacity: 0.6;
}

.clause:hover::before:hover {
    opacity: 1;
}

/* ========== Адаптивность для планшетов и мобильных ========== */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 40px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .content {
        padding: 40px;
    }

    section h2 {
        font-size: 24px;
    }

    .clause h3 {
        font-size: 16px;
    }

    .document-header h1 {
        font-size: 32px;
    }

    .clause::before {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        padding: 30px 20px;
    }

    .content {
        padding: 30px 20px;
        max-width: 100%;
    }

    .document-header h1 {
        font-size: 28px;
    }

    .subtitle {
        font-size: 18px;
    }

    section h2 {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .clause h3 {
        font-size: 15px;
        flex-wrap: wrap;
    }

    .clause p {
        font-size: 15px;
    }

    .toc-list a {
        font-size: 13px;
    }
}

/* Скроллбар для боковых менюшек */
.sidebar::-webkit-scrollbar,
html::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
html::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
html::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
html::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}

/* Активная ссылка в навигации (при скролле) */
.toc-list a.active {
    background-color: var(--color-accent);
    color: white;
}

/* Печать */
@media print {
    .sidebar {
        display: none;
    }

    .content {
        padding: 20px;
        max-width: 100%;
    }

    section h2 {
        page-break-after: avoid;
    }

    .clause {
        page-break-inside: avoid;
    }

    hr {
        page-break-after: avoid;
    }
}
