:root {
  --bg: #07070b;
  --panel: #121218;
  --panel-2: #1a1a24;
  --line: #2c2c38;
  --text: #f4f4f8;
  --muted: #9b9baf;
  --ice: #ff4d8d;
  --ice-2: #ff2d6a;
  --ok: #34d399;
  --bad: #fb7185;
  --warn: #ffd166;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html {
  color-scheme: only dark;
}
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 420px at 8% -12%, rgba(255, 45, 106, 0.22), transparent 58%),
    radial-gradient(700px 340px at 100% 0%, rgba(255, 77, 141, 0.10), transparent 52%);
  pointer-events: none;
}

.top, main { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px 0;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand strong { display: block; font-size: 20px; letter-spacing: 0.04em; }
.brand small { color: var(--muted); }
.flake {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 11px;
  background: none;
  flex: 0 0 auto;
  overflow: hidden;
}
.flake img { width: 36px; height: 36px; display: block; }

main { padding: 4px 24px 80px; }
.search-hero {
  text-align: center;
  padding: 16px 0 14px;
}
.search-hero .eyebrow {
  margin: 0 0 4px;
  color: var(--ice);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}
.search-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(22px, 3.4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 6px 6px 16px;
  background: rgba(18, 18, 24, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.search-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--muted);
  display: block;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 12px 8px;
  border-radius: 0;
}
.search-bar .primary {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 10px 18px;
}
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 6px;
  background: rgba(18, 18, 24, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.hud-tabs, .hud-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hud-field {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0;
  font-weight: 600;
}
.hud-field select {
  width: auto;
  min-width: 0;
  max-width: 160px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--panel);
}
.search-row { display: flex; gap: 10px; align-items: stretch; }
.search-row input { flex: 1; min-width: 0; }
.search-row .primary { white-space: nowrap; flex: 0 0 auto; }
.path-row { display: flex; gap: 8px; align-items: stretch; }
.path-row input { flex: 1; min-width: 0; }
.path-row .ghost {
  flex: 0 0 auto;
  border-radius: 12px;
  white-space: nowrap;
  height: auto;
}
.search-box > span { display: block; color: var(--muted); margin-bottom: 8px; font-size: 13px; }

input[type="search"],
input[type="text"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
textarea { min-height: 72px; resize: vertical; font-size: 13px; line-height: 1.4; word-break: break-all; }
input:focus, textarea:focus, select:focus {
  border-color: var(--ice-2);
  box-shadow: 0 0 0 3px rgba(255, 45, 106, 0.22);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
button:disabled { opacity: .55; cursor: wait; }
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--ice-2);
}
.chip, .ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 13px;
}
.chip.active { background: rgba(255, 45, 106, 0.18); border-color: var(--ice-2); color: var(--ice); }
.primary {
  background: linear-gradient(180deg, #ff6b9d, #ff2d6a);
  color: #1a0710;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
}
.hint { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  background: var(--panel);
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: inherit;
  padding: 0;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 18px 36px rgba(0,0,0,.5); }
.card .poster { border-radius: 0; }
.card .meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  padding: 32px 10px 10px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.92));
}
.card b { display: block; font-size: 13px; overflow-wrap: anywhere; line-height: 1.25; }
.card small { color: #c9c9d6; }
.card .rating {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--warn);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
}
.card .kind-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  background: rgba(255, 45, 106, 0.9);
  color: #fff;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card .lib-tag {
  position: absolute;
  top: 32px;
  left: 8px;
  z-index: 2;
  background: rgba(52, 211, 153, 0.92);
  color: #04110c;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.lib-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.trailer-box {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 48px 20px 20px;
  background: rgba(7, 7, 11, 0.92);
}
.trailer-box.hidden { display: none !important; }
.trailer-box .close { z-index: 26; }
.trailer-frame {
  width: min(100%, 720px);
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.trailer-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.shelf { margin: 18px 0 28px; }
.shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.shelf-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.shelf-head button { color: var(--ice); font-weight: 700; }
.card.skel { pointer-events: none; }
.card.skel .poster {
  background: linear-gradient(90deg, #16161e, #242432, #16161e);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.sentinel {
  height: 80px;
  width: 100%;
  pointer-events: none;
}
.pager {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 8px 0 24px;
}
.pager .ghost { min-width: 180px; }

.poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: linear-gradient(160deg, #1c1420, #0c0c12);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster img.is-hidden { display: none; }
.poster-fallback {
  font-size: 42px;
  font-weight: 700;
  color: #6b5a72;
  user-select: none;
}

dialog {
  border: 0;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  color-scheme: only dark;
  max-width: 620px;
  width: min(620px, calc(100vw - 40px));
  max-height: min(78vh, 700px);
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
}
dialog[open] { display: flex; }
dialog::backdrop {
  background: rgba(2, 8, 14, 0.72);
  color-scheme: only dark;
}
.sheet {
  background: transparent;
  color: var(--text);
  color-scheme: only dark;
  border: 0;
  border-radius: 0;
  padding: 48px 20px 20px;
  position: relative;
  box-shadow: none;
  max-height: none;
  overflow: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #3a3a48 transparent;
}
.sheet::-webkit-scrollbar { width: 8px; }
.sheet::-webkit-scrollbar-thumb {
  background: #3a3a48;
  border-radius: 8px;
}
.sheet.slim { max-width: none; }
.close {
  position: absolute;
  right: 10px; top: 10px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
  z-index: 30;
  flex: none;
}

.hero {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.hero .poster { border-radius: 14px; }
.hero-text { min-width: 0; }
.hero-text h2 { margin: 0 0 6px; overflow-wrap: anywhere; color: var(--text); }
.stream-head h3, .sheet h2, .sheet h3, .season strong {
  color: var(--text);
}
.kicker { color: var(--ice); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; margin: 0 0 6px; }
.meta-line { color: var(--muted); margin: 0 0 8px; overflow-wrap: anywhere; }
.plot { color: #c5d4e0; line-height: 1.45; margin: 0; }
.hidden { display: none !important; }

.stream-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 10px;
}
.stream-head h3 { margin: 0; }
.streams { display: grid; gap: 8px; margin: 0 0 16px; }
.stream {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 0;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.stream input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 4px 0 0;
  flex: none;
  accent-color: var(--ice-2);
}
.stream-body { min-width: 0; }
.stream-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.stream-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #3a1830;
  color: var(--ice);
}
.badge.q { background: #12352c; color: var(--ok); }
.badge.lang { background: #2a2440; color: #c4b5fd; }
.probe {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.probe.ok { color: var(--ok); }
.probe.bad { color: var(--bad); }
.probe.wait {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.probe.wait::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid var(--line);
  border-top-color: var(--ice);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.series-tools { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 8px 0 16px; flex-wrap: wrap; }
.season {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}
.season header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.season strong { font-size: 15px; }
.eps { color: var(--muted); font-size: 13px; margin-top: 8px; overflow-wrap: anywhere; }
.ep-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ep-pills span {
  background: #0c0c12;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.work {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  background: rgba(7, 7, 11, 0.86);
  backdrop-filter: blur(10px);
  color: var(--text);
}
.work.hidden { display: none !important; }
.work-card {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  width: min(100%, 460px);
  background: #16161f;
  border: 1px solid rgba(255, 45, 106, 0.28);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  color: var(--text);
}
.work.ok .work-card { border-color: rgba(52, 211, 153, 0.4); }
.work.bad .work-card { border-color: rgba(251, 113, 133, 0.45); }
.work-visual {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--ice-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.work-mark {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}
.work.ok .spinner, .work.bad .spinner { display: none; }
.work.ok .work-mark, .work.bad .work-mark { display: grid; }
.work.ok .work-mark {
  background: rgba(52, 211, 153, 0.16);
  color: var(--ok);
}
.work.ok .work-mark::before { content: "✓"; }
.work.bad .work-mark {
  background: rgba(251, 113, 133, 0.16);
  color: var(--bad);
}
.work.bad .work-mark::before { content: "!"; }
.work-copy { min-width: 0; flex: 1 1 220px; }
.work-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.work-copy b { display: block; color: var(--text); font-size: 15px; }
.work-pct { color: var(--ice); font-weight: 700; font-variant-numeric: tabular-nums; }
.work-copy small { display: block; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.work-actions {
  flex: 1 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.work-actions:empty { display: none; }
.work-actions .primary { padding: 8px 14px; }
.progress {
  height: 7px;
  background: #241018;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.progress > i {
  display: block;
  height: 100%;
  width: 18%;
  background: linear-gradient(90deg, #ff2d6a, #ffd166);
  border-radius: 999px;
  transition: width .25s ease;
}
.progress.indeterminate > i {
  width: 38%;
  animation: indeterminate 1.1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes indeterminate {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(270%); }
}

.skeleton {
  display: grid;
  gap: 8px;
}
.skeleton i {
  display: block;
  height: 58px;
  border-radius: 12px;
  background: linear-gradient(90deg, #16161e, #242432, #16161e);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.result-msg { min-height: 0; overflow-wrap: anywhere; color: var(--text); }
.result-msg.ok { color: var(--ok); }
.result-msg.bad { color: var(--bad); }

.sheet.slim label { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); }
.addons-title { margin: 20px 0 8px; }
.addon-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0;
}
.example {
  background: #0c0c12;
  color: #9fb4c6;
  padding: 12px;
  border-radius: 12px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
}
.help { color: var(--muted); overflow-wrap: anywhere; }
.help a {
  color: var(--ice);
}
.help code, .sheet code {
  color: var(--ice);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }

@media (max-width: 700px) {
  .hero { grid-template-columns: 110px minmax(0, 1fr); }
  .top, main { padding-left: 16px; padding-right: 16px; }
  .search-hero { padding: 18px 0 12px; }
  .search-bar {
    border-radius: 22px;
    flex-wrap: wrap;
    padding: 10px;
  }
  .search-bar .primary { width: 100%; }
  .browse-nav { flex-direction: column; align-items: stretch; }
}
