:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f5f7fb);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --section-bg: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17191d);
  --hint: var(--tg-theme-hint-color, #747a84);
  --primary: var(--tg-theme-link-color, #2777f8);
  --button: var(--tg-theme-button-color, #2777f8);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --separator: var(--tg-theme-section-separator-color, rgba(63, 71, 82, .16));
  --container: color-mix(in srgb, var(--text) 8%, var(--bg));
  --safe-top: var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --catalog-header-height: 76px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; background: var(--bg); }
body { max-width: 100%; margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding: calc(10px + var(--safe-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
}
.catalog-tabs-row { display: flex; align-items: center; gap: 8px; }
.mode-tabs { display: flex; flex: 1 1 auto; gap: clamp(16px, 4vw, 24px); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mode-tabs::-webkit-scrollbar, .filters::-webkit-scrollbar, .featured-row::-webkit-scrollbar,
.preview-row::-webkit-scrollbar, .actor-row::-webkit-scrollbar { display: none; }
.tab, .filter-tab {
  position: relative;
  flex: none;
  border: 0;
  padding: 8px 6px 12px;
  color: var(--hint);
  background: transparent;
  font-size: 15px;
  font-weight: 650;
  line-height: 20px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active, .filter-tab.active { color: var(--primary); font-weight: 800; }
.mode-tabs .tab { padding-right: 4px; padding-left: 4px; }
.tab.active::after, .filter-tab.active::after {
  content: "";
  position: absolute;
  right: 50%;
  bottom: 0;
  width: 28px;
  height: 3px;
  transform: translateX(50%);
  border-radius: 999px;
  background: var(--primary);
}
.icon-button {
  display: grid;
  flex: 0 0 48px;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.icon-button:active { background: var(--container); }
.icon-button svg, .search-input-row svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

main { min-height: 70vh; padding: 0 0 calc(40px + var(--safe-bottom)); }
.featured { padding: 4px 17px 16px; }
.featured-row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; }
.feature-card {
  position: relative;
  flex: 0 0 86%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  padding: 0;
  color: #fff;
  background: #24272d;
  text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
}
.feature-card::after { content: ""; position: absolute; inset: 38% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .85)); }
.feature-card > .catalog-image { width: 100%; height: 100%; object-fit: cover; }
.feature-card > div { position: absolute; z-index: 2; right: 58px; bottom: 14px; left: 16px; }
.feature-card strong, .feature-card div > span { display: block; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px #000; }
.feature-card strong { display: -webkit-box; font-size: 15px; line-height: 1.2; font-weight: 800; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.feature-card div > span { margin-top: 5px; color: rgba(255, 255, 255, .82); font-size: 12px; font-weight: 600; white-space: nowrap; }

.filter-shell {
  position: sticky;
  z-index: 19;
  top: var(--catalog-header-height);
  padding: 0 24px 12px;
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
}
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs { display: flex; flex: 0 0 auto; gap: 24px; }
.filter-tab { padding-top: 6px; padding-bottom: 10px; font-size: 14px; }
.top-filters { display: flex; align-items: center; width: 100%; min-width: 0; gap: 16px; }
.top-filters .filter-tabs { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top-year-filter { display: flex; flex: 0 0 auto; align-items: center; margin-left: auto; color: var(--hint); }
.top-year-filter select { appearance: none; border: 0; padding: 7px 0 7px 8px; color: var(--text); background: transparent; font-size: 13px; font-weight: 750; outline: none; }
.top-year-filter span { margin-left: 3px; }
.segmented { display: flex; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--separator); border-radius: 6px; }
.segment { min-width: 48px; border: 0; padding: 6px 10px; color: var(--hint); background: transparent; font-size: 12px; font-weight: 650; }
.segment.active { color: var(--button-text); background: var(--primary); font-weight: 750; }
.option-filters { display: flex; gap: 28px; width: 100%; overflow-x: auto; }
.option-filter { flex: 0 0 auto; }
.option-filter > span { display: block; color: var(--hint); font-size: 10px; font-weight: 700; }
.option-value { display: flex; align-items: center; margin-top: 3px; color: var(--primary); }
.option-value select { appearance: none; border: 0; padding: 0; color: var(--text); background: transparent; font-size: 13px; font-weight: 750; outline: none; }
.option-value > span { margin-left: 3px; color: var(--hint); }
.search-result-bar { display: flex; align-items: center; width: 100%; gap: 8px; }
.search-result-bar strong { flex: 1; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.search-result-icon { color: var(--primary); font-size: 20px; }
.search-result-bar button { border: 0; padding: 7px 0 7px 10px; color: var(--primary); background: transparent; font-size: 13px; }

.movie-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; padding: 8px 24px 24px; }
.movie-card { min-width: 0; border: 0; padding: 0; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.poster {
  position: relative;
  overflow: hidden;
  aspect-ratio: .65;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--container), color-mix(in srgb, var(--text) 13%, var(--bg)));
}
.poster.landscape { aspect-ratio: 1.42; }
.poster > .catalog-image { width: 100%; height: 100%; object-fit: cover; }
.catalog-image { opacity: 0; transition: opacity .18s ease; }
.catalog-image.loaded { opacity: 1; }
.catalog-image.failed { display: none; }
.movie-card:active .poster > .catalog-image { transform: scale(.985); }
.play-indicator {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 68%, transparent);
}
.play-indicator::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 14px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid var(--bg);
}
.feature-play { right: 14px; bottom: 14px; background: rgba(0, 0, 0, .58); }
.feature-play::before { border-left-color: #fff; }
.movie-copy { padding-top: 8px; }
.movie-copy strong { display: -webkit-box; overflow: hidden; font-size: 14px; line-height: 1.18; font-weight: 700; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.movie-copy span { display: block; overflow: hidden; margin-top: 4px; color: var(--hint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 12px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading span { color: var(--hint); font-size: 12px; }
.state-card { display: grid; place-items: center; min-height: 42vh; padding: 35px 24px; color: var(--hint); text-align: center; }
.spinner { width: 29px; height: 29px; margin-bottom: 12px; border: 3px solid var(--separator); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.retry { margin-top: 12px; border: 1px solid var(--separator); border-radius: 10px; padding: 9px 14px; color: var(--text); background: var(--section-bg); }
.load-sentinel { height: 1px; }
.loading-more { padding: 24px; color: var(--hint); text-align: center; }

.actor-section + .actor-section { margin-top: 4px; }
.actor-section .section-heading { margin: 0; padding: 20px 24px 12px; }
.actor-section .section-heading h2 { font-size: 16px; font-weight: 650; }
.actor-row { display: flex; gap: 16px; overflow-x: auto; padding: 0 24px 20px; scrollbar-width: none; }
.actor-card { flex: 0 0 88px; width: 88px; border: 0; padding: 0; color: inherit; background: transparent; cursor: pointer; text-align: center; }
.avatar { width: 80px; height: 80px; margin: 0 auto 8px; overflow: hidden; border-radius: 50%; background: var(--container); }
.avatar .catalog-image { width: 100%; height: 100%; object-fit: cover; }
.actor-card strong { display: -webkit-box; overflow: hidden; font-size: 12px; font-weight: 500; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.actor-card > span { color: var(--hint); font-size: 10px; }

.review-list { padding: 8px 24px 32px; }
.review-card { padding: 0 0 18px; background: transparent; }
.review-card + .review-card { padding-top: 18px; border-top: 1px solid var(--separator); }
.review-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--hint); font-size: 11px; }
.review-card > p { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.review-movie { display: flex; align-items: stretch; width: 100%; min-height: 64px; margin-top: 10px; border: 0; padding: 0; color: inherit; background: transparent; text-align: left; }
.quote-bar { flex: 0 0 3px; margin-right: 10px; border-radius: 2px; background: var(--separator); }
.review-poster { flex: 0 0 45px; height: 64px; overflow: hidden; border-radius: 8px; background: var(--container); }
.review-poster .catalog-image { width: 100%; height: 100%; object-fit: cover; }
.review-movie-copy { align-self: center; min-width: 0; margin-left: 12px; }
.review-movie-copy strong, .review-movie-copy span { display: block; overflow: hidden; text-overflow: ellipsis; }
.review-movie-copy strong { font-size: 13px; font-weight: 800; white-space: nowrap; }
.review-movie-copy span { margin-top: 3px; color: var(--hint); font-size: 11px; line-height: 1.35; }

.search-overlay { position: fixed; z-index: 70; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .42); }
.search-dialog { width: min(100%, 390px); border-radius: 22px; padding: 22px; background: var(--section-bg); box-shadow: 0 20px 70px rgba(0, 0, 0, .28); }
.search-dialog h2 { margin: 0 0 18px; font-size: 20px; }
.search-input-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--separator); border-radius: 10px; padding: 0 12px; color: var(--hint); background: var(--surface); }
.search-input-row svg { width: 20px; height: 20px; }
.search-input-row input { width: 100%; min-width: 0; border: 0; padding: 12px 0; color: var(--text); background: transparent; outline: none; }
.search-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.search-actions button { min-height: 40px; border: 0; border-radius: 10px; padding: 0 18px; color: var(--primary); background: transparent; font-weight: 700; }
.search-actions .primary-button { color: var(--button-text); background: var(--button); }

.sheet { position: fixed; z-index: 30; inset: 0; max-width: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
.sheet-handle { display: none; }
.sheet-content { padding: calc(8px + var(--safe-top)) 16px calc(38px + var(--safe-bottom)); }
.sheet-content .movie-grid { padding-right: 0; padding-left: 0; }
.detail-hero { position: relative; min-height: 260px; margin: calc(-8px - var(--safe-top)) -16px 18px; overflow: hidden; }
.detail-hero > .catalog-image { width: 100%; height: 320px; object-fit: cover; filter: saturate(.9); }
.detail-hero::after { content: ""; position: absolute; inset: 18% 0 0; background: linear-gradient(transparent, var(--bg)); }
.detail-title { position: absolute; z-index: 1; inset: auto 16px 10px; }
.detail-title h2 { margin: 4px 0; font-size: 25px; line-height: 1.15; }
.detail-title p { margin: 0; color: color-mix(in srgb, var(--text) 75%, transparent); font-size: 12px; }
.detail-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0 20px; }
.action-button { min-height: 44px; border: 1px solid var(--separator); border-radius: 10px; color: var(--text); background: var(--section-bg); font-weight: 700; }
.action-button.primary { border-color: var(--button); color: var(--button-text); background: var(--button); }
.detail-section { margin-top: 24px; }
.detail-section h3 { margin: 0 0 11px; font-size: 17px; }
.detail-section p { color: color-mix(in srgb, var(--text) 84%, var(--hint)); line-height: 1.65; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 13px; color: var(--hint); font-size: 13px; }
.meta-grid dd { margin: 0; color: var(--text); }
.inline-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.inline-link { border: 0; padding: 3px 0; color: var(--primary); background: transparent; cursor: pointer; text-align: left; }
.inline-link:disabled { color: var(--text); cursor: default; opacity: 1; }
.inline-separator { color: var(--hint); }
.source-options { display: flex; flex-wrap: wrap; gap: 7px; }
.source-options button { border: 1px solid var(--separator); border-radius: 8px; padding: 7px 11px; color: var(--text); background: var(--section-bg); }
.preview-row { display: flex; gap: 9px; overflow-x: auto; }
.preview-row .catalog-image { flex: none; width: 76%; max-width: 400px; aspect-ratio: 16 / 10; border-radius: 8px; object-fit: cover; }
.resources-section { scroll-margin-top: calc(12px + var(--safe-top)); }
.resource-tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--separator); }
.resource-tab { position: relative; border: 0; padding: 10px 2px 12px; color: var(--hint); background: transparent; font-weight: 650; cursor: pointer; }
.resource-tab.active { color: var(--text); font-weight: 800; }
.resource-tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; background: var(--primary); }
.resource-panel { min-height: 150px; padding-top: 4px; }
.resource-panel .review-list { padding: 8px 0 0; }
.inline-loading, .empty-inline, .inline-error { display: grid; place-items: center; min-height: 112px; margin: 0; color: var(--hint); text-align: center; }
.inline-error { color: color-mix(in srgb, #d33 76%, var(--text)); }
.detail-pagination { display: flex; align-items: center; justify-content: center; min-height: 48px; gap: 10px; color: var(--hint); font-size: 12px; }
.detail-pagination button { width: 40px; height: 40px; border: 0; padding: 0; color: var(--primary); background: transparent; font-size: 28px; line-height: 1; cursor: pointer; }
.detail-pagination button:disabled { color: var(--separator); cursor: default; }
.magnet-list, .list-cards { display: grid; min-width: 0; }
.magnet-item, .list-card { min-width: 0; max-width: 100%; border: 0; border-bottom: 1px solid var(--separator); border-radius: 0; padding: 13px 0; background: transparent; }
.magnet-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; width: 100%; min-width: 0; gap: 10px; }
.magnet-copy > :first-child { min-width: 0; }
.magnet-copy strong, .magnet-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.magnet-copy span { margin-top: 3px; color: var(--hint); font-size: 11px; }
.magnet-copy-button { border: 0; padding: 9px 4px 9px 12px; color: var(--primary); background: transparent; font-weight: 750; cursor: pointer; }
.list-card { width: 100%; color: inherit; text-align: left; }
.list-card span { display: block; margin-top: 4px; color: var(--hint); font-size: 11px; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); max-width: 86%; border-radius: 999px; padding: 10px 15px; color: white; background: rgba(22, 23, 28, .94); box-shadow: 0 8px 32px rgba(0, 0, 0, .35); font-size: 13px; }
.player-layer { position: fixed; z-index: 60; inset: 0; padding: calc(8px + var(--safe-top)) 10px calc(10px + var(--safe-bottom)); color: #fff; background: #000; }
.player-layer header { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.player-layer video { width: 100%; height: calc(100% - 88px); background: #000; }
.player-status { height: 24px; margin: 8px; color: #aaa; text-align: center; font-size: 12px; }

@media (min-width: 460px) { .movie-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 720px) {
  .app-header, .filter-shell, .featured, .movie-grid, .review-list { padding-left: max(24px, calc((100vw - 980px) / 2)); padding-right: max(24px, calc((100vw - 980px) / 2)); }
  .movie-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .feature-card { flex-basis: calc(43% - 7px); }
  .sheet { left: 50%; width: min(760px, 100%); transform: translateX(-50%); }
}
@media (min-width: 980px) { .movie-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .movie-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
