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

:root {
  --bg: #0a0a0f;
  --surface: #1a1a2e;
  --primary: #e94560;
  --primary-glow: rgba(233, 69, 96, 0.4);
  --text: #eee;
  --text-dim: #888;
  --accent: #16213e;
  --green: #00c853;
  --green-glow: rgba(0, 200, 83, 0.4);
}

html, body {
  height: 100%;
  overflow: auto;
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 1rem;
  padding-top: env(safe-area-inset-top, 1rem);
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}

header {
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--primary), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#status {
  margin-top: 0.4rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  min-height: 1.3em;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Visualizer */
#visualizer {
  width: 280px;
  height: 120px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Loop controls */
#loop-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

#progress-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
}

#progress-ring {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--green);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.05s linear;
}

#loop-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* Record button */
.rec-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--text-dim);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
}

.rec-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--primary);
  text-transform: uppercase;
}

.rec-button.recording .rec-label { color: var(--primary); }
.rec-button.playing .rec-label { color: var(--green); }

.rec-button:not(:disabled):active {
  transform: translate(-50%, -50%) scale(0.95);
}

.rec-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  transition: all 0.2s ease;
}

.rec-button.recording {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
  animation: pulse 1.5s ease-in-out infinite;
}

.rec-button.recording .rec-icon {
  border-radius: 4px;
  width: 22px;
  height: 22px;
}

.rec-button.playing {
  border-color: var(--green);
}

.rec-button.playing .rec-icon {
  background: var(--green);
  border-radius: 4px;
  width: 22px;
  height: 22px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px var(--primary-glow); }
  50% { box-shadow: 0 0 40px var(--primary-glow), 0 0 80px var(--primary-glow); }
}

/* Track strips */
#tracks {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.track-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--green);
  border-radius: 8px;
  padding: 8px 10px;
}

.track-strip.muted {
  border-left-color: var(--text-dim);
  opacity: 0.5;
}

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

.track-label {
  font-size: 0.8rem;
  font-weight: 600;
  flex: 1;
}

.track-btn {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 5px 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mute-btn {
  background: var(--accent);
  color: var(--text-dim);
}

.mute-btn.active {
  background: #e9456033;
  color: var(--primary);
}

.del-btn {
  background: #e9456022;
  color: var(--primary);
}

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

/* Volume slider row */
.track-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-icon {
  font-size: 0.7rem;
  opacity: 0.6;
}

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  outline: none;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.vol-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  border: 2px solid var(--bg);
}

/* Transport bar */
#transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  padding: 10px 0;
}

.transport-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

.transport-btn span {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.transport-btn:active {
  transform: scale(0.95);
  background: var(--accent);
}

.transport-main {
  padding: 10px 20px;
  border-color: var(--green);
  color: var(--green);
}

.transport-main:active {
  background: rgba(0, 200, 83, 0.15);
}
