:root {
  --bg: #0a0a10;
  --panel: #14141c;
  --panel2: #1c1c28;
  --line: #2a2a3a;
  --text: #e8e8f0;
  --muted: #9a9ab0;
  --right: #22d3ee; /* sağ əl */
  --left: #f59e0b;  /* sol əl */
  --primary: #22c55e;
  --blue: #3b82f6;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; }

/* ---- Üst panel ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) 10px 6px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
#hud {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#hud .sep { opacity: .5; }
.icon-btn {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 10px;
  font-size: 18px;
}
.icon-btn:active { filter: brightness(1.3); }

/* ---- Seek zolağı ---- */
#seekbar {
  position: relative;
  height: 16px;
  background: var(--panel2);
  touch-action: none;
}
#loopRegion {
  position: absolute; top: 0; bottom: 0;
  background: rgba(34, 197, 94, .28);
  display: none;
}
#seekFill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  background: linear-gradient(90deg, var(--right), var(--blue));
}
#seekHandle {
  position: absolute; top: -2px; left: 0;
  width: 4px; height: 20px;
  background: #fff; border-radius: 2px;
  transform: translateX(-2px);
}
.seek-mark {
  position: absolute; top: 0; bottom: 0; width: 2px; display: none;
}
.seek-mark.a { background: #34d399; }
.seek-mark.b { background: #fbbf24; }

/* ---- Canvas ---- */
#stage {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: none;
}

/* ---- Kontrol paneli ---- */
#controls {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.row { display: flex; align-items: center; gap: 8px; }

.transport .ctrl {
  flex: 1;
  height: 54px;
  border-radius: var(--radius);
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}
.ctrl small { font-size: 11px; color: var(--muted); }
.ctrl.primary { background: var(--primary); border-color: var(--primary); color: #04120a; }
.ctrl.primary small { color: #04120a; }
.ctrl:active { filter: brightness(1.2); }

.speed label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.speed b { color: var(--text); font-variant-numeric: tabular-nums; }
input[type=range] { flex: 1; height: 38px; accent-color: var(--right); }

.toggles { flex-wrap: wrap; }
.toggle {
  flex: 1; min-width: 70px; height: 46px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.toggle:active { filter: brightness(1.25); }
.toggle.on { color: #04120a; }
.toggle.right.on { background: var(--right); border-color: var(--right); }
.toggle.left.on { background: var(--left); border-color: var(--left); }
#btnSound.on, #btnLoop.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.looprow, .sectionrow { font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.mini {
  height: 42px; padding: 0 12px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}
.mini:active { filter: brightness(1.25); }
.mini.demo { margin-left: auto; background: #3b1d5e; border-color: #5b2a8a; color: #e9d5ff; }
.ablabel { margin-left: auto; font-variant-numeric: tabular-nums; }

.sectionrow label { white-space: nowrap; }
select, input[type=number] {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  height: 42px;
  border-radius: 10px;
  padding: 0 8px;
  font-size: 14px;
}
select { flex: 1; min-width: 90px; }
input[type=number] { width: 62px; }

/* ---- Başlanğıc overlay ---- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(5, 5, 10, .94);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 16px;
}
.overlay.hidden { display: none; }
.card {
  position: relative;
  width: min(94%, 420px);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
}
.card h1 { margin: 0 0 6px; font-size: 26px; }
.card p { color: var(--muted); font-size: 14px; margin: 6px 0 16px; line-height: 1.45; }
.card .hint { font-size: 12px; margin-top: 16px; margin-bottom: 0; }
.big {
  display: block; width: 100%; height: 56px; margin: 10px 0;
  border-radius: 14px;
  background: var(--primary); border: none; color: #04120a;
  font-size: 17px; font-weight: 700;
}
.big:active { filter: brightness(1.15); }
.big.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }

/* ---- Saxlanmış mahnılar (overlay siyahısı) ---- */
#btnCloseOverlay {
  position: absolute; top: 10px; right: 10px;
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  font-size: 18px; line-height: 1;
  display: none;
}
#btnCloseOverlay.show { display: block; }
.saved-wrap { margin-top: 16px; text-align: left; }
.saved-title {
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 8px;
}
.song-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 38vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 6px;
}
.song-item { display: flex; align-items: center; gap: 6px; }
.song-open {
  flex: 1; min-width: 0;
  height: 46px; padding: 0 12px;
  text-align: left;
  border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-open:active { filter: brightness(1.25); }
.song-item.pinned .song-open {
  background: #3b1d5e; border-color: #5b2a8a; color: #e9d5ff;
}
.song-del {
  flex: none; width: 46px; height: 46px;
  border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--line); color: #f87171;
  font-size: 22px; line-height: 1;
}
.song-del:active { filter: brightness(1.3); }
.song-empty {
  list-style: none;
  color: var(--muted); font-size: 13px;
  padding: 8px 2px;
}

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  background: #1c1c28; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  z-index: 60; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
