/* ======================================================
  WebPiano — Pink neon theme
  ====================================================== */

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

:root {
  --bg:          #140916;
  --surface:     rgba(39, 18, 39, 0.82);
  --surface2:    rgba(56, 25, 56, 0.78);
  --border:      rgba(255, 155, 232, 0.25);
  --text:        #ffdff5;
  --text-dim:    #d6a9cc;
  --accent:      #ff61c7;
  --accent2:     #ff9ce8;
  --accent-glow: rgba(255, 97, 199, 0.45);
  --ctrl-h:      50px;
  --prog-h:      4px;
  --hint-h:      26px;
  --custom-bg-image: none;
}

html, body {
  width: 100%; height: 100%;
  background:
    radial-gradient(130% 80% at 50% -10%, #6d2b6b 0%, rgba(109,43,107,0.18) 46%, transparent 74%),
    linear-gradient(180deg, #140916 0%, #110714 100%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--custom-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  filter: saturate(1.04) contrast(1.02);
  transform: scale(1.02);
  transition: opacity 0.25s ease;
  z-index: -2;
  pointer-events: none;
}

body.has-custom-bg::before {
  opacity: 0.44;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(20,9,22,0.62), rgba(20,9,22,0.72));
  z-index: -1;
  pointer-events: none;
}

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

/* ─── Controls bar ─────────────────────────────────── */
#controls {
  height: var(--ctrl-h);
  background: rgba(8, 3, 12, 0.52);
  border-bottom: 1px solid rgba(255, 155, 232, 0.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  flex-shrink: 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}
.logo-icon {
  font-size: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
}
.logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #ff6bca, #ffc3f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* General button */
.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--accent);
}
.btn:active {
  background: rgba(255,255,255,0.12);
}
.btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.btn-accent {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-accent:hover {
  background: rgba(255,97,199,0.15);
  box-shadow: 0 0 10px var(--accent-glow);
}
.btn.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Transport icon buttons */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon.playing {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Slider group */
.slider-group {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
}
.slider-group input[type=range] {
  -webkit-appearance: none;
  width: 90px;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.slider-group input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: pointer;
}
.slider-group input[type=range]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
#speed-display {
  min-width: 32px;
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Song info */
#song-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
#song-title {
  color: var(--text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#song-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 70px;
  text-align: right;
}

/* ─── Progress track ────────────────────────────────── */
#progress-track {
  height: var(--prog-h);
  background: var(--surface2);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff61c7, #ffd3f5);
  transition: width 0.1s linear;
  pointer-events: none;
}
#progress-cursor {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#progress-track:hover #progress-cursor { opacity: 1; }

/* ─── Main canvas ─────────────────────────────────── */
#main-canvas {
  flex: 1;
  display: block;
  width: 100%;
  /* height auto from flex */
}

/* ─── Keyboard hint ─────────────────────────────────── */
#kb-hint {
  height: var(--hint-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ─── Background modal ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
}
.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 8, 16, 0.72);
}

.modal-panel {
  position: relative;
  width: min(560px, calc(100vw - 24px));
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(43,19,44,0.95), rgba(30,13,33,0.96));
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 0 24px rgba(255,97,199,0.22);
  overflow: hidden;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  color: var(--text-dim);
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field-row .btn { flex-shrink: 0; }

.text-input,
#bg-file {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

.text-input:focus,
#bg-file:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,97,199,0.18);
}

.sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.opacity-row {
  align-items: center;
  gap: 10px;
}
.opacity-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.opacity-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: pointer;
}
.opacity-row input[type=range]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
#bg-opacity-display {
  min-width: 36px;
  font-size: 12px;
  color: var(--accent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  #controls {
    gap: 8px;
    padding: 0 10px;
  }

  #song-title {
    max-width: 140px;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .field-row .btn {
    width: 100%;
  }
}

/* ─── File import drag overlay ─────────────────────── */
#drag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9,9,15,0.88);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  font-size: 20px;
  color: var(--accent);
  border: 2px dashed var(--accent);
  pointer-events: none;
}
#drag-overlay.active { display: flex; }
#drag-overlay .drag-icon { font-size: 48px; }

/* ─── Track legend ──────────────────────────────────── */
#track-legend {
  position: absolute;
  top: calc(var(--ctrl-h) + var(--prog-h) + 10px);
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
  pointer-events: none;
}
.track-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.track-dot-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ─── Track color modal rows ─────────────────────────── */
.tc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tc-row:last-child { border-bottom: none; }

.tc-swatch-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  overflow: hidden;
}
.tc-swatch-wrap input[type=color] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: 0;
}
.tc-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}
.tc-hex {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  text-align: right;
}

/* ─── Sample download progress bar ─────────────────── */
.sample-dl-bar {
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.sample-dl-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff61c7, #ffd3f5);
  border-radius: 3px;
  transition: width 0.25s ease;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* ─── Sample prompt modal — frosted glass ────────────── */
#sample-modal .modal-panel {
  width: min(500px, calc(100vw - 28px));
  background: rgba(22, 6, 28, 0.46);
  -webkit-backdrop-filter: blur(32px) saturate(1.6) brightness(1.08);
  backdrop-filter: blur(32px) saturate(1.6) brightness(1.08);
  border: 1px solid rgba(255, 155, 232, 0.30);
  box-shadow:
    0 28px 72px rgba(0,0,0,0.52),
    0 0 0 1px rgba(255,97,199,0.08) inset,
    0 0 48px rgba(255,97,199,0.14);
}
#sample-modal .modal-header {
  padding: 18px 22px;
  background: rgba(255,255,255,0.035);
  border-bottom: 1px solid rgba(255,155,232,0.15);
}
#sample-modal .modal-header h2 {
  font-size: 20px;
  letter-spacing: 0.04em;
}
#sample-modal .modal-body {
  padding: 22px;
  gap: 16px;
}
.sample-p-main {
  font-size: 17px;
  color: var(--text);
  font-weight: 500;
}
.sample-p-sub {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.85;
}
.sample-p-sub strong {
  color: var(--accent);
}
.sample-dl-section {
  margin-top: 6px;
}
#sample-modal .sample-dl-bar {
  height: 8px;
}
.sample-dl-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-dim);
}
#sample-modal .modal-footer {
  padding: 14px 22px;
  background: rgba(255,255,255,0.028);
  border-top: 1px solid rgba(255,155,232,0.12);
}
#sample-modal .modal-footer .btn {
  padding: 9px 24px;
  font-size: 14px;
}
