/* The closing inscription extends the existing locally bundled Ma Shan Zheng (OFL). */
@font-face {
  font-family: BrushFinal; font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/fonts/closing-brush.woff2") format("woff2");
  unicode-range: U+3002,U+5B64,U+6696,U+77E3,U+FF0C;
}
:root {
  color-scheme: dark;
  --paper: #edddc7;
  --ivory: #f6efdf;
  --dim: #c8c2b3;
  --gold: #d0b27b;
  --song: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft Yahei", sans-serif;
  --edge: clamp(18px, 3.8vw, 72px);
}
* { box-sizing: border-box }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #171b1a }
body { font-family: var(--sans); color: var(--ivory); -webkit-font-smoothing: antialiased }
button, input { font: inherit }
button { padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer }
button:disabled { cursor: wait; opacity: .65 }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px }
[hidden], .symbols { display: none !important }
svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none }

.theater { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; isolation: isolate; background: #171b1a; outline: 0 }
#film, #titles, #cover { position: absolute; inset: 0; width: 100%; height: 100% }
#film, #titles { display: block }
#titles { pointer-events: none }
#cover {
  display: flex;
  align-items: center;
  padding: 0 max(7.4vw, env(safe-area-inset-left));
  color: #272a25;
  background: var(--paper);
  isolation: isolate;
}
#cover-art {
  position: absolute; z-index: 0; inset: 0;
  width: 100%; height: 100%; object-fit: cover; object-position: 56% 48%;
}
#cover::before {
  content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgb(244 230 202 / .72), rgb(243 229 202 / .4) 22%, transparent 54%);
}
.cover-copy { position: relative; z-index: 2; max-width: 48vw; margin-bottom: 2vh }
h1 {
  margin: 0 0 0 -.07em; color: #262823;
  font: 400 clamp(70px, 9.3vw, 188px)/1.15 BrushTitle, "Kaiti SC", "STKaiti", var(--song);
  letter-spacing: .025em;
}
.artists { margin: clamp(6px, 1.4vh, 17px) 0 0; color: #53493c; font: 500 clamp(16px, 1.42vw, 25px)/1.45 var(--song); letter-spacing: .15em }
.artists span { padding: 0 .45em; color: #967b58; font-size: .8em }
.start {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 47px; margin-top: clamp(23px, 4.6vh, 54px); padding: 0 24px 0 21px;
  background: #883d30; color: #fff5dc; border: 1px solid #733628; border-radius: 3px;
  font: 600 14px var(--sans); letter-spacing: .16em; transition: background .22s;
}
.start:hover { background: #723326 }
.start svg { width: 14px; height: 14px }
.start:focus-visible { outline-color: #512c22 }

.tools {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + clamp(11px, 2.6vh, 30px)) max(var(--edge), env(safe-area-inset-right)) 16px max(var(--edge), env(safe-area-inset-left));
  pointer-events: none; transition: opacity .38s;
}
.title-mark, .side-actions, .side-actions button { display: flex; align-items: center }
.title-mark { gap: 10px; color: #fff6e5; white-space: nowrap; line-height: 1; text-shadow: 0 1px 6px #0f100feb, 0 0 2px #0b0c0b }
.title-mark .seal { width: 29px; height: 29px; stroke: none; color: #9a4130 }
.title-mark b { font: 600 18px var(--song); letter-spacing: .07em }
#chapter-name { font-size: 11px; letter-spacing: .1em }
#chapter-name::before { content: ""; display: inline-block; vertical-align: middle; height: .9em; margin: 0 10px 0 0; border-left: 1px solid #d4c7af }
.theater:not(.started) .title-mark b, .theater:not(.started) #chapter-name { display: none }
.theater.started .tools { background: linear-gradient(to bottom, #1015149c, transparent) }
.side-actions {
  pointer-events: auto; border: 1px solid #f1e7d53d; border-radius: 4px;
  background: #20231fea; color: #f7eedb;
}
.side-actions button { min-height: 38px; padding: 0 12px; gap: 7px; font: 500 13px var(--sans); letter-spacing: .08em }
.side-actions button + button { position: relative }
.side-actions button + button::before { content: ""; height: 13px; position: absolute; left: 0; border-left: 1px solid currentColor; opacity: .28 }
.side-actions svg { width: 15px; height: 15px }
.side-actions button:hover { background: #ffffff12 }
.theater:not(.started) .side-actions { color: #372f26; border-color: #8e745262; background: #f2e6d3f2 }
.theater:not(.started) .side-actions button:hover { background: #bba88c47 }

#controls {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  visibility: hidden; opacity: 0; pointer-events: none;
  padding: 24px max(var(--edge), env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left));
  background: linear-gradient(0deg, #0e1413cf, #0e141373 48%, transparent); transition: opacity .34s;
}
.theater.started #controls { visibility: visible; opacity: 1 }
.transport { display: flex; align-items: center; gap: clamp(3px, .7vw, 11px); color: #fff8e9; text-shadow: 0 1px 4px #151411 }
.spacer { flex: 1 }
.icon-button { display: grid; place-items: center; min-width: 40px; height: 40px; pointer-events: auto; border-radius: 3px }
.icon-button:hover { background: #ffffff20 }
.icon-button svg { width: 19px; height: 19px }
.time { display: flex; gap: 7px; align-items: center; font: 500 12px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums }
.time b { font-weight: 400; opacity: .55 }
#length { color: #dfd8c7 }
.lyric-icon { padding: 2px 3px; border: 1px solid currentColor; border-radius: 2px; font: 600 12px/1 var(--song) }
#lyrics[aria-pressed=false] { opacity: .5 }
.theater.quiet #controls, .theater.quiet .tools { opacity: 0 }
.theater.quiet .icon-button, .theater.quiet .side-actions { pointer-events: none }
.theater.quiet { cursor: none }
.error { position: absolute; z-index: 5; bottom: 15%; left: 50%; transform: translateX(-50%); font: 14px/1.6 var(--sans); width: max-content; max-width: min(88%, 520px); margin: 0; padding: 9px 15px; border: 1px solid #9a7f55; background: #262923ed; border-radius: 3px }

dialog { color: var(--ivory); background: #282b26; border: 1px solid #84775d; border-radius: 5px; width: min(88vw, 560px); max-height: 84vh; max-height: 84dvh; overflow: auto; padding: 0; box-shadow: 0 18px 90px #08090677 }
dialog::backdrop { background: #080b09a8; backdrop-filter: blur(3px) }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 23px; border-bottom: 1px solid #d8caa52c }
.dialog-close { display: grid; place-items: center; width: 34px; height: 34px }
.dialog-close svg { width: 17px; height: 17px }
dialog article { padding: 10px 25px 23px }
h2 { margin: 0; font: 600 21px/1.5 var(--song); letter-spacing: .08em }
dialog article p { font: 15px/1.95 var(--song); color: #e6e1d2 }
.byline { font: 12px var(--sans); color: var(--dim) }
.chapter-row { display: flex; gap: 14px; align-items: center; padding: 13px 3px; width: 100%; border-bottom: 1px solid #d8caa522; text-align: left }
.chapter-row small { font: 12px var(--song); color: #bcad90 }
.chapter-row strong { font: 600 17px var(--song); letter-spacing: .06em }
.chapter-row time { margin-left: auto; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: #bfb9a9 }
.chapter-row[aria-current=true] strong, .chapter-row:hover strong { color: #ebcc92 }
.track-current, .track-actions, #track-form, .url-row { display: flex; gap: 10px }
.track-current { flex-direction: column; font: 13px var(--sans) }
.track-actions { margin-bottom: 20px; flex-wrap: wrap }
.outline-button { padding: 7px 12px; border: 1px solid #b3a57a70; border-radius: 3px; font: 13px var(--sans); cursor: pointer }
#track-form { flex-direction: column; font-size: 13px }
.url-row input { min-width: 28px; flex: 1; background: #33372d; color: var(--ivory); border: 1px solid #b3a57a70; padding: 8px }
.url-row button { flex: none }
#track-status { font: 13px/1.65 var(--sans); color: var(--gold) }

/* Preserve a readable paper margin when a nearly square screen crops the panoramic cover. */
@media (min-aspect-ratio: 1/1) and (max-aspect-ratio: 8/5) {
  #cover-art {
    left: 12%; width: 88%; object-position: 61% 47%;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 29%);
    mask-image: linear-gradient(90deg, transparent, #000 29%);
  }
}
@media (max-aspect-ratio: 1/1) {
  #cover { align-items: flex-end; padding-bottom: max(8vh, env(safe-area-inset-bottom)); background: linear-gradient(115deg, #f0dfc6, #e6cfaf) }
  #cover-art { left: 0; width: 100%; height: 76%; object-position: 67% 45%; -webkit-mask-image: linear-gradient(#000 72%, transparent); mask-image: linear-gradient(#000 72%, transparent) }
  #cover::before { display: none }
  .cover-copy { max-width: none; margin: 0 }
  h1 { font-size: clamp(70px, 13.8vw, 130px) }
  .artists { margin-top: 2px }
  .start { margin-top: 20px }
}
@media (max-width: 620px) {
  :root { --edge: 15px }
  .title-mark { gap: 6px }
  .title-mark b { font-size: 15px }
  .title-mark .seal { width: 25px; height: 25px }
  #chapter-name { font-size: 10px; letter-spacing: 0 }
  #chapter-name::before { margin-right: 6px }
  .side-actions button { gap: 4px; min-height: 36px; padding: 0 9px; font-size: 12px }
  .side-actions svg { width: 14px; height: 14px }
  #controls { padding-top: 18px }
  .transport { gap: 1px }
  .time { gap: 5px; font-size: 11px }
  dialog article { padding: 8px 19px 16px }
  .dialog-head { padding: 10px 17px }
}
@media (max-height: 500px) and (orientation: landscape) {
  h1 { font-size: clamp(55px, 18vh, 85px) }
  .cover-copy { margin: 0 }
  .start { min-height: 36px; margin-top: 14px }
  .tools { padding-top: max(6px, env(safe-area-inset-top)) }
  #controls { padding-top: 7px; padding-bottom: max(3px, env(safe-area-inset-bottom)) }
}
@media (pointer: coarse) {
  .side-actions button, .icon-button { min-height: 44px; min-width: 44px }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important } }
