:root {
  --bg: #ebebe8;
  --surface: #f6f6f4;
  --ink: #0b0b0b;
  --mute: #9b9b97;
  --line: #d4d4d0;
  --red: #ff3b2f;
  --inv-bg: #0b0b0b;
  --inv-ink: #f6f6f4;
  --inv-mute: #6d6d69;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b;
    --surface: #161616;
    --ink: #f2f2ef;
    --mute: #6f6f6b;
    --line: #262626;
    --inv-bg: #f2f2ef;
    --inv-ink: #0b0b0b;
    --inv-mute: #8a8a86;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b;
  --surface: #161616;
  --ink: #f2f2ef;
  --mute: #6f6f6b;
  --line: #262626;
  --inv-bg: #f2f2ef;
  --inv-ink: #0b0b0b;
  --inv-mute: #8a8a86;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) var(--gutter) 160px;
}

/* ---------- Header ---------- */
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  font-size: 13px;
  font-weight: 600;
}
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--mute); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.theme { display: flex; background: var(--surface); border-radius: 12px; padding: 3px; }
.theme button {
  height: 30px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--mute);
  transition: background .2s, color .2s;
}
.theme button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
body, .controls, .player, .search, .chip, .t-btn, .pill, .seg, .round { transition: background-color .3s, color .3s; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--ink);
}
.brand h1 {
  font-size: clamp(64px, 16vw, 168px);
  font-weight: 700;
  line-height: .82;
  letter-spacing: -.055em;
  display: flex;
  align-items: flex-end;
}
.dot {
  width: .14em; height: .14em;
  background: var(--red);
  border-radius: 50%;
  margin: 0 0 .04em .06em;
  flex: none;
}
.sub {
  font-size: clamp(32px, 7vw, 72px);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1;
  color: var(--mute);
  margin-top: .12em;
}
.count { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.count-label { font-size: 13px; color: var(--mute); font-weight: 500; }
.count-num { font-size: clamp(36px, 7vw, 64px); font-weight: 700; letter-spacing: -.05em; line-height: .9; }

/* ---------- Controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--line);
}
.search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-radius: 14px;
}
.search svg { color: var(--mute); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: 0;
  outline: 0;
}
.search input::placeholder { color: var(--mute); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font: inherit; font-size: 12px; color: var(--mute);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
}
@media (hover: none) { .search kbd { display: none; } }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 12px calc(var(--gutter) * -1) 0;
  padding: 0 var(--gutter);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .2s, color .2s;
}
.chip sup { font-size: 10px; color: var(--mute); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] sup { color: var(--inv-mute); }
.chip--fav::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }

/* ---------- List ---------- */
.list { list-style: none; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 84px;
}
.row:hover .row-name { color: var(--mute); }
.row-num {
  font-size: 15px;
  font-weight: 600;
  width: 3.2ch;
  color: var(--ink);
  align-self: start;
  padding-top: 6px;
}
.row-num .z, .mini-num .z, .big-num .z { color: var(--mute); opacity: .55; }
.row-main { min-width: 0; }
.row-name {
  font-size: clamp(24px, 4.4vw, 40px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.02;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .2s;
}
.row-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--mute);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-side { display: flex; align-items: center; gap: 10px; }
.row-fav { color: var(--mute); padding: 8px; margin: -8px; }
.row-fav svg { width: 18px; height: 18px; }
.row-fav[aria-pressed="true"] { color: var(--red); }
.row-fav[aria-pressed="true"] svg { fill: currentColor; }
.row-codec { font-size: 11px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }

.row.is-active .row-name { color: var(--ink); }
.row.is-active::after {
  content: "";
  position: absolute;
  left: calc(var(--gutter) * -1);
  right: calc(var(--gutter) * -1);
  top: 50%;
  height: 2px;
  background: var(--red);
  pointer-events: none;
  transform-origin: left;
  animation: sweep .5s var(--ease);
}
.row.is-active .row-num { color: var(--red); }
.row.is-active .row-codec { display: none; }
.eq { display: none; gap: 3px; align-items: flex-end; height: 18px; }
.row.is-active .eq { display: flex; }
.eq i { width: 3px; background: var(--ink); height: 30%; }
.is-playing .eq i { animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; }
.eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@keyframes sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.state {
  padding: 64px 0;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.05;
}
.state small { display: block; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--mute); margin-top: 12px; }
.state button { margin-top: 20px; font-size: 15px; font-weight: 600; letter-spacing: 0; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; }

.skeleton { height: 84px; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.skeleton::before {
  content: ""; position: absolute; left: 3.2ch; margin-left: 20px; top: 22px; height: 28px; width: 45%;
  background: var(--surface); border-radius: 6px; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- Ruler ---------- */
.ruler { position: relative; overflow: hidden; }
.ruler-track {
  position: absolute; inset: 0;
  width: 400%;
  background:
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 50px) bottom left / 100% 70% no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 10px) bottom left / 100% 38% no-repeat;
  opacity: .35;
  transition: transform .8s var(--ease);
  will-change: transform;
}
.needle {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; margin-left: -1px;
  background: var(--red);
}

/* ---------- Mini player ---------- */
.mini {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 0 var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
  pointer-events: none;
}
.mini > * { pointer-events: auto; }
.mini-row {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--inv-bg); color: var(--inv-ink);
  padding: 10px 10px 10px 18px;
  border-radius: 18px;
  box-shadow: 0 12px 40px -12px rgb(0 0 0 / .35);
}
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; text-align: left; padding: 4px 0; }
.mini-num { font-size: 28px; font-weight: 700; letter-spacing: -.05em; flex: none; }
.mini-num .z { color: var(--inv-mute); opacity: 1; }
.mini-text { min-width: 0; display: flex; flex-direction: column; }
.mini-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-meta { font-size: 12px; color: var(--inv-mute); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; }
.mini-play { width: 56px; height: 56px; border-radius: 14px; background: var(--inv-ink); color: var(--inv-bg); }
.mini-play svg { fill: currentColor; stroke: none; }

.mini.enter { animation: rise .45s var(--ease); }
@keyframes rise { from { transform: translateY(110%); } }

/* ---------- Full player ---------- */
.player {
  position: fixed; inset: 0; z-index: 30;
  background: var(--surface);
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 16px) var(--gutter) calc(env(safe-area-inset-bottom) + 16px);
  transition: transform .5s var(--ease);
}
.player[data-closing] { transform: translateY(100%); }
.player.enter { animation: rise .5s var(--ease); }
.player > * { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }
.player-top { display: flex; align-items: center; gap: 10px; }
.ghost { margin-left: -10px; }
.pill {
  height: 36px; padding: 0 14px; border-radius: 10px; background: var(--bg);
  display: inline-flex; align-items: center; font-size: 14px; font-weight: 600;
  max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg { margin-left: auto; display: flex; background: var(--bg); border-radius: 12px; padding: 3px; font-size: 13px; font-weight: 700; }
.seg span { padding: 7px 12px; border-radius: 9px; }
.seg span:last-child { color: var(--mute); }
.seg span:last-child::after { content: " kbps"; font-weight: 500; }
.seg-on { background: var(--ink); color: var(--surface); }

.player-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 0; }
.big-num {
  font-size: clamp(96px, 30vw, 200px);
  font-weight: 600;
  letter-spacing: -.07em;
  line-height: .85;
  margin-left: -.06em;
}
.big-name {
  margin-top: 14px; font-size: 17px; font-weight: 500; color: var(--mute);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dial { position: relative; display: grid; grid-template-columns: 1fr; padding: 28px 0; }
.dial .round { position: absolute; top: 0; width: 44px; height: 44px; border-radius: 50%; background: var(--bg); z-index: 2; }
.dial #favBtn { left: 0; }
.dial #shareBtn { right: 0; }
.dial #favBtn[aria-pressed="true"] { color: var(--red); }
.dial #favBtn[aria-pressed="true"] svg { fill: currentColor; }
.dial .round svg { width: 18px; height: 18px; }
.ruler--big {
  height: 150px;
  margin: 0 calc(var(--gutter) * -1);
  color: var(--ink);
  -webkit-mask: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
          mask: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.ruler--big .ruler-track { top: 50px; bottom: 40px; }
.ruler-labels { position: absolute; left: 0; bottom: 14px; width: 400%; height: 16px; transition: transform .8s var(--ease); }
.ruler-labels span { position: absolute; transform: translateX(-50%); font-size: 11px; font-weight: 500; color: var(--mute); }

.player-bottom { padding-top: 8px; }
.now { display: flex; flex-direction: column; margin-bottom: 14px; min-height: 52px; }
.now-label { font-size: 13px; color: var(--mute); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.now-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mute); }
.is-playing .now-label::before { background: var(--red); animation: pulse 1.6s ease-in-out infinite; }
.now-title { font-size: clamp(22px, 5.5vw, 30px); font-weight: 700; letter-spacing: -.035em; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.transport { display: grid; grid-template-columns: 1fr 2.6fr 1fr; gap: 6px; height: 96px; }
.t-btn { border-radius: 18px; background: var(--bg); display: grid; place-items: center; transition: transform .15s var(--ease), background .2s; }
.t-btn:active { transform: scale(.97); }
.t-btn svg { width: 18px; height: 18px; fill: currentColor; }
.t-main { background: var(--ink); color: var(--surface); font-size: 17px; font-weight: 600; }
.is-loading .t-main span { animation: pulse 1s ease-in-out infinite; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 16px); z-index: 40;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px);
}
.toast::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 10px; vertical-align: 1px; }

@media (min-width: 900px) {
  .row { grid-template-columns: 4ch 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
