:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b202b;
  --line: #293040;
  --text: #eef1f7;
  --muted: #98a2b6;
  --accent: #ff6b4a;
  --accent-2: #7c8cff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: radial-gradient(1100px 500px at 12% -10%, #21283b 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: manipulation;
}

.wrap { width: min(1200px, calc(100% - 32px)); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.site-header {
  border-bottom: 1px solid var(--line); background: #0c0f16cc;
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; gap: 20px; padding: 20px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.lang-select { position: relative; flex: 0 0 auto; margin-left: auto; }
.lang-button {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.lang-button:hover { border-color: #3b455c; }
.lang-arrow { color: var(--muted); font-size: 10px; }
.lang-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; min-width: 140px;
  padding: 5px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: 0 12px 28px #0009;
}
.lang-menu[hidden] { display: none; }
.lang-option {
  display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); text-align: left; font: inherit; font-size: 13px; cursor: pointer;
}
.lang-option:hover { background: var(--panel-2); }
.lang-option.is-active { color: var(--accent); font-weight: 700; }

.settings { position: relative; flex: 0 0 auto; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  color: var(--text); font: inherit; font-size: 16px; cursor: pointer;
}
.icon-button:hover { border-color: #3b455c; }
.icon-button[hidden] { display: none; }
.settings-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; width: 230px;
  padding: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: 0 12px 28px #0009;
}
.settings-menu[hidden] { display: none; }
.setting-label {
  display: block; margin-bottom: 6px; color: var(--muted);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.browser-select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px;
}
.setting-hint { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.setting-version { margin: 8px 0 0; color: var(--muted); font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.brand-mark {
  flex: 0 0 44px; display: grid; place-items: center; width: 44px; height: 44px;
  aspect-ratio: 1 / 1; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #ff9c53); color: #17110d; font-size: 18px; padding-left: 3px;
}
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.brand p, .muted { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

input[type="search"] {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font: inherit; outline: none;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.recent { margin: 8px 0 2px; }
.recent[hidden] { display: none; }
.recent h2 { margin: 0 0 10px; font-size: 15px; }
.recent-track {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 0; padding: 2px 0 6px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; -ms-overflow-style: none;
}
.recent-track::-webkit-scrollbar { display: none; width: 0; height: 0; }
.recent-card {
  flex: 0 0 230px; display: flex; align-items: center; gap: 10px; padding: 7px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  color: var(--text); text-decoration: none; scroll-snap-align: start;
}
.recent-card:hover { border-color: #3b455c; }
.recent-card img, .recent-thumb {
  flex: 0 0 auto; width: 54px; height: 78px; border-radius: 7px;
  object-fit: cover; background: var(--panel-2);
}
.recent-thumb { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.recent-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.recent-kind { color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.recent-title {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  font-size: 13px; font-weight: 600; line-height: 1.3;
}

.toolbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 28px 0 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tab {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px;
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.search { position: relative; }
.search input { width: min(380px, 100%); padding-right: 42px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.search-clear:hover { color: var(--text); }
.search-clear[hidden] { display: none; }

.status { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.loading { display: grid; place-items: center; min-height: 50vh; }
.loading[hidden] { display: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card {
  position: relative; aspect-ratio: 2 / 3; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 0; overflow: hidden;
}
.card:hover { border-color: #3b455c; }
.poster {
  position: absolute; inset: 0; display: block; background: var(--panel-2);
  overflow: hidden; color: var(--muted);
}
.poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.poster.is-empty { display: grid; place-items: center; font-size: 34px; background: linear-gradient(150deg, #232a3a, #151922); }
.card-body {
  position: absolute; z-index: 1; left: 8px; right: 8px; bottom: 8px;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 11px;
  background: rgba(9, 12, 18, .76);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.card-top {
  position: absolute; z-index: 2; top: 8px; left: 8px; right: 8px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.kind, .year {
  padding: 4px 7px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(9, 12, 18, .72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: 10px; line-height: 1.25;
}
.kind { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.year { color: var(--text); font-variant-numeric: tabular-nums; }
.card h3 {
  margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card a { color: var(--accent-2); font-size: 12px; text-decoration: none; }
.card a:hover { text-decoration: underline; }
.card .title-link { color: var(--text); font-size: 14px; }
.card .title-link:hover { color: var(--accent); text-decoration: none; }
.card a.play {
  display: block; width: 100%; margin-top: 2px; border-radius: 8px; padding: 8px 10px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; text-align: center;
}
.play:hover { filter: brightness(1.08); text-decoration: none; }

.more {
  display: block; margin: 24px auto; padding: 11px 22px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; cursor: pointer;
}
.more:hover { border-color: var(--accent-2); }

body.detail-open .site-header, body.detail-open .footer { display: none; }
.detail {
  min-height: 100vh; min-height: 100dvh;
  padding-top: env(safe-area-inset-top); padding-bottom: 20px;
}
.back { display: inline-block; margin: 24px 0 18px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back:hover { color: var(--text); }
.detail-head { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.detail-poster {
  flex: 0 0 auto; width: 180px; aspect-ratio: 2 / 3; display: grid; place-items: center;
  border-radius: 12px; overflow: hidden; background: var(--panel-2); color: var(--muted); font-size: 34px;
}
.detail-poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 220px; padding-top: 4px; }
.detail-info h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.02em; }
.resume-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.resume {
  display: inline-flex; align-items: center; padding: 9px 13px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700; text-decoration: none;
}
.resume:hover { filter: brightness(1.08); text-decoration: none; }
.resume.is-secondary {
  background: transparent; border: 1px solid var(--line); color: var(--text);
}
.resume.is-secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.resume[hidden] { display: none; }
.overview {
  margin: 18px 0 0; max-width: 900px;
  color: var(--text); font-size: 14px; line-height: 1.65;
}
.overview[hidden] { display: none; }
.trailer {
  position: relative; margin-top: 18px; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 12px; background: #000; border: 1px solid var(--line);
}
.trailer[hidden] { display: none; }
.trailer iframe { display: block; width: 100%; height: 100%; border: 0; }
.season { margin-top: 28px; }
.season h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 16px; }
.season .count { color: var(--muted); font-size: 12px; font-weight: 400; }
.episode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.episode {
  display: block; padding: 10px 6px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--text); text-align: center; text-decoration: none;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.episode:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.episode.is-current {
  border-color: var(--accent); color: var(--accent);
  background: rgba(255, 107, 74, .12); box-shadow: inset 0 0 0 1px var(--accent);
}

.footer {
  border-top: 1px solid var(--line); margin-top: 34px; color: var(--muted); font-size: 12px;
  padding: 22px 0 calc(40px + env(safe-area-inset-bottom));
}
.footer p { margin: 4px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 620px) {
  .header-inner { gap: 10px; }
  .toolbar { flex-direction: column-reverse; align-items: stretch; }
  .tabs { align-self: center; }
  .search input { width: 100%; }
  .recent { margin-inline: calc(50% - 50vw); }
  .recent h2 { padding-inline: 16px; }
  .recent-track { padding-inline: 16px; scroll-padding-inline: 16px; }
  .recent-card { flex-basis: calc(50% - 12px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .detail-poster { width: 130px; }
}
