:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b6f76;
  --line: #e4ded4;
  --accent: #c2410c;
  --accent-soft: #fbe6d9;
  --track: #e8e2d8;
  --danger: #c0392b;
  --shadow: 0 6px 20px rgba(60, 40, 20, 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16191d;
    --card: #20252b;
    --text: #eceff2;
    --muted: #9aa3ad;
    --line: #2f363e;
    --accent: #f08a4b;
    --accent-soft: #3a2a20;
    --track: #343b43;
    --danger: #ff7b6e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
}

.top h1 { margin: 0; font-size: 24px; }

.add-button {
  position: relative;
  overflow: hidden;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.add-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  font-size: 0;
  cursor: pointer;
}

main { padding: 0 16px 32px; }

.player {
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.resume-hint {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.now-title {
  margin: 0 0 14px;
  font-size: 19px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.seek {
  --fill: 0%;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--track) var(--fill));
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
}

.seek::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
.seek::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.seek::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--accent); }
.seek:disabled { opacity: 0.4; }

.times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin: 14px 0 12px;
}

.ctl {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.ctl small { font-size: 11px; color: var(--muted); margin-top: 1px; }
.ctl .jump { font-size: 26px; }
.ctl.small { width: 44px; height: 44px; font-size: 20px; color: var(--muted); }
.ctl:disabled { opacity: 0.3; }

.ctl.play {
  width: 68px;
  height: 68px;
  background: var(--accent);
  color: #fff;
}

.ctl.play svg { width: 34px; height: 34px; fill: currentColor; }
.ctl.play .icon-pause { display: none; }
.ctl.play.playing .icon-pause { display: block; }
.ctl.play.playing .icon-play { display: none; }

.options { display: flex; gap: 10px; }

.chip {
  flex: 1;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.library { margin-top: 22px; }

.library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.library-head h2 { margin: 0 0 8px; font-size: 17px; }
.storage-info { color: var(--muted); font-size: 13px; }

.import-status {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.track-list { margin: 0; padding: 0; list-style: none; }

.track {
  display: flex;
  align-items: stretch;
  margin-bottom: 8px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.track.current { border-color: var(--accent); }

.track-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 4px 12px 14px;
  border: none;
  background: transparent;
  text-align: left;
}

.track-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.track.playing .track-name::before { content: "▶ "; color: var(--accent); }
.track-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.track.done .track-meta { color: #2e8b57; }

.track-bar {
  display: block;
  height: 4px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}

.track-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.track.done .track-bar span { background: #2e8b57; }

.track-more {
  flex: 0 0 48px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.empty {
  padding: 18px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.empty p { margin: 0 0 8px; }
.empty .tip { color: var(--text); }
.version { margin-top: 24px; text-align: center; color: var(--muted); font-size: 12px; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.4);
}

.sheet[hidden] { display: none; }

.sheet-panel {
  width: 100%;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--card);
}

.sheet-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
  text-align: center;
  overflow-wrap: anywhere;
}

.sheet-options { display: grid; gap: 8px; }

.sheet-options button, .sheet-cancel {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: 16px;
}

.sheet-options button.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sheet-options button.danger { color: var(--danger); }
.sheet-cancel { margin-top: 12px; border: none; background: transparent; color: var(--muted); }

.update-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.update-bar[hidden] { display: none; }

.update-bar button {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}
