@import url("https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Unbounded:wght@300;700;900&display=swap");

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

:root {
  --bg: #06060a;
  --panel: #0e0e16;
  --panel2: #161620;
  --border: rgba(255, 255, 255, 0.07);
  --borderl: rgba(255, 255, 255, 0.15);
  --send: #e8563b;
  --send-dim: rgba(232, 86, 59, 0.18);
  --recv: #36b37e;
  --recv-dim: rgba(54, 179, 126, 0.18);
  --text: #eeebe6;
  --muted: #55536a;
  --mono: "Space Mono", monospace;
  --display: "Unbounded", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 60px;
  gap: 0;
}

/* Scanline overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.07) 2px,
    rgba(0, 0, 0, 0.07) 4px
  );
  z-index: 999;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 48px;
}

.wordmark {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.wordmark .fwd {
  color: var(--text);
}
.wordmark .sep {
  color: var(--recv);
  font-weight: 900;
  font-size: 1em;
  margin: 0 1px;
}
.wordmark .rev {
  color: var(--muted);
  font-weight: 300;
}

.tagline {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
}

/* ── Two-panel layout ── */
.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: 100%;
  max-width: 860px;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
}

.panel.sender {
  border-right: 1px solid var(--border);
}

.panel-label {
  font-size: 9px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid;
}
.sender .panel-label {
  color: var(--send);
  border-color: rgba(232, 86, 59, 0.35);
  background: var(--send-dim);
}
.receiver .panel-label {
  color: var(--recv);
  border-color: rgba(54, 179, 126, 0.35);
  background: var(--recv-dim);
}

.panel-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
}

/* ── Canvas visualizer ── */
.viz {
  width: 100%;
  height: 64px;
  background: var(--panel2);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.viz canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Divider line ── */
.divider {
  width: 1px;
  background: var(--border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.divider-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--borderl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  z-index: 1;
  flex-shrink: 0;
}

/* ── Big action button ── */
.action-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1.5px solid var(--borderl);
  background: var(--panel2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  outline: none;
  position: relative;
  flex-shrink: 0;
}

.sender .action-btn:hover {
  border-color: var(--send);
  box-shadow: 0 0 20px var(--send-dim);
}
.sender .action-btn.active {
  background: var(--send);
  border-color: var(--send);
  box-shadow: 0 0 32px rgba(232, 86, 59, 0.5);
}
.sender .action-btn.locked {
  background: rgba(250, 204, 21, 0.12);
  border-color: #facc15;
  box-shadow: 0 0 32px rgba(250, 204, 21, 0.4);
  animation: lock-pulse 1.8s ease-in-out infinite;
}
@keyframes lock-pulse {
  0%,
  100% {
    box-shadow: 0 0 24px rgba(250, 204, 21, 0.35);
  }
  50% {
    box-shadow: 0 0 44px rgba(250, 204, 21, 0.65);
  }
}
.sender .action-btn.locked .ripple {
  animation: ripple-lock 2s ease-out infinite;
  border-color: #facc15;
}
@keyframes ripple-lock {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}
.lock-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--send);
  color: #1a1200;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
}
.sender .action-btn.locked .lock-badge {
  opacity: 1;
  transform: scale(1);
}
.receiver .action-btn:hover {
  border-color: var(--recv);
  box-shadow: 0 0 20px var(--recv-dim);
}
.receiver .action-btn.active {
  background: rgba(54, 179, 126, 0.15);
  border-color: var(--recv);
  box-shadow: 0 0 32px rgba(54, 179, 126, 0.4);
  animation: recv-pulse 1.4s ease-in-out infinite;
}

@keyframes recv-pulse {
  0%,
  100% {
    box-shadow: 0 0 28px rgba(54, 179, 126, 0.35);
  }
  50% {
    box-shadow: 0 0 48px rgba(54, 179, 126, 0.6);
  }
}

.action-btn .ripple {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1.5px solid var(--send);
  opacity: 0;
}
.sender .action-btn.active .ripple {
  animation: ripple 1.6s ease-out infinite;
}

@keyframes ripple {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

.action-btn svg {
  width: 30px;
  height: 30px;
  pointer-events: none;
}

/* ── State text ── */
.state-text {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  min-height: 34px;
}

/* ── Clips list ── */
.clips-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.clips-wrap::-webkit-scrollbar {
  width: 4px;
}
.clips-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.clips-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.clip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.15s;
}
.clip-row:hover {
  border-color: rgba(54, 179, 126, 0.4);
}

.clip-n {
  font-size: 9px;
  color: var(--recv);
  min-width: 20px;
}
.clip-dur {
  flex: 1;
  font-size: 10px;
  color: var(--muted);
}
.clip-actions {
  display: flex;
  gap: 6px;
}

.clip-btn {
  font-size: 9px;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid var(--borderl);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono);
}
.clip-btn:hover {
  border-color: var(--recv);
  color: var(--recv);
}
.clip-btn.dl:hover {
  border-color: var(--muted);
  color: var(--muted);
}
.clip-btn.del:hover {
  border-color: #e8563b;
  color: #e8563b;
}
.clip-btn.ren:hover {
  border-color: #a78bfa;
  color: #a78bfa;
}

.clip-name {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.clip-name-text {
  font-size: 10px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s;
}
.clip-name-text:hover {
  color: #a78bfa;
}
.clip-name-sub {
  font-size: 9px;
  color: var(--muted);
}
.clip-rename-input {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--panel);
  border: 1px solid #a78bfa;
  border-radius: 4px;
  color: var(--text);
  padding: 2px 6px;
  outline: none;
  width: 100%;
}
.clip-row.is-current {
  border-color: rgba(54, 179, 126, 0.5);
  background: rgba(54, 179, 126, 0.04);
}

.no-clips {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 20px 0 8px;
  line-height: 1.8;
}

/* ── Waveform scrubber ── */
.waveform-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.waveform-canvas {
  width: 100%;
  height: 80px;
  background: var(--panel2);
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: crosshair;
  display: block;
  touch-action: none;
}
.waveform-canvas.has-clip {
  cursor: crosshair;
}
.waveform-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.region-time {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.05em;
  flex: 1;
}
.region-time span {
  color: var(--recv);
}
.loop-btn {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.loop-btn:hover {
  border-color: rgba(54, 179, 126, 0.5);
  color: var(--recv);
}
.loop-btn.active {
  border-color: var(--recv);
  background: var(--recv-dim);
  color: var(--recv);
}
.loop-btn svg {
  width: 11px;
  height: 11px;
}
.clear-region-btn {
  font-family: var(--mono);
  font-size: 9px;
  padding: 4px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.clear-region-btn:hover {
  border-color: rgba(232, 86, 59, 0.5);
  color: #e8563b;
}

/* ── Speed controls ── */
.speed-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.speed-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.speed-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.speed-value {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  color: var(--recv);
  letter-spacing: -0.02em;
  min-width: 42px;
  text-align: right;
}
.speed-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.speed-pill {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.speed-pill:hover {
  border-color: rgba(54, 179, 126, 0.5);
  color: var(--recv);
}
.speed-pill.active {
  border-color: var(--recv);
  background: var(--recv-dim);
  color: var(--recv);
}
.speed-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--panel2);
  outline: none;
  cursor: pointer;
  accent-color: var(--recv);
}
.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--recv);
  border: 2px solid var(--panel);
  box-shadow: 0 0 6px rgba(54, 179, 126, 0.4);
  cursor: pointer;
}
.speed-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--recv);
  border: 2px solid var(--panel);
  cursor: pointer;
}

/* ── Recording timer ── */
.timer {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--send);
  opacity: 0;
  transition: opacity 0.2s;
  height: 36px;
  display: flex;
  align-items: center;
}
.timer.visible {
  opacity: 1;
}

/* ── Section label ── */
.sec-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: flex-start;
}

@media (max-width: 600px) {
  .stage {
    grid-template-columns: 1fr;
  }
  .panel.sender {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ── Welcome dialog ── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 10, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog-backdrop.hidden {
  display: none;
}
.dialog {
  background: var(--panel);
  border: 1px solid var(--borderl);
  border-radius: 20px;
  padding: 40px 40px 32px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: dialog-in 0.25s ease;
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.dialog-logo {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.04em;
}
.dialog-logo .fwd {
  color: var(--text);
}
.dialog-logo .sep {
  color: var(--recv);
}
.dialog-logo .rev {
  color: var(--muted);
  font-weight: 300;
}
.dialog-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dialog-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.dialog-pill svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}
.dialog-pill.green {
  border-color: rgba(54, 179, 126, 0.35);
  color: var(--recv);
}
.dialog-pill.red {
  border-color: rgba(232, 86, 59, 0.35);
  color: var(--send);
}
.dialog-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.85;
}
.dialog-body strong {
  color: var(--text);
  font-weight: 700;
}
.dialog-divider {
  height: 1px;
  background: var(--border);
}
.dialog-confirm {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 13px 24px;
  border-radius: 10px;
  border: none;
  background: var(--recv);
  color: #04342c;
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.15s;
  align-self: stretch;
}
.dialog-confirm:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.dialog-note {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
}
