/* Výběr částí učebnice a okno s obsahem k tisku. */

.tb-print-open {
    overflow: hidden;
}

.textbook-print-dialog {
    width: min(100%, 40rem);
    max-width: 40rem;
    min-width: 0;
    margin-top: auto;
    margin-bottom: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1.5rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    padding: 0.35rem 1rem 0.85rem;
}

.tb-picker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 0.15rem 0.35rem;
}

.tb-picker-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #b8962e;
}

.tb-picker-head h2 {
    margin: 0.15rem 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.55rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: #0f172a;
}

.tb-picker-lead {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.45;
    font-weight: 400;
}

.tb-icon-btn {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    flex: 0 0 auto;
}

.tb-icon-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.tb-picker-form {
    min-width: 0;
}

.tb-picker-subject {
    margin: 0.35rem 0 0.85rem;
    font-weight: 700;
    color: #0f172a;
}

.tb-picker-subject span {
    font-weight: 500;
    color: #64748b;
}

.tb-note {
    margin: 0 0 0.85rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.9rem;
    background: #f8fafc;
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.45;
}

.tb-fieldset {
    border: 0;
    margin: 0 0 1rem;
    padding: 0;
    min-width: 0;
}

.tb-fieldset legend {
    padding: 0;
    margin: 0 0 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #94a3b8;
}

.tb-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.2rem 0.7rem;
    border-radius: 0.85rem;
    cursor: pointer;
    color: #0f172a;
    font-weight: 600;
    line-height: 1.3;
}

.tb-check input {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    accent-color: #d4af37;
    flex: 0 0 auto;
}

.tb-check:has(input:checked) {
    background: rgba(212, 175, 55, 0.1);
}

.tb-check small {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
}

.tb-topic-block {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    margin-bottom: 0.55rem;
    overflow: hidden;
}

.tb-topic-block > .tb-check {
    background: #f8fafc;
    border-radius: 0;
}

.tb-lessons {
    padding: 0.15rem 0.35rem 0.35rem 0.85rem;
}

.tb-picker-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.85rem 0 0.25rem;
    background: linear-gradient(to top, #fff 72%, rgba(255, 255, 255, 0));
}

.tb-summary {
    margin: 0;
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 600;
}

.tb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0 1.1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    color: #0f172a;
}

.tb-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tb-btn-primary {
    background: linear-gradient(90deg, #d4af37, #b8962e);
    color: #0f172a;
    box-shadow: 0 8px 18px rgba(184, 150, 46, 0.28);
}

.tb-btn-ghost {
    background: #fff;
    border-color: #e2e8f0;
}

.tb-btn-ghost:hover,
.tb-btn-primary:hover {
    filter: brightness(0.98);
}

.tb-empty,
.tb-loading {
    margin: 0.5rem 0 1rem;
    color: #64748b;
    line-height: 1.5;
}

.tb-picker-page {
    min-width: 0;
    overflow-x: hidden;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 40%, #fffbeb 100%);
}

.tb-picker-wrap {
    width: min(100%, 42rem);
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.tb-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: #64748b;
    font-weight: 600;
    text-decoration: none;
}

.tb-back:hover {
    color: #b8962e;
}

.tb-picker-page h1 {
    margin: 0.2rem 0 0.35rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    letter-spacing: -0.03em;
    color: #0f172a;
}

.tb-picker-page .tb-page-lead {
    margin: 0 0 1rem;
    color: #64748b;
    line-height: 1.5;
}

#textbook-print-modal .textbook-print-dialog {
    display: flex;
    flex-direction: column;
    max-height: min(52rem, calc(100dvh - 2rem));
    overflow: hidden;
}

#textbook-print-modal .tb-picker-head {
    flex: 0 0 auto;
    background: #fff;
}

#textbook-print-modal #textbook-print-slot,
#textbook-print-modal .tb-picker-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#textbook-print-modal .tb-picker-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    padding-right: 0.15rem;
}

#textbook-print-modal .tb-picker-actions {
    position: static;
    flex: 0 0 auto;
    background: #fff;
}

body.textbook-print-sheet #site-top,
body.textbook-print-sheet footer,
body.textbook-print-sheet .main-wrapper > *:not(.tb-toolbar):not(.tb-paper) {
    display: none !important;
}

body.textbook-print-sheet .main-wrapper {
    padding-top: 0 !important;
    min-height: 0 !important;
    display: block !important;
}

body.textbook-print-sheet {
    background: #e7e5e4;
}

.tb-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid #e2e8f0;
    backdrop-filter: blur(10px);
}

.tb-toolbar p {
    margin: 0;
    color: #64748b;
    font-size: 0.92rem;
}

.tb-toolbar strong {
    color: #0f172a;
}

.tb-paper {
    width: min(100% - 1.5rem, 48rem);
    margin: 1.25rem auto 2.5rem;
    padding: 1.6rem 1.15rem 2rem;
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    min-width: 0;
    color: #1e293b;
}

.tb-cover {
    padding-bottom: 0.55rem;
    margin-bottom: 0.7rem;
    border-bottom: 2px solid var(--tb-accent, #d4af37);
}

.tb-cover-kicker {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #b8962e;
}

.tb-cover h1 {
    margin: 0.1rem 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.65rem;
    line-height: 1.12;
    letter-spacing: -0.03em;
    color: #0f172a;
}

.tb-cover-meta,
.tb-included {
    margin: 0.45rem 0 0;
    color: #64748b;
    line-height: 1.45;
}

.tb-toc {
    margin: 0 0 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid #e7e5e4;
}

.tb-toc h2,
.tb-topic-title,
.tb-lesson-title,
.tb-block-title,
.tb-question-label {
    font-family: Georgia, "Times New Roman", serif;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.tb-toc h2 {
    margin: 0 0 0.3rem;
    font-size: 0.95rem;
}

.tb-toc-topic {
    margin: 0.45rem 0 0.1rem;
    font-size: 0.82rem;
    font-weight: 700;
    break-after: avoid;
}

.tb-toc ol {
    margin: 0.05rem 0 0.25rem;
    padding-left: 0;
    list-style: none;
    columns: 2;
    column-gap: 1.25rem;
}

.tb-toc li {
    break-inside: avoid;
    margin: 0.08rem 0;
    font-size: 0.82rem;
    line-height: 1.35;
}

.tb-toc-num,
.tb-lesson-num {
    color: #b8962e;
    font-family: Outfit, system-ui, sans-serif;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    margin-right: 0.35rem;
}

.tb-toc a {
    color: #0f172a;
    text-decoration: none;
}

.tb-toc a:hover {
    color: #b8962e;
}

.tb-topic + .tb-topic {
    margin-top: 1.15rem;
}

.tb-topic-title {
    margin: 0 0 0.45rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid #0f172a;
    font-size: 1.15rem;
    line-height: 1.2;
    break-after: avoid;
}

.tb-lesson {
    margin: 0 0 0.85rem;
    padding-top: 0.15rem;
}

.tb-lesson + .tb-lesson {
    margin-top: 0.85rem;
    padding-top: 0.7rem;
    border-top: 2px solid var(--tb-accent, #d4af37);
}

.tb-lesson-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 0.35rem;
}

.tb-lesson-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.25;
    break-after: avoid;
}

.tb-lesson-link {
    color: #b8962e;
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.tb-draft {
    display: inline-flex;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-family: Outfit, system-ui, sans-serif;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
}

.tb-question-wrap {
    margin: 0;
}

.tb-question-wrap + .tb-question-wrap {
    margin-top: 0.75rem;
    padding-top: 0.55rem;
    border-top: 1px dashed #d6d3d1;
}

.tb-question-label {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    break-after: avoid;
}

.tb-block {
    margin: 0.85rem 0 0;
    padding-top: 0.45rem;
    border-top: 1.5px solid #d6d3d1;
}

.tb-question-wrap > .tb-block:first-child,
.tb-lesson > .tb-block:first-child {
    margin-top: 0.35rem;
    padding-top: 0;
    border-top: 0;
}

.tb-block-title,
.tb-question .tb-question-kicker {
    display: block;
    margin: 0 0 0.28rem;
    padding-bottom: 0.12rem;
    border-bottom: 1.5px solid var(--tb-accent, #d4af37);
    font-family: Outfit, system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1.3;
    text-transform: uppercase;
    color: #9a7b1a;
    break-after: avoid;
}

.tb-question-text {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.35;
    color: #0f172a;
}

.tb-rich {
    max-width: 100%;
    overflow-x: auto;
    line-height: 1.55;
}

.tb-rich > :first-child {
    margin-top: 0;
}

.tb-rich p,
.tb-rich ul,
.tb-rich ol,
.tb-rich blockquote {
    margin: 0.55em 0 0.8em;
}

.tb-rich ul,
.tb-rich ol {
    padding-left: 1.4em;
}

.tb-rich li {
    margin: 0.25em 0;
}

.tb-rich h1,
.tb-rich h2,
.tb-rich h3,
.tb-rich h4 {
    color: #0f172a;
    line-height: 1.25;
    margin: 1em 0 0.4em;
}

.tb-rich img,
.tb-rich video,
.tb-rich iframe {
    max-width: 100%;
    height: auto;
}

.tb-rich img {
    border-radius: 0.75rem;
}

.tb-rich table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0 1rem;
    font-size: 0.95em;
}

.tb-rich th,
.tb-rich td {
    border: 1px solid #cbd5e1;
    padding: 0.35rem 0.5rem;
    vertical-align: top;
    text-align: left;
}

.tb-rich a {
    color: #9a6b12;
    font-weight: 600;
}

.tb-terms {
    margin: 0.2rem 0 0;
}

.tb-terms dt {
    font-weight: 700;
    color: #0f172a;
    margin-top: 0.55rem;
}

.tb-terms dd {
    margin: 0.15rem 0 0;
    color: #334155;
}

.tb-rich details,
.tb-rich details > * {
    display: block;
}

.tb-paper .nl-youtube-wrap,
.tb-paper .video-embed-wrapper,
.tb-paper figure:has(iframe),
.tb-paper iframe,
.tb-paper video {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.tb-solution {
    margin-top: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-left: 3px solid var(--tb-accent, #d4af37);
    background: #fffbeb;
    border-radius: 0 0.75rem 0.75rem 0;
}

.tb-solution-label {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #b8962e;
}

.tb-tone-solution {
    padding: 0.75rem 0.9rem;
    border-left: 3px solid var(--tb-accent, #d4af37);
    background: #fffbeb;
    border-radius: 0 0.75rem 0.75rem 0;
}

.tb-tone-teacher {
    padding: 0.85rem 0.95rem;
    border: 1px dashed #94a3b8;
    border-radius: 0.9rem;
    background: #f8fafc;
}

.tb-files {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
}

.tb-files li {
    margin: 0.35rem 0;
}

.tb-files a {
    color: #0f172a;
    font-weight: 600;
}

.tb-files img {
    display: block;
    max-width: min(100%, 36rem);
    height: auto;
    margin-top: 0.35rem;
    border-radius: 0.75rem;
}

.tb-file-name {
    display: block;
    margin-bottom: 0.2rem;
}

@media (max-width: 640px) {
    .textbook-print-dialog {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .tb-picker-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .tb-actions {
        width: 100%;
    }

    .tb-actions .tb-btn {
        flex: 1 1 auto;
    }

    .tb-paper {
        width: min(100% - 1rem, 48rem);
        margin-top: 0.75rem;
        padding: 1.15rem 0.9rem 1.5rem;
        border-radius: 1rem;
    }

    .tb-toc ol {
        columns: 1;
    }

    .tb-toolbar .tb-actions {
        width: 100%;
    }
}

@media print {
    body.textbook-print-sheet {
        background: #fff !important;
    }

    .tb-noprint,
    .tb-toolbar {
        display: none !important;
    }

    .tb-paper {
        width: auto;
        margin: 0;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .tb-rich {
        overflow: visible;
    }

    .tb-paper {
        font-size: 10.5pt;
        line-height: 1.38;
    }

    .tb-cover {
        margin-bottom: 3mm;
        padding-bottom: 2mm;
    }

    .tb-cover h1 {
        font-size: 16pt;
    }

    .tb-cover-meta,
    .tb-included,
    .tb-toc,
    .tb-toc li {
        font-size: 9pt;
    }

    .tb-topic + .tb-topic {
        margin-top: 5mm;
        break-before: auto;
    }

    .tb-topic-title {
        font-size: 12.5pt;
        margin-bottom: 2mm;
    }

    .tb-lesson {
        margin-bottom: 3.5mm;
    }

    .tb-lesson + .tb-lesson {
        margin-top: 3.5mm;
        padding-top: 2.5mm;
        break-before: auto;
    }

    .tb-lesson-title {
        font-size: 11.5pt;
    }

    .tb-question-text {
        font-size: 11.5pt;
    }

    .tb-block {
        margin-top: 3.2mm;
        padding-top: 2mm;
        border-top-color: #a8a29e;
    }

    .tb-block-title,
    .tb-question .tb-question-kicker {
        font-size: 8pt;
        margin-bottom: 1.2mm;
    }

    .tb-rich p,
    .tb-rich ul,
    .tb-rich ol,
    .tb-rich blockquote {
        margin: 0.2em 0 0.35em;
    }

    .tb-rich h1,
    .tb-rich h2,
    .tb-rich h3,
    .tb-rich h4 {
        margin: 0.45em 0 0.2em;
        font-size: 11.5pt;
    }

    .tb-rich img,
    .tb-files img {
        border-radius: 0;
        box-shadow: none;
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        max-height: 85mm !important;
        margin: 1.5mm auto !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .tb-solution,
    .tb-tone-solution,
    .tb-tone-teacher {
        background: #fff !important;
        padding: 1.5mm 2.5mm;
        margin-top: 1.5mm;
    }

    .tb-rich a,
    .tb-toc a,
    .tb-files a {
        color: inherit;
        text-decoration: none;
        font-weight: 600;
    }

    .tb-topic,
    .tb-lesson,
    .tb-block,
    .tb-question-wrap {
        break-before: auto;
        break-inside: auto;
        page-break-before: auto;
        page-break-inside: auto;
    }

    .tb-cover,
    .tb-lesson + .tb-lesson,
    .tb-block-title,
    .tb-question-kicker {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .tb-topic-title,
    .tb-lesson-title,
    .tb-block-title,
    .tb-question-label,
    .tb-question-kicker {
        break-after: avoid;
        page-break-after: avoid;
    }

    p, li, dd {
        orphans: 2;
        widows: 2;
    }

    @page {
        margin: 11mm 13mm 12mm;
    }
}
