/*
 * VOLUMES: тома тайтла — оглавление блоками (views/book/_toc_vols.php, _toc_vol_body.php), инструменты тома, форма тома
 * (views/volume/_form.php), режим выбора глав и панель переноса (www/js/modules/volumes.js), страница /book/<id>/volumes,
 * метка тома и группы в читалке (views/volume/_reader_head.php, www/js/modules/volumes-reader.js).
 * Строки глав — прежние стили nb.css (.nb-toc #Chapters …). Только токены nb.css, обе темы.
 */

/* ---------------------------------------------------------------- блоки */
.nb-toc-vols { display: grid; gap: 10px; min-width: 0; }
.nb-vol {
	position: relative; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
	background: color-mix(in oklab, var(--card) 60%, transparent); scroll-margin-top: 176px;
}
.nb-vol.is-current { box-shadow: inset 3px 0 0 var(--translator); }
.nb-vol.is-loose { border-style: dashed; background: transparent; }
.nb-vol.is-empty .nb-vol-t { color: var(--muted-foreground); }

/* заголовок тома — одна строка ≈ 44 px: стрелка · название «…» · «N глав · 1–7» · прочитано · чипы; инструменты справа */
.nb-vol-d > summary {
	list-style: none; position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px;
	min-height: 44px; box-sizing: border-box; padding: 6px 12px 7px; cursor: pointer; border-radius: var(--radius-lg);
}
.nb-vol-d > summary::-webkit-details-marker { display: none; }
.nb-vol-d > summary:hover { background: var(--muted); }
.nb-vol-d > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.nb-vol.has-tools > .nb-vol-d > summary { padding-right: 206px; }
.nb-vol-arr { display: inline-grid; place-items: center; width: 22px; height: 22px; color: var(--muted-foreground); transform: rotate(-90deg); transition: transform .15s; }
.nb-vol-d[open] > summary .nb-vol-arr { transform: none; }
.nb-vol-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.nb-vol-t {
	flex: 0 0 auto; max-width: 62%; font-size: 14.5px; font-weight: 650; line-height: 1.3; color: var(--foreground);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nb-vol-meta { display: flex; flex: 1 1 auto; flex-wrap: nowrap; align-items: center; gap: 4px 8px; min-width: 0; overflow: hidden; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.nb-vol-meta > * { flex: none; }
.nb-vol-meta > span:first-child { white-space: nowrap; }
.nb-vol-read { color: var(--success); font-weight: 550; white-space: nowrap; }
.nb-vol-meta .nb-chip { font-size: 11px; padding: 0 6px; margin: 0; }
.nb-vol-meta .nb-cchip { height: 20px; padding: 0 6px; font-size: 11.5px; }
.nb-vol-bar {
	position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; border-radius: 2px; pointer-events: none;
	background: linear-gradient(to right, var(--success) var(--p, 0%), color-mix(in oklab, var(--border) 70%, transparent) var(--p, 0%));
}
.nb-vol-d:not([open]) .nb-vol-bar { opacity: .8; }

.nb-vol-body { padding: 0 10px 8px; min-width: 0; }
.nb-vol-descr { margin: 0 4px 8px; font-size: 13.5px; line-height: 1.55; color: var(--muted-foreground); white-space: normal; overflow-wrap: anywhere; }
.is-js .nb-vol-descr.is-clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nb-vol-more-descr { margin: -4px 4px 8px; padding: 0; border: 0; background: none; color: var(--link); font-size: 12.5px; cursor: pointer; }
.nb-vol-none { margin: 2px 4px 8px; font-size: 13.5px; color: var(--muted-foreground); }
.nb-vol-lazy {
	display: flex; align-items: center; justify-content: center; min-height: 40px; margin: 4px 0; padding: 0 12px; box-sizing: border-box;
	border: 1px dashed var(--border); border-radius: var(--radius); color: var(--link); font-size: 13px;
}
.nb-vol-lazy:hover { border-color: var(--input); text-decoration: none; background: var(--muted); }
.nb-vol-wait {
	display: grid; place-items: center; margin: 4px 0; border-radius: var(--radius); color: var(--muted-foreground); font-size: 13px;
	background: repeating-linear-gradient(to bottom, var(--muted) 0 52px, transparent 52px 58px);
}
.nb-vol-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 4px; }
.nb-vol-pager .nb-btn { gap: 4px; }
.nb-vol-pager .is-disabled { opacity: .45; pointer-events: none; }

/* таблицы строк: те же карточки строк, что у плоского списка (toc.css — строки в одну строку), без шапки */
.nb-toc #Chapters .nb-vol-table { width: 100%; max-width: 100%; margin: 0; border: 0; background: transparent; border-collapse: separate; border-spacing: 0 4px; }
.nb-toc #Chapters .nb-vol-table + .nb-vol-table { margin-top: -4px; }
/* ширины колонок (fixed): те же, что у шапки плоского списка (toc.css); в узком оглавлении дата и статус уходят во вторую
   строку сводки — их колонки нулевые */
.nb-toc #Chapters .nb-vol-table { table-layout: fixed; }
.nb-vol-table col.c-pk { width: 28px; }
.nb-vol-table col.c-dat { width: 66px; }
.nb-vol-table col.c-st { width: 84px; }
.nb-vol-table col.c-act { width: 104px; }
.nb-vol-table col.c-e { width: 32px; }
@container nb-toc (max-width: 559px) {
	.nb-vol-table col.c-dat, .nb-vol-table col.c-st { width: 0; }
	.nb-vol-table col.c-act { width: 106px; }
}
@container nb-toc (min-width: 560px) {
	.nb-toc .nb-vol-cols { display: grid; }	/* сильнее базового правила ниже */
}
/* шапка колонок над блоками: «Глава · Дата · Статус» — только в широкой колонке (ширины — как col выше) */
.nb-vol-cols {
	display: none; grid-template-columns: minmax(0, 1fr) 66px 104px; gap: 0; padding: 0 11px 1px;
	font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-foreground);
}
.nb-vol-cols.has-st { grid-template-columns: minmax(0, 1fr) 66px 84px 104px; }
.nb-vol-cols.has-pk { grid-template-columns: 28px minmax(0, 1fr) 66px 104px 32px; }
.nb-vol-cols.has-pk.has-st { grid-template-columns: 28px minmax(0, 1fr) 66px 84px 104px 32px; }
.nb-vol-cols > span { padding: 0 8px; }
.nb-vol-cols > .c-dat { text-align: right; }

/* ---------------------------------------------------------------- инструменты тома (вне <summary>) */
.nb-vol-tools { position: absolute; top: 4px; right: 8px; display: flex; align-items: center; gap: 2px; margin: 0; }
.nb-vol-tool {
	display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; box-sizing: border-box;
	border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.nb-vol-tool:hover { background: var(--muted); color: var(--foreground); text-decoration: none; }
.nb-vol-tool:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.nb-vol-tools .nb-vol-more { display: none; }
.nb-vol-tools .nb-vol-more > summary { list-style: none; }
.nb-vol-tools .nb-vol-more > summary::-webkit-details-marker { display: none; }
.nb-vol-tools .nb-dropdown { top: calc(100% + 4px); min-width: 200px; }
.nb-vol-tools .nb-dropdown a, .nb-vol-tools .nb-dropdown button { min-height: 40px; }
/* «выбрать все главы тома» — поле панели массовых действий (views/book/_toc_bulk.php) */
.nb-vol-pickall { margin: 0; }
.nb-vol-pickall input { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--primary); }
/* телефон: инструменты — меню «⋯», целей касания не меньше 40 px */
@media (max-width: 559px) {
	.nb-vol-tools > .nb-vol-tool { display: none; }
	.nb-vol-tools > .nb-vol-tool.nb-vol-pickall { display: inline-grid; width: 40px; height: 40px; }
	.nb-vol-tools .nb-vol-more { display: block; }
	.nb-vol-tools .nb-vol-more > summary { width: 40px; height: 40px; }
	.nb-vol.has-tools > .nb-vol-d > summary { padding-right: 92px; }
	.nb-vol-d > summary { min-height: 48px; padding: 5px 10px 6px; gap: 6px; }
	.nb-vol-main { flex-wrap: wrap; row-gap: 1px; }
	.nb-vol-t { flex-basis: 100%; max-width: none; font-size: 14.5px; }
	.nb-vol-body { padding: 0 3px 4px; }
}

/* ---------------------------------------------------------------- панель «Развернуть все / Свернуть все» */
.nb-toc-bar .nb-toc-volctl button {
	display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; color: var(--muted-foreground); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.nb-toc-bar .nb-toc-volctl button + button { border-left: 1px solid var(--border); }
.nb-toc-bar .nb-toc-volctl button:hover { background: var(--muted); color: var(--foreground); }
.nb-toc-volctl { order: 3; }
.nb-toc-volctl[hidden] { display: none; }
@media (max-width: 760px) {
	.nb-toc-bar .nb-toc-volctl { flex: 1 1 100%; }
	.nb-toc-bar .nb-toc-volctl button { flex: 1 1 0; justify-content: center; height: 38px; }
}

/* ---------------------------------------------------------------- перестановка и выбор */
.nb-toc-section.is-reordering .nb-vol-tools, .nb-toc-section.is-reordering .nb-vol-pager,
.nb-toc-section.is-reordering .nb-toc-volctl, .nb-toc-section.is-reordering .nb-vol-lazy { display: none; }
.nb-toc-section.is-reordering .nb-vol.has-tools > .nb-vol-d > summary { padding-right: 14px; }
.nb-vol-add td.editing, .nb-vol-add td.loading { border-radius: var(--radius-lg); }


/* ---------------------------------------------------------------- форма тома */
.nb-vf { display: grid; gap: 12px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card-solid); }
.nb-vf-card { margin: 0 0 12px; box-shadow: var(--elev-2); }
.nb-vol-body > .nb-vf { margin: 2px 0 10px; }
.nb-vf h3 { margin: 0; font-size: 15px; }
.nb-vf .row2 { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; align-items: start; }
.nb-vf label.l { display: block; margin: 0 0 5px; font-size: 12px; font-weight: 600; }
.nb-vf input[type=text], .nb-vf input[type=number], .nb-vf select, .nb-vf textarea { width: 100%; max-width: 100%; margin: 0; box-sizing: border-box; }
.nb-vf input[type=text], .nb-vf input[type=number], .nb-vf select { height: 38px; }
.nb-vf textarea { min-height: 70px; resize: vertical; }
.nb-vf .hint { margin: 5px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted-foreground); }
.nb-vf .range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.nb-vf .range input { width: 90px !important; }
.nb-vf .range .sugg { padding: 0 10px; min-height: 30px; border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; color: var(--link); font-size: 12.5px; cursor: pointer; }
.nb-vf .picked { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: color-mix(in oklab, var(--link) 9%, transparent); font-size: 13px; }
.nb-vf .pos { display: flex; flex-wrap: wrap; gap: 6px; }
.nb-vf .pos label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; }
.nb-vf .pos input { margin: 0; }
.nb-vf .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nb-vf .acts .sp { flex: 1; }
.nb-vf .has-error input, .nb-vf .has-error textarea, .nb-vf .has-error select { border-color: var(--destructive); }
.nb-vf .errs { margin: 0; padding: 8px 12px; border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent); border-radius: var(--radius); background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); font-size: 13px; line-height: 1.45; }
.nb-vf .errs[hidden] { display: none; }
.nb-vf .confirm { display: grid; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--radius); background: color-mix(in oklab, var(--warning) 12%, transparent); font-size: 13px; }
.nb-vf .confirm[hidden] { display: none; }
.nb-vf-del { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid color-mix(in oklab, var(--destructive) 35%, transparent); border-radius: var(--radius); }
.nb-vf-del[hidden] { display: none; }
.nb-vf-del p { margin: 0; font-size: 13px; }
.nb-vf-del label { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 13px; font-weight: 500; }
.nb-vf-del label.is-off { opacity: .55; }
.nb-vf-del label small { display: block; color: var(--muted-foreground); font-size: 12px; }
.nb-vf-del input { margin: 3px 0 0; }
@media (max-width: 600px) {
	.nb-vf .row2 { grid-template-columns: 1fr; }
	.nb-vf { padding: 12px; }
	.nb-vf .acts .nb-btn { min-height: 40px; }
}

/* поле «Том» в форме главы (views/volume/_chapter_field.php) */
.ce-vol-hint { margin: 5px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted-foreground); }
.ce-vol-place { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------------- страница /book/<id>/volumes */
.nb-volpage { display: grid; gap: 14px; max-width: 920px; }
.nb-volpage-list { display: grid; gap: 10px; }
.nb-volpage-item { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); scroll-margin-top: 140px; }
.nb-volpage-item.is-loose { border-style: dashed; background: transparent; }
.nb-volpage-item:target { border-color: var(--ring); }
.nb-volpage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.nb-volpage-row .t { font-weight: 650; font-size: 15px; }
.nb-volpage-row .m { color: var(--muted-foreground); font-size: 13px; font-variant-numeric: tabular-nums; }
.nb-volpage-row .sp { flex: 1; }
.nb-volpage-row form { margin: 0; display: inline-flex; gap: 4px; }
.nb-volpage details > summary { cursor: pointer; font-size: 13px; color: var(--link); min-height: 32px; display: inline-flex; align-items: center; }
.nb-volpage details[open] > summary { margin-bottom: 8px; }
/* список томов — строки в одну строку (≈ 44 px): название «…» · главы · кнопки · «Изменить» · «Удалить»; раскрытая
   форма и описание тома — под строкой во всю ширину */
.nb-volpage-list { gap: 6px; }
.nb-volpage-list .nb-volpage-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; min-height: 44px; box-sizing: border-box; padding: 5px 8px 5px 12px; }
.nb-volpage-list .nb-volpage-row { flex: 1 1 300px; flex-wrap: nowrap; gap: 10px; min-width: 0; }
.nb-volpage-list .nb-volpage-row .t { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; }
.nb-volpage-list .nb-volpage-row .m { flex: none; white-space: nowrap; font-size: 12.5px; }
.nb-volpage-list .nb-volpage-row .nb-btn-sm { height: 30px; }
.nb-volpage-list .nb-volpage-item > .nb-vol-descr { order: 3; flex: 1 1 100%; margin: 0 0 6px !important; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-volpage-list .nb-volpage-item > details { order: 2; flex: none; }
.nb-volpage-list .nb-volpage-item > details > summary { min-height: 30px; font-size: 12.5px; }
.nb-volpage-list .nb-volpage-item > details[open] { order: 4; flex: 1 1 100%; padding: 2px 0 8px; }
/* телефон: две строки — «Том 4 · главы 1–7 · 7 глав», под ней кнопки (строка тома раскладывается прямо в карточку) */
@media (max-width: 600px) {
	.nb-volpage-list .nb-volpage-item { row-gap: 4px; column-gap: 8px; padding: 6px 8px 6px 12px; }
	.nb-volpage-list .nb-volpage-row { display: contents; }
	.nb-volpage-list .nb-volpage-row .t { flex: 0 1 auto; }
	.nb-volpage-list .nb-volpage-row .m { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
	.nb-volpage-list .nb-volpage-row .sp { flex: 1 1 100%; height: 0; order: 1; }
	.nb-volpage-list .nb-volpage-row > .nb-btn, .nb-volpage-list .nb-volpage-row > form { order: 2; }
	.nb-volpage-list .nb-volpage-row .nb-btn-sm { height: 36px; min-width: 36px; padding: 0 9px; }
	.nb-volpage-list .nb-volpage-row .lbl { display: none; }	/* «+» — подпись в title */
	.nb-volpage-list .nb-volpage-item > details { order: 3; }
	.nb-volpage-list .nb-volpage-item > .nb-vol-descr { order: 4; }
	.nb-volpage-list .nb-volpage-item > details[open] { order: 5; }
}

/* ---------------------------------------------------------------- читалка: том в шапке, группы в выборе главы */
.nb-rd-vol { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.nb-rd-vol svg { flex: none; color: var(--muted-foreground); }
.nb-rd-vol a { color: inherit; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.nb-rd-vol a:hover { color: var(--link); }
.nb-reader-meta .nb-cchip { font-family: var(--font-sans); }
.nb-rd-chgroup {
	position: sticky; top: 0; z-index: 1; padding: 8px 10px 4px; background: var(--popover);
	font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-foreground);
	list-style: none;
}
.nb-rd-chgroup[hidden] { display: none; }
/* «Дальше · Том 3»: nb.css делает все span кнопки блочными (.nb-reader .nb-chapter-nav .nb-btn span { display: grid }) —
   метка тома остаётся в строке «Дальше», а не уходит на свою */
.nb-rd-nextvol, .nb-reader .nb-chapter-nav .nb-btn .nb-rd-nextvol { display: inline; opacity: .8; }
@media (max-width: 399px) { .nb-rd-nextvol, .nb-reader .nb-chapter-nav .nb-btn .nb-rd-nextvol { display: none; } }

/* ---------------------------------------------------------------- массовый импорт: блок «Тома», строки томов */
.bi-vols { display: grid; gap: 6px; align-content: start; }
.bi-vols .bi-vol-l { margin: 6px 0 0; font-size: 12.5px; font-weight: 600; }
.bi-vols select { width: 100%; max-width: 360px; height: 36px; margin: 0; }
.bi-volnew { display: flex; flex-wrap: wrap; gap: 6px; }
.bi-volnew[hidden] { display: none; }
.bi-volnew input { margin: 0; height: 34px; }
.bi-volnew input:first-child { width: 80px; }
.bi-volnew input:last-child { flex: 1 1 180px; }
.bi-volwarn { color: var(--rating-text); }
.bi-volwarn[hidden] { display: none; }
.bi-volnote { display: none; margin-left: 6px; font-size: 12px; color: var(--translator); font-weight: 600; }
.bi-preview.is-voldetect tr.is-volrow .bi-volnote { display: inline; }
.bi-preview.is-voldetect tr.is-volrow .bi-c-inc input { visibility: hidden; }
.bi-preview.is-voldetect tr.is-volrow td { background: color-mix(in oklab, var(--translator) 7%, transparent); }
.bi-preview.is-voldetect tr.is-volrow .bi-title { font-weight: 650; }

@media (prefers-reduced-motion: reduce) {
	.nb-vol-arr { transition: none; }
}
