:root {
  --bg: #14110f;
  --surface: #1f1a17;
  --surface-2: #2b2521;
  --line: #3b332d;
  --text: #f6f0e6;
  --muted: #b9ad9e;
  --accent: #f2b544;
  --accent-ink: #241803;
  --radius: 14px;
  --gutter: clamp(16px, 2.5vw, 40px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Noto Sans TC", "PingFang SC", "Noto Sans SC", "Hiragino Sans", "Noto Sans JP", Thonburi, "Noto Sans Thai", "Myanmar Sangam MN", "Noto Sans Myanmar", "Khmer Sangam MN", "Noto Sans Khmer", "Geeza Pro", "Noto Sans Arabic", sans-serif;
}
html:lang(zh-Hans) body { font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
html:lang(ja) body { font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif; }
html:lang(my) body, html:lang(km) body { line-height: 1.85; }
html:lang(ar) body { line-height: 1.75; }

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.wrap { max-width: 1680px; margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; }
html[dir="rtl"] .flip { transform: scaleX(-1); }

/* 顶部导航 */
.site-head {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  background: rgba(20, 17, 15, .9);
  backdrop-filter: blur(14px);
  border-block-end: 1px solid var(--line);
}
.head-row { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--accent); white-space: nowrap; }
.mark { width: 28px; height: 28px; flex: none; }
.head-nav { display: flex; gap: 4px; }
.head-nav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.head-nav a:hover { color: var(--text); }
.head-nav a.is-on { color: var(--text); background: var(--surface-2); }
.head-end { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  font-weight: 600;
  text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f7c766; }
.btn.ghost { border-color: var(--line); background: rgba(255, 255, 255, .04); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.is-disabled { opacity: .4; }
.scan-btn { white-space: nowrap; min-height: 40px; padding-inline: 16px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}

/* 语言切换 */
.lang { position: relative; }
.lang summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-inline: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
}
.lang summary::-webkit-details-marker { display: none; }
.lang-list {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + 8px);
  display: grid;
  min-width: 210px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.lang-list a { padding: 8px 12px; border-radius: 8px; text-align: start; }
.lang-list a:hover { background: var(--surface-2); }
.lang-list a[aria-current] { color: var(--accent); font-weight: 600; }

/* 首屏轮播 */
.hero { position: relative; height: clamp(400px, 38vw, 640px); overflow: hidden; }
.slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .6s, visibility .6s; }
.slide.is-on { opacity: 1; visibility: visible; }
.slide > .art, .slide > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(20, 17, 15, .92), rgba(20, 17, 15, .45) 55%, rgba(20, 17, 15, .1)), linear-gradient(0deg, var(--bg), transparent 30%);
}
html[dir="rtl"] .slide::after { background: linear-gradient(270deg, rgba(20, 17, 15, .92), rgba(20, 17, 15, .45) 55%, rgba(20, 17, 15, .1)), linear-gradient(0deg, var(--bg), transparent 30%); }
.slide-body { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 14px; height: 100%; padding-block-end: 36px; }
.slide-body h2 { max-width: 16em; font-size: clamp(32px, 5vw, 60px); line-height: 1.15; }
html:lang(my) .slide-body h2, html:lang(km) .slide-body h2, html:lang(th) .slide-body h2, html:lang(ar) .slide-body h2 { line-height: 1.5; }
.slide-body p { max-width: 34em; color: #e4dacb; font-size: 17px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 6px; }
.dots { position: absolute; z-index: 2; inset-block-end: 22px; inset-inline: 0; display: flex; justify-content: center; }
.dot { width: 34px; height: 24px; padding: 0; border: 0; background: none; }
.dot::before { content: ""; display: block; height: 4px; margin-inline: 4px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.dot.is-on::before { background: var(--accent); }

/* 封面与卡片 */
.art { position: relative; width: 100%; height: 100%; }
.art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.poster { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: var(--radius); background: var(--surface-2); }
.poster > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip { position: absolute; inset-block-end: 8px; inset-inline-start: 8px; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .66); font-size: 12px; }
.rank-no { position: absolute; inset-block-start: 0; inset-inline-start: 0; min-width: 34px; padding: 2px 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; text-align: center; border-end-end-radius: 12px; }
.card { display: block; min-width: 0; }
.card .poster { transition: transform .2s; }
.card:hover .poster { transform: translateY(-4px); }
.card h3 { margin-block-start: 10px; font-size: 16px; line-height: 1.4; }
.tags { color: var(--muted); font-size: 13px; }

.block { margin-block-start: 44px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-block-end: 16px; }
.block-head h2 { font-size: clamp(20px, 2.4vw, 26px); }
.more { flex: none; color: var(--accent); font-size: 14px; }
.scroller-wrap { position: relative; }
.scroller { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(168px, 1fr); gap: 16px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller .card { scroll-snap-align: start; }
.arrow { position: absolute; z-index: 2; inset-block-start: 36%; translate: 0 -50%; background: rgba(20, 17, 15, .88); border: 1px solid var(--line); }
.arrow:hover { background: var(--surface-2); }
.arrow[hidden] { display: none; }
.arrow-prev { inset-inline-start: -10px; }
.arrow-next { inset-inline-end: -10px; }
.arrow-next .icon { transform: scaleX(-1); }
html[dir="rtl"] .arrow-prev .icon { transform: scaleX(-1); }
html[dir="rtl"] .arrow-next .icon { transform: none; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }

/* 扫码横幅 */
.band { display: flex; align-items: center; gap: 28px; margin-block-start: 44px; padding: 24px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.band-qr { flex: none; width: 120px; height: 120px; overflow: hidden; border-radius: 10px; }
.band-qr svg { display: block; width: 100%; height: 100%; }
.band h2 { font-size: 22px; }
.band .muted { font-size: 14px; }

/* 分类和榜单 */
.page { padding-block: 32px 16px; }
.page > h1 { font-size: clamp(24px, 3vw, 34px); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 16px 22px; }
.pill { padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 14px; }
.pill:hover { color: var(--text); }
.pill.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.empty { padding-block: 60px; color: var(--muted); text-align: center; }
.rank-list { display: grid; gap: 4px; margin-block-start: 18px; }
.rank-row { display: grid; grid-template-columns: 48px 84px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 12px; border-radius: var(--radius); }
.rank-row:hover { background: var(--surface); }
.rank-num { color: var(--muted); font-size: 24px; font-weight: 800; text-align: center; }
.rank-row:nth-child(-n+3) .rank-num { color: var(--accent); }
.rank-row .poster { border-radius: 10px; }
.rank-text { display: grid; gap: 3px; }
.rank-text h3 { font-size: 17px; }
.rank-text p:not(.tags) { color: #d9cebf; font-size: 14px; }
.rank-heat { color: var(--accent); font-size: 14px; white-space: nowrap; }

/* 详情页 */
.detail { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "poster head" "poster body"; column-gap: 32px; row-gap: 20px; }
.detail-poster { grid-area: poster; align-self: start; }
.detail-head { grid-area: head; }
.detail-head h1 { font-size: clamp(26px, 4vw, 44px); line-height: 1.25; }
.detail-head .tags { margin-block-start: 8px; font-size: 15px; }
.detail-head .pills { margin-block: 14px 0; }
.detail-body { grid-area: body; }
.detail-body h2 { margin-block-end: 8px; font-size: 18px; }
.detail-body .actions { margin-block-start: 22px; }
.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.ep { display: grid; place-items: center; min-height: 44px; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
.ep:hover { background: var(--line); }
.ep.is-off { color: var(--muted); opacity: .6; }
.ep.is-on { background: var(--accent); color: var(--accent-ink); opacity: 1; }

.not-found { padding-block: 100px; display: grid; justify-items: center; gap: 22px; text-align: center; }

.site-foot { margin-block-start: 56px; padding-block: 28px; border-block-start: 1px solid var(--line); font-size: 14px; }
.foot-brand { color: var(--accent); font-weight: 700; font-size: 16px; }
.tabbar { display: none; }

/* 扫码弹窗 */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .72); }
.qr-dialog { width: min(420px, calc(100vw - 32px)); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-align: center; }
.qr-dialog h2 { font-size: 21px; padding-inline: 36px; }
.qr-close { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; }
.qr-label { margin-block-start: 6px; color: var(--accent); }
.qr-code { width: 224px; height: 224px; margin: 18px auto; overflow: hidden; border-radius: 12px; }
.qr-code svg { display: block; width: 100%; height: 100%; }
.qr-noapp { font-weight: 600; }
.qr-dialog .muted { margin-block-start: 4px; font-size: 14px; }
.qr-url { display: flex; gap: 8px; margin-block-start: 18px; }
.qr-url input { flex: 1; min-width: 0; padding-inline: 12px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; font: 13px/1 ui-monospace, Menlo, monospace; }
.qr-url .btn { padding-inline: 14px; white-space: nowrap; }
.qr-here { width: 100%; margin-block-start: 10px; }

/* 手机 H5 播放页 */
body.is-watch { background: #000; }
.watch { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; max-width: 480px; margin-inline: auto; background: #000; }
.watch-top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; }
.watch-title { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.watch-title strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.watch-title span { color: var(--muted); font-size: 13px; }
.stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage video::cue { color: #fff; background: rgba(0, 0, 0, .6); font-size: clamp(15px, 2vh, 24px); }
.stage-msg { padding: 24px; color: var(--muted); text-align: center; }
.watch-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px); }
.ep-sheet { width: min(480px, 100%); max-width: 100%; max-height: 72dvh; margin: auto auto 0; padding: 16px; background: var(--surface); border: 0; border-radius: 18px 18px 0 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-block-end: 12px; }
.sheet-head h2 { font-size: 18px; }
.sub-list { display: grid; gap: 8px; }
.sub-option { min-height: 44px; padding: 8px 14px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; text-align: start; cursor: pointer; }
.sub-option:hover { background: var(--line); }
.sub-option.is-on { background: var(--accent); color: var(--accent-ink); }

@media (min-width: 1400px) {
  .grid-4 .poster { aspect-ratio: 4 / 5; }
}

@media (max-width: 1180px) {
  .scan-btn span { display: none; }
  .scan-btn { padding-inline: 10px; }
}

@media (max-width: 820px) {
  body:not(.is-watch) { padding-block-end: calc(64px + env(safe-area-inset-bottom)); }
  .head-row { min-height: 56px; gap: 12px; }
  .head-nav, .scan-btn, .band, .only-desktop, .arrow { display: none; }
  .lang-name { display: none; }
  .lang summary { padding-inline: 9px; min-height: 40px; }
  .logo { min-width: 0; }
  .logo span { overflow: hidden; text-overflow: ellipsis; }

  .hero { height: min(128vw, 560px); }
  .slide::after, html[dir="rtl"] .slide::after { background: linear-gradient(0deg, var(--bg) 4%, rgba(20, 17, 15, .72) 46%, rgba(20, 17, 15, .05)); }
  .slide-body { justify-content: flex-end; padding-block-end: 44px; }
  .slide-body p { font-size: 15px; }

  .block { margin-block-start: 32px; }
  .scroller { grid-auto-columns: 40vw; gap: 12px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .card h3 { font-size: 15px; }

  .page { padding-block-start: 20px; }
  .rank-row { grid-template-columns: 30px 72px minmax(0, 1fr); gap: 10px; padding: 10px 0; }
  .rank-num { font-size: 20px; }
  .rank-heat { grid-column: 3; }

  .detail { grid-template-columns: 112px minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: "poster head" "body body"; column-gap: 14px; }
  .detail-poster { border-radius: 10px; }
  .detail-body .btn { width: 100%; }
  .detail-body .actions { display: block; }

  .tabbar {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-block-end: env(safe-area-inset-bottom);
    background: rgba(20, 17, 15, .96);
    border-block-start: 1px solid var(--line);
  }
  .tabbar a { display: grid; justify-items: center; gap: 1px; min-width: 0; min-height: 56px; padding: 7px 4px 5px; color: var(--muted); font-size: 11px; line-height: 1.25; text-align: center; }
  .tabbar a span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tabbar a.is-on { color: var(--accent); }
  body.is-watch .tabbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .card .poster { transition: none; }
}
