@font-face {
  font-family: "Moon Song";
  src: url("assets/moon-song.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --paper: #f9eee2;
  --muted: #c5b3b4;
  --rose: #ffb7a4;
  --line: #ffffff1c;
  --frame: min(72rem, 88vw);
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--paper);
  background: #18141b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: radial-gradient(ellipse at 21% 14%, #513a2b80, transparent 45rem),
              radial-gradient(ellipse at 92% 16%, #28283952, transparent 60%);
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner {
  width: var(--frame);
  min-height: 4.5rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: .34rem; }
.brand img { margin-right: .4rem; border-radius: .6rem; }
.fm { font: 600 .78rem/1 ui-monospace, monospace; color: var(--rose); letter-spacing: .08em; }
.wordmark { font: bold 1.75rem/1 Georgia, serif; letter-spacing: -.055em; }
.signal { display: flex; align-items: center; gap: 3px; height: 22px; color: var(--rose); opacity: .7; }
.signal i { width: 2px; height: 6px; border-radius: 2px; background: currentColor; }
.signal i:nth-child(2), .signal i:nth-child(4) { height: 13px; }
.signal i:nth-child(3) { height: 20px; }

.release {
  width: var(--frame);
  margin-inline: auto;
  min-height: calc(100svh - 4.5rem - 1px);
  padding-block: clamp(2rem, 5.5vh, 4rem);
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(0, 1fr);
  grid-template-areas: "art details" "art lyrics" "controls lyrics";
  align-content: center;
  align-items: start;
  gap: 1.2rem clamp(2.25rem, 5.5vw, 5.25rem);
}
.artwork { grid-area: art; align-self: center; position: relative; width: 100%; isolation: isolate; }
.sleeve {
  position: relative;
  width: 84%;
  aspect-ratio: 1;
  background: linear-gradient(115deg, #efddbd, #dcc39e);
  border: 1px solid #f5e6c9;
  border-radius: .18rem;
  overflow: hidden;
  box-shadow: 0 1.5rem 3rem -1rem #070509b8, 5px 2px 9px #06050a73;
}
.cover { display: block; position: absolute; top: 2%; width: 100%; height: 96%; object-fit: contain; }
.record {
  position: absolute;
  right: .3%;
  top: 4%;
  height: 92%;
  aspect-ratio: 1;
  border: 1px solid #61545e;
  border-radius: 50%;
  overflow: hidden;
  background: #121116;
  box-shadow: .2rem .65rem 1.25rem #09070b80;
}
.grooves {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 2px, #ffffff13 2.4px 3px, transparent 3.6px 4.5px),
              conic-gradient(from -20deg, #17141c, #625457 37deg, #17141c 61deg, #242129 110deg, #534851 157deg, #19161d 186deg, #40323a 244deg, #19161d 281deg, #453e46 333deg, #17141c);
}
.details { grid-area: details; min-width: 0; }
.edition { margin-bottom: .6rem; font-size: .9rem; color: var(--rose); letter-spacing: .21em; }
h1 { font: 400 clamp(2.85rem, 5.25vw, 5rem)/1.23 "Moon Song", "Songti SC", "Noto Serif CJK SC", serif; letter-spacing: .018em; }
.artists { margin-top: .82rem; font: italic clamp(1.3rem, 2vw, 1.9rem)/1.3 Georgia, "Times New Roman", serif; color: #dfccc4; }
.artists span { margin-inline: .13em; color: #b59592; }

.player { grid-area: controls; width: 100%; min-width: 0; }
.player audio { width: 100%; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.save-link { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; padding: .7rem 1.3rem; min-height: 3.25rem; border: 1px solid #896c69; border-radius: 2rem; color: #f5dbcf; font-weight: 550; text-decoration: none; }
@media (hover:hover) { .save-link:hover { background: #493335; border-color: var(--rose); } }
.timeline { margin-bottom: 1.45rem; }
#seek {
  --played: 0%;
  display: block;
  appearance: none;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  cursor: pointer;
  border: none;
  outline-offset: -1px;
  background: transparent;
  touch-action: pan-y;
  accent-color: var(--rose);
}
#seek:disabled { cursor: default; }
#seek::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--rose) 0 var(--played), #644f57 var(--played) 100%); }
#seek::-moz-range-track { height: 4px; border-radius: 4px; background: #644f57; }
#seek::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--rose); }
#seek::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; margin-top: -4.5px; border: 0; border-radius: 50%; background: #ffd0bf; }
#seek::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #ffd0bf; }
.times { display: flex; justify-content: space-between; margin-top: -.35rem; color: var(--muted); font: .88rem/1.4 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
#play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 3.25rem;
  min-width: 10rem;
  padding: .7rem 1.55rem;
  border: 1px solid #ffd2c0;
  border-radius: 2rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  background: #f5b5a4;
  color: #341f22;
  box-shadow: 0 5px 20px #0a070b40;
  cursor: pointer;
  touch-action: manipulation;
}
@media (hover:hover) { #play:hover { background: #ffcab8; } }
#play:active { transform: translateY(1px); }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 4px; }
.play-icon { display: block; width: .9rem; height: 1rem; background: currentColor; clip-path: polygon(12% 0, 100% 50%, 12% 100%); }
body.is-playing .play-icon { clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100%, 65% 0); }
.message { margin-top: .9rem; color: var(--muted); font-size: .92rem; }
.message:empty { display: none; }

.lyrics-sheet {
  --inset: clamp(1.15rem, 2.15vw, 2rem);
  grid-area: lyrics;
  align-self: stretch;
  min-width: 0;
  min-height: clamp(17rem, 41svh, 27rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e6d7c2;
  border-radius: .55rem;
  background: #f4ecdf;
  color: #34292b;
  scroll-margin-block-start: 35svh;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; flex: none; gap: .65rem; padding: .45rem var(--inset); border-bottom: 1px solid #d3c3af; }
.sheet-head h2 { font: 400 1.6rem/1.3 "Moon Song", "Songti SC", serif; letter-spacing: .05em; }
#lyric-follow { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 .1rem; border: 0; background: none; color: #70564d; font: inherit; font-size: .875rem; white-space: nowrap; cursor: pointer; }
.switch-track { display: inline-flex; align-items: center; width: 1.52rem; height: .9rem; padding: 2px; border: 1px solid #88766d; border-radius: 2rem; background: #ddd1c3; }
.switch-track::after { content: ""; width: .54rem; height: .54rem; border-radius: 50%; background: #756059; }
#lyric-follow[aria-pressed="true"] .switch-track { justify-content: flex-end; background: #824d43; border-color: #824d43; }
#lyric-follow[aria-pressed="true"] .switch-track::after { background: #fff2e2; }
.lyric-scroll { flex: 1 1 0; height: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #a78672 transparent; }
.lyric-text { padding: 1.15rem var(--inset) 1.5rem; }
.stanza + .stanza { margin-top: 1.5rem; }
.stanza h3 { color: #875144; font-size: .9rem; font-weight: 600; line-height: 1.5; letter-spacing: .055em; margin: 0 0 .5rem -.45em; }
.stanza p { font: 400 clamp(1.1rem, 1.5vw, 1.35rem)/1.85 "Moon Song", "Songti SC", "Noto Serif CJK SC", serif; }
.lyrics-sheet :focus-visible { outline-color: #8c4939; }
.lyric-scroll:focus-visible { outline-offset: -3px; }

#save-dialog { width: min(90vw, 27rem); padding: 1.5rem; color: var(--paper); background: #2a2028; border: 1px solid #72565d; border-radius: 1.15rem; box-shadow: 0 1.25rem 4rem #08060b99; }
#save-dialog:not([open]) { display: none; }
#save-dialog::backdrop { background: #120e16c9; }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-top h2 { font: 400 1.65rem/1.3 "Moon Song", "Songti SC", serif; }
#close-save { background: none; color: var(--paper); border: none; cursor: pointer; font: 1.8rem/1 system-ui; width: 44px; height: 44px; }
#save-dialog p { margin: .85rem 0 0; line-height: 1.7; color: #e0cfd3; }
#save-status { font-size: .94rem; }
#share-file, .file-actions a { font: inherit; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
#share-file { width: 100%; border-radius: 2rem; margin: 1.2rem 0 .25rem; padding: .6rem 1rem; border: 0; cursor: pointer; background: #f5b5a4; color: #341f22; font-weight: 600; }
#share-file:disabled { opacity: .65; cursor: wait; }
.file-actions { display: flex; flex-wrap: wrap; gap: .6rem 1.5rem; margin-top: .6rem; }
.file-actions a { color: #f4c7b8; text-underline-offset: .25em; }

@media (prefers-reduced-motion: no-preference) {
  .grooves { animation: spin 18s linear infinite; animation-play-state: paused; }
  body.is-playing .grooves { animation-play-state: running; }
  body.is-playing .signal i { animation: pulse .85s ease-in-out infinite alternate; }
  body.is-playing .signal i:nth-child(even) { animation-delay: -.46s; }
  body.is-playing .signal i:nth-child(3) { animation-delay: -.25s; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { to { transform: scaleY(.38); } }
}
@media (max-width: 45rem) {
  :root { --frame: min(94vw, 34rem); }
  .masthead-inner { min-height: 3.7rem; }
  .wordmark { font-size: 1.52rem; }
  .brand img { width: 30px; height: 30px; }
  .release { min-height: calc(100svh - 3.7rem - 1px); grid-template-columns: minmax(0, .52fr) minmax(0, 1fr); grid-template-areas: "details details" "art lyrics" "controls controls"; gap: 1.45rem .55rem; padding: 1.5rem 0 max(1.5rem, env(safe-area-inset-bottom)); }
  .artwork { width: 100%; }
  .sleeve { width: 95%; aspect-ratio: 3/4; }
  .record { height: auto; width: 81%; top: 50%; transform: translateY(-50%); }
  .edition { margin-bottom: .5rem; }
  h1 { font-size: clamp(2.65rem, 10.3vw, 3.55rem); }
  .artists { margin-top: .48rem; }
  .lyrics-sheet { --inset: .6rem; height: clamp(14rem, 40svh, 23rem); min-height: 0; }
  .sheet-head { gap: .35rem; padding-block: .1rem; }
  .sheet-head h2 { font-size: 1.18rem; }
  #lyric-follow { gap: .28rem; }
  .lyric-text { padding-block: .75rem 1.15rem; }
  .stanza h3 { font-size: .875rem; margin-bottom: .4rem; }
  .stanza p { font-size: 1rem; line-height: 1.75; text-wrap: balance; }
  .stanza + .stanza { margin-top: 1.1rem; }
  .timeline { margin-bottom: 1rem; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
  #play, .save-link { width: 100%; min-width: 0; padding-inline: .35rem; }
}
@media (max-width: 45rem) and (max-height: 42rem) {
  .release { row-gap: .8rem; padding-block: 1rem; }
  .timeline { margin-bottom: .75rem; }
}
