:root {
  --bg: #0b0b0f;
  --surface: #15151b;
  --surface-2: #1c1c24;
  --border: rgba(255,255,255,.06);
  --border-2: rgba(255,255,255,.1);
  --text: #f4f4f7;
  --muted: rgba(244,244,247,.58);
  --faint: rgba(244,244,247,.36);
  --gold: #ffcf5c;
  --good: #4ade80;
  --bad: #ff6b6b;
  --accent: #f5b642;
  --accent-rgb: 245,182,66;
  --accent-ink: #1a1305;
  --r-lg: 20px;
  --r-md: 16px;
  --font: -apple-system, "SF Pro Display", "SF Pro Text", Inter, Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --sat: calc(env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --sab: env(safe-area-inset-bottom, 0px);
  --tabh: 58px;
  --ease: cubic-bezier(.22,.8,.3,1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); color-scheme: dark; overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#app { min-height: 100vh; padding-bottom: calc(var(--tabh) + var(--sab) + 16px); }
body.no-tabs #app { padding-bottom: calc(var(--sab) + 110px); }
#view { position: relative; min-height: 100vh; }
.enter { animation: enter .22s var(--ease) both; }
.enter.back { animation-name: enterBack; }
@keyframes enter { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes enterBack { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* Tab bar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 16px calc(6px + var(--sab));
  background: rgba(14,14,19,.72); backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-top: 1px solid var(--border);
  transition: transform .25s var(--ease);
}
body.no-tabs #tabbar { transform: translateY(110%); }
.tab { flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .01em; transition: color .2s; position: relative; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* Search bar */
.searchbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--sat) + 10px) 16px 10px;
  background: linear-gradient(to bottom, rgba(11,11,15,.88), rgba(11,11,15,.6));
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
}
.searchfield { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 14px; background: rgba(255,255,255,.08); border: 1px solid var(--border); transition: border-color .2s, background .2s; }
.searchfield:focus-within { border-color: rgba(var(--accent-rgb), .55); background: rgba(255,255,255,.1); }
.searchfield svg { width: 19px; height: 19px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; flex: none; }
.searchfield input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; font-size: 16px; }
.searchfield input::placeholder { color: var(--faint); }
.searchfield .clear { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.2); color: #000; font-size: 14px; line-height: 20px; text-align: center; flex: none; }

.page { padding: 4px 16px 24px; }
.pagehead { padding: calc(var(--sat) + 18px) 16px 6px; }
.pagehead h1 { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 20px 2px 10px; display: flex; justify-content: space-between; align-items: center; }
.section-title button { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; }
.section-sub { margin: -6px 2px 12px; font-size: 13px; color: var(--muted); }
.ideas .section-title { margin-top: 24px; }
.more-ideas { display: block; width: 100%; margin-top: 14px; }

/* Poster grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 14px; padding-top: 8px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(5, 1fr); } .page, .searchbar, .pagehead { max-width: 1100px; margin-inline: auto; } }
.pcard { text-align: left; display: block; width: 100%; animation: enter .3s var(--ease) both; }
.pcard:active .pposter { transform: scale(.97); }
.pposter { position: relative; aspect-ratio: 2/3; border-radius: var(--r-md); overflow: hidden; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 28px rgba(0,0,0,.45); transition: transform .18s var(--ease); }
.pposter img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s; }
.pposter img.loaded { opacity: 1; }
.nopic { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 34px; background: linear-gradient(160deg, var(--surface-2), var(--surface)); }
.rating { position: absolute; top: 8px; right: 8px; padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(0,0,0,.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; gap: 3px; border: 1px solid var(--border-2); }
.rating::before { content: "★"; color: var(--gold); font-size: 11px; }
.ptitle { margin-top: 9px; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.porig { margin-top: 2px; font-size: 12.5px; color: var(--muted); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { margin-top: 4px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.chip-type { padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.08); color: var(--muted); }

/* Skeleton */
.skel { position: relative; overflow: hidden; background: var(--surface); border-radius: 10px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-poster { aspect-ratio: 2/3; border-radius: var(--r-md); }
.skel-line { height: 12px; margin-top: 10px; width: 80%; }
.skel-line.s { width: 45%; }
.skel-card { height: 118px; border-radius: var(--r-md); margin-bottom: 12px; }

/* Hint / empty / error */
.hint { text-align: center; padding: 36px 24px 12px; color: var(--muted); }
.hint .big { font-size: 54px; margin-bottom: 10px; filter: saturate(.9); }
.hint h3 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--text); margin-bottom: 6px; }
.hint p { font-size: 14.5px; max-width: 300px; margin: 0 auto; }
.hint .btn { margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 24px; border-radius: 15px; font-weight: 700; font-size: 16px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(var(--accent-rgb), .28); transition: transform .15s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--text); box-shadow: none; }
.btn.block { width: 100%; }
.rawcta { width: 100%; margin-top: 18px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px dashed var(--border-2); color: var(--muted); text-align: left; display: flex; gap: 12px; align-items: center; }
.rawcta b { color: var(--text); display: block; font-weight: 650; }
.rawcta .ico { font-size: 22px; }

/* Title screen */
.hero { position: relative; height: 330px; overflow: hidden; background: var(--surface); }
.hero-bg { position: absolute; left: 0; top: -20px; width: 100%; height: calc(100% + 20px); object-fit: cover; object-position: center top; will-change: transform; opacity: 0; transition: opacity .5s; }
.hero-bg.blur { filter: blur(28px) saturate(1.3); transform-origin: top; scale: 1.3; }
.hero-bg.loaded { opacity: 1; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(11,11,15,.35) 0%, rgba(11,11,15,0) 35%, rgba(11,11,15,.75) 80%, var(--bg) 100%); }
.hero-glow { position: absolute; inset: 0; z-index: 1; background: radial-gradient(120% 80% at 50% 0%, rgba(var(--accent-rgb), .35), transparent 70%); }
.tinfo { position: relative; margin-top: -120px; padding: 0 16px; display: flex; gap: 16px; align-items: flex-end; z-index: 2; }
.tposter { width: 112px; flex: none; aspect-ratio: 2/3; border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: 0 14px 40px rgba(0,0,0,.6), 0 0 0 1px var(--border-2); position: relative; }
.tposter img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s; }
.tposter img.loaded { opacity: 1; }
.thead { min-width: 0; padding-bottom: 4px; }
.thead h1 { font-size: 27px; line-height: 1.08; font-weight: 800; letter-spacing: -.035em; text-wrap: balance; overflow-wrap: anywhere; }
.thead .orig { margin-top: 5px; color: var(--muted); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 16px 16px 0; color: var(--muted); font-size: 14px; }
.meta .dot { opacity: .4; }
.meta .star { color: var(--gold); font-weight: 700; }
.genres { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 16px 0; }
.genre { padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(var(--accent-rgb), .13); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), .22); }
.tagline { margin: 18px 16px 0; font-style: italic; color: rgba(244,244,247,.78); font-size: 16px; letter-spacing: -.005em; }
.overview { margin: 12px 16px 0; color: rgba(244,244,247,.8); font-size: 15px; line-height: 1.5; }
.overview.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.more { margin: 6px 16px 0; color: var(--accent); font-weight: 600; font-size: 14.5px; }
.seasons { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 16px 0; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); transition: all .18s; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 4px 16px rgba(var(--accent-rgb), .3); }
.cta { margin: 22px 16px 0; }

/* Releases */
.relhead { padding: calc(var(--sat) + 16px) 16px 4px; }
.relhead h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.relhead p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.filters { position: sticky; top: 0; z-index: 15; display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 10px; scrollbar-width: none; background: linear-gradient(to bottom, rgba(11,11,15,.94) 70%, rgba(11,11,15,0)); }
.filters::-webkit-scrollbar { display: none; }
.rcard { position: relative; display: block; width: 100%; text-align: left; padding: 15px 16px 14px; margin-bottom: 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); transition: transform .15s var(--ease), border-color .2s; animation: enter .28s var(--ease) both; overflow: hidden; }
.rcard:active { transform: scale(.985); }
.rcard.t1 { border-color: rgba(255,207,92,.28); background: linear-gradient(160deg, rgba(var(--accent-rgb), .14), var(--surface) 55%); box-shadow: 0 0 0 1px rgba(255,207,92,.06), 0 10px 40px -10px rgba(var(--accent-rgb), .35); }
.rcard.bad { opacity: .5; }
.ribbon { position: absolute; top: 0; right: 0; padding: 4px 11px 5px 13px; border-bottom-left-radius: 12px; font-size: 14px; font-weight: 800; }
.t1 .ribbon { background: linear-gradient(135deg, #ffd978, #f0a92b); color: #3a2600; }
.t2 .ribbon { background: rgba(255,255,255,.08); color: var(--gold); }
.rq { font-size: 17px; font-weight: 750; letter-spacing: -.015em; padding-right: 36px; line-height: 1.25; }
.rsub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.07); color: rgba(244,244,247,.8); border: 1px solid var(--border); }
.pill.orig { background: rgba(120,170,255,.12); color: #9dc0ff; border-color: rgba(120,170,255,.2); }
.pill.ru { background: rgba(74,222,128,.1); color: #7ee9a6; border-color: rgba(74,222,128,.2); }
.pill.sub { background: rgba(var(--accent-rgb), .12); color: var(--accent); border-color: rgba(var(--accent-rgb), .2); }
.pill.warn { background: rgba(255,107,107,.12); color: var(--bad); border-color: rgba(255,107,107,.25); }
.rrow { display: flex; align-items: center; gap: 14px; margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.rrow b { color: var(--text); font-weight: 650; }
.seed { display: inline-flex; align-items: center; gap: 6px; }
.seed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.seed.low::before { background: #ffb347; box-shadow: 0 0 8px #ffb347; }
.seed.zero::before { background: var(--bad); box-shadow: none; }
.rrow .tr { margin-left: auto; color: var(--faint); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity .25s; }
.scrim.on { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 86vh; overflow-y: auto; padding: 0 20px calc(24px + var(--sab)); background: #17171e; border-radius: 26px 26px 0 0; border-top: 1px solid var(--border-2); box-shadow: 0 -20px 60px rgba(0,0,0,.6); transform: translateY(100%); transition: transform .3s var(--ease); max-width: 640px; margin-inline: auto; }
.sheet.on { transform: translateY(var(--dy, 0px)); }
.sheet.drag { transition: none; }
.grab { position: sticky; top: 0; padding: 10px 0 12px; display: grid; place-items: center; background: #17171e; touch-action: none; }
.grab i { width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); }
.sheet h2 { font-size: 21px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
.sheet .rawtitle { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--border); color: rgba(244,244,247,.78); font-size: 13.5px; line-height: 1.45; word-break: break-word; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.sheet .rrow { margin-top: 14px; flex-wrap: wrap; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 8px; border-radius: 14px; background: rgba(255,255,255,.06); }
.seg button { height: 40px; border-radius: 11px; font-weight: 650; color: var(--muted); transition: all .18s; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seglabel { margin-top: 16px; color: var(--muted); font-size: 13px; }
.sheet .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.sheet .linkbtn { color: var(--accent); font-weight: 650; text-align: center; height: 46px; border-radius: 14px; background: rgba(var(--accent-rgb), .1); }

/* Downloads */
.dcard { position: relative; padding: 14px 16px 15px; margin-bottom: 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); animation: enter .28s var(--ease) both; }
.dtop { display: flex; gap: 10px; align-items: flex-start; }
.dname { flex: 1; min-width: 0; font-weight: 650; font-size: 15px; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.dcard .chipc { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: rgba(var(--accent-rgb), .13); color: var(--accent); }
.bar { position: relative; height: 8px; margin-top: 13px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--accent); box-shadow: 0 0 14px rgba(var(--accent-rgb), .6); transition: width .8s var(--ease); overflow: hidden; }
.bar > i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent); transform: translateX(-100%); animation: shimmer 1.6s infinite; }
.dcard.done .bar > i::after, .dcard.paused .bar > i::after { display: none; }
.dcard.done .bar > i { background: var(--good); box-shadow: none; }
.dcard.paused .bar > i { background: rgba(255,255,255,.3); box-shadow: none; }
.dbot { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.dbot .pc { color: var(--text); font-weight: 700; }
.dbot .del { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); margin-right: -6px; }
.dbot .del:active { background: rgba(255,255,255,.08); color: var(--bad); }
.dbot .del svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dbot .ok { color: var(--good); font-weight: 650; }
.dcard.compact { padding: 11px 14px 12px; margin-bottom: 8px; }
.dcard.compact .dname { font-size: 14px; -webkit-line-clamp: 1; }
.dcard.compact .bar { height: 6px; margin-top: 9px; }
.dcard.compact .dbot { margin-top: 7px; font-size: 12.5px; }
.dcard.compact .del { display: none; }

/* Toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabh) + var(--sab) + 18px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
body.no-tabs #toasts { bottom: calc(var(--sab) + 90px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 460px; padding: 12px 16px; border-radius: 16px; background: rgba(36,36,44,.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border-2); box-shadow: 0 14px 40px rgba(0,0,0,.55); font-weight: 600; font-size: 14.5px; animation: toastIn .3s var(--ease) both; }
.toast.err { border-color: rgba(255,107,107,.35); }
.toast.out { animation: toastOut .25s ease both; }
.toast button { color: var(--accent); font-weight: 700; white-space: nowrap; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }

/* Denied */
#denied { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 32px; text-align: center; }
.denied-ico { font-size: 56px; margin-bottom: 12px; }
.denied-card h2 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 8px; }
.denied-card p { color: var(--muted); max-width: 300px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .hero-bg { transform: none !important; }
}

/* the app draws its own clear button */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
