.catalog-page {
  min-height: 100dvh;
}

.catalog-page .atmosphere .glow,
.catalog-page .particle-field {
  display: none;
}

.cat-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding:
    max(0.7rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    0.7rem
    max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.cat-back {
  color: var(--mute);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.cat-back:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.cat-top-main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  justify-content: center;
}

.cat-brand.brand {
  margin: 0;
  font-size: clamp(1.15rem, 4.2vw, 1.65rem);
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  line-height: 1;
  animation: brand-enter 1.15s ease-out both;
}

.cat-brand.brand::before,
.cat-brand.brand::after {
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.cat-brand .brand-main {
  filter: drop-shadow(0 0 12px var(--brand-glow))
    drop-shadow(0 0 28px var(--brand-glow-soft));
}

.cat-total {
  font-variant-numeric: tabular-nums;
  color: var(--mute);
  font-size: 0.85rem;
  font-weight: 600;
  align-self: flex-end;
  margin-bottom: 0.1rem;
}

.cat-top .theme-switch {
  justify-self: end;
}

.cat-shell {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 max(1.25rem, env(safe-area-inset-bottom));
  display: grid;
  gap: 0.85rem;
}

.cat-controls {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.cat-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 0.7rem 0.9rem;
  outline: none;
}

.cat-search:focus {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.cat-filters {
  margin: 0;
  justify-content: flex-start;
}

.cat-sort {
  width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.cat-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.9fr);
  gap: 0.85rem;
  align-items: start;
  min-height: min(70vh, 720px);
}

.cat-list-panel,
.cat-detail {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  overflow: hidden;
  min-height: 0;
}

.cat-list-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(72vh, 760px);
}

.cat-list-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  color: var(--mute);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cat-list-head strong {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.cat-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.2rem;
  gap: 0.1rem;
}

.cat-item {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.cat-item:hover,
.cat-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.cat-item-thumb-frame {
  width: 3rem;
  height: 3rem;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  flex: 0 0 auto;
  overflow: hidden;
  contain: paint;
  padding: 0.12rem;
  box-sizing: border-box;
  place-items: center;
}

.cat-item-thumb {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
}

.cat-item-thumb.empty {
  display: grid;
  place-items: center;
  color: var(--mute);
  width: 3rem;
  height: 3rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}

.cat-card-thumb-frame,
.cat-card-look-frame {
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  height: auto;
  padding: 0.18rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  overflow: hidden;
  contain: paint;
  box-sizing: border-box;
  place-items: center;
}

.cat-item-main {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.cat-item-name {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
  align-items: center;
  color: var(--mute);
  font-size: 0.78rem;
}

.cat-item-price {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.cat-item.is-sale .cat-item-price {
  color: var(--accent-2);
}

.cat-item-old {
  text-decoration: line-through;
  opacity: 0.75;
}

.cat-tag {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.35rem;
}

.cat-tag-gone {
  color: color-mix(in srgb, var(--mute) 90%, #c4a574);
  border-color: color-mix(in srgb, var(--mute) 45%, transparent);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.cat-item.is-unavailable .cat-item-name {
  opacity: 0.72;
}

.cat-item.is-unavailable .cat-item-price {
  text-decoration: line-through;
  opacity: 0.55;
}

.cat-card.is-unavailable {
  opacity: 0.95;
}

.cat-gone-note {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--mute) 85%, #c4a574);
}

.cat-fav {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--mute);
  opacity: 0.4;
  cursor: pointer;
  font-size: 1rem;
}

.cat-fav.on,
.cat-fav:hover {
  opacity: 1;
  color: var(--accent-2);
}

.cat-detail {
  position: sticky;
  top: 4.2rem;
  padding: 1rem;
  min-height: 320px;
}

.cat-detail-empty {
  height: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--mute);
  padding: 1rem;
}

.cat-card {
  display: grid;
  gap: 0.85rem;
}

.cat-card-top {
  display: grid;
  grid-template-columns: 5.75rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
}

.cat-card-top:has(.cat-card-media.has-look) {
  grid-template-columns: minmax(8.75rem, 10.5rem) minmax(0, 1fr);
}

.cat-card-media {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  align-items: center;
  justify-items: stretch;
}

.cat-card-media.has-look {
  grid-template-columns: 1fr 1fr;
}

.cat-card-media:not(.has-look) .cat-card-thumb-frame {
  width: 100%;
}

.cat-card-thumb,
.cat-card-look {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  filter: none;
}

.cat-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
}

.cat-card-prices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: baseline;
}

.cat-card-price {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
}

.cat-card.is-sale .cat-card-price {
  color: var(--accent-2);
}

.cat-card-old {
  color: var(--mute);
  text-decoration: line-through;
  font-weight: 700;
}

.cat-card-desc {
  margin: 0.35rem 0 0;
  color: var(--mute);
  font-size: 0.86rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.cat-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.86rem;
  opacity: 0.8;
}

.cat-link:hover {
  color: var(--accent);
  opacity: 1;
}

.cat-history {
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.cat-history h3 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

.cat-history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  font-size: 0.82rem;
  color: var(--mute);
}

.cat-history-stats b {
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
}

.cat-spark {
  width: 100%;
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 2.5%, transparent);
}

.cat-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.cat-history-table th,
.cat-history-table td {
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-align: left;
}

.cat-history-table th {
  color: var(--mute);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cat-history-empty {
  color: var(--mute);
  font-size: 0.85rem;
}

.cat-list-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--mute);
}

@media (max-width: 860px) {
  /* весь каталог в высоту экрана — без «уезда» карточки вниз */
  html:has(body.catalog-page) {
    height: 100%;
    overflow: hidden;
  }

  body.catalog-page {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .cat-top {
    flex: 0 0 auto;
    grid-template-columns: auto 1fr auto;
  }

  .cat-shell {
    flex: 1 1 auto;
    min-height: 0;
    width: min(100% - 1rem, 1120px);
    padding: 0.55rem 0 max(0.45rem, env(safe-area-inset-bottom));
    gap: 0.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .cat-controls {
    flex: 0 0 auto;
    padding: 0.6rem 0.7rem;
    gap: 0.45rem;
  }

  .cat-search {
    padding: 0.6rem 0.8rem;
  }

  .cat-stage {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: 1fr;
    /* превью сверху (название/цена всегда на экране), список снизу */
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.5rem;
  }

  /* компактная карточка: без внутреннего скролла */
  .cat-detail {
    order: 1;
    position: relative;
    top: auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    padding: 0.55rem 0.65rem;
  }

  .cat-list-panel {
    order: 2;
    max-height: none;
    min-height: 0;
    height: 100%;
  }

  .cat-list {
    padding: 0.2rem 0.2rem 0.45rem;
  }

  .cat-detail-empty {
    min-height: 3.2rem;
    height: auto;
    padding: 0.45rem 0.35rem;
    font-size: 0.82rem;
  }

  .cat-card {
    gap: 0.4rem;
  }

  .cat-card-top {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
  }

  .cat-card-media {
    display: flex;
    flex-direction: row;
    gap: 0.28rem;
    align-items: center;
    justify-content: flex-start;
  }

  .cat-card-media.has-look {
    grid-template-columns: unset;
  }

  .cat-card-thumb-frame,
  .cat-card-look-frame,
  .cat-card-media:not(.has-look) .cat-card-thumb-frame {
    width: 3.25rem;
    height: 3.25rem;
    aspect-ratio: 1;
    flex: 0 0 auto;
    padding: 0.1rem;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--ink) 3%, transparent);
    overflow: hidden;
    contain: paint;
    box-sizing: border-box;
  }

  .cat-card-thumb,
  .cat-card-look {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    filter: none;
  }

  .cat-card-title {
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
  }

  .cat-card-prices {
    gap: 0.25rem 0.45rem;
    margin-top: 0.1rem;
  }

  .cat-card-price {
    font-size: 0.98rem;
  }

  .cat-card-old {
    font-size: 0.76rem;
  }

  /* описание и длинная сноска — только на ПК, на телефоне мешают */
  .cat-card-desc,
  .cat-gone-note {
    display: none;
  }

  .cat-card-actions {
    margin-top: 0.28rem;
    gap: 0.3rem;
    align-items: center;
  }

  .cat-link {
    font-size: 0.74rem;
  }

  .cat-card-actions .chip-toggle {
    font-size: 0.7rem;
    padding: 0.22rem 0.45rem 0.22rem 0.4rem;
  }

  .cat-history {
    padding-top: 0.4rem;
    gap: 0.22rem;
  }

  .cat-history h3 {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    margin: 0;
  }

  .cat-history-stats {
    font-size: 0.72rem;
    gap: 0.25rem 0.55rem;
  }

  .cat-history-stats b {
    font-size: 0.78rem;
  }

  .cat-spark {
    height: 36px;
    border-radius: 8px;
  }

  .cat-history-empty {
    display: block;
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.25;
  }

  /* полная таблица — на ПК; на мобиле заголовок + мин/макс + график */
  .cat-history-table {
    display: none;
  }

  .cat-item {
    gap: 0.5rem;
    padding: 0.48rem 0.5rem;
    grid-template-columns: 2.75rem minmax(0, 1fr);
  }

  .cat-item-thumb-frame,
  .cat-item-thumb.empty {
    width: 2.75rem;
    height: 2.75rem;
    aspect-ratio: 1;
    padding: 0.1rem;
    box-sizing: border-box;
  }

  .cat-item-name {
    font-size: 0.88rem;
  }

  .cat-item-meta {
    font-size: 0.74rem;
  }

  .cat-fav {
    width: 2.1rem;
    font-size: 0.95rem;
  }

  .cat-brand.brand {
    font-size: clamp(1.05rem, 5vw, 1.35rem);
    letter-spacing: 0.12em;
    text-indent: 0.12em;
  }

  .cat-brand.brand::before,
  .cat-brand.brand::after {
    letter-spacing: 0.12em;
    text-indent: 0.12em;
  }
}
