:root {
  --bg: #000000;
  --card: #0d1117;
  --text: #e6e6e6;
  --muted: #a0a0a0;
  --primary: #4da6ff;
  --danger: #ff3333;
  --danger-hover: #ff1a1a;
  --success: #4dff4d;
  --pause: #ffcc00;
  --border: #1f2a38;
  --player-bg: #0a0e14;
  --shadow: 0 6px 25px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.app { max-width: 1400px; margin: 0 auto; }

header { text-align: center; margin-bottom: 2.5rem; }

h1 { color: var(--primary); font-size: 3rem; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 1.2rem; margin-top: 0.5rem; }

/* 3-column layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 1024px) {
  .main-content { grid-template-columns: 1fr; }
}

/* Left – Instructions */
.instructions-column {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.instructions h3 { color: var(--primary); margin-bottom: 1rem; font-size: 1.4rem; }
.instructions ol, .instructions ul { padding-left: 1.8rem; line-height: 1.7; }
.instructions li { margin-bottom: 0.8rem; font-size: 1.05rem; }

/* Center – Recording */
.center-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.center-column h3, .player-column h3 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

/* Transport */
.transport {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.transport-left, .transport-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.gain-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
}

.gain-control input[type="range"] { width: 140px; accent-color: var(--primary); }

button {
  padding: 0.9rem 1.8rem;
  border: none;
  border-radius: 50px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.btn-record { background: var(--danger); color: white; }
.btn-record:hover:not(:disabled) { background: var(--danger-hover); transform: scale(1.05); }
.btn-record.recording { animation: pulse 1.3s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,51,51,0.7); }
  70% { box-shadow: 0 0 0 18px rgba(255,51,51,0); }
}

.btn-pause-record { background: var(--pause); color: white; }
.btn-stop { background: #2d3748; color: white; }

select, .toggle-label {
  padding: 0.8rem 1.2rem;
  border-radius: 50px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1.05rem;
  font-weight: 500;
}

.toggle-label input {
  width: 1.3rem;
  height: 1.3rem;
  accent-color: var(--success);
}

/* Meter */
.meter-container {
  height: 32px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
  position: relative;
}

.meter {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4da6ff 0%, #4da6ff 60%, #ffcc00 60%, #ffcc00 85%, #ff4d4d 85%);
  transition: width 0.08s linear;
}

.peak {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: white;
  opacity: 0.8;
  box-shadow: 0 0 12px white;
}

/* Visualizer */
.visualizer {
  background: #000;
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Canvas */
canvas {
  display: block;
  width: 100%;
  height: 220px;
  background: #000;
  border-radius: 12px;
}

/* Player column */
.player-column {
  background: var(--card);
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: fit-content;
}

.custom-player {
  background: var(--player-bg);
  border-radius: 16px;
  padding: 1.5rem;
}

.player-btn {
  background: var(--primary);
  color: white;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.25s;
  border: none;
  box-shadow: 0 4px 15px rgba(77,166,255,0.4);
}

.player-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 8px 25px rgba(77,166,255,0.6); }
.player-btn:disabled { background: #4a5568; cursor: not-allowed; box-shadow: none; }

.progress-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 220px;
}

.progress-container span { font-size: 1.1rem; min-width: 55px; text-align: center; font-weight: 500; }

#progress {
  flex: 1;
  height: 10px;
  accent-color: var(--primary);
  cursor: pointer;
  border-radius: 5px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.volume-control i { font-size: 1.3rem; color: var(--muted); }

.volume-control input[type="range"] { width: 120px; accent-color: var(--primary); }

/* Footer */
.footer-section {
  text-align: center;
  margin-top: 2.5rem;
}

.footer-section .actions {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.actions button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 1rem 2.2rem;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 4px 15px rgba(77,166,255,0.4);
}

.actions button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(77,166,255,0.6); }
.actions button:disabled { background: #4a5568; cursor: not-allowed; box-shadow: none; }

/* Filename preview */
#filenamePreview {
  display: none;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

#filenamePreview label { color: var(--muted); font-weight: 500; }

#filenameInput {
  padding: 0.6rem 1rem;
  width: 320px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

#filenameInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(77,166,255,0.3);
}

/* Status & error */
.status, .error {
  margin: 1rem 0;
  font-size: 1.2rem;
}

.status { color: var(--muted); font-weight: 500; }
.error { color: var(--danger); }

/* Countdown */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.countdown-overlay.active { opacity: 1; pointer-events: all; }

#countdownNumber {
  font-size: 14rem;
  color: var(--primary);
  font-weight: 900;
  text-shadow: 0 0 40px rgba(77,166,255,0.7);
}

/* Responsive */
@media (max-width: 1024px) {
  .main-content { grid-template-columns: 1fr; }
}