:root {
  --bg: #0b0d12;
  --panel: #151922;
  --panel-2: #1c212c;
  --line: #262c38;
  --line-2: #3a4254;
  --text: #eef0f5;
  --text-2: #c7ccd8;
  --muted: #8b93a5;
  --accent: #e50914;
  --accent-2: #ff3d47;
  --on-accent: #fff;
  --top-bg: rgba(11, 13, 18, .88);
  --movie: #4f8cff;
  --series: #b56cff;
  --radius: 12px;
  /* Telegram fullscreen / notch insets (0 in a normal browser) */
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}
/* Inside Telegram the page follows the user's Telegram theme (light or dark). */
html.tg {
  --bg: var(--tg-theme-bg-color, #0b0d12);
  --panel: var(--tg-theme-secondary-bg-color, #151922);
  --panel-2: color-mix(in srgb, var(--text) 7%, var(--panel));
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --line-2: color-mix(in srgb, var(--text) 25%, transparent);
  --text: var(--tg-theme-text-color, #eef0f5);
  --text-2: color-mix(in srgb, var(--text) 80%, var(--bg));
  --muted: var(--tg-theme-hint-color, #8b93a5);
  --accent: var(--tg-theme-button-color, #e50914);
  --accent-2: var(--tg-theme-link-color, #ff3d47);
  --on-accent: var(--tg-theme-button-text-color, #fff);
  --top-bg: color-mix(in srgb, var(--bg) 92%, transparent);
}
html.tg.tg-light { color-scheme: light; }
html.tg .brand { display: none; }
html.tg .search { max-width: none; margin: 0; }
html.tg .card:hover .poster { transform: none; box-shadow: none; }
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; padding-top: var(--safe-top); background: var(--top-bg); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1400px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 20px; }
.brand { color: var(--accent); font-weight: 800; font-size: 20px; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.search { flex: 1; max-width: 640px; margin-left: auto; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 14px; width: 18px; height: 18px; fill: var(--muted); pointer-events: none; }
.search input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 11px 40px 11px 42px; font-size: 16px; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search button { position: absolute; right: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 8px; border-radius: 50%; }
.search button:hover { color: var(--text); }
@media (max-width: 640px) {
  .top-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .search { max-width: none; margin: 0; }
}

/* toolbar */
.wrap { max-width: 1400px; margin: 0 auto; padding: 18px 16px calc(60px + var(--safe-bottom)); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; background: var(--panel); padding: 4px; border-radius: 999px; border: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button span { font-weight: 400; opacity: .75; font-size: 12px; margin-left: 2px; }
.tabs button.active { background: var(--accent); color: var(--on-accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; max-width: 280px; cursor: pointer; }
@media (max-width: 640px) {
  .toolbar, .filters { width: 100%; }
  .tabs { width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; padding: 7px 6px; }
  .filters select { flex: 1; min-width: 0; max-width: none; }
}
.summary { color: var(--muted); margin: 0 0 16px; min-height: 1.45em; }
.summary b { color: var(--text); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 14px; }
@media (max-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px 10px; } }
.card { cursor: pointer; border-radius: var(--radius); outline: none; min-width: 0; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: linear-gradient(145deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); transition: transform .18s, border-color .18s, box-shadow .18s; }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-3px); border-color: var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.card:focus-visible .poster { border-color: var(--accent); }
.poster img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; background: var(--panel); }
.poster .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; }
.badge { position: absolute; z-index: 2; top: 8px; left: 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; color: #fff; }
.badge.movie { background: var(--movie); }
.badge.series { background: var(--series); }
.rating { position: absolute; z-index: 2; top: 8px; right: 8px; font-size: 11px; font-weight: 700; padding: 3px 6px; border-radius: 6px; background: rgba(0, 0, 0, .7); color: #ffd35c; }
.card h3 { font-size: 14px; font-weight: 600; margin: 8px 2px 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 12px; color: var(--muted); margin: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .where { font-size: 12px; color: var(--text-2); margin: 3px 2px 0; display: flex; gap: 4px; align-items: baseline; }
.card .where span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .where em { font-style: normal; color: var(--muted); flex: none; }

.skeleton .poster { animation: pulse 1.2s ease-in-out infinite; }
.skeleton .line { height: 12px; background: var(--panel-2); border-radius: 6px; margin: 10px 2px 0; width: 80%; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }
.sentinel { height: 1px; }
.updated { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }
.more { display: block; margin: 24px auto 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 10px 22px; cursor: pointer; }

/* modal */
.modal { padding: 0; border: 0; background: transparent; width: min(860px, calc(100% - 24px)); max-height: calc(100% - 24px); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .75); backdrop-filter: blur(4px); }
.modal-inner { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: 16px; }
.close:hover { background: var(--accent); color: var(--on-accent); }
.hero { position: relative; min-height: 120px; background-size: cover; background-position: center; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, color-mix(in srgb, var(--panel) 20%, transparent), var(--panel)); }
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 22px; padding: 0 24px 24px; margin-top: -70px; position: relative; z-index: 1; }
.detail .poster { box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.detail h2 { margin: 74px 0 6px; font-size: 24px; line-height: 1.2; }
.detail .sub { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.location { margin: 18px 0; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 14px; }
.location h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip small { color: var(--muted); }
.plot { color: var(--text-2); margin: 0 0 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.seasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.seasons span { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.trailer { display: inline-block; margin-top: 14px; color: var(--accent-2); font-weight: 600; text-decoration: none; }
.loading-text { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .detail { grid-template-columns: 110px 1fr; gap: 14px; padding: 0 16px 20px; margin-top: -50px; }
  .detail h2 { margin-top: 54px; font-size: 18px; }
  .detail .body { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  /* 16px stops iOS from zooming the page when a field gets focus */
  select { font-size: 16px; }
  .modal { width: 100%; max-width: 100%; max-height: calc(100% - var(--safe-top)); margin: auto 0 0; }
  .modal-inner { border-radius: 16px 16px 0 0; padding-bottom: var(--safe-bottom); }
}
