/* =====================================================================
   Тема нового дизайну: БІБЛІОТЕКА (views/beta-theme/library/*)
   Каталог /biblioteka (+ фільтри, НУШ), пошук, календар, додавання/редагування
   розробки, добірки. Компоненти — з beta.css; тут лише доповнення з префіксом tb-library-.
   ===================================================================== */

/* ---------- загальне ---------- */
.tb-library .items { margin-top: 0; }
.tb-library .tb-catalog-head { margin-bottom: 16px; }
.tb-library .tb-catalog-head-row .tb-btn { flex: none; }
.tb-library .tb-catalog-head-row .tb-btn svg { width: 18px; height: 18px; }
.tb-library .tb-crumbs { margin: 0 0 14px; padding: 0; background: none; border: 0; border-radius: 0; line-height: 1.4; }
/* крихти над сіткою — 14px (DESIGN.md §2.12); класичне .library .breadcrumb { margin: 0 0 15px } вантажиться пізніше */
.tb-page.tb-library > .tb-crumbs { margin: 0 0 14px; }
.tb-library .tb-crumbs svg { width: 14px; height: 14px; color: var(--line-2); flex: none; }
.tb-library .tb-crumbs > span:not([itemprop]) { color: var(--ink); font-weight: 700; }
.tb-library .tb-crumbs a:hover { color: var(--orange-d) !important; }
.tb-library-grid { grid-template-areas: "main top" "main bottom"; }
.tb-library-grid > .tb-lib-main { grid-area: main; }
.tb-library-seo { font-size: 15px; }
.tb-library-seo h2, .tb-library-seo h3 { margin: 18px 0 8px; font: 800 18px/1.25 var(--f-display); }
.tb-library-seo p { margin: 0 0 10px; }

/* ---------- предмети гостя ---------- */
.tb-library-subjects { display: grid; gap: 6px; margin-bottom: 16px; }
.tb-library-subjects .tb-chips + .tb-chips { margin-top: 2px; }
.tb-library-subjects .tb-chip-btn.is-more { font-family: var(--f-body); }

/* ---------- фільтри ---------- */
.tb-library-filters { gap: 12px; }
/* рядки фільтрів — з рівним проміжком (gap .tb-filters діє лише на саму форму, не на її рядки) */
.tb-library-form { display: grid; gap: 12px; margin: 0; }
.tb-library-form > .tb-filters-row, .tb-library-form > .tb-filters-block { margin: 0; }
.tb-library .tb-search .form-group { flex: 1; margin: 0; min-width: 0; }
.tb-library .tb-search .help-block { display: none; }
.tb-library .tb-search .tb-search-clear { position: absolute; right: 6px; top: 50%; left: auto; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3) !important; text-transform: none; text-decoration: none !important; }
.tb-library .tb-search .tb-search-clear:hover { background: var(--paper); color: var(--ink) !important; }
.tb-library .tb-search .tb-search-clear svg { width: 16px; height: 16px; }
.tb-library-filters .search-query-button { flex: none; }
.tb-library-filters .search-query-button svg { width: 18px; height: 18px; }
.tb-library-selects { align-items: stretch; }
/* підручник і тема без варіантів приховані — порожній ряд не має додавати ще один проміжок форми */
.tb-library-selects:not(:has(option)) { display: none; }
.tb-library-filters .tb-selectbox { display: flex; flex: 1 1 200px; min-width: 0; align-items: center; margin: 0; font-weight: 700; }
.tb-library-filters .tb-selectbox .form-group { flex: 1; margin: 0; min-width: 0; }
.tb-library-filters .tb-selectbox select { width: 100%; min-height: 44px; padding: 6px 32px 6px 12px; border: 2px solid var(--line); border-radius: 12px; background-color: var(--paper); font: 600 14px/1.3 var(--f-body); color: var(--ink); box-shadow: none; }
.tb-library-filters .tb-selectbox select:focus { border-color: var(--sky); background-color: #fff; outline: none; }
.tb-library-filters .tb-selectbox select:disabled { opacity: .55; cursor: default; }
/* ряд пошуку: запит · предмет · клас · «Знайти» — однакова висота 44px, проміжок 10px (DESIGN.md §1.5) */
.tb-library-filters .tb-library-select-subject { flex: 0 1 260px; }
.tb-library-filters .tb-library-select-grade { flex: 0 1 150px; }
/* клас до вибору предмета — неактивний, але видимий (правило _layout.css ховає select без варіантів) */
.tb-library-filters .tb-library-select-grade:has(select) { display: flex; }
.tb-library-filters .tb-chips a.tb-chip-btn { text-decoration: none !important; color: var(--ink) !important; }
.tb-library-filters .tb-chips a.tb-chip-btn.is-on { color: var(--ink) !important; }
.tb-library-checks { gap: 8px; }
.tb-library-checks .form-group, .tb-library-checks .form-group + .form-group { margin: 0; } /* site.css: .form-group + .form-group { margin-top: 15px } */
.tb-library-checks .tb-toggle-chip { min-height: 44px; padding: 6px 14px; font-size: 13.5px; line-height: 1.3; cursor: pointer; }
.tb-library-checks .help-block { display: none; }

/* ---------- список розробок ---------- */
.tb-library-list { margin-bottom: 4px; }
.tb-library-item .tb-lib-author { font-size: 13px; color: var(--ink-3); }
.tb-library-item .tb-lib-author a { color: var(--ink-2) !important; font-weight: 700; }
.tb-library-item .tb-lib-author a:hover { color: var(--orange-d) !important; text-decoration: underline; text-decoration-color: var(--go); text-underline-offset: 3px; }
.tb-library-item .tb-lib-title a { color: var(--ink) !important; }
.tb-library-item .tb-lib-title a:hover { color: var(--orange-d) !important; }
.tb-library-rating { white-space: nowrap; }
.tb-library-rating b { font-weight: 800; color: var(--ink); }
.tb-library-rating small { font-size: 12.5px; color: var(--ink-3); }
.tb-library-attach-label { font-weight: 800; color: var(--ink-3); }
.tb-library-item .tb-lib-attach + .tb-lib-attach { margin-top: -2px; }
.tb-library-admin { align-self: center; }
.tb-library-empty { margin: 8px 0 12px; padding: 28px 16px; border-radius: 18px; background: #fff; border: 2px dashed var(--line-2); text-align: center; }
.tb-library-count { margin: 0 0 10px; font-weight: 700; color: var(--ink-2); }

/* ---------- посторінкова навігація (LinkPager класики у стилі бети) ---------- */
ul.tb-library-pager { list-style: none; margin: 0; padding: 22px 0 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
ul.tb-library-pager li { display: contents; }
ul.tb-library-pager .tb-pager-page { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 10px; border: 2px solid var(--line); background: #fff; color: var(--ink) !important; font-weight: 700; text-decoration: none !important; }
ul.tb-library-pager a.tb-pager-page:hover { border-color: var(--ink); }
ul.tb-library-pager li.is-on .tb-pager-page { background: var(--ink); border-color: var(--ink); color: #fff !important; }
ul.tb-library-pager .tb-pager-page.is-disabled { opacity: .35; }
ul.tb-library-pager .tb-pager-page svg { width: 16px; height: 16px; }

/* ---------- права колонка ---------- */
.tb-library-aside { gap: 14px; }
/* сітка без правої колонки (сторінка додавання розробки) */
.tb-library-grid.tb-library-grid-full { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
.tb-library-bot { display: grid; gap: 10px; background: #fff8e1; border-color: var(--go); }
.tb-library-bot-name { font: 800 15px/1.3 var(--f-display); }
.tb-library-bot img { display: block; width: 100%; border-radius: 10px; box-shadow: 0 3px 0 var(--line); }
.tb-library-bot > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tb-library-bot .tb-btn { justify-content: center; }
/* прев’ю відзнаки — зверху на всю ширину картки, під ним текст і кнопка */
.tb-library-award { --g: var(--go); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.tb-library-award-img { display: block; width: 100%; height: 150px; object-fit: cover; object-position: center top; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 0 var(--line); animation: tb-library-award-pan 9s ease-in-out 1s infinite alternate; }
/* прев’ю відзнаки повільно прокручується вгору-вниз, щоб було видно всю грамоту; на hover — пауза */
@keyframes tb-library-award-pan { 0%, 12% { object-position: center top; } 88%, 100% { object-position: center bottom; } }
.tb-library-award:hover .tb-library-award-img { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .tb-library-award-img { animation: none; } }
.tb-library-award-body { display: grid; gap: 6px; min-width: 0; }
.tb-library-award-body > small { font: 800 11px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.tb-library-award-body > b { font: 800 14.5px/1.3 var(--f-display); }
.tb-library-award-body > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.tb-library-award-body > em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.tb-library-award-body .tb-cert-bar { height: 8px; }
.tb-library-award-body .tb-btn { width: 100%; margin-top: 4px; justify-content: center; font-size: 14px; }
.tb-library-fb { min-height: 154px; text-align: center; }
.tb-library-vpromo img { display: block; width: 100%; border-radius: 14px; }

/* ---------- НУШ ---------- */
.tb-library-intro { margin-bottom: 16px; }
.tb-library-intro p:last-child { margin-bottom: 0; }
.tb-library-weeks { display: grid; gap: 10px; }
.tb-library-weeks .tb-chips { gap: 5px; }
.tb-library-weeks a.tb-chip-btn { min-height: 32px; padding: 0 10px; font-size: 13px; color: var(--ink) !important; text-decoration: none !important; }
.tb-library-weeks a.tb-chip-btn:hover { border-color: var(--ink); }
.tb-library-nus-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; font-size: 13.5px; line-height: 1.3; cursor: pointer; }
.tb-library-nus-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--go); }

/* ---------- пошук /biblioteka/poshuk ---------- */
.tb-library-search .tb-catalog-head { margin-bottom: 12px; }
.tb-library-diplom { display: grid; gap: 10px; text-align: center; }
.tb-library-diplom img { display: block; width: 100%; border-radius: 10px; box-shadow: 0 3px 0 var(--line); }
.tb-library-diplom p { margin: 0; font-weight: 700; }

/* ---------- календар ---------- */
.tb-library-months { margin-bottom: 0; }
.tb-library-dates { display: grid; gap: 4px; }
.tb-library-date { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; font-size: 14.5px; }
.tb-library-date:hover { background: var(--paper); }
.tb-library-date.is-on { background: #fff8e1; }
.tb-library-date > span { font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-library-date > a { color: var(--ink) !important; font-weight: 600; }
.tb-library-date > a:hover { color: var(--orange-d) !important; }
.tb-library-date > b { font-weight: 800; }
.tb-library-months-list { display: grid; gap: 4px; }
.tb-library-months-list a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--ink) !important; font-weight: 600; text-decoration: none !important; }
.tb-library-months-list a:hover { background: var(--paper); }
.tb-library-months-list a.active { background: var(--ink); color: #fff !important; font-weight: 800; }
.tb-library h2.tb-section-h2, .tb-library h3.tb-section-h2 { margin: 22px 0 12px; font: 800 20px/1.2 var(--f-display); }
.tb-library-posts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.tb-library-post { display: flex; flex-direction: column; border-radius: 16px; background: #fff; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); overflow: hidden; color: var(--ink) !important; text-decoration: none !important; transition: transform .12s, box-shadow .12s; }
.tb-library-post:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--line-2); }
.tb-library-post-img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--paper); }
.tb-library-post-ico { display: grid; place-items: center; height: 90px; background: var(--paper); color: var(--ink-3); font-size: 34px; }
.tb-library-post-body { display: grid; gap: 6px; padding: 12px 14px 14px; }
.tb-library-post-cat { font: 800 11px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; color: var(--orange-d); }
.tb-library-post-title { font: 800 15px/1.3 var(--f-display); }
.tb-library-post-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.tb-library-post-meta span { display: inline-flex; align-items: center; gap: 4px; }
.tb-library-post-meta svg { width: 13px; height: 13px; }
.tb-library-test { grid-template-columns: 56px minmax(0, 1fr) auto; }
.tb-library-test-count { display: grid; place-items: center; width: 56px; height: 64px; border-radius: 10px; background: var(--sky); color: #fff; font: 800 20px/1 var(--f-display); }
.tb-library-test-count small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; opacity: .85; margin-top: 2px; }
.tb-library-test-img { width: 120px; border-radius: 10px; overflow: hidden; background: var(--paper); align-self: center; }
.tb-library-test-img img { display: block; width: 100%; }
.tb-library-example { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }

/* ---------- форми додавання / редагування розробки ---------- */
.tb-library-form-card { padding: clamp(16px, 2.5vw, 24px); }
.tb-library-rules { margin-bottom: 16px; font-weight: 600; color: var(--ink-2); }
.tb-library-rules .dashed-link { color: var(--ink); font-weight: 800; border-bottom: 2px dashed var(--go); text-decoration: none !important; cursor: pointer; }
.tb-library-rules .rulesBlock { display: none; margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--paper); font-weight: 500; color: var(--ink); line-height: 1.5; font-size: 14px; }
.tb-library-upload .tb-field { margin-bottom: 18px; }
.tb-library-upload .tb-label { display: block; margin-bottom: 6px; font: 800 13px/1.2 var(--f-display); color: var(--ink-2); }
.tb-library-upload .tb-input, .tb-library-upload .tb-select, .tb-library-upload .tb-textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: 500 15px/1.4 var(--f-body); color: var(--ink); box-shadow: none; }
.tb-library-upload .tb-select { padding-right: 36px; }
.tb-library-upload .tb-textarea { min-height: 180px; resize: vertical; }
.tb-library-upload .tb-input:focus, .tb-library-upload .tb-select:focus, .tb-library-upload .tb-textarea:focus { border-color: var(--sky); outline: none; }
.tb-library-upload .has-error .tb-input, .tb-library-upload .has-error .tb-select, .tb-library-upload .has-error .tb-textarea, .tb-library-upload .has-error .tb-library-file { border-color: var(--coral); }
.tb-library-upload .help-block { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.tb-library-upload .has-error .help-block { color: var(--coral-d); }
.tb-library-upload .help-block:empty { display: none; }
.tb-library-file { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px dashed var(--line-2); border-radius: 14px; background: var(--paper); }
.tb-library-file svg { flex: none; width: 24px; height: 24px; color: var(--ink-3); }
.tb-library-file input[type="file"] { flex: 1; min-width: 0; font: 600 14px/1.3 var(--f-body); color: var(--ink); }
.tb-library-upload .tb-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-library-upload .tb-field-row .tb-field { margin-bottom: 18px; }
.tb-library-check { margin-bottom: 10px; }
.tb-library-check label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; font-size: 14px; line-height: 1.4; color: var(--ink); cursor: pointer; }
.tb-library-check label:hover { border-color: var(--line-2); }
.tb-library-check input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--go); }
.tb-library-check.hide { display: none !important; }
.tb-library-upload .tb-library-check .help-block { margin-left: 2px; }
.tb-library-authors { display: grid; gap: 8px; margin-bottom: 14px; }
.tb-library-author-row { display: flex; gap: 8px; align-items: center; }
.tb-library-author-row .tb-input { flex: 1; }
.tb-library-author-row .tb-btn { flex: none; }
.tb-library-submit { display: grid; gap: 14px; padding-top: 6px; }
.tb-library-submit .tb-btn { justify-self: start; }
.tb-library-submit-note { font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.tb-library-submit-note p:last-child { margin-bottom: 0; }
.tb-library-upload .redactor-box { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.tb-library-wait { display: grid; gap: 8px; justify-items: start; }
.tb-library-wait b { font: 800 26px/1 var(--f-display); }

/* ---------- добірки ---------- */
.tb-library-sets { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tb-library-set { position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 150px; padding: 16px; border-radius: 18px; background: #fff; border: 2px solid var(--line); border-top: 8px solid var(--g); box-shadow: 0 4px 0 var(--line); }
.tb-library-set.is-c0 { --g: var(--go); } .tb-library-set.is-c1 { --g: var(--sky); } .tb-library-set.is-c2 { --g: var(--mint); } .tb-library-set.is-c3 { --g: var(--coral); } .tb-library-set.is-c4 { --g: var(--grape); }
.tb-library-set.is-c5 { --g: var(--pink); } .tb-library-set.is-c6 { --g: var(--orange); } .tb-library-set.is-c7 { --g: var(--teal); } .tb-library-set.is-c8 { --g: var(--ink-2); } .tb-library-set.is-c9 { --g: var(--sun); }
.tb-library-set-name { font: 800 17px/1.25 var(--f-display); color: var(--ink) !important; text-decoration: none !important; }
.tb-library-set-name:hover { color: var(--orange-d) !important; }
.tb-library-set-count { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.tb-library-set-private { position: absolute; top: 10px; right: 12px; }
.tb-library-set-private svg { width: 12px; height: 12px; vertical-align: -1px; }
.tb-library-set-foot { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.tb-library-set-foot .tb-btn { flex: 1; justify-content: center; font-family: var(--f-body); }
.tb-library-set-new { align-items: center; justify-content: center; border-style: dashed; border-top-width: 2px; background: var(--paper); }
.tb-library-set-new .tb-btn { width: 100%; justify-content: center; font-family: var(--f-body); }
.tb-library-set-head { --g: var(--go); border-top: 8px solid var(--g); margin-bottom: 16px; }
.tb-library-set-head .tb-page-h1 { margin: 0 0 6px; }
.tb-library-set-head p { margin: 0; color: var(--ink-2); font-weight: 600; }
.tb-library-set-head p:empty { display: none; }
.tb-library .modal-content { border-radius: 18px; border: 2px solid var(--line); box-shadow: 0 6px 0 var(--line), 0 20px 50px rgba(0, 0, 0, .2); font-family: var(--f-body); }
.tb-library .modal-header { border-bottom: 1px solid var(--line); font: 800 18px/1.25 var(--f-display); }
.tb-library .modal-header .close { font-size: 26px; opacity: .5; }
.tb-library-modal-form .tb-field { margin-bottom: 14px; }
.tb-library-modal-form .tb-label { display: block; margin-bottom: 6px; font: 800 13px/1.2 var(--f-display); color: var(--ink-2); }
.tb-library-modal-form .tb-input { width: 100%; min-height: 44px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; font: 500 15px/1.4 var(--f-body); box-shadow: none; }
.tb-library-modal-form .tb-input:focus { border-color: var(--sky); outline: none; }
.tb-library-modal-form .has-error .tb-input { border-color: var(--coral); }
.tb-library-modal-form .help-block { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--coral-d); }
.tb-library-modal-form .help-block:empty { display: none; }
.tb-library-radios { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-library-radios .radio { margin: 0; }
.tb-library-radios .modal-radio { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; font-size: 14px; cursor: pointer; }
.tb-library-radios .modal-radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--go); }
.tb-library-radios .modal-radio i { display: none; }
.tb-library-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 0; padding-top: 4px; }
.tb-library-modal-text { margin: 0 0 14px; font-weight: 600; color: var(--ink); }

/* ---------- мобільні ---------- */
@media (max-width: 991px) {
    .tb-library-grid { grid-template-areas: "main" "top" "bottom"; }
}
@media (max-width: 760px) {
    .tb-library-test { grid-template-columns: 44px minmax(0, 1fr); }
    .tb-library-test-count { width: 44px; height: 52px; font-size: 17px; }
    .tb-library-test-img { grid-column: 1 / -1; width: 100%; max-width: none; } /* обкладинка на всю ширину картки */
    .tb-library-admin { grid-column: 1 / -1; }
    /* телефон: кнопки адміністратора — рівна сітка 2 колонки, «Видалити» окремим рядком на всю ширину (було 2 + 1 вужча) */
    .tb-lib-actions.tb-library-admin { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .tb-lib-actions.tb-library-admin > .tb-btn { width: 100%; justify-content: center; }
    .tb-lib-actions.tb-library-admin > .tb-btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .tb-library .tb-catalog-head-row { flex-direction: column; align-items: stretch; }
    .tb-library .tb-catalog-head-row .tb-btn { width: 100%; justify-content: center; }
    .tb-library-filters .search-query-button { width: 100%; justify-content: center; }
    .tb-library-filters .tb-selectbox { flex-basis: 100%; }
    .tb-library-selects .tb-selectbox > span { display: none; }
    .tb-library-checks .tb-toggle-chip { width: 100%; }
    .tb-library-nus-check { width: 100%; }
    .tb-library-award { gap: 10px; }
    .tb-library-award-body .tb-btn { width: 100%; }
    .tb-library-posts { grid-template-columns: 1fr; }
    .tb-library-date { grid-template-columns: 1fr; gap: 2px; }
    .tb-library-upload .tb-field-row { grid-template-columns: 1fr; gap: 0; }
    .tb-library-submit .tb-btn { justify-self: stretch; width: 100%; }
    .tb-library-author-row { flex-wrap: wrap; }
    .tb-library-author-row .tb-btn { width: 100%; justify-content: center; }
    .tb-library-file { flex-direction: column; align-items: flex-start; }
    .tb-library-file input[type="file"] { width: 100%; }
    .tb-library-sets { grid-template-columns: 1fr; }
    .tb-library-modal-actions .tb-btn { flex: 1; justify-content: center; }
    ul.tb-library-pager .tb-pager-page { min-width: 34px; height: 34px; }
}
/* «Додати розробку»: форма на всю ширину, бічна колонка під нею */
.tb-library-grid:has(> .tb-lib-main > .tb-library-upload), .tb-library-grid:has(> .tb-lib-main > form.tb-library-upload) { grid-template-columns: minmax(0, 1fr) !important; grid-template-areas: "main" "top" !important; }
.tb-library-upload { max-width: none; width: 100%; }
/* Промо вебінара з подарунком (картка документа): обкладинка з датою-плиткою, подарунок окремою плашкою, дата й кнопка внизу */
.tb-lib-webinar.is-promo { grid-template-columns: 240px minmax(0, 1fr); gap: 20px; padding: 14px; align-items: stretch; border-color: color-mix(in srgb, var(--sun, #ffab00) 45%, var(--line)); box-shadow: 0 4px 0 color-mix(in srgb, var(--sun, #ffab00) 45%, var(--line)); background: linear-gradient(135deg, #fffaf0 0%, #fff 55%); }
.tb-lib-webinar.is-promo .tb-lib-webinar-img { position: relative; aspect-ratio: auto; min-height: 168px; height: 100%; border-radius: 14px; background: linear-gradient(135deg, #fff3d6, #ffe0a3); }
.tb-lib-webinar.is-promo .tb-lib-webinar-img img { position: absolute; inset: 0; transition: transform .3s ease; }
.tb-lib-webinar.is-promo:hover .tb-lib-webinar-img img { transform: scale(1.04); }
.tb-lib-webinar-date { position: absolute; top: 10px; left: 10px; display: grid; justify-items: center; min-width: 58px; padding: 6px 8px 7px; border-radius: 12px; background: #fff; box-shadow: 0 3px 0 rgba(38, 50, 56, .18); color: var(--ink); line-height: 1; text-align: center; }
.tb-lib-webinar-date b { font: 800 24px/1 var(--f-display); }
.tb-lib-webinar-date small { margin-top: 2px; font: 700 11px/1.1 var(--f-body); color: var(--ink-2); }
.tb-lib-webinar-date i { margin-top: 5px; padding: 2px 6px; border-radius: 6px; background: var(--sun, #ffab00); font: 800 11px/1.2 var(--f-body); font-style: normal; color: var(--ink); }
.tb-lib-webinar.is-promo .tb-lib-webinar-body { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.tb-lib-webinar.is-promo .tb-tcard-tags { align-self: flex-start; }
.tb-lib-webinar.is-promo .tb-tcard-tags .tb-chip svg { width: 14px; height: 14px; margin-right: 2px; }
.tb-lib-webinar.is-promo .tb-lib-webinar-title { font: 800 clamp(17px, 1.6vw, 19px)/1.28 var(--f-display); }
.tb-lib-webinar.is-promo .tb-lib-webinar-title a { color: var(--ink) !important; text-decoration: none !important; }
.tb-lib-webinar.is-promo .tb-lib-webinar-title a:hover { color: var(--orange-d, #e65100) !important; }
.tb-lib-webinar-gift { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #fff3d6; color: var(--ink); }
.tb-lib-webinar-gift-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--sun, #ffab00); color: #fff; }
.tb-lib-webinar.is-promo .tb-lib-webinar-gift-ico svg { width: 20px; height: 20px; vertical-align: 0; }
.tb-lib-webinar-gift > span:last-child { display: grid; gap: 1px; min-width: 0; }
.tb-lib-webinar-gift small { font: 700 12px/1.2 var(--f-body); color: #a86b00; }
.tb-lib-webinar-gift b { font: 700 14px/1.35 var(--f-body); color: var(--ink); }
.tb-lib-webinar-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: auto; padding-top: 2px; }
.tb-lib-webinar-when { display: inline-flex; align-items: center; gap: 6px; font: 700 14px/1.3 var(--f-body); color: var(--ink-2); }
.tb-lib-webinar.is-promo .tb-btn { justify-self: auto; margin-top: 0; }
.tb-lib-webinar.is-promo .tb-btn svg { width: 16px; height: 16px; vertical-align: 0; }
/* ширина картки, а не екрана: у вузькій колонці (бічні панелі) — обкладинка зверху */
.tb-lib-promo:has(> .tb-lib-webinar.is-promo) { container-type: inline-size; }
@container (max-width: 760px) { .tb-lib-webinar.is-promo { grid-template-columns: 190px minmax(0, 1fr); gap: 16px; } }
@container (max-width: 560px) {
    .tb-lib-webinar.is-promo { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .tb-lib-webinar.is-promo .tb-lib-webinar-img { min-height: 0; aspect-ratio: 16 / 7; }
}
@container (max-width: 420px) {
    .tb-lib-webinar.is-promo .tb-lib-webinar-img { aspect-ratio: 16 / 9; }
    .tb-lib-webinar-foot .tb-btn { width: 100%; justify-content: center; }
}
/* перегляд презентації: класичні від’ємні відступи (-20px) розраховані на інший padding картки — у новому дизайні переглядач усередині картки */
.tb-lib-single .content-block .presentation-preview { margin: 0 !important; max-width: 100%; border-radius: 12px; overflow: hidden; }
/* схожі / рекомендовані: посилання лише на назві (анкор = назва розробки), уся картка клікабельна через ::after */
.tb-lib-rel { position: relative; cursor: pointer; }
.tb-lib-rel-link { color: inherit !important; text-decoration: none !important; }
.tb-lib-rel-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.tb-lib-rel:focus-within { background: var(--paper); }
.tb-lib-rel-link:focus-visible { outline: none; }
.tb-lib-rel-link:focus-visible::after { outline: 2px solid var(--sky); outline-offset: 2px; }
/* ---------- Перегляд файлу (.doc-content, HTML від конвертера) ----------
   Word (.doc/.docx → LibreOffice): написи й рамки з position:absolute у дюймах, Times 14pt, відступи в дюймах,
   порожні абзаци, сміттєві hspace — нормалізуємо до типографіки сайту, усе в потоці тексту.
   PDF (pdftohtml): сторінка — блок #pageN-div фіксованої ширини з фоном-картинкою і абсолютно позиціонованим
   текстом; позиціонування НЕ чіпаємо, сторінку масштабує скрипт у views/beta/library-single.php (zoom).
   Довгий файл згорнуто до ~1400px з кнопкою «Показати весь документ» (той самий скрипт). */
.tb-lib-single .doc-content { position: relative; overflow-x: auto !important; overflow-y: hidden; max-width: 100%; font: 400 15.5px/1.65 var(--f-body); color: var(--ink); overflow-wrap: break-word; }
.tb-lib-single .doc-content :is([style*="position: absolute"], [style*="position:absolute"], [style*="position: fixed"], [style*="position:fixed"]):not([id^="page"][id$="-div"] *) { position: static !important; display: block; top: auto !important; left: auto !important; right: auto !important; bottom: auto !important; width: auto !important; max-width: 100%; height: auto !important; margin: 6px 0; text-indent: 0 !important; }
.tb-lib-single .doc-content img:not([id^="page"][id$="-div"] img) { display: block; float: none !important; max-width: 100% !important; height: auto !important; margin: 14px auto !important; border-radius: 6px; }
.tb-lib-single .doc-content img[width="1"], .tb-lib-single .doc-content img[height="1"] { display: none !important; }
/* Word: шрифти, розміри, відступи, інтервали — як у тексті сайту */
.tb-lib-single .doc-content:not(.is-pdf) :is(p, span, font, li, td, th, div, a, b, strong, i, em, u, sup, sub) { font-family: inherit !important; letter-spacing: normal !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(span, font, b, strong, i, em, u, a) { font-size: inherit !important; line-height: inherit !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(p, li, div) { font-size: 15.5px !important; line-height: 1.65 !important; }
.tb-lib-single .doc-content:not(.is-pdf) p { margin: 0 0 .7em !important; padding: 0 !important; text-indent: 0 !important; text-align: left !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(p, div, ul, ol, table, h1, h2, h3, h4, h5, h6) { margin-left: 0 !important; margin-right: 0 !important; max-width: 100%; }
.tb-lib-single .doc-content:not(.is-pdf) :is(h1, h2, h3, h4, h5, h6) { margin: 1.2em 0 .5em !important; padding: 0 !important; font-family: var(--f-display) !important; font-weight: 800 !important; line-height: 1.3 !important; color: var(--ink) !important; text-indent: 0 !important; text-align: left !important; }
.tb-lib-single .doc-content:not(.is-pdf) h1, .tb-lib-single .doc-content:not(.is-pdf) h1 * { font-size: 21px !important; }
.tb-lib-single .doc-content:not(.is-pdf) h2, .tb-lib-single .doc-content:not(.is-pdf) h2 * { font-size: 18.5px !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(h3, h4, h5, h6), .tb-lib-single .doc-content:not(.is-pdf) :is(h3, h4, h5, h6) * { font-size: 16.5px !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(ul, ol) { margin: 0 0 .8em !important; padding-left: 24px !important; }
.tb-lib-single .doc-content:not(.is-pdf) li { margin: 0 0 .3em !important; text-indent: 0 !important; }
.tb-lib-single .doc-content:not(.is-pdf) a { color: var(--sky-d, #1565c0); }
.tb-lib-single .doc-content:not(.is-pdf) table { width: 100% !important; margin: .4em 0 1em !important; border-collapse: collapse; font-size: 14.5px; }
.tb-lib-single .doc-content:not(.is-pdf) :is(td, th) { width: auto !important; padding: 6px 8px !important; vertical-align: top; border: 1px solid var(--line-2, #cfd8dc) !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(td, th) p { margin: 0 0 .3em !important; font-size: 14.5px !important; }
.tb-lib-single .doc-content:not(.is-pdf) :is(td, th) p:last-child { margin-bottom: 0 !important; }
.tb-lib-single .doc-content .tb-doc-empty { display: none !important; }
.tb-lib-single .doc-content [style*="page-break-before"]:not(:first-child) { margin-top: 1.4em !important; }
/* конвертер пише сміттєві hspace/vspace (напр. hspace="286331153" → бічний відступ у сотні мільйонів px) */
.tb-lib-single .doc-content img[hspace] { margin-left: auto !important; margin-right: auto !important; }
/* PDF: сторінки масштабує скрипт; між сторінками — проміжок і легка рамка, як аркуші */
.tb-lib-single .doc-content.is-pdf [id^="page"][id$="-div"] { margin: 0 auto 14px; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 3px 0 var(--line); background: #fff; }
.tb-lib-single .doc-content.is-pdf { overflow-x: hidden !important; }
/* довгий перегляд згорнуто */
.tb-lib-single .doc-content.is-collapsed { max-height: 1400px; overflow: hidden !important; }
.tb-lib-single .doc-content.is-collapsed::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 160px; background: linear-gradient(rgba(255, 255, 255, 0), #fff); pointer-events: none; }
.tb-lib-doc-more { display: flex; justify-content: center; margin-top: 10px; }
.tb-lib-single .doc-content .tb-doc-label { display: inline-block !important; width: auto !important; margin: 0 10px 6px 0 !important; padding: 2px 8px; border-radius: 6px; background: var(--paper); color: var(--ink-2); }
.tb-lib-single .doc-content .tb-doc-label :is(p, span, font) { display: inline !important; margin: 0 !important; font-size: 13px !important; line-height: 1.5 !important; }
/* порожні абзаци й переноси всередині підписів діаграм — не показувати (правило вище робить їх inline) */
.tb-lib-single .doc-content .tb-doc-label .tb-doc-empty, .tb-lib-single .doc-content .tb-doc-label br { display: none !important; }
