:root {
  --bg: #0d0f14;
  --card: #161a22;
  --card-border: #232a36;
  --text: #e8ecf2;
  --muted: #8b94a5;
  --accent: #4fd1c5;
  --accent2: #f6ad55;
  --rec: #f56565;
  --play: #48bb78;
  --slider-track: #2a3140;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { padding-bottom: 2rem; }

/* ---------- Start Overlay ---------- */
#startOverlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
#startOverlay.hidden { display: none; }
.start-inner .logo { font-size: 2rem; font-weight: 800; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.start-inner p { color: var(--muted); margin-bottom: 1.5rem; }
.start-inner .hint { font-size: 0.8rem; margin-top: 1.5rem; }
#startBtn {
  font-size: 1.2rem; padding: 1rem 2.5rem; border-radius: 999px;
  border: none; background: var(--accent); color: #06281f; font-weight: 700;
  cursor: pointer;
}

/* ---------- Layout ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1rem; position: sticky; top: 0; z-index: 10;
  background: rgba(13,15,20,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
header h1 { font-size: 1.1rem; letter-spacing: 0.05em; }

#master-meter {
  width: 100px; height: 8px; border-radius: 4px;
  background: var(--slider-track); overflow: hidden;
}
#master-meter-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--rec));
  transition: width 0.05s linear;
}

main {
  max-width: 640px; margin: 0 auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 1rem;
}

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 1rem;
}
.card h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--muted); margin-bottom: 0.8rem;
}

.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.row:last-child { margin-bottom: 0; }
.label-inline { color: var(--muted); font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  font-size: 0.95rem; font-weight: 600;
  padding: 0.65rem 1.1rem; border-radius: 12px;
  border: 1px solid var(--card-border);
  background: #1d2330; color: var(--text);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn.rec.active { background: var(--rec); border-color: var(--rec); color: #fff; animation: pulse 1s infinite; }
.btn.play.active { background: var(--play); border-color: var(--play); color: #06281f; }
.btn.toggle.on { background: var(--accent); border-color: var(--accent); color: #06281f; }

@keyframes pulse { 50% { opacity: 0.6; } }

.file-btn { display: inline-block; }
.timer { color: var(--rec); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Waveform ---------- */
#waveform {
  width: 100%; height: 140px; display: block;
  background: #0a0c10; border-radius: 10px;
  touch-action: none;
}
.hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.5rem; }

/* ---------- Sliders ---------- */
.sliders { display: flex; flex-direction: column; gap: 0.55rem; }
.slider-row { display: grid; grid-template-columns: 90px 1fr 58px; align-items: center; gap: 0.6rem; }
.slider-row label { font-size: 0.8rem; color: var(--muted); }
.slider-row .val { font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: var(--slider-track);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); margin-top: -9px;
  border: 3px solid var(--card);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--slider-track);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card);
}

/* ---------- Looper ---------- */
.loop-track {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  align-items: center; gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--card-border);
}
.loop-track:last-child { border-bottom: none; }
.loop-track .btn { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
.loop-track .track-len { font-size: 0.7rem; color: var(--muted); min-width: 3.2em; text-align: right; }
.loop-track input[type="range"] { min-width: 60px; }

footer { text-align: center; color: var(--muted); font-size: 0.72rem; padding: 1rem; }
