:root {
  --bg: #1a1a1a;
  --surface: #242424;
  --surface-light: #2e2e2e;
  --gold: #ffcb05;
  --pink: #ea6485;
  --light-pink: #ffd2dd;
  --white: #ffffff;
  --text-muted: #888888;
  --text-dim: #555555;
  --danger: #ff4444;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  touch-action: manipulation;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #111;
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
}

/* ── APP CONTAINER ── */
.app {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── TOP BAR ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--gold);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.logo {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}

.btn-hamburger {
  background: none;
  border: none;
  color: var(--bg);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.btn-hamburger:hover {
  opacity: 0.8;
}

.btn-hamburger:active {
  transform: scale(0.95);
}

/* ── MENU OVERLAY ── */
.menu-overlay {
  position: absolute;
  top: 76px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 999;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.menu-panel {
  background: #1a1a1a;
  border-bottom: 1px solid var(--surface-light);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}

.menu-row {
  display: flex;
  gap: 10px;
}

.url-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--white, #fff);
  font-size: 16px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.url-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.url-input:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-add {
  padding: 10px 16px;
  background: var(--bg);
  color: var(--gold);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.btn-add:hover {
  background: #333;
}

.btn-add:active {
  transform: scale(0.95);
}

.btn-share {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  color: var(--gold);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.btn-share:hover:not(:disabled) {
  background: #333;
}

.btn-share:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-share.copied {
  background: #4caf50;
  color: #000;
}

.btn-share:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── TRACK LIST ── */
.track-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.track-list::-webkit-scrollbar {
  width: 4px;
}

.track-list::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 2px;
}

.track-list-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.track-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.track-row.active {
  background: var(--surface);
  border-left-color: var(--gold);
  color: var(--gold);
}

.track-row.active .track-num {
  color: var(--gold);
}

.track-row.active .track-name {
  color: var(--gold);
}

.track-row.playing .track-num::before {
  content: '▶';
  margin-right: 4px;
  font-size: 10px;
}

.track-row.playing .track-num {
  font-size: 0;
}

.track-num {
  font-size: 12px;
  color: var(--text-dim);
  width: 20px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.track-name {
  flex: 1;
  min-width: 0;
  color: var(--white);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.btn-rm {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s;
}

.btn-rm:hover {
  color: var(--danger);
}

/* ── CONTROLS (BOTTOM PANEL) ── */
.controls {
  background: var(--surface);
  border-top: 1px solid var(--surface-light);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

/* Now Playing Section */
.now-playing {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.np-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}

.np-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Scrubber Section */
.scrubber {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scrub-track {
  position: relative;
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  cursor: pointer;
  overflow: visible;
}

.scrub-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  border-radius: 3px;
  pointer-events: none;
  transition: width 0.05s linear;
}

.scrub-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: var(--gold);
  border: 2px solid #000;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 203, 5, 0.27);
  pointer-events: none;
  transition: transform 0.1s;
}

.scrub-track:hover .scrub-thumb {
  transform: translate(-50%, -50%) scale(1.2);
}

.loop-marker {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  pointer-events: none;
  display: none;
}

.loop-marker.show {
  display: block;
}

.loop-start {
  background: var(--gold);
}

.loop-end {
  background: var(--pink);
}

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

/* Button Row */
.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-play,
.btn-rewind,
.btn-loop {
  height: 64px;
  border: none;
  border-radius: 14px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.15s;
}

.btn-play {
  flex: 1;
  background: var(--gold);
  color: #000;
  box-shadow: 0 4px 16px rgba(255, 203, 5, 0.2);
}

.btn-play:hover {
  background: #ffe550;
  box-shadow: 0 6px 20px rgba(255, 203, 5, 0.3);
}

.btn-play:active {
  transform: scale(0.95);
}

.btn-play svg {
  width: 32px;
  height: 32px;
}

.btn-play.loading {
  animation: pulse-loop 1.0s ease-in-out infinite;
  opacity: 0.8;
}

.btn-play.loading svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-rewind {
  flex: 1;
  background: var(--gold);
  color: #000;
  border: none;
  box-shadow: 0 4px 16px rgba(255, 203, 5, 0.2);
}

.btn-rewind:hover {
  background: #ffe550;
}

.btn-rewind:active {
  transform: scale(0.95);
}

.btn-rewind svg {
  width: 28px;
  height: 28px;
}

.btn-loop {
  flex: 1;
  background: var(--gold);
  color: #000;
  box-shadow: 0 4px 16px rgba(255, 203, 5, 0.2);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.btn-loop:hover {
  background: #ffe550;
}

.btn-loop.state-end,
.btn-loop.state-clear {
  animation: pulse-loop 1.5s ease-in-out infinite;
}

@keyframes pulse-loop {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 203, 5, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255, 203, 5, 0); }
}

.btn-loop:active {
  transform: scale(0.95);
}


/* ── DRAG REORDER ── */
.track-row.drag-source {
  opacity: 0.3;
}

.track-row.drag-over-above {
  border-top: 2px solid var(--gold);
}

.track-row.drag-over-below {
  border-bottom: 2px solid var(--gold);
}

.drag-clone {
  border-radius: 6px;
  background: var(--surface);
}

/* Audio element */
audio {
  display: none;
}
