* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --bg-card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #dbe3ef;
    --soft-blue: #eaf2ff;
    --soft-green: #e9f9ef;
    --soft-red: #fff0f0;
    --green: #15803d;
    --red: #dc2626;
    --shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
    --radius: 18px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 34%),
        linear-gradient(135deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.6;
}

.page {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.main-page {
    padding-top: 44px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 34px;
    margin-bottom: 22px;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.course-label {
    margin: 0 0 8px;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

h1 {
    margin: 0 0 12px;
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1.1;
}

h2 {
    margin: 0 0 14px;
    font-size: 24px;
}

h3 {
    margin: 24px 0 10px;
    font-size: 19px;
}

.subtitle {
    margin: 0;
    max-width: 720px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 18px;
}

.card,
.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card {
    padding: 24px;
    margin-bottom: 18px;
}

.intro-card p {
    margin-bottom: 0;
    color: var(--muted);
}

.toc {
    display: grid;
    gap: 16px;
}

.chapter-card {
    overflow: hidden;
}

.chapter-card summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 20px 24px;
    cursor: pointer;
    list-style: none;
    background: white;
    transition: background 0.2s ease;
}

.chapter-card summary:hover {
    background: var(--soft-blue);
}

.chapter-card summary::-webkit-details-marker {
    display: none;
}

.chapter-card summary span {
    position: relative;
    padding-left: 30px;
    font-weight: 700;
    font-size: 19px;
}

.chapter-card summary span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 48%;

    width: 22px;
    height: 22px;

    background: var(--primary);
    border-radius: 50%;

    transform: translateY(-50%);
}

.chapter-card summary span::after {
    content: "›";
    position: absolute;
    left: 9px;
    top: 43%;

    color: white;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;

    transform: translateY(-52%);
    transition: transform 0.2s ease;
}

.chapter-card[open] summary span::after {
    transform: translateY(-43%) rotate(90deg);
}

.chapter-card summary a {
    padding: 8px 12px;
    border-radius: 999px;
    color: white;
    background: var(--primary);
    font-size: 14px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.chapter-card summary a:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.chapter-card ul {
    margin: 0;
    padding: 0 24px 22px 56px;
}

.chapter-card li {
    margin: 8px 0;
    color: var(--muted);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.final-link a {
    font-weight: 700;
}

.final-card {
    border-color: rgba(37, 99, 235, 0.35);
    background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.top-nav a {
    display: inline-block;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: white;
    color: var(--primary);
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(31, 41, 55, 0.05);
}

.top-nav a:hover {
    background: var(--soft-blue);
    text-decoration: none;
}

.page-type {
    display: inline-block;
    margin: 0 0 20px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--soft-blue);
    color: var(--primary-dark);
    font-weight: 700;
}

.placeholder {
    color: var(--muted);
}

pre {
    overflow-x: auto;
    padding: 18px;
    border-radius: 14px;
    background: #0f172a;
    color: #e5e7eb;
}

code {
    font-family: Consolas, "Courier New", monospace;
}

button,
.show-answer-button {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover,
.show-answer-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.answer-block {
    margin-top: 22px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.hidden {
    display: none;
}

/* будущие классы для тестов */

.quiz-question {
    margin-bottom: 24px;
}

.quiz-option {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    cursor: pointer;
    text-align: left;
}

.quiz-option.correct {
    border-color: #86efac;
    background: var(--soft-green);
    color: var(--green);
}

.quiz-option.wrong {
    border-color: #fecaca;
    background: var(--soft-red);
    color: var(--red);
}

.quiz-explanation {
    margin-top: 12px;
    padding: 14px;
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    background: var(--soft-blue);
}

@media (max-width: 720px) {
    .page {
        width: min(100% - 20px, 1100px);
        padding-top: 18px;
    }

    .hero {
        padding: 24px;
        border-radius: 20px;
    }

    .chapter-card summary {
        grid-template-columns: 1fr;
    }

    .chapter-card ul {
        padding-left: 36px;
    }

    h1 {
        font-size: 30px;
    }
}