:root {
  --bg: #0a0a0b;
  --surface: #151517;
  --surface-2: #1d1d20;
  --surface-3: #252529;
  --line: #343439;
  --line-strong: #4b4b52;
  --text: #ffffff;
  --muted: #b9b9c1;
  --accent: #ff4b8b;
  --accent-strong: #ff2f7d;
  --success: #49d58a;
  --warning: #f2b94b;
  --lyrics-size: 1.3rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(102px + var(--safe-bottom));
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, .lyrics-viewport:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: #111113;
}
.topbar-inner {
  width: min(1440px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 7px;
  color: #111113;
  font-size: 1.55rem;
  font-weight: 950;
}
.brand-text strong { display: block; font-size: 1.3rem; letter-spacing: -.035em; }
.brand-text small { display: block; margin-top: 1px; color: var(--muted); font-size: .74rem; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-badge, .count-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 10px;
  font-size: .78rem;
  font-weight: 750;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.status-badge.offline .status-dot { background: var(--warning); }
.button, .icon-button, .transport-button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
}
.button:hover, .icon-button:hover, .transport-button:hover { background: var(--surface-3); }
.button.compact { padding: 8px 11px; font-weight: 800; font-size: .78rem; }

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 34px;
  display: grid;
  grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
  gap: 18px;
}
.library-panel, .lyrics-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.library-panel { align-self: start; padding: 20px; }
.lyrics-panel {
  min-height: calc(100vh - 132px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.section-heading, .lyrics-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .68rem;
  font-weight: 900;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 2.6vw, 2.15rem); line-height: 1; letter-spacing: -.05em; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 2.1vw, 1.7rem); line-height: 1.05; letter-spacing: -.04em; }
.subline { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }

.song-list { display: grid; gap: 8px; margin: 18px 0 22px; }
.song-card {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 9px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}
.song-card:hover { border-color: var(--line-strong); background: var(--surface-3); }
.song-card.active {
  border-color: var(--accent);
  background: #281921;
  box-shadow: inset 4px 0 0 var(--accent);
}
.song-cover {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--cover, var(--accent));
  color: #101012;
  font-size: .92rem;
  font-weight: 950;
}
.song-meta strong { display: block; font-size: .96rem; }
.song-meta span { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }
.song-duration { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }

.mode-block { padding-top: 18px; border-top: 1px solid var(--line); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.segment {
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}
.segment:hover { background: var(--surface-3); }
.segment.active { border-color: var(--accent); background: var(--accent); color: #101012; }
.segment strong, .segment small { display: block; }
.segment strong { font-size: .95rem; }
.segment small { margin-top: 2px; color: inherit; opacity: .78; font-size: .72rem; }

.lyrics-tools { display: flex; gap: 6px; }
.icon-button { min-width: 40px; height: 38px; padding: 0 9px; font-weight: 850; }
.scroll-controls {
  margin: 16px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
}
.scroll-option {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}
.scroll-option input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 36px;
  height: 20px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-3);
}
.switch::after {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform .15s ease;
}
.scroll-option input:checked + .switch { border-color: var(--accent); background: var(--accent); }
.scroll-option input:checked + .switch::after { transform: translateX(16px); background: #111113; }
.resume-scroll {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: #ffffff;
  font-size: .76rem;
  font-weight: 850;
  cursor: pointer;
}
.resume-scroll:hover { background: #281921; }

.lyrics-scroll-layout {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 360px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: stretch;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #030304;
}
.page-scroll-gutter {
  min-width: 30px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  touch-action: pan-y;
}

.lyrics-viewport {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  background: #030304;
  scrollbar-color: #777780 #111113;
  touch-action: pan-y;
}
.lyrics-content {
  padding: 34vh clamp(24px, 5vw, 72px) 38vh;
  color: #ffffff;
  font-size: var(--lyrics-size);
  font-weight: 720;
  line-height: 1.58;
  letter-spacing: .006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.lyric-section { margin-bottom: 34px; }
.section-label {
  margin: 0 0 11px;
  color: #a8a8b0;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: .62rem;
  font-weight: 900;
}
.lyric-line { margin: 0; padding: 2px 0; color: #ffffff; }
.lyric-line.paragraph-end { margin-bottom: 16px; }

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(190px, .75fr) minmax(360px, 1.4fr) minmax(220px, .75fr);
  align-items: center;
  gap: 20px;
  padding: 10px max(20px, calc((100vw - 1440px) / 2));
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line-strong);
  background: #111113;
}
.now-playing { min-width: 0; display: flex; align-items: center; gap: 10px; }
.mini-cover {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #101012;
  font-size: .9rem;
  font-weight: 950;
}
.now-text { min-width: 0; }
.now-text strong, .now-text span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.now-text span { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.transport { min-width: 0; }
.transport-buttons { display: flex; justify-content: center; align-items: center; gap: 8px; }
.transport-button { width: 42px; height: 34px; padding: 0; font-size: .75rem; font-weight: 800; }
.play-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #101012;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}
.play-button:hover { background: var(--accent-strong); }
.timeline-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
}
.timeline, .volume-control input { accent-color: var(--accent); }
.timeline { width: 100%; }
.player-options { display: flex; justify-content: flex-end; align-items: center; gap: 16px; }
.speed-select, .volume-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .74rem; font-weight: 700; }
.speed-select select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  padding: 6px 8px;
}
.volume-control input { width: 100px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-bottom));
  z-index: 80;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #1c1c20;
  color: #ffffff;
  padding: 10px 14px;
  font-size: .8rem;
  font-weight: 750;
  transition: opacity .15s ease, transform .15s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.lyrics-panel:fullscreen {
  padding: 24px;
  background: var(--bg);
}
.lyrics-panel:fullscreen .lyrics-scroll-layout { max-height: none; }
.lyrics-panel:fullscreen .page-scroll-gutter { display: none; }
.lyrics-panel:fullscreen .lyrics-scroll-layout { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 980px) {
  body { padding-bottom: calc(146px + var(--safe-bottom)); }
  .app-shell { width: min(100% - 24px, 760px); grid-template-columns: 1fr; padding-top: 12px; }
  .lyrics-panel { min-height: 720px; }
  .lyrics-scroll-layout { min-height: 420px; max-height: 68vh; }
  .player-bar { grid-template-columns: 1fr 1.4fr; padding-inline: 14px; }
  .player-options { grid-column: 1 / -1; justify-content: center; padding-top: 7px; border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
  body { padding-bottom: calc(174px + var(--safe-bottom)); }
  .topbar-inner { width: calc(100% - 20px); min-height: 64px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-text small, #offlineText, .count-pill { display: none; }
  .status-badge { padding: 7px; }
  .app-shell { width: calc(100% - 16px); gap: 8px; }
  .library-panel, .lyrics-panel { padding: 14px; border-radius: 8px; }
  .song-list { margin: 14px 0 18px; }
  .song-card { grid-template-columns: 42px 1fr auto; min-height: 58px; padding: 7px; }
  .song-cover { width: 42px; height: 42px; }
  .lyrics-header { align-items: center; }
  .lyrics-tools { gap: 4px; }
  .icon-button { min-width: 36px; height: 36px; padding: 0 7px; }
  .scroll-controls { margin: 13px 0 10px; align-items: flex-start; }
  .scroll-option { max-width: calc(100% - 112px); }
  .resume-scroll { max-width: 108px; line-height: 1.1; }
  .lyrics-panel { min-height: 650px; padding-right: 10px; }
  .lyrics-scroll-layout { min-height: 390px; max-height: 62vh; grid-template-columns: minmax(0, 1fr) 24px; }
  .page-scroll-gutter { min-width: 24px; }
  .lyrics-content { padding: 29vh 19px 34vh; line-height: 1.54; }
  .player-bar { grid-template-columns: 1fr; gap: 6px; padding: 8px; padding-bottom: calc(8px + var(--safe-bottom)); }
  .now-playing { display: none; }
  .transport { padding-top: 44px; }
  .transport-buttons { position: absolute; left: 50%; top: 7px; transform: translateX(-50%); }
  .player-options { grid-column: auto; justify-content: center; gap: 12px; padding-top: 6px; }
  .volume-control span { display: none; }
  .volume-control input { width: 90px; }
  .toast { bottom: calc(184px + var(--safe-bottom)); }
}

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