:root {
  color-scheme: dark;
  --page: #101619;
  --text: #e4e5dd;
  --muted: #a2aea9;
  --line: #2d3738;
  --gold: #dfc598;
  --serif: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", STSong, SimSun, serif;
  font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--page); }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.masthead, main { width: min(1100px, calc(100% - 96px)); margin: 0 auto; }
.masthead { display: flex; justify-content: space-between; align-items: center; padding: 27px 0 25px; }
.brand, .lamp, .setting-title, .player-strip { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand b { font: 600 24px/1.2 var(--serif); letter-spacing: .08em; }
.brand span { margin: 4px 0 0 1px; font: italic 16px/1.2 Georgia, serif; color: #b5b6a8; }
.lamp {
  gap: 7px; min-height: 40px; padding: 5px 15px; background: #182023;
  border: 1px solid #354041; color: #d4d8cf; border-radius: 24px; font-size: 14px;
}
.lamp svg, .setting-title svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lamp:hover, .durations button:hover { background: #2b3332; color: #f0e8d9; }
main { padding-bottom: max(35px, env(safe-area-inset-bottom)); }
.player { border-radius: 13px; overflow: hidden; background: #192124; border: 1px solid #364042; }
#window-scene { position: relative; width: 100%; aspect-ratio: 2.52; overflow: hidden; isolation: isolate; background-color: #25313d; }
.player-strip { min-height: 100px; gap: 20px; padding: 19px 30px; border-top: 1px solid #394142; }
.play {
  flex: none; display: grid; place-content: center; width: 54px; height: 54px; padding: 0;
  border: 1px solid #e3cda9; background: var(--gold); color: #2b2d27; border-radius: 50%;
}
.play:hover { background: #edd8b3; }
.play:active { transform: scale(.96); }
.play svg { grid-area: 1 / 1; width: 25px; height: 25px; fill: currentColor; }
.play-icon { margin-left: 1px; }
.pause-icon, .is-playing .play-icon { visibility: hidden; }
.is-playing .pause-icon { visibility: visible; }
.track { min-width: 0; }
.track h1 { font: 500 clamp(24px, 2.25vw, 31px)/1.25 var(--serif); letter-spacing: .09em; margin: 0 0 3px; }
.track-status, .range-ends, .timer-note { font-size: 12px; color: var(--muted); }
.meter { margin-left: auto; height: 36px; display: flex; align-items: center; gap: 3px; color: #a69a80; }
.meter i { width: 2px; height: 8px; border-radius: 3px; background: currentColor; }
.meter i:nth-child(3n) { height: 15px; }
.meter i:nth-child(4n) { height: 24px; }
.meter i:nth-child(5n) { height: 12px; }
.meter i:nth-child(7n) { height: 31px; }
.is-playing .meter i { animation: sound 1.6s ease-in-out infinite alternate; }
.meter i:nth-child(2n) { animation-delay: -.7s; }
.meter i:nth-child(3n) { animation-delay: -1.15s; }
@keyframes sound { from { transform: scaleY(.46); } to { transform: scaleY(1); } }
.settings { display: grid; grid-template-columns: 1fr 1fr; margin-top: 29px; padding: 13px 0; }
.setting { min-width: 0; }
.opening-setting { padding: 0 46px 0 4px; }
.timer-setting { padding: 0 4px 0 46px; border-left: 1px solid var(--line); }
.setting-title { gap: 9px; margin-bottom: 14px; }
.setting-title svg { color: #b8a987; }
.setting-title label, .setting-title h2 { margin: 0; font-size: 16px; font-weight: 550; letter-spacing: .06em; }
.setting-title output { margin-left: auto; font: 14px/1.5 ui-monospace, Consolas, monospace; color: #d8c59f; }
#opening { --opening: 45%; display: block; appearance: none; background: transparent; margin: 0; width: 100%; height: 40px; cursor: pointer; touch-action: pan-y; }
#opening::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, #c6ae83 var(--opening), #344043 var(--opening)); }
#opening::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--gold); border: 2px solid #f0d9b3; box-shadow: 0 0 0 4px #bfa57c18; }
#opening::-moz-range-track { height: 4px; border-radius: 4px; background: #344043; }
#opening::-moz-range-progress { height: 4px; background: #c6ae83; }
#opening::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--gold); border: 2px solid #f0d9b3; }
.range-ends { display: flex; justify-content: space-between; margin-top: 4px; }
.durations { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.durations button {
  font-size: 14px; white-space: nowrap; min-height: 40px; padding: 3px 2px;
  border: 1px solid #344042; border-radius: 7px; background: #1c2427; color: #c7cfca;
}
.durations button[aria-pressed="true"] { color: #e6cc9f; background: #322f28; border-color: #7b6d54; }
.timer-note { margin: 7px 0 0; }
#remaining { font-variant-numeric: tabular-nums; }
#remaining:not([hidden])::after { content: " · "; }
#night { max-width: none; max-height: none; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: #000; }
#night::backdrop { background: #000; }
#wake { width: 100%; height: 100%; background: #000; border: 0; outline-offset: -5px; color: #adb1af; }
#wake span { opacity: 0; font-size: 14px; }
#night[open] #wake span { animation: goodnight 2.8s forwards; }
body:has(#night[open]) .meter i, body:has(#night[open]) .scene-runner { animation-play-state: paused; }
@keyframes goodnight { 0%, 50% { opacity: .82; } 100% { opacity: 0; } }
@media (max-width: 800px) {
  .masthead, main { width: calc(100% - 48px); }
  .opening-setting { padding-right: 22px; }
  .timer-setting { padding-left: 22px; }
}
@media (max-width: 640px) {
  .masthead, main { width: calc(100% - 32px); }
  .masthead { padding: max(16px, env(safe-area-inset-top)) 1px 17px; }
  .brand { gap: 8px; }
  .brand img { width: 25px; height: 30px; }
  .brand b { font-size: 21px; }
  .brand span { font-size: 14px; }
  .lamp { min-height: 42px; }
  #window-scene { aspect-ratio: 1.42; }
  .player-strip { min-height: 87px; padding: 14px 17px; gap: 14px; }
  .play { width: 49px; height: 49px; }
  .settings { grid-template-columns: 1fr; padding: 0 3px; margin-top: 25px; }
  .opening-setting { padding: 0 0 19px; }
  .timer-setting { padding: 19px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .setting-title { margin-bottom: 6px; }
  .timer-setting .setting-title { margin-bottom: 13px; }
  .durations button { min-height: 43px; }
}
@media (prefers-reduced-motion: reduce) {
  .is-playing .meter i { animation: none; }
  #night[open] #wake span { animation: goodnight 2.8s steps(1) forwards; }
}
