:root {
  --bg-top: #1b2838;
  --bg-bottom: #12161d;
  --panel: #1f2c3b;
  --panel-2: #2a3f55;
  --text: #dfe6ec;
  --muted: #8f98a0;
  --accent: #66c0f4;
  --green: #5ba32b;
  --blue: #4a9eda;
  --gray: #5a6570;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* display:flex у .price-row/.tag-row/.parse-status иначе перебивает атрибут hidden */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 420px);
  background-color: var(--bg-bottom);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 14px 10px;
  background: rgba(23, 26, 33, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(103, 193, 245, .08);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2.5px;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .4px;
  margin-top: 1px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  border: 1px solid rgba(103, 193, 245, .15);
  background: rgba(0, 0, 0, .25);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px 8px 32px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  appearance: none;
}

#search:focus { border-color: rgba(103, 193, 245, .5); }
#search::placeholder { color: var(--muted); }

.chips {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }

/* Чип «Скидки» с активной распродажей */
.chip-sale.has-sales {
  border-color: rgba(190, 238, 17, .45);
  color: #cfe8a0;
}
.chip-count {
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 700;
  background: #4c6b22;
  color: #beee11;
  padding: 1px 5px;
  border-radius: 999px;
}
.chip-sale.active .chip-count { background: rgba(0, 0, 0, .3); color: #fff; }

.chip {
  flex: 0 0 auto;
  border: 1px solid rgba(103, 193, 245, .18);
  background: rgba(103, 193, 245, .06);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.chip.active {
  background: linear-gradient(90deg, #47bfff2b, #1a44c22b);
  border-color: rgba(103, 193, 245, .55);
  color: #fff;
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  padding: 12px 14px calc(76px + var(--safe-b));
}

/* Сетка внутри секции магазина: нижний зазор даёт .shop, не сетка. */
.grid-embed { padding: 10px 14px 6px; }

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  transition: transform .16s ease, box-shadow .16s ease;
  animation: pop .3s ease both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.card:active { transform: scale(.96); }

.card.dim .cover-img, .card.dim .cover-fallback { filter: saturate(.35) brightness(.6); }

/* Пройденные игры: карточка полностью серая + диагональная лента «ПРОЙДЕНО».
   Правила ниже .dim — при пересечении статусов побеждает «пройдено». */
.card.done .cover-img,
.card.done .cover-sharp,
.card.done .cover-fallback { filter: grayscale(1) brightness(.55); }
.card.done .cover-hz .cover-img { filter: blur(12px) grayscale(1) brightness(.35); }
.card.done .cover-hz .cover-fallback { filter: none; color: #aeb6bd; }
.card.done .title-bar .name { color: var(--muted); }
.card.done .badge, .card.done .sale-badge {
  filter: grayscale(1) brightness(.75);
}

.done-ribbon {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.done-ribbon span {
  position: absolute;
  left: -25%;
  right: -25%;
  top: 50%;
  transform: translateY(-50%) rotate(-24deg);
  text-align: center;
  background: rgba(12, 16, 22, .82);
  border-top: 1px solid rgba(255, 255, 255, .22);
  border-bottom: 1px solid rgba(255, 255, 255, .22);
  color: #d6dde3;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 3.5px;
  padding: 5px 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}

/* Маринующиеся: обложка серая как у пройденных, поверх — жёлто-чёрная
   «строительная» лента МАРИНУЕТСЯ (цветная, чтобы выделялась на сером). */
.card.marinating .cover-img,
.card.marinating .cover-sharp,
.card.marinating .cover-fallback { filter: grayscale(1) brightness(.55); }
.card.marinating .cover-hz .cover-img { filter: blur(12px) grayscale(1) brightness(.35); }
.card.marinating .cover-hz .cover-fallback { filter: none; color: #aeb6bd; }
.card.marinating .title-bar .name { color: var(--muted); }
.card.marinating .badge, .card.marinating .sale-badge {
  filter: grayscale(1) brightness(.75);
}

.marinate-ribbon {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.marinate-ribbon span {
  position: absolute;
  left: -25%;
  right: -25%;
  top: 50%;
  transform: translateY(-50%) rotate(-24deg);
  text-align: center;
  background: repeating-linear-gradient(
    45deg,
    rgba(245, 197, 24, .92) 0 12px,
    rgba(17, 19, 24, .92) 12px 24px
  );
  border-top: 1px solid rgba(0, 0, 0, .55);
  border-bottom: 1px solid rgba(0, 0, 0, .55);
  padding: 4px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.marinate-ribbon b {
  display: inline-block;
  background: rgba(12, 14, 18, .82);
  border-radius: 3px;
  padding: 1px 8px;
  color: #f5c518;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(160deg, var(--panel-2), #17212d);
  overflow: hidden;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

/* Горизонтальный header в вертикальной плитке — как генерённая обложка в
   библиотеке Steam: блюр-заливка фоном + чёткая копия картинки полосой по
   центру + название внизу. Расширение отступами (не transform) +
   overflow:hidden у .cover — чтобы размытые края и прозрачная кайма блюра
   не вылезали на строку названия. */
.cover-hz .cover-img {
  inset: -14%;
  width: 128%;
  height: 128%;
  filter: blur(12px) saturate(1.15) brightness(.45);
}
.cover-sharp {
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  transform: translateY(-50%);
  width: 100%;
  height: auto;
  z-index: 1;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .55);
}
.cover-hz .cover-fallback {
  z-index: 2;
  background: none;
  align-items: flex-end;
  padding-bottom: 12px;
  font-size: 11.5px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
  color: #e8eef4;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  color: #dbe4ec;
  /* Тёмный фон, подкрашенный цветом из названия — карточки без обложки
     выглядят «как для недоступных», но у каждой свой оттенок. */
  background:
    radial-gradient(120% 90% at 20% 0%, hsla(var(--hue, 210), 45%, 45%, .30), transparent 58%),
    linear-gradient(160deg, hsl(var(--hue, 210) 26% 25%), #131a24);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
  word-break: break-word;
}

.card-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.07), transparent 22%);
  pointer-events: none;
  z-index: 2;
}

.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 5px;
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.badge-released  { background: rgba(91, 163, 43, .92); }
.badge-early     { background: rgba(74, 158, 218, .92); }
.badge-unreleased{ background: rgba(90, 101, 112, .92); }

/* Скидка на плитке — зелёный бейдж как в Steam */
.sale-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  background: #4c6b22;
  color: #beee11;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}

.title-bar {
  padding: 7px 8px 8px;
  background: rgba(22, 30, 40, .96);
}

.title-bar .name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.6em;   /* фикс. высота (2 строки) — карточки одинаковые */
}

/* Слот под названием фикс. высоты: дата или цветная заливка из названия */
.date-slot {
  height: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.title-bar .date {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 14px;
}

/* ---------- bottom sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, .6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 20;
  opacity: 0;
  transition: opacity .22s ease;
}
.backdrop.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  background: #1a232e;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
  transform: translate(var(--cx, 0px), 100%);
  transition: transform .28s cubic-bezier(.32, .72, .25, 1);
  padding-bottom: calc(16px + var(--safe-b));
}
.sheet.show { transform: translate(var(--cx, 0px), var(--dy, 0px)); }
.sheet.dragging { transition: none; }

.sheet-grab {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 8px 0 4px;
  display: flex;
  justify-content: center;
}
.sheet-grab::before {
  content: "";
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .25);
}

.sheet-hero {
  position: relative;
  height: 150px;
  margin-top: -16px;
  background-size: cover;
  background-position: center 25%;
}
.sheet-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(26,35,46,.25) 0%, rgba(26,35,46,0) 35%, #1a232e 100%);
}

/* Кнопки управления поверх обложки: назад и свернуть */
.hero-btn {
  position: absolute;
  top: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(13, 18, 24, .62);
  color: #dfe6ec;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  transition: background .15s, transform .1s;
}
.hero-btn:active { transform: scale(.92); background: rgba(30, 42, 56, .8); }
.hero-back { left: 12px; }
.hero-down { right: 12px; }

.sheet-body { padding: 10px 18px 6px; }

.sheet-body h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: .2px;
}

.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 14px;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 6px;
  color: #fff;
}
.pill-date {
  text-transform: none;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, .06);
}

/* Русская локализация */
.pill-ru-full { background: rgba(91, 163, 43, .18); color: #8fd06a; border: 1px solid rgba(91, 163, 43, .4); }
.pill-ru-text { background: rgba(74, 158, 218, .15); color: #7db8e8; border: 1px solid rgba(74, 158, 218, .35); }
.pill-ru-none { background: rgba(255, 255, 255, .05); color: var(--muted); border: 1px solid rgba(255, 255, 255, .12); }

/* ---------- теги в шторке ---------- */

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}

.tag {
  border: none;
  background: rgba(103, 193, 245, .12);
  color: #9fc6e0;
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tag:active { background: rgba(103, 193, 245, .3); color: #fff; }

/* Активный тег-фильтр в строке чипов */
.chip-tag { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-tag .chip-x { margin-left: 7px; opacity: .7; font-size: 11px; }

/* ---------- цена в шторке (как в Steam) ---------- */

.price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 14px;
}

.price-steam {
  display: inline-flex;
  align-items: stretch;
  background: rgba(0, 0, 0, .35);
  border-radius: 6px;
  overflow: hidden;
}

.price-cut {
  display: flex;
  align-items: center;
  background: #4c6b22;
  color: #beee11;
  font-size: 16px;
  font-weight: 700;
  padding: 0 9px;
}

.price-cols {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 11px;
  line-height: 1.2;
}
.price-old {
  font-size: 11px;
  color: #738895;
  text-decoration: line-through;
}
.price-new {
  font-size: 14px;
  font-weight: 600;
  color: #beee11;
}

.price-plain {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, .35);
  padding: 7px 13px;
  border-radius: 6px;
}
.price-free { color: #8fd06a; }
.price-na { color: var(--muted); font-weight: 500; }

.sale-pill {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: #beee11;
  border: 1px solid rgba(190, 238, 17, .45);
  padding: 4px 9px;
  border-radius: 6px;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn svg { flex: 0 0 auto; }

.btn-steam { background: linear-gradient(90deg, #47bfff, #1a44c2); }
.btn-of    { background: linear-gradient(90deg, #ff9d3f, #d8501e); }
.btn-torrent { background: linear-gradient(90deg, #6fbf35, #3d7a14); }
.btn-torrent.busy { opacity: .65; pointer-events: none; }
.btn-torrent .spinner { border-top-color: #fff; border-color: rgba(255,255,255,.35); }
.btn-magnet-icon {
  flex: 0 0 46px;
  background: rgba(255, 255, 255, .09);
  color: var(--muted);
}
.btn-disabled {
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  cursor: default;
}

.btn-propose {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #6fbf35, #3d7a14);
  margin-bottom: 14px;
  transition: filter .15s, transform .1s, opacity .15s;
}
.btn-propose:active { transform: scale(.97); filter: brightness(1.12); }
.btn-propose.busy { opacity: .55; pointer-events: none; }

.quote {
  border-left: 3px solid var(--accent);
  background: rgba(102, 192, 244, .07);
  border-radius: 0 8px 8px 0;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 12px;
}
.quote .q-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}

.desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: #b9c2cb;
  margin: 0 0 14px;
}

/* Кламп описания: шторка компактная, без простыни текста */
.desc.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
#sheet-desc-wrap { margin-bottom: 14px; }
.desc-more {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

/* ---------- сворачиваемый блок тегов внизу ---------- */

.tags-block {
  border-top: 1px solid rgba(255, 255, 255, .06);
  margin-bottom: 10px;
}
.tags-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 11px 0;
  cursor: pointer;
}
.tags-chev { transition: transform .2s ease; margin-left: auto; }
.tags-block.open .tags-chev { transform: rotate(180deg); }
.tags-block .tag-row { display: none; }
.tags-block.open .tag-row {
  display: flex;
  margin: 0 0 12px;
}

/* ---------- add/edit form ---------- */

.card-add .cover {
  border: 1.5px dashed rgba(102, 192, 244, .4);
  border-radius: var(--radius);
  background: rgba(102, 192, 244, .05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-add .plus {
  font-size: 44px;
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
}
.card-add .title-bar { background: transparent; }
.card-add .name { color: var(--accent); text-align: center; min-height: 0; }

.f-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.f-label .req { color: #ff7a7a; }
.f-label input, .f-label textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid rgba(103, 193, 245, .18);
  background: rgba(0, 0, 0, .25);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  appearance: none;
  resize: none;
}
.f-label input:focus, .f-label textarea:focus { border-color: rgba(103, 193, 245, .55); }

.parse-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin: -4px 0 12px;
}
.parse-status.ok { color: #8fd06a; }
.parse-status.err { color: #e08a8a; }
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(102, 192, 244, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.f-caption {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.f-status-row { margin-bottom: 14px; }
.f-status-row .chips { margin-top: 0; }

.btn-ghost {
  background: rgba(255, 255, 255, .07);
  color: var(--text);
}

.btn-edit {
  flex: 0 0 46px;
  background: rgba(255, 255, 255, .09);
}

.btn-del {
  display: block;
  width: 100%;
  margin-top: 2px;
  background: none;
  border: 1px solid rgba(224, 108, 108, .45);
  color: #e08a8a;
  border-radius: 8px;
  padding: 11px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-del.confirm { background: rgba(216, 80, 80, .85); color: #fff; border-color: transparent; }

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(20, 28, 38, .95);
  border: 1px solid rgba(102, 192, 244, .3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  max-width: 88vw;
  text-align: center;
}

.sheet-footer {
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding-top: 10px;
}

/* ---------- широкие экраны (десктоп / расширенное окно) ----------
   Карточки растут вместе с окном до разумного предела, контент
   центрируется, шторка становится центрированным диалогом. */

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .title-bar .name { font-size: 13px; }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 16px;
    max-width: 1240px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
  }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .topbar-row { max-width: 1192px; margin: 0 auto; }
  .topbar .chips { max-width: 1192px; margin: 10px auto 0; }
  .title-bar .name { font-size: 13.5px; }
  .title-bar .date { font-size: 11px; }
  .badge { font-size: 10.5px; }
  .sale-badge { font-size: 12px; }

  .sheet {
    --cx: -50%;
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 640px;
    border-radius: 16px 16px 0 0;
  }
  .sheet-hero { height: 190px; }
}

@media (min-width: 1400px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    max-width: 1480px;
  }
  .topbar-row, .topbar .chips { max-width: 1432px; }
}

/* Ховер только там, где есть мышь — на тачах не липнет */
@media (hover: hover) and (pointer: fine) {
  .card { transition: transform .18s ease, box-shadow .18s ease; }
  .card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .6);
  }
  .chip:hover { color: var(--text); border-color: rgba(103, 193, 245, .45); }
  .tag:hover { background: rgba(103, 193, 245, .28); color: #fff; }
  .btn:hover, .btn-propose:hover { filter: brightness(1.12); }
}


/* ---------- нижний таббар (Библиотека | Магазин) ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  background: rgba(23, 26, 33, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(103, 193, 245, .1);
  padding-bottom: var(--safe-b);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s;
}
.tab.active { color: var(--accent); }
.tab:active { transform: scale(.96); }

/* ---------- магазин ---------- */

.shop { padding: 6px 12px calc(76px + var(--safe-b)); }

/* Каждая секция магазина — отдельная панель-карточка, чтобы
   «Рекомендации» и «Новинки» явно читались как разные блоки. */
.shop-sec {
  margin-top: 14px;
  background: rgba(31, 44, 59, .55);
  border: 1px solid rgba(255, 255, 255, .05);
  border-radius: 16px;
  padding-bottom: 6px;
  overflow: hidden;
}
.shop-sec:first-child { margin-top: 6px; }

.shop-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  margin-bottom: 4px;
}
.shop-sec-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text);
  position: relative;
  padding-left: 13px;
}
/* Цветной акцент-бар слева: рекомендации — зелёный, новинки — синий. */
.shop-sec-head h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
}
.shop-sec:nth-of-type(1) .shop-sec-head h3::before { background: #6fbf35; }
.shop-sec:nth-of-type(2) .shop-sec-head h3::before { background: var(--accent); }
.sec-note {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Плавное появление карточек, дорисованных кнопкой «Показать ещё». */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.card-in { animation: cardIn .3s ease both; }
@media (prefers-reduced-motion: reduce) {
  .card-in { animation: none; }
}

.empty-sec {
  text-align: center;
  color: var(--muted);
  padding: 26px 20px 30px;
  font-size: 13.5px;
}

/* Лента «В БИБЛИОТЕКЕ» на карточках магазина: как «ПРОЙДЕНО», но синяя
   и без обесцвечивания обложки. */
.lib-ribbon span {
  background: rgba(28, 60, 92, .88) !important;
  color: var(--accent) !important;
  border-top: 1px solid rgba(102, 192, 244, .45);
  border-bottom: 1px solid rgba(102, 192, 244, .45);
}

/* Кнопка «Добавить в библиотеку» в шторке магазина. */
.btn-addlib { background: linear-gradient(90deg, #4a9eda, #2f6ea8); }
.btn-addlib.inlib {
  background: var(--panel-2);
  color: var(--muted);
  cursor: default;
}

/* Блок «почему вам зайдёт» у рекомендаций. */
.quote-why {
  border-left-color: #6fbf35;
  background: rgba(111, 191, 53, .08);
}
.quote-why .q-label { color: #8ed060; }

/* Кнопка «Показать ещё» под секцией магазина. */
.show-more {
  display: block;
  margin: 2px 14px 6px;
  width: calc(100% - 28px);
  padding: 11px 10px;
  border: 1px solid rgba(102, 192, 244, .28);
  border-radius: 9px;
  background: rgba(102, 192, 244, .06);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.show-more:active { transform: scale(.98); filter: brightness(1.15); }
