:root {
  --bg: #0b0f14;
  --bg2: #11161d;
  --card: #151b23;
  --card2: #1b232d;
  --line: #232c38;
  --txt: #f2f5f8;
  --muted: #8b97a7;
  --muted2: #5d6878;
  --accent: #ff7a18;
  --accent2: #ff2d55;
  --grad: linear-gradient(135deg, #ff7a18, #ff2d55);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; }

/* ---------- Шапка ---------- */
.header {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
  background: rgba(11, 15, 20, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  display: grid; place-items: center; font-size: 17px; flex: 0 0 auto;
}
.brand h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -0.3px; }
.brand .count { margin-left: auto; font-size: 12px; color: var(--muted); }

.searchbar { display: flex; gap: 8px; align-items: center; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 12px; height: 44px;
}
.search input {
  flex: 1; background: none; border: 0; outline: none; color: var(--txt);
  font-size: 16px; min-width: 0;
}
.search .ic { color: var(--muted); font-size: 16px; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px;
  position: relative; flex: 0 0 auto;
}
.iconbtn.active { background: var(--grad); border-color: transparent; }
.iconbtn .dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--accent2); color: #fff; font-size: 11px;
  display: grid; place-items: center; padding: 0 4px; font-weight: 700;
}
.iconbtn .dot[hidden] { display: none; }

/* ---------- Чипы категорий ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- Список ---------- */
.list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 4px 14px calc(var(--safe-b) + 28px);
}
@media (min-width: 540px) { .list { grid-template-columns: 1fr 1fr 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; position: relative; display: flex; flex-direction: column;
}
.card .thumbwrap {
  position: relative; aspect-ratio: 1 / 1; background: #fff;
  display: grid; place-items: center; overflow: hidden;
}
.card .thumbwrap img { width: 100%; height: 100%; object-fit: cover; }
.card .skel { position: absolute; inset: 0; background: linear-gradient(100deg,#e9edf2 30%,#f6f8fa 50%,#e9edf2 70%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.card .body { padding: 9px 10px 11px; }
.card .name { font-size: 13px; font-weight: 700; line-height: 1.25; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 11px; color: var(--muted); display: flex; gap: 5px; flex-wrap: wrap; }
.card .meta .t { color: var(--accent); font-weight: 600; }
.fav {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 10px;
  background: rgba(11,15,20,0.55); backdrop-filter: blur(6px); display: grid; place-items: center;
  font-size: 16px; z-index: 2; color: #fff;
}
.fav.on { color: #ffd23f; }

.empty { text-align: center; color: var(--muted); padding: 60px 24px; grid-column: 1 / -1; }
.sentinel { grid-column: 1 / -1; height: 1px; }

/* ---------- Деталь ---------- */
.detail {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  overflow-y: auto; transform: translateX(100%); transition: transform .26s ease;
  -webkit-overflow-scrolling: touch;
}
.detail.open { transform: none; }
.detail .topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  background: rgba(11,15,20,0.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.detail .back { width: 40px; height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 20px; }
.detail .topbar .ttl { font-size: 15px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail .hero { background: #fff; aspect-ratio: 1 / 1; max-height: 56vh; display: grid; place-items: center; overflow: hidden; }
.detail .hero img { width: 100%; height: 100%; object-fit: contain; }
.detail .content { padding: 16px 16px calc(var(--safe-b) + 40px); }
.detail h2 { font-size: 23px; font-weight: 800; margin: 4px 0 14px; letter-spacing: -0.4px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tag { font-size: 13px; padding: 7px 12px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.tag b { color: var(--txt); font-weight: 600; }
.tag.accent { background: rgba(255,122,24,0.14); border-color: rgba(255,122,24,0.4); color: #ffb27a; }
.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted2); margin: 6px 0 12px; font-weight: 700; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 46px; min-height: 34px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 32px; height: 32px;
  border-radius: 10px; background: var(--grad); color: #fff; font-weight: 800; font-size: 15px;
  display: grid; place-items: center;
}
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 6px; width: 2px; background: var(--line); }
.detailfav {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin-top: 22px; padding: 15px; border-radius: 14px; font-weight: 700; font-size: 16px;
  background: var(--card2); border: 1px solid var(--line);
}
.detailfav.on { background: var(--grad); border-color: transparent; }

/* ---------- Нижний лист (фильтры/меню) ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--bg2);
  border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  transform: translateY(100%); transition: transform .26s ease;
  padding: 8px 16px calc(var(--safe-b) + 20px); max-height: 82vh; overflow-y: auto;
}
.sheet.open { transform: none; }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 14px; }
.sheet h3 { font-size: 18px; font-weight: 800; margin: 4px 0 14px; }
.sheet .label { font-size: 13px; color: var(--muted2); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 10px; }
.optgrid { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { padding: 9px 13px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.opt.on { background: var(--grad); color: #fff; border-color: transparent; }
.sheet .actions { display: flex; gap: 10px; margin-top: 22px; }
.btn { flex: 1; padding: 14px; border-radius: 14px; font-weight: 700; font-size: 15px; text-align: center; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.btn.primary { background: var(--grad); color: #fff; }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 15px 4px; border-bottom: 1px solid var(--line); }
.menu-row .mi { font-size: 20px; width: 24px; text-align: center; }
.menu-row .mt { flex: 1; }
.menu-row .mt b { display: block; font-size: 15px; }
.menu-row .mt span { font-size: 13px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted2); line-height: 1.5; margin-top: 16px; }
.bar { height: 8px; border-radius: 4px; background: var(--card); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translate(-50%, 20px);
  background: #fff; color: #0b0f14; font-weight: 600; font-size: 14px; padding: 11px 18px;
  border-radius: 999px; z-index: 80; opacity: 0; transition: all .25s; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Баннер программы ---------- */
.program-banner {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 28px);
  margin: 2px 14px 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--grad); color: #fff; text-align: left;
}
.program-banner .pb-ic { font-size: 24px; }
.program-banner .pb-txt { flex: 1; line-height: 1.25; }
.program-banner .pb-txt b { display: block; font-size: 16px; font-weight: 800; }
.program-banner .pb-txt span { font-size: 12px; opacity: .9; }
.program-banner .pb-arrow { font-size: 26px; font-weight: 700; opacity: .9; }

/* ---------- Оверлей программы (поверх — деталь выше) ---------- */
#program { z-index: 48; }
.prog-head { padding: 4px 16px 6px; }
.prog-head h2 { font-size: 24px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -0.4px; }
.prog-head p { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
.day {
  margin: 0 14px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.day-h { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.day-h b { font-size: 16px; font-weight: 800; flex: 1; }
.day-h .tag2 { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,122,24,0.16); color: #ffb27a; white-space: nowrap; }
.ex-row { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); }
.ex-row .erthumb { width: 52px; height: 52px; border-radius: 11px; background: #fff; object-fit: cover; flex: 0 0 auto; }
.ex-row .ername { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.25; }
.ex-row .ername small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
.ex-row .ersets { font-size: 13px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.ex-row .go { color: var(--muted2); font-size: 20px; }
.swimbox { padding: 4px 6px 6px; }
.swimbox .snote { font-size: 13px; color: var(--muted); padding: 0 8px 10px; }
.swimbox ol { margin: 0; padding: 0 8px; list-style: none; counter-reset: sw; }
.swimbox li { counter-increment: sw; position: relative; padding: 0 0 14px 40px; font-size: 14px; line-height: 1.4; }
.swimbox li::before { content: counter(sw); position: absolute; left: 0; top: -2px; width: 28px; height: 28px;
  border-radius: 9px; background: #1e90ff22; color: #6cb6ff; border: 1px solid #1e90ff55;
  font-weight: 800; font-size: 13px; display: grid; place-items: center; }
