/* MangaNew — каталог з фільтрами (catalog.js) */
.cat-fallback { display: none; }
html:not(.js) .cat-fallback { display: block; }
html:not(.js) .cat-bar, html:not(.js) .cat-grid { display: none; }

.cat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.cat-search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 8px; border: 2px solid var(--line-strong); color: var(--muted); transition: border-color var(--t-fast, .22s) ease; }
.cat-search:focus-within { border-color: var(--accent); }
.cat-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.cat-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cat-chip { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; border-radius: var(--radius-btn); border: 2px solid var(--line-strong); background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.cat-chip::after { content: ""; width: 7px; height: 7px; margin-left: 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .6; transition: transform var(--t, .38s) var(--ease, ease); }
.cat-chip[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.cat-chip:hover, .cat-chip[aria-expanded="true"] { border-color: var(--frame-soft); }
.cat-chip.is-set { border-color: var(--accent); }
.cat-chip b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 20px; text-align: center; }
.cat-chip b:empty { display: none; }
.cat-sort select { height: 42px; padding: 0 34px 0 12px; border-radius: var(--radius-btn); border: 2px solid var(--line-strong); background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; -webkit-appearance: none; appearance: none; cursor: pointer; }

/* Панель фільтра */
.cat-pop { margin-bottom: 14px; padding: 14px; border-radius: 12px; background: var(--surface); border: 2px solid var(--line-strong); box-shadow: 6px 6px 0 var(--frame-shade); animation: pop-in var(--t, .38s) var(--ease, ease) both; }
.cat-pop[hidden] { display: none; }
.cat-pop__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.cat-pop__find { width: 220px; max-width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; }
.cat-pop__hint { font-size: 12px; color: var(--muted); }
.cat-pop__hint .inc { color: var(--accent); }
.cat-pop__hint .exc { color: var(--danger); }
.cat-genres { display: flex; flex-wrap: wrap; gap: 6px; max-height: 320px; overflow-y: auto; padding: 2px; }
.cat-g, .cat-opt { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 7px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color var(--t-fast, .22s) ease, color var(--t-fast, .22s) ease; }
.cat-g small { font-size: 11px; font-weight: 500; opacity: .55; }
.cat-g:hover, .cat-opt:hover { background: var(--line-strong); }
.cat-g.is-inc, .cat-opt.is-on { background: var(--accent); color: var(--accent-ink); }
.cat-g.is-inc::before { content: "✓"; }
.cat-g.is-exc { background: var(--danger-soft); color: var(--danger-ink); text-decoration: line-through; }
.cat-g.is-exc::before { content: "✕"; text-decoration: none; }
.cat-g[hidden] { display: none; }
.cat-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-year { display: flex; flex-direction: column; gap: 12px; }
.cat-year label { display: inline-flex; align-items: center; gap: 8px; margin-right: 14px; font-size: 14px; color: var(--muted); }
.cat-year input { width: 100px; height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: inherit; }
.cat-pop__foot { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cat-link { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cat-link:hover { color: var(--accent); }

/* Активні фільтри */
.cat-active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.cat-active[hidden] { display: none; }
.cat-on { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 11px; border-radius: 15px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cat-on span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(127, 127, 127, .25); font-size: 13px; line-height: 1; }
.cat-on:hover span { background: var(--danger); color: #fff; }
.cat-on.is-inc { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cat-on.is-exc { box-shadow: inset 0 0 0 1.5px var(--danger); }

/* Сітка тайтлів */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 24px 18px; min-height: 300px; transition: opacity .2s ease; }
/* затемнення під час завантаження — у style.css (.cat.is-loading), лише якщо запит довший за 150 мс */
.ci { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--text); }
.ci:hover { color: var(--text); }
.ci__cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 2px solid var(--frame-soft); transition: transform var(--t, .38s) var(--ease, ease), box-shadow var(--t, .38s) var(--ease, ease), border-color var(--t-fast, .22s) ease; }
.ci:hover .ci__cover { transform: translate(-2px, -2px); border-color: var(--frame); box-shadow: 5px 5px 0 var(--accent); }
.ci__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow, .7s) var(--ease, ease); }
.ci:hover .ci__cover img { transform: scale(1.05); }
.ci__rate { position: absolute; right: 6px; top: 6px; padding: 1px 7px; border-radius: 4px; background: var(--hot); color: var(--hot-ink); font-size: 12px; font-weight: 800; }
.ci__rate::before { content: "★ "; }
.ci__adult { position: absolute; left: 6px; top: 6px; padding: 1px 5px; border-radius: 4px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; transform: rotate(-4deg); }
.ci__name { font-size: 14px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; transition: color var(--t-fast, .22s) ease; }
.ci:hover .ci__name { color: var(--accent); }
.ci__meta { display: flex; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.ci__ch { margin-left: auto; }
.ci__st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.ci__st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.ci__st[data-status="Триває"]::before { background: var(--ok); }
.ci__st[data-status="Закінчений"]::before { background: var(--accent); }
.ci__st[data-status="Заморожено"]::before { background: var(--l-planned); }
.ci__st[data-status="Покинуто"]::before { background: var(--danger); }
.cat-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 50px 16px; text-align: center; color: var(--muted); }
.cat-empty b { color: var(--text); font-size: 16px; }
.cat-foot { display: flex; justify-content: center; margin-top: 28px; }
.cat-more { min-width: 220px; }
@media (prefers-reduced-motion: reduce) { .ci:hover .ci__cover, .ci:hover .ci__cover img { transform: none; } }

@media (max-width: 760px) {
  .cat-filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
  .cat-filters::-webkit-scrollbar { display: none; }
  .cat-chip, .cat-sort select { height: 38px; flex: none; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 18px 12px; }
  .cat-pop { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: 75vh; overflow-y: auto; margin: 0; border-radius: 16px 16px 0 0; border-width: 2px 0 0; box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, .7); }
  .cat-genres { max-height: none; }
}

/* Каталог і закладинки на телефоні: три колонки, коротший підпис (тип і рік, без кількості розділів) */
@media (max-width: 760px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; }
  .ci { gap: 4px; }
  .ci__cover { border-radius: 6px; border-width: 1.5px; }
  .ci__name { font-size: 13px; }
  .ci__meta, .ci__st { font-size: 11px; }
  .ci__ch { display: none; }
  .ci__rate, .ci__adult { font-size: 10px; padding: 1px 5px; }
}
@media (max-width: 359px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cat-more[hidden] { display: none; }

/* Каталог: фіксована кількість колонок, як у «Оновленні релізів» на головній — 6 / 4 / 3 / 2.
   Порція підвантаження (36, catalog.js) ділиться на кожну з них, тож ряди завжди повні (раніше auto-fill давав 8 колонок і неповний ряд) */
.cat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 22px 16px; }
@media (max-width: 899px) { .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 12px; } }
@media (max-width: 760px) { .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; } }
@media (max-width: 359px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Нові фільтри: кількість у варіантах «Мої списки», підказки під варіантами */
.cat-opt small { margin-left: 4px; font-size: 12px; font-weight: 500; opacity: .6; }
.cat-opts + .cat-pop__hint { display: block; margin: 10px 2px 0; }

/* Рік: повзунок з двома ручками (два input[type=range] один над одним) */
.cat-year { gap: 16px; }
.cat-range { --a: 0; --b: 100; max-width: 560px; padding: 2px 4px 0; }
.cat-range__vals { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 15px; }
.cat-range__vals b { padding: 5px 12px; border-radius: 8px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.cat-range__vals span { color: var(--muted); }
.cat-range__track { position: relative; height: 28px; }
.cat-range__track::before, .cat-range__fill { content: ""; position: absolute; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; }
.cat-range__track::before { left: 0; right: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.cat-range__fill { left: calc(11px + (100% - 22px) * var(--a) / 100); right: calc(11px + (100% - 22px) * (100 - var(--b)) / 100); background: var(--accent); }
.cat-year .cat-range input[type=range] { position: absolute; inset: 0; width: 100%; height: 28px; margin: 0; padding: 0; border: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; outline: none; }
.cat-range input[type=range]::-webkit-slider-runnable-track { height: 28px; background: none; }
.cat-range input[type=range]::-moz-range-track { height: 28px; background: none; }
.cat-range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: 3px; border-radius: 50%; border: 3px solid var(--accent); background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); cursor: grab; pointer-events: auto; transition: transform .15s ease; }
.cat-range input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--accent); background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); cursor: grab; pointer-events: auto; }
.cat-range input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.12); }
.cat-range input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }
.cat-range input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }
.cat-range__scale { position: relative; height: 16px; margin: 4px 11px 0; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cat-range__scale span { position: absolute; transform: translateX(-50%); }
.cat-range__scale span:first-child { transform: none; }

/* Підпис картки: «Манхва · 2026» і «36 розд. · ● Триває» — два рівні рядки */
.ci__meta { font-size: 12px; }
.ci__row { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.ci__row .ci__ch { margin-left: 0; }
.ci__row .ci__st { font-size: inherit; }
@media (max-width: 760px) {
  .ci__meta, .ci__row, .ci__row .ci__st { font-size: 12px; }
  .ci__row .ci__ch { display: inline; }
}
/* Без обкладинки — заглушка з першою літерою */
.ci__cover.is-noimg, .ci__cover.is-broken { background: linear-gradient(150deg, var(--accent-soft), var(--surface-2) 70%); }
.ci__cover.is-noimg::after, .ci__cover.is-broken::after { content: attr(data-letter); position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 48px; font-weight: 800; color: var(--accent); opacity: .55; }
.ci__cover.is-broken img { visibility: hidden; }

/* ── Сортування: власне випадаюче меню (catalog.js), у стилі кнопок-фільтрів і панелей ── */
.cat-sort { position: relative; }
.cat-sort.is-enh select { display: none; }
.cat-sort__btn { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 14px; border-radius: var(--radius-btn); border: 2px solid var(--line-strong); background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: border-color var(--t-fast, .22s) ease; }
.cat-sort__btn::after { content: ""; width: 7px; height: 7px; margin-left: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .6; transition: transform var(--t, .38s) var(--ease, ease); }
.cat-sort.is-open .cat-sort__btn::after { transform: translateY(1px) rotate(-135deg); }
.cat-sort__btn:hover, .cat-sort.is-open .cat-sort__btn { border-color: var(--frame-soft); }
.cat-sort__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-sort__k { color: var(--muted); font-weight: 500; }
.cat-sort__btn b { font-weight: 700; }
.cat-sort__list { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; display: flex; flex-direction: column; gap: 2px; min-width: 250px; padding: 6px; border-radius: 12px; background: var(--surface); border: 2px solid var(--line-strong); box-shadow: 6px 6px 0 var(--frame-shade); animation: pop-in var(--t, .38s) var(--ease, ease) both; }
.cat-sort__list[hidden] { display: none; }
.cat-sort__head { display: none; margin: 4px 8px 8px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.cat-sort__opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 38px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; transition: background-color var(--t-fast, .22s) ease, color var(--t-fast, .22s) ease; }
.cat-sort__opt:hover, .cat-sort__opt:focus-visible { background: var(--surface-2); outline: 0; }
.cat-sort__opt.is-on { color: var(--accent); }
.cat-sort__opt.is-on::after { content: ""; width: 10px; height: 5px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(-45deg); }
@media (max-width: 760px) {
  .cat-sort__btn { height: 38px; flex: none; }
  .cat-sort__k { display: none; }
  /* рядок фільтрів гортається вбік і обрізав би список — на телефоні це нижня шторка, як панелі фільтрів */
  .cat-sort.is-open::before { content: ""; position: fixed; inset: 0; z-index: 69; background: rgba(0, 0, 0, .5); }
  .cat-sort__list { position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 70; min-width: 0; max-height: 75vh; overflow-y: auto; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; border-width: 2px 0 0; box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, .7); }
  .cat-sort__head { display: block; }
  .cat-sort__opt { min-height: 46px; font-size: 15px; }
}
