/* Same shell unlock as series/authors/books: long collection lists need page scroll. */
html:has(#collections-view.is-active),
body:has(#collections-view.is-active) {
  min-width: 0;
  background: var(--color-background);
}
.app-shell:has(#collections-view.is-active) {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

.col-page { min-width: 0; }
/* Same back-row rhythm as book/author detail shells. */
.col-detail-shell {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}
@media (max-width: 1199px) {
  /* Match ser-detail-layout gap below the profile (title ↔ panel = panel ↔ books). */
  .col-detail-shell { gap: 16px; }
}
.col-detail-top {
  display: flex;
  align-items: center;
  min-height: 28px;
}
.col-detail-summary .ser-detail-summary-copy > span {
  color: var(--ink, var(--color-text));
  font-size: var(--type-caption-size, 0.875rem);
  line-height: var(--type-caption-line, 1.4);
  text-transform: none;
}
@media (max-width: 1199px) {
  #collections-view .col-detail-summary.ser-detail-summary {
    padding: 7px 4px;
  }
  #collections-view .col-detail-summary .ser-detail-summary-stat {
    gap: 4px;
    padding: 2px 6px;
  }
  #collections-view .col-detail-summary .ser-detail-summary-copy {
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    gap: 4px 6px;
  }
  #collections-view .ser-detail-profile {
    padding: 12px;
    gap: 10px;
  }
}
.col-detail-side {
  min-width: 0;
  display: grid;
  gap: 16px;
  align-content: start;
}
.col-detail-filters {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 18px;
  border-radius: var(--radius-panel);
  background: var(--surface);
  border: 1px solid var(--line);
}
.col-detail-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.col-detail-filter-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: var(--type-caption-size, 0.875rem);
  line-height: var(--type-caption-line, 1.3);
  font-weight: var(--weight-medium, 500);
}
.col-detail-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.col-filter-chip {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  width: var(--control-height, 36px);
  min-width: var(--control-height, 36px);
  height: var(--control-height, 36px);
  border: 0;
  border-radius: var(--radius-round, 50%);
  background: var(--soft);
  color: var(--muted, var(--color-text-secondary));
  box-shadow: none;
  font-family: var(--font-body, inherit);
  font-size: var(--type-caption-size, 12px);
  line-height: 1;
  font-weight: var(--weight-medium, 500);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.col-filter-chip--gr {
  width: auto;
  min-width: var(--control-height, 36px);
  padding: 0 10px;
  border-radius: var(--radius-pill, 999px);
}
.col-filter-chip:hover:not(:disabled):not(.is-selected):not([aria-pressed="true"]) {
  color: var(--ink, var(--color-text));
  background: #ececec;
}
.col-filter-chip.is-selected,
.col-filter-chip[aria-pressed="true"] {
  background: var(--ink, var(--color-text));
  color: var(--surface, var(--color-surface));
  box-shadow: none;
}
.col-filter-chip.is-selected:hover:not(:disabled),
.col-filter-chip[aria-pressed="true"]:hover:not(:disabled) {
  background: #303030;
  color: var(--surface, var(--color-surface));
}
.col-filter-chip:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
.col-detail-books-empty {
  margin: 0;
  color: var(--muted);
}
.collections-shell { display: grid; gap: 0; }
.collections-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  margin-bottom: 0;
}
.collections-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
  flex: 1 1 auto;
  min-width: 0;
}
.collections-heading h1 {
  display: none;
}
.collections-statuses {
  flex: 1 1 auto;
  margin: 0;
}
.collections-filters {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 24px;
  min-width: 0;
}
.collections-sort-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
}
.collections-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  font-weight: 500;
}
.collections-sort svg,
.collections-sort .rm-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
  fill: currentColor;
  stroke: none;
}
.collections-sort #collections-sort {
  min-width: 0;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.collections-sort #collections-sort:hover,
.collections-sort #collections-sort:focus,
.collections-sort #collections-sort:focus-visible {
  border: 0;
  border-color: transparent;
  box-shadow: none;
  outline: none;
}
#collections-count {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#collections-view #collections-results {
  min-width: 0;
  width: 100%;
}
.col-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding-top: 0;
}
.col-empty {
  grid-column: 1 / -1;
  padding: 32px 8px;
  color: var(--muted);
}
.col-empty--add {
  display: grid;
  gap: 16px;
  justify-items: start;
  max-width: 28rem;
}
.col-empty--add .ds-btn {
  margin: 0;
}
.col-card {
  --col-tone: var(--color-surface, #fff);
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) auto;
  gap: 16px;
  align-items: stretch;
  min-height: 168px;
  padding: 20px;
  border: 0;
  border-radius: 20px;
  background: var(--col-tone);
  color: var(--ink, #111);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-card, 0 4px 16px rgba(0, 0, 0, 0.04));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.col-card:has(.library-card-menu-toggle) {
  overflow: visible;
}
.col-card .col-card-covers,
.col-card .col-card-art,
.col-card .col-card-body {
  position: relative;
}
.col-card > .library-card-menu-toggle,
.col-card > .library-card-menu-toggle.ds-icon-btn,
.col-card > .library-card-menu-toggle.ds-icon-btn--surface {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: auto;
  left: auto;
  z-index: 4;
  margin: 0;
}
.col-card:has(> .library-card-menu-toggle) .col-card-title {
  padding-right: 40px;
}
.col-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(17, 17, 17, 0.08);
}
.col-card:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
/* Tone classes kept for markup compatibility; all non-master cards stay white. */
.col-card[class*="col-card--"]:not(.col-card--master) {
  --col-tone: var(--color-surface, #fff);
}
.col-card--master {
  --col-tone: #111;
  color: #fff;
  box-shadow: none;
}
.col-card--master:hover {
  box-shadow: 0 8px 20px rgba(17, 17, 17, 0.18);
}
.col-card--master .col-card-title,
.col-card--master .col-card-copy {
  color: #fff;
}
.col-card.has-illustration {
  grid-template-columns: minmax(0, 1fr);
}
.col-card.has-illustration .col-card-body {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 210px);
}
.col-card-art {
  position: absolute;
  right: 10px;
  bottom: 0;
  height: calc(100% - 10px);
  width: auto;
  aspect-ratio: 5 / 4;
  object-fit: contain;
  object-position: bottom right;
  pointer-events: none;
  z-index: 0;
}
.col-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.col-card-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.25;
  font-weight: var(--weight-semibold, 600);
}
.col-card-copy {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted, #5b5b5b);
  font-size: var(--type-caption-size, 0.875rem);
  line-height: var(--type-caption-line, 1.4);
}
.col-card-count {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-background, #f4f4f2);
  color: var(--ink, #111);
  font-size: var(--type-micro-size, 0.75rem);
  line-height: 1.2;
  font-weight: var(--weight-medium, 500);
  box-shadow: none;
}
.col-card--master .col-card-count {
  background: #fff;
  color: #111;
}
.col-card-covers.is-cover-stack {
  --stack-cover-size: 42%;
  --stack-step: calc(var(--stack-cover-size) * 0.7);
  position: relative;
  display: block;
  align-self: center;
  width: min(39%, 138px);
  height: 95px;
  max-height: 95px;
  flex-shrink: 0;
}
.col-card-covers.is-cover-stack .col-card-cover {
  position: absolute;
  top: auto;
  bottom: 8%;
  left: auto;
  right: auto;
  width: var(--stack-cover-size);
  height: auto;
  aspect-ratio: 2 / 3;
  transform-origin: 50% 100%;
  z-index: 1;
}
.col-card-covers.is-cover-stack .col-card-cover:only-child {
  left: 50%;
  transform: translateX(-50%);
  width: 46%;
}
.col-card-covers.is-cover-stack.has-two-covers {
  --stack-spread: calc(var(--stack-cover-size) + var(--stack-step));
  --stack-offset: calc((100% - var(--stack-spread)) / 2);
}
.col-card-covers.is-cover-stack.has-two-covers .col-card-cover:first-child {
  left: var(--stack-offset);
  transform: rotate(-7deg);
  z-index: 1;
}
.col-card-covers.is-cover-stack.has-two-covers .col-card-cover:last-child {
  left: calc(var(--stack-offset) + var(--stack-step));
  transform: rotate(4deg);
  z-index: 2;
}
.col-card-covers.is-cover-stack.has-three-covers {
  --stack-spread: calc(var(--stack-cover-size) + var(--stack-step) * 2);
  --stack-offset: calc((100% - var(--stack-spread)) / 2);
}
.col-card-covers.is-cover-stack.has-three-covers .col-card-cover:first-child {
  left: var(--stack-offset);
  transform: rotate(-8deg);
  z-index: 1;
}
.col-card-covers.is-cover-stack.has-three-covers .col-card-cover:nth-child(2) {
  left: calc(var(--stack-offset) + var(--stack-step));
  width: var(--stack-cover-size);
  transform: rotate(-1deg);
  z-index: 2;
}
.col-card-covers.is-cover-stack.has-three-covers .col-card-cover:last-child {
  left: calc(var(--stack-offset) + var(--stack-step) * 2);
  width: var(--stack-cover-size);
  transform: rotate(7deg);
  z-index: 3;
}
.col-card-cover {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.col-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.col-card-cover.is-missing {
  display: flex;
  align-items: flex-end;
  padding: 6px;
}
.col-card-cover-fallback {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.2;
  color: var(--muted, #5b5b5b);
}
@media (max-width: 1100px) {
  .col-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Desktop list: title + count only; description stays on the collection page. */
@media (min-width: 721px) {
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card {
    min-height: 140px;
  }
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card-copy {
    display: none;
  }
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card-body {
    gap: 8px;
    justify-content: flex-start;
  }
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card-title {
    font-family: var(--font-head, Georgia, serif);
    font-size: var(--type-panel-size, 24px);
    line-height: var(--type-panel-line, 1.2);
    font-weight: var(--weight-semibold, 600);
    letter-spacing: var(--tracking-panel, -0.02em);
  }
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card-count {
    margin-top: 0;
    align-self: flex-start;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted, #5b5b5b);
    font-size: var(--type-body-size, 15px);
    line-height: var(--type-body-line, 1.35);
    font-weight: var(--weight-regular, 400);
  }
  :is(#collections-view #collections-results, #capture-drawer .col-results) .col-card--master .col-card-count {
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
  }
}

@media (max-width: 720px) {
  .col-results { grid-template-columns: 1fr; }
  .col-card {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .col-card.has-illustration {
    grid-template-columns: 1fr;
  }
  .col-card.has-illustration .col-card-body {
    max-width: calc(100% - 160px);
  }
  .col-card-covers.is-cover-stack {
    align-self: flex-start;
    width: min(40%, 129px);
    height: 89px;
    max-height: 89px;
  }
}

/* All collection tabs use the sports-romance card's compact geometry.
   Same geometry in «Добавить из каталога» via #capture-drawer .col-results. */
:is(#collections-results, #capture-drawer .col-results) .col-card {
  container-type: inline-size;
  box-sizing: border-box;
  height: 140px;
  min-height: 140px;
  grid-template-columns: minmax(0, 1fr);
}
:is(#collections-results, #capture-drawer .col-results) .col-card-body,
:is(#collections-results, #capture-drawer .col-results) .col-card.has-illustration .col-card-body {
  position: relative;
  z-index: 1;
  width: 55%;
  max-width: none;
  gap: 6px;
}
:is(#collections-view #collections-results, #capture-drawer .col-results) .col-card-title {
  font-family: var(--font-head, Georgia, serif);
  font-size: 18px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}
:is(#collections-results, #capture-drawer .col-results) .col-card-copy { display: none; }
:is(#collections-results, #capture-drawer .col-results) .col-card:not(.has-illustration) {
  overflow: visible;
}
:is(#collections-results, #capture-drawer .col-results) .col-card-art,
:is(#collections-results, #capture-drawer .col-results) .col-card-covers {
  position: absolute;
  right: 10px;
  top: 50%;
  bottom: auto;
  width: min(43%, 162.5px);
  height: 130px;
  transform: translateY(-50%);
}
:is(#collections-results, #capture-drawer .col-results) .col-card-art {
  bottom: 0;
  top: auto;
  transform: none;
}
:is(#collections-results, #capture-drawer .col-results) .col-card-covers.is-cover-stack {
  right: 20px;
  width: min(39%, 138px);
  height: 95px;
  max-height: 95px;
  transform: translateY(-50%);
}
@media (max-width: 720px) {
  :is(#collections-results, #capture-drawer .col-results) .col-card-count {
    margin-top: 0;
    padding: 0;
    background: transparent;
    color: var(--muted);
  }
  :is(#collections-results, #capture-drawer .col-results) .col-card--master .col-card-count {
    color: rgba(255, 255, 255, 0.78);
  }
}
