/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ── */
:root {
  --bg:           #0d0700;
  --bg-panel:     #140c04;
  --bg-elevated:  #1e1208;
  --border:       #3d2a10;
  --border-light: #5a3f1a;
  --accent:       #c8860a;
  --accent-hi:    #f0a830;
  --text:         #e8d4a0;
  --text-dim:     #7a6040;
  --text-mid:     #b09060;
  --danger:       #c03030;
  --vinyl-dark:   #0a0a0a;
  --vinyl-mid:    #161616;
  --label-bg:     #7a1515;
  --label-hi:     #a82020;
  --radius:       8px;
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.8);
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1e1208 0%, #140c04 100%);
  flex-shrink: 0;
}

#logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(200,134,10,.35);
}

#install-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Layout ── */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─────────────────────────────────────
   LEFT – Player panel
───────────────────────────────────── */
#player-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 20px;
  min-width: 320px;
  width: 360px;
  border-right: 1px solid var(--border);
  background: radial-gradient(ellipse at 50% 0%, #1a0e05 0%, #0d0700 70%);
  flex-shrink: 0;
}

/* ── Turntable ── */
#turntable {
  position: relative;
  width: 270px;
  height: 270px;
  margin-bottom: 22px;
}

/* Platter mat (felt) */
#platter-mat {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #1a1005 0%, #0e0902 100%);
  box-shadow:
    0 0 0 6px #1c1408,
    0 0 0 8px #2a1e0c,
    var(--shadow-lg);
}

/* ── Vinyl record ── */
#vinyl {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.025) 0%, transparent 55%),
    repeating-radial-gradient(
      circle at 50% 50%,
      var(--vinyl-dark)  0px,
      var(--vinyl-dark)  1.2px,
      var(--vinyl-mid)   1.2px,
      var(--vinyl-mid)   3px
    );
  box-shadow:
    inset 0 0 18px rgba(0,0,0,0.7),
    0 2px 8px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

/* Center label */
#vinyl-label {
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--label-hi) 0%, var(--label-bg) 55%, #4a0d0d 100%);
  box-shadow: 0 0 0 2px #3a0808, inset 0 2px 6px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

#album-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: none;
}
#album-art.show { display: block; }

#album-art-default {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
#album-art-default span {
  font-size: 2.2rem;
  color: rgba(240,200,120,0.45);
}

#spindle {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #aaa, #555);
  box-shadow: 0 0 0 1.5px #333;
  z-index: 3;
}

/* ── Tonearm ── */
#tonearm-pivot-dot {
  position: absolute;
  top: 4px;
  right: -4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bbb, #666);
  box-shadow: 0 2px 6px rgba(0,0,0,0.7), 0 0 0 2px #444;
  z-index: 11;
}

#tonearm-arm {
  position: absolute;
  top: 13px;
  right: 5px;
  width: 5px;
  height: 158px;
  background: linear-gradient(90deg, #aaa 0%, #777 40%, #555 100%);
  border-radius: 0 0 3px 3px;
  transform-origin: top center;
  transform: rotate(-28deg);
  transition: transform 0.8s ease;
  z-index: 10;
  box-shadow: 1px 0 3px rgba(0,0,0,0.4);
}

#tonearm-head {
  position: absolute;
  bottom: -2px;
  left: -8px;
  width: 21px; height: 11px;
  background: linear-gradient(180deg, #777, #444);
  border-radius: 2px 2px 4px 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#stylus {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px; height: 8px;
  background: #ccc;
  border-radius: 0 0 2px 2px;
}

/* ── Track info ── */
#track-info {
  width: 100%;
  text-align: center;
  margin-bottom: 14px;
}

#track-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
  padding: 0 8px;
}

#progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

#current-time, #duration {
  min-width: 34px;
  font-variant-numeric: tabular-nums;
}

/* Custom seek / volume track */
#seek-track, .sl-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

#seek-fill, .sl-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
  transition: width 0.1s linear;
}

/* Hide native track, keep thumb */
#seek-bar, #vol-bar, .sl-track input[type=range] {
  position: absolute;
  inset: -6px 0;
  width: 100%;
  height: calc(100% + 12px);
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* Visible thumb overlay */
#seek-track::after, .sl-track::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(200,134,10,.5);
  pointer-events: none;
  left: var(--thumb-pct, 0%);
  transition: left 0.1s linear;
}

/* ── Controls ── */
#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

#controls button {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
#controls button:hover {
  background: var(--border);
  border-color: var(--border-light);
}

.btn-play-main {
  font-size: 1.25rem !important;
  padding: 9px 20px !important;
  background: var(--accent) !important;
  color: #1a0800 !important;
  border-color: var(--accent-hi) !important;
  box-shadow: 0 0 18px rgba(200,134,10,.3);
}
.btn-play-main:hover {
  box-shadow: 0 0 28px rgba(200,134,10,.5) !important;
}

#vol-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
#vol-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px;
}
#vol-track {
  width: 76px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}
#vol-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  width: 80%;
}
#vol-track::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  left: var(--vol-pct, 80%);
}

/* ─────────────────────────────────────
   RIGHT – Playlist + Effects
───────────────────────────────────── */
#right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.panel-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ── Playlist ── */
#playlist-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

#playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

#pl-actions { display: flex; gap: 6px; }

#pl-actions button {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.75rem;
  transition: border-color 0.12s, color 0.12s;
}
#pl-actions button:hover { border-color: var(--accent); color: var(--accent); }

#drop-zone {
  flex: 1;
  overflow-y: auto;
  position: relative;
}
#drop-zone.drag-over {
  background: rgba(200,134,10,0.04);
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}

#drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 140px;
  gap: 5px;
  pointer-events: none;
}
#drop-hint p { font-size: 0.85rem; color: var(--text-dim); }
#drop-hint small { font-size: 0.7rem; color: var(--text-dim); opacity: .6; }
#drop-hint.hidden { display: none; }

#playlist-list { list-style: none; padding: 4px 0; }

.pl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(61,42,16,.25);
  transition: background 0.1s;
}
.pl-item:hover { background: var(--bg-elevated); }
.pl-item.active {
  background: rgba(200,134,10,.09);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
.pl-item.active .pi-name { color: var(--accent-hi); }

.pi-num  { font-size: 0.7rem; color: var(--text-dim); min-width: 18px; text-align: right; }
.pi-name { flex: 1; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-dur  { font-size: 0.7rem; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.pi-del  {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.pl-item:hover .pi-del { opacity: 1; }
.pi-del:hover { background: rgba(192,48,48,.15); }

/* ── Effects panel ── */
#effects-panel {
  padding: 14px 18px 16px;
  background: var(--bg-panel);
  flex-shrink: 0;
}

#presets-row {
  display: flex;
  gap: 6px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.preset-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.75rem;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  letter-spacing: 0.4px;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent-hi);
  color: #1a0800;
  font-weight: 600;
}

#effect-sliders { display: flex; flex-direction: column; gap: 9px; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row label {
  font-size: 0.78rem;
  color: var(--text-mid);
  min-width: 82px;
}
.sl-val {
  font-size: 0.72rem;
  color: var(--text-dim);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Responsive ── */
@media (max-width: 680px) {
  #main-layout { flex-direction: column; }
  #player-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 20px 16px; }
  #turntable { width: 240px; height: 240px; }
}
