:root {
  color-scheme: dark;
  --canvas: #101614;
  --surface: #17201c;
  --border: #29352e;
  --text: #f3f3e9;
  --muted: #adb7ac;
  --gold: #f3b951;
  --gold-hover: #ffd27a;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; color: inherit; }
svg { width: 1.25rem; height: 1.25rem; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  z-index: 2;
  inset: .75rem auto auto .75rem;
  padding: .75rem;
  color: #17140c;
  background: var(--gold);
}

.frame { width: min(100% - 6rem, 84rem); margin-inline: auto; }

.site-header { border-bottom: 1px solid #26312a; background: #121916; }
.header-inner { display: flex; align-items: center; min-height: 4.5rem; gap: clamp(1.5rem, 4vw, 3.7rem); }
.wordmark { display: inline-flex; align-items: center; gap: .7rem; white-space: nowrap; font-weight: 750; font-size: 1.35rem; letter-spacing: .02em; }
.wordmark img { width: 2.35rem; height: 2.35rem; border-radius: .72rem; }
.wordmark-tail { color: #e2e8d9; }
.main-nav { display: flex; align-self: stretch; gap: 1.85rem; white-space: nowrap; }
.main-nav button { position: relative; border: 0; padding: 0; color: var(--muted); background: none; font-size: .93rem; font-weight: 600; }
.main-nav button[aria-current] { color: var(--gold); }
.main-nav button[aria-current]::after { position: absolute; content: ""; height: 2px; inset: auto 0 -1px; background: var(--gold); border-radius: 2px; }
.header-actions { display: flex; gap: .8rem; align-items: center; margin-left: auto; }

.search, .collection-button {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 2.6rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  color: var(--muted);
  background: var(--surface);
}

.search { width: clamp(10rem, 19vw, 17.5rem); padding: 0 .65rem 0 .8rem; }
.search:focus-within { border-color: var(--gold); }
.search input { flex: 1; min-width: 0; padding: .4rem 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search input::placeholder { color: var(--muted); font-size: .9rem; }
.search kbd { display: grid; place-items: center; width: 1.35rem; height: 1.4rem; border: 1px solid #425146; border-radius: .3rem; font-size: .82rem; }
.collection-button { padding: .55rem .8rem; color: var(--text); white-space: nowrap; font-size: .88rem; font-weight: 600; }
.collection-button[aria-current], .collection-button:hover { border-color: #5a624d; color: var(--gold); }

.hero {
  position: relative;
  isolation: isolate;
  min-height: clamp(24rem, 33vw, 29.25rem);
  display: flex;
  align-items: center;
  margin-top: 1.8rem;
  overflow: hidden;
  border: 1px solid #3c4538;
  border-radius: 1.15rem;
  background: #202a22;
}

.hero-image, .hero::after { position: absolute; z-index: -1; inset: 0; }
.hero-image { background-size: cover; background-position: center 22%; }
.hero-image.is-poster { background-size: auto max(128%, 40rem); background-position: right 22%; background-repeat: no-repeat; }
.hero::after {
  content: "";
  background: linear-gradient(90deg, #111a15 1%, #111a15ed 22%, #111a158f 41%, #111a150e 65%), linear-gradient(0deg, #0e1512b8, transparent 25%);
}

.hero-content { width: min(100%, 34rem); padding: 2.5rem 0 4rem clamp(2rem, 5.35vw, 5.35rem); }
.hero-kicker { display: flex; align-items: center; gap: .55rem; color: var(--gold); font-size: .88rem; font-weight: 650; letter-spacing: .18em; }
.hero-kicker span { width: .48rem; height: .48rem; border-radius: 50%; background: currentColor; }
.hero h1 { margin: .75rem 0 .75rem; font-size: clamp(3.4rem, 5.4vw, 5.35rem); line-height: 1.12; font-weight: 800; letter-spacing: .035em; text-wrap: balance; }
.hero-meta { margin: 1rem 0 .6rem; color: #e8e9da; font-weight: 650; font-size: .9rem; }
.hero-description { max-width: 23.5rem; margin: .65rem 0 1.6rem; color: #c5cfc3; line-height: 1.75; font-size: 1rem; }
.hero-actions, .detail-actions { display: flex; gap: .7rem; flex-wrap: wrap; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.85rem; padding: .68rem 1.15rem; border: 1px solid transparent; border-radius: .6rem; font-size: .93rem; font-weight: 720; line-height: 1.25; }
.button-primary { color: #191609; background: var(--gold); }
.button-primary:hover { background: var(--gold-hover); }
.button-neutral { color: var(--text); border-color: #586054; background: #202921d9; }
.button-plain { color: var(--text); border-color: var(--border); background: #242d25; }
:is(.button-neutral, .button-plain):hover, [data-save][aria-pressed="true"] { color: var(--gold); border-color: #8b6d36; }

.hero-pagination { display: flex; align-items: center; position: absolute; bottom: 1.1rem; left: clamp(2rem, 5.35vw, 5.35rem); gap: .35rem; }
.hero-pagination button { display: grid; place-items: center; height: 1.5rem; min-width: 1.05rem; border: 0; padding: 0 3px; background: none; }
.hero-pagination button span { width: .45rem; height: .4rem; border-radius: 999px; background: #9caa9e; }
.hero-pagination button[aria-pressed="true"] span { width: 1.75rem; background: var(--gold); }
.hero-pagination button[data-edition] { height: auto; min-height: 1.75rem; padding: .15rem .55rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text); background: var(--surface); font-size: .875rem; }
.hero-pagination button[data-edition][aria-pressed="true"] { color: var(--gold); border-color: #75582d; background: #342b19; }

.library { min-height: 21rem; margin-block: 2.35rem 3.5rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .8rem; }
.section-title h2 { display: inline-flex; align-items: center; gap: .7rem; margin: 0; font-size: clamp(1.45rem, 2.4vw, 1.85rem); font-weight: 760; letter-spacing: .015em; }
.section-title h2::before { content: ""; background: var(--gold); width: .22rem; height: .86em; border-radius: 2px; }
.section-title span { color: var(--muted); font-size: .875rem; }
.sort { display: inline-grid; align-items: center; position: relative; }
.sort select { appearance: none; width: 7.5rem; min-height: 2.35rem; padding: .35rem 1.8rem .35rem .68rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: .55rem; font-size: .875rem; cursor: pointer; }
.sort svg { position: absolute; justify-self: end; right: .45rem; width: 1.05rem; height: 1.05rem; pointer-events: none; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1.1rem 0 1.13rem; }
.filters button { min-height: 2.25rem; border-radius: 999px; padding: .35rem .97rem; color: #c2cbc2; border: 1px solid var(--border); background: var(--surface); font-size: .875rem; white-space: nowrap; }
.filters button:hover { border-color: #687260; }
.filters button[aria-pressed="true"] { color: var(--gold); background: #342b19; border-color: #75582d; }

.poster-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 1.35rem .9rem; }
.poster-card { display: block; min-width: 0; border-radius: .65rem; }
.poster-art { position: relative; overflow: hidden; border: 1px solid #364137; border-radius: .7rem; background: var(--surface); aspect-ratio: 4 / 5; }
.poster-art img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease; }
.poster-card:is(:hover,:focus-visible) img { transform: scale(1.045); }
.episode-count { position: absolute; bottom: .5rem; right: .5rem; padding: .23rem .45rem; border: 1px solid #ffffff23; border-radius: .33rem; color: #f8faef; background: #0c1513db; font-size: .77rem; font-weight: 650; }
.poster-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 2.85rem; height: 2.85rem; opacity: 0; border-radius: 50%; color: #17150c; background: var(--gold); transition: opacity .2s ease; }
.poster-card:is(:hover,:focus-visible) .poster-play { opacity: 1; }
.poster-card h3 { margin: .55rem 0 .15rem; line-height: 1.4; font-size: .98rem; overflow-wrap: anywhere; }
.poster-card:hover h3 { color: var(--gold); }
.poster-card p { margin: 0; color: var(--muted); font-size: .87rem; }
.playable-label { color: var(--gold); }
.empty-state { display: grid; justify-items: center; align-content: center; gap: .65rem; min-height: 15rem; padding: 1.5rem; background: var(--surface); border: 1px dashed #39473b; border-radius: .8rem; text-align: center; color: var(--muted); }

.site-footer { border-top: 1px solid #26312a; color: var(--muted); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding-block: 1.25rem; font-size: .875rem; }
.footer-inner p { display: flex; align-items: center; gap: .65rem; margin: 0; }
.footer-divider { height: .8rem; width: 1px; background: #405045; }

body:has(dialog[open]) { overflow: hidden; }
dialog { width: min(calc(100% - 2rem), 41rem); max-height: calc(100% - 2rem); max-height: calc(100dvh - 2rem); padding: 0; color: var(--text); background: var(--surface); border: 1px solid #4a5241; border-radius: 1rem; }
dialog::backdrop { background: #070c09c4; backdrop-filter: blur(5px); }
.detail-art { position: relative; min-height: 12.5rem; display: flex; align-items: end; overflow: hidden; background: linear-gradient(0deg, #101614 0%, #10161422 100%), var(--detail-cover) center 28% / cover no-repeat; }
.detail-info { position: relative; padding: 1.5rem 1.65rem 1rem; }
.detail-info h2 { margin: .2rem 0 0; line-height: 1.22; font-size: clamp(1.65rem, 4.6vw, 2.45rem); overflow-wrap: anywhere; }
.detail-meta { margin: 0; color: var(--gold-hover); font-size: .88rem; font-weight: 700; }
.close-dialog { position: absolute; z-index: 1; top: .8rem; right: .8rem; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; color: var(--text); border: 1px solid #ffffff55; border-radius: .5rem; background: #101614da; }
.close-dialog:hover { color: var(--gold); }
.detail-content { padding: .75rem 1.65rem 1.5rem; }
.edition-links { display: flex; gap: .5rem; margin: 0 0 .75rem; }
.edition-links .button { min-height: 2.2rem; padding: .35rem .7rem; }
.edition-links [aria-current="page"] { color: var(--gold); border-color: #75582d; background: #342b19; }
.detail-description { margin: .9rem 0 0; color: #c5cfc3; line-height: 1.7; }
.auto-next { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); }
.auto-next input { accent-color: var(--gold); width: 1rem; height: 1rem; }
.episode-heading { display: flex; gap: .65rem; align-items: baseline; }
.episode-heading h3 { margin: 0; font-size: 1.05rem; }
.episode-heading span { color: var(--muted); font-size: .875rem; }
.episode-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.7rem, 1fr)); gap: .45rem; margin: .7rem 0 1.2rem; }
.episode-list button { padding: .55rem .25rem; min-height: 2.55rem; border: 1px solid #3d4b40; border-radius: .45rem; color: var(--text); background: #212d25; }
.episode-list button:enabled:hover, .episode-list button[aria-pressed="true"] { color: var(--gold); border-color: #9c7540; background: #372d1d; }
.episode-list button:disabled { opacity: .5; cursor: default; }
.episode-player { margin-bottom: 1rem; overflow: hidden; border: 1px solid var(--border); border-radius: .65rem; background: #0b100d; }
.episode-player video, .episode-player iframe { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: min(62vh, 26rem); border: 0; object-fit: contain; }
.player-status { margin: 0; padding: .95rem 1rem; color: var(--muted); font-size: .9375rem; }

@media (max-width: 78rem) {
  .poster-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem 1rem; }
}
@media (max-width: 58rem) {
  .frame { width: calc(100% - 3rem); }
  .header-inner { gap: 1.6rem; }
  .main-nav { gap: 1.15rem; }
  .hero-image.is-poster { background-size: auto max(108%, 30rem); }
  .hero-description { max-width: 21rem; }
}
@media (max-width: 47rem) {
  .frame { width: calc(100% - 2rem); }
  .header-inner { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: 3.6rem 2.6rem; gap: 0 .85rem; padding-bottom: .55rem; }
  .wordmark { gap: .4rem; font-size: 1.15rem; }
  .wordmark img { width: 1.95rem; height: 1.95rem; }
  .header-actions { display: contents; }
  .header-inner .search { width: 100%; grid-column: 1 / -1; grid-row: 2; }
  .header-inner .collection-button { grid-column: 3; grid-row: 1; min-height: 2rem; padding: .35rem .5rem; gap: .3rem; font-size: .84rem; }
  .collection-button svg { width: 1rem; height: 1rem; }
  .main-nav { align-self: center; justify-content: center; gap: .8rem; }
  .main-nav button { min-height: 2.2rem; font-size: .86rem; }
  .main-nav button[aria-current]::after { inset: auto 0 1px; }
  .hero { margin-top: 1rem; min-height: 27rem; align-items: end; }
  .hero-image { background-position: 66% 25%; }
  .hero-image.is-poster { background-size: cover; background-position: center 22%; }
  .hero::after { background: linear-gradient(0deg, #101614 3%, #101614ed 23%, #1016148c 49%, #111a1505 80%), linear-gradient(90deg, #111a1555, transparent 69%); }
  .hero-content { padding: 7rem 1.15rem 3rem; width: min(100%, 29rem); }
  .hero h1 { font-size: clamp(2.6rem, 10vw, 3.5rem); }
  .hero-meta { margin-top: .65rem; }
  .hero-description { margin-bottom: 1rem; }
  .hero-pagination { left: 1.15rem; bottom: .55rem; }
  .library { margin-block: 1.65rem 2.5rem; }
  .poster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem .7rem; }
}
@media (max-width: 34rem) {
  .poster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title { gap: 0 .45rem; }
  .sort select { width: 6.75rem; }
  .filters { gap: .4rem; }
  .filters button { padding-inline: .7rem; }
  .footer-inner { flex-wrap: wrap; }
}
@media (max-width: 22rem) {
  .frame { width: calc(100% - 1.25rem); }
  .wordmark { font-size: 1rem; }
  .main-nav { gap: .5rem; }
  .collection-button span { position: absolute; clip-path: inset(50%); }
  .filters { gap: .35rem; }
  .filters button { padding-inline: .62rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
