/* =========================================================
   DRUCK — 1 Thema = СТРОГО 1 A4-Seite
   ========================================================= */

@media print {

    @page {
        size: A4 portrait;
        margin: 6mm 8mm; /* Немного уменьшили поля страницы */
    }

    html,
    body {
        width: 100%;
        height: 100%;
        max-height: 285mm; /* Жесткое ограничение высоты 1 листа */
        margin: 0;
        padding: 0;
        overflow: hidden !important; /* Запрет выхода за границы 1 листа */
        background: white !important;
        color: #000 !important;

        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        font-size: 9.5pt; /* Слегка уменьшен базовый шрифт */
        line-height: 1.25;
    }

    /* ---------- Web-Elemente ausblenden ---------- */

    header.site-header,
    .top-bar,
    footer.site-footer,
    .no-print,
    .cta-container {
        display: none !important;
    }

    /* ---------- A4-Hauptbereich ---------- */

    main {
        width: 100%;
        height: 100%;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;

        background: white !important;
        box-shadow: none !important;
        border-radius: 0 !important;

        display: flex;
        flex-direction: column;
        justify-content: space-between; /* Равномерно распределяет блоки по листу */
    }

    /* ---------- Druckkopf ---------- */

    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;

        width: 100%;

        border-bottom: 2px solid var(--primary, #000);

        padding-bottom: 2px;
        margin-bottom: 6px;
    }

    .print-header .title {
        font-size: 14pt;
        font-weight: bold;
        color: var(--primary, #000);
    }

    .print-header .info {
        font-size: 9.5pt;
    }

    .print-header .line {
        display: inline-block;
        border-bottom: 1px solid #718096;
        width: 70px;
    }

    /* ---------- Заголовки ---------- */

    h2 {
        font-size: 11pt !important;

        margin-top: 5px !important;
        margin-bottom: 3px !important;

        padding-bottom: 1px !important;

        border-bottom: 1px solid var(--primary, #000) !important;
    }

    /* ---------- Теория и Объяснение ---------- */

    .explanation-box {
        padding: 4px 8px !important;

        margin-bottom: 5px !important;

        font-size: 9pt !important;

        border-left-width: 3px !important;

        border-radius: 4px;
    }

    .explanation-box h2 {
        font-size: 9.5pt !important;

        margin-top: 0 !important;
        margin-bottom: 2px !important;

        border: none !important;
    }

    .explanation-box p {
        margin: 1px 0 !important;
    }

    /* ---------- Примеры ---------- */

    .example-row {
        margin: 4px 0 !important;
        gap: 12px;
        font-size: 8.5pt !important;
    }

    /* ---------- Таблицы ---------- */

    .table-responsive {
        margin: 4px 0 !important;
    }

    table.numbers-table {
        width: 100%;
        border-collapse: collapse;
    }

    table.numbers-table th,
    table.numbers-table td {
        padding: 1.5px 4px !important; /* Уменьшен вертикальный паддинг */
        font-size: 8.5pt !important;
    }

    .dot-cell {
        letter-spacing: 0.5px !important;
        font-size: 8pt !important;
    }

    /* ---------- Блоки заданий ---------- */

    .task-card {
        padding: 4px 8px !important;

        margin-bottom: 4px !important;

        border: 1px solid #cbd5e0 !important;
        border-radius: 4px;

        page-break-inside: avoid;
        break-inside: avoid;
    }

    .task-title {
        font-size: 9.5pt !important;
        font-weight: bold;

        margin-bottom: 2px !important;
    }

    .answer-box {
        display: inline-block;
        vertical-align: middle;
        width: 26px !important;
        height: 18px !important;

        border: 1.5px solid var(--primary, #000);
    }

    .underline-input {
        display: inline-block;
        width: 32px !important;
        border-bottom: 1px solid #000;
    }

    /* ---------- Памятка (Merke) ---------- */

    .merke-box {
        padding: 4px 8px !important;

        margin-top: 4px !important;

        font-size: 8.5pt !important;

        border-radius: 4px;
    }

    /* ---------- QR-Code ---------- */

    .qr-print img {
        width: 40px !important;
        height: 40px !important;
    }

    /* ---------- Запрет переноса страниц ---------- */

    * {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}