*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--body); font: 400 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: inherit; -webkit-user-select: none; user-select: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold-l); outline-offset: 2px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

:root {
  --safe-top: var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --title-h: max(var(--tg-content-safe-area-inset-top, 0px), 44px);
  --top: calc(var(--safe-top) + var(--title-h));
  --bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --bar-h: 68px;
}

/* Title in Telegram's control row (fullscreen) or a slim header (older clients). */
.titlebar {
  position: fixed; z-index: 50; top: 0; left: 0; right: 0; height: var(--top); padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: center; gap: 8px; pointer-events: none;
  font: 700 15px 'Playfair Display', Georgia, serif; color: var(--head);
  /* Opaque through the logo row, so scrolled content never runs into the title. */
  background: linear-gradient(180deg, var(--bg) calc(100% - 8px), rgba(var(--bg-rgb), 0));
}
.titlebar img { width: 24px; height: 24px; filter: var(--sign-filter); }

.pages { position: fixed; inset: 0; }
.page, .pushed {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--glow), var(--bg);
}
.page { padding: calc(var(--top) + 6px) 16px calc(var(--bar-h) + var(--bottom) + 48px); }
.page > *, .pushed > * { max-width: 640px; margin-left: auto; margin-right: auto; }

.page-head { padding-top: 4px; }
.eyebrow { display: flex; align-items: center; gap: 10px; font: 500 11px Inter, sans-serif; letter-spacing: .15em; text-transform: uppercase; color: var(--gold-text); }
.eyebrow::before { content: ''; width: 20px; height: 1px; background: var(--gold); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.ltitle { font: 700 34px/1.1 'Playfair Display', Georgia, serif; letter-spacing: -.02em; color: var(--head); }
.ltitle em { font-style: normal; color: var(--gold-text); }
.ltitle-sm { font-size: 28px; }

/* Liquid-glass tab bar */
.fade {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: calc(var(--bottom) + 120px); pointer-events: none;
  /* Fully opaque from the bottom edge of the tab bar down through the home indicator area. */
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), .72) 52%, rgba(var(--bg-rgb), 1) calc(100% - var(--bottom) - 10px));
}
.tabbar {
  position: fixed; z-index: 30; left: max(14px, calc(50% - 260px)); right: max(14px, calc(50% - 260px)); bottom: calc(var(--bottom) + 10px);
  height: var(--bar-h); border-radius: 30px; padding: 6px; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bar); -webkit-backdrop-filter: blur(22px) saturate(185%); backdrop-filter: blur(22px) saturate(185%);
  border: 1px solid var(--bar-b); box-shadow: inset 0 1px 0 var(--bar-hi), inset 0 -1px 0 rgba(0, 0, 0, .18), var(--bar-shadow);
}
.tabbar::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0) 46%), radial-gradient(70% 90% at 18% 0%, rgba(255, 255, 255, .10), transparent 60%);
}
.tab-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 4); border-radius: 24px;
  background: var(--pill-bg); border: 1px solid var(--pill-b); box-shadow: var(--pill-glow);
  transform: translateX(calc(var(--i, 0) * 100%)); transition: transform .45s var(--spring);
}
.tab { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--tab); font: 500 11px Inter, sans-serif; letter-spacing: .01em; transition: color .25s; }
.tab[aria-selected="true"] { color: var(--tab-on); font-weight: 600; }
.tab .ic { width: 25px; height: 25px; }
.bdg {
  position: absolute; top: 5px; left: calc(50% + 5px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  display: grid; place-items: center; font: 700 11px/1 Inter, sans-serif; font-style: normal; color: #1a1208;
  background: var(--gold-badge); box-shadow: 0 0 0 2.5px var(--ring);
}
/* The chat dot sits just outside the icon's top-right corner, so it needs no cut-out ring. */
.bdg.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; top: 3px; left: calc(50% + 12px); box-shadow: 0 0 0 0 rgba(201, 168, 76, .4); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(201, 168, 76, 0); } }

/* Pushed views and sheets */
.pushed { z-index: 40; padding: calc(var(--top) + 6px) 16px calc(var(--bottom) + 32px); transform: translateX(100%); transition: transform .38s var(--ease); }
.pushed.in { transform: none; }
.backlink { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font: 500 14px Inter; color: var(--gold-text); }
.backlink .ic { width: 18px; height: 18px; }
.sheet-layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet-layer.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .58); opacity: 0; transition: opacity .3s; }
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: calc(100% - var(--top) - 12px); overflow-y: auto;
  border-radius: 30px 30px 0 0; padding: 10px 18px calc(var(--bottom) + 18px);
  background: var(--sheet-bg); -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%);
  border-top: 1px solid var(--glass-b2); box-shadow: 0 -24px 60px rgba(0, 0, 0, .55);
  transform: translateY(100%); transition: transform .38s var(--ease);
}
.sheet-layer.open .sheet { transform: translateY(var(--drag, 0px)); }
.sheet.dragging { transition: none; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--glass-b2); margin: 0 auto 14px; }

/* Buttons, covers, feedback */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 54px; border-radius: 16px; font: 600 16px Inter, sans-serif; transition: transform .15s var(--ease); }
.btn:active { transform: scale(.98); }
.btn .ic { width: 22px; height: 22px; }
.btn-gold { color: #1a1208; background: var(--gold-fill); box-shadow: 0 8px 26px rgba(201, 168, 76, .28), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn-glass { color: var(--head); background: var(--glass); border: 1px solid var(--glass-b2); }
.btn-glass .ic { color: var(--gold-l); }
.btn-small { height: 40px; font-size: 14px; border-radius: 12px; }
.btn-small .ic { width: 18px; height: 18px; }
.cover { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--ph); }
.cover > img { width: 100%; height: 100%; object-fit: cover; }
.ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--ph); color: var(--gold-text); font: 600 11px Inter; letter-spacing: .1em; text-transform: uppercase; text-align: center; padding: 0 12px; }
.ph img { width: 36px; height: 36px; filter: var(--sign-filter); }
.badge-new { position: absolute; top: 8px; left: 8px; height: 22px; padding: 0 9px; border-radius: 8px; display: inline-flex; align-items: center; font: 700 10.5px Inter; letter-spacing: .1em; text-transform: uppercase; color: #1a1208; background: var(--gold-fill); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.play { position: absolute; right: 10px; bottom: 10px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(20, 20, 20, .35); border: 1px solid rgba(255, 255, 255, .35); -webkit-backdrop-filter: blur(10px) saturate(160%); backdrop-filter: blur(10px) saturate(160%); }
.play .ic { width: 16px; height: 16px; margin-left: 2px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + var(--bar-h) + 24px); z-index: 70; padding: 10px 16px; border-radius: 14px; background: var(--toast-bg); color: var(--toast-fg); font: 500 14px Inter; opacity: 0; transform: translate(-50%, 16px); transition: opacity .25s, transform .25s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fatal { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; text-align: center; background: var(--glow), var(--bg); }
.fatal h1 { font: 700 26px 'Playfair Display', Georgia, serif; color: var(--head); }
.fatal p { color: var(--muted); }
.fatal .btn { max-width: 280px; margin-top: 8px; }
.fatal-ic { width: 40px; height: 40px; color: var(--gold-text); }
