:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: rgba(255, 253, 247, 0.78);
  --panel-strong: rgba(255, 252, 242, 0.94);
  --text: #22221d;
  --muted: #827c6f;
  --line: rgba(89, 77, 55, 0.15);
  --accent: #53765f;
  --accent-strong: #3e6f52;
  --accent-soft: rgba(83, 118, 95, 0.13);
  --gold: #b58a43;
  --shadow: 0 18px 50px rgba(65, 52, 29, 0.08);
  --ring: rgba(83, 118, 95, 0.24);
  --center-art: url("./medal-eye.png");
  --sound-glow: rgba(83, 118, 95, 0.2);
  --texture: radial-gradient(circle at 18% 12%, rgba(83, 118, 95, 0.08), transparent 28%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(244, 236, 222, 0.72));
}

:root[data-theme="day"] {
  --bg: #f4f5f1;
  --panel: rgba(255, 255, 252, 0.76);
  --panel-strong: rgba(255, 255, 252, 0.94);
  --text: #202224;
  --muted: #7b807d;
  --line: rgba(67, 77, 82, 0.14);
  --accent: #b9904b;
  --accent-strong: #9d7131;
  --accent-soft: rgba(185, 144, 75, 0.13);
  --gold: #b9904b;
  --shadow: 0 20px 60px rgba(71, 75, 74, 0.09);
  --ring: rgba(185, 144, 75, 0.25);
  --center-art: url("./medal-day.png");
  --sound-glow: rgba(185, 144, 75, 0.22);
  --texture: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(235, 238, 235, 0.82)),
    radial-gradient(circle at 78% 28%, rgba(185, 144, 75, 0.12), transparent 34%);
}

:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #101211;
  --panel: rgba(22, 24, 23, 0.78);
  --panel-strong: rgba(25, 27, 26, 0.94);
  --text: #f1e6ce;
  --muted: #a79a81;
  --line: rgba(223, 183, 103, 0.2);
  --accent: #d4aa5c;
  --accent-strong: #f0c979;
  --accent-soft: rgba(212, 170, 92, 0.16);
  --gold: #d4aa5c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.33);
  --ring: rgba(212, 170, 92, 0.3);
  --center-art: url("./medal-night.png");
  --sound-glow: rgba(240, 201, 121, 0.55);
  --texture: linear-gradient(135deg, rgba(31, 35, 33, 0.92), rgba(12, 14, 13, 0.98)),
    radial-gradient(circle at 70% 30%, rgba(212, 170, 92, 0.14), transparent 32%);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  height: 100vh;
  padding: 12px;
  background: var(--texture);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.topbar,
.library,
.stage,
.side-panel,
.transport {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.topbar {
  min-height: 64px;
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 500;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-strong);
}

.mode-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.player-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 12px;
}

.library,
.stage,
.side-panel {
  min-height: 0;
  border-radius: 22px;
}

.library {
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
}

.library-head span:last-child {
  color: var(--muted);
  font-weight: 500;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

.track-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
  padding-bottom: 4px;
}

.track-item {
  width: 100%;
  min-height: 66px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
}

.track-item:hover,
.track-item.is-active {
  border-color: var(--line);
  background: var(--panel-strong);
}

.track-item.is-active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.track-number,
.track-duration,
.track-copy small {
  color: var(--muted);
}

.track-copy {
  min-width: 0;
}

.track-copy strong,
.track-copy small {
  display: block;
}

.track-copy strong {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.25;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 17px;
  font-weight: 500;
}

.track-copy small {
  margin-top: 4px;
  font-size: 11px;
}

.track-duration {
  font-size: 13px;
}

.stage {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 3vw, 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 22px;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background:
    linear-gradient(transparent 62%, rgba(128, 128, 128, 0.08)),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(128, 128, 128, 0.035) 46px 47px);
}

.stage-top,
.timeline,
.resonance {
  position: relative;
  z-index: 1;
}

.stage-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-weight: 500;
  letter-spacing: 0;
  font-size: clamp(34px, 4.6vw, 64px);
  line-height: 1.05;
}

.track-meta {
  margin: 12px 0 0;
  color: var(--muted);
}

.ghost-button,
.play-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  cursor: pointer;
}

.ghost-button {
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  white-space: nowrap;
}

.ghost-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.resonance {
  min-height: clamp(240px, 36vh, 330px);
  display: block;
  overflow: hidden;
}

.resonance::before {
  content: "";
  position: absolute;
  inset: 9% 2% 13%;
  opacity: 0.72;
  background:
    radial-gradient(ellipse at 76% 62%, color-mix(in srgb, var(--accent) 14%, transparent) 0 14%, transparent 36%),
    radial-gradient(ellipse at 60% 70%, color-mix(in srgb, var(--gold) 13%, transparent) 0 20%, transparent 44%),
    linear-gradient(115deg, transparent 0 44%, color-mix(in srgb, var(--gold) 18%, transparent) 50%, transparent 58%),
    linear-gradient(245deg, transparent 0 42%, color-mix(in srgb, var(--accent) 14%, transparent) 50%, transparent 59%);
  clip-path: polygon(0 64%, 11% 58%, 21% 66%, 34% 48%, 45% 60%, 58% 42%, 70% 56%, 82% 36%, 100% 58%, 100% 100%, 0 100%);
  filter: blur(0.4px);
}

:root[data-theme="night"] .resonance::before {
  opacity: 0.5;
  background:
    radial-gradient(circle at 50% 42%, rgba(212, 170, 92, 0.2), transparent 28%),
    linear-gradient(90deg, transparent, rgba(240, 201, 121, 0.24), transparent);
  clip-path: none;
}

.resonance-mark {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 45%;
  width: min(21vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ring) 62%, transparent);
  background:
    radial-gradient(circle, color-mix(in srgb, var(--panel-strong) 72%, transparent), transparent 72%),
    var(--center-art) center / cover no-repeat;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 18px color-mix(in srgb, var(--ring) 16%, transparent),
    0 0 0 42px color-mix(in srgb, var(--ring) 9%, transparent),
    0 18px 42px rgba(0, 0, 0, 0.08);
}

.resonance-mark::before,
.resonance-mark::after {
  content: "";
  position: absolute;
  border: 1px solid var(--ring);
  border-radius: 50%;
}

.resonance-mark::before {
  inset: -18%;
}

.resonance-mark::after {
  inset: -34%;
  border-style: dotted;
  opacity: 0.7;
}

.resonance-mark span {
  position: absolute;
  width: 1px;
  height: 150%;
  background: var(--ring);
  transform-origin: center;
  opacity: 0.45;
}

.resonance-mark span:nth-child(2) {
  transform: rotate(60deg);
}

.resonance-mark span:nth-child(3) {
  transform: rotate(120deg);
}

.waveform {
  position: absolute;
  z-index: 1;
  left: 7%;
  right: 7%;
  top: 45%;
  height: 116px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(3px, 0.45vw, 7px);
  filter: drop-shadow(0 0 10px var(--sound-glow));
}

.waveform::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 48%, transparent), transparent);
}

.waveform span {
  width: clamp(2px, 0.35vw, 5px);
  height: var(--h);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0.58;
  transform-origin: center;
}

:root[data-theme="night"] .waveform span {
  background: color-mix(in srgb, var(--accent-strong) 78%, transparent);
  opacity: 0.74;
}

.is-playing .waveform span {
  animation: breathe 1.35s ease-in-out infinite alternate;
  animation-delay: var(--d);
}

@keyframes breathe {
  from {
    transform: scaleY(0.68);
    opacity: 0.45;
  }
  to {
    transform: scaleY(1.08);
    opacity: 0.9;
  }
}

.timeline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --value: 0%;
  width: 100%;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0 var(--value),
    color-mix(in srgb, var(--muted) 24%, transparent) var(--value) 100%
  );
  border: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -8px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 24%, transparent);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

.side-panel {
  display: none;
}

.side-block {
  border-bottom: 1px solid var(--line);
  padding: 0 0 16px;
  display: grid;
  gap: 8px;
}

.side-block:last-child {
  border-bottom: 0;
}

.side-label {
  color: var(--muted);
  font-size: 13px;
}

.side-block strong {
  font-size: 20px;
  font-weight: 600;
}

.transport {
  border-radius: 20px;
  padding: 12px 18px;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 18px;
}

.mini-now {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.mini-now span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 18px;
}

.mini-now small,
.transport-volume span {
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.play-button {
  min-width: 92px;
  height: 58px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.transport-volume {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

@media (max-width: 1040px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto;
  }

  .player-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .library {
    max-height: 310px;
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .side-block {
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 0 14px 0 0;
  }

  .side-block:last-child {
    border-right: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
    padding-bottom: 96px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    border-radius: 16px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-button {
    padding: 10px 8px;
  }

  .library {
    max-height: 270px;
    border-radius: 16px;
  }

  .stage {
    border-radius: 16px;
    min-height: 430px;
  }

  .stage-top {
    display: grid;
  }

  h2 {
    font-size: clamp(36px, 12vw, 54px);
  }

  .resonance {
    min-height: 250px;
  }

  .resonance-mark {
    width: min(44vw, 170px);
  }

  .waveform {
    left: 4%;
    right: 4%;
    height: 92px;
    gap: 2px;
  }

  .waveform span {
    width: 3px;
  }

  .side-panel {
    display: none;
  }

  .transport {
    position: fixed;
    z-index: 8;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 76px;
    padding: 10px 12px;
  }

  .transport-volume {
    display: none;
  }

  .controls {
    gap: 8px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .play-button {
    min-width: 72px;
    height: 48px;
  }
}
