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

:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --off:   #f2f2f0;
  --mid:   #999999;
  --line:  #dddddd;
  --rule:  2px solid #0a0a0a;
}

html, body {
  background: var(--white);
  color: var(--black);
}

body {
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 1.5rem 2rem 1rem;
  border-bottom: var(--rule);
}

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3.5rem, 10vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0.01em;
}

.version {
  font-size: 11px;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 0.4rem;
}

/* ── Main grid ── */
main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: var(--rule);
}

/* ── Shared panel pieces ── */
.panel-left  { border-right: var(--rule); display: flex; flex-direction: column; }
.panel-right { display: flex; flex-direction: column; }

.panel-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mid);
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

/* ── Waveform ── */
.wave-area {
  flex: 1;
  position: relative;
  min-height: 180px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wave-idle {
  display: flex;
  align-items: center;
  gap: 4px;
}

.idle-tick {
  width: 2px;
  height: 14px;
  background: var(--line);
}

#waveCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}

.clip-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--black);
  color: var(--white);
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.05s;
}

/* ── Level meter ── */
.meter-section {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
}

.meter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.meter-key {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mid);
}

.meter-db {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 4px;
  background: #e8e8e8;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--black);
  transition: width 0.04s linear;
}

.meter-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.meter-ticks span { font-size: 9px; color: var(--mid); }

/* ── Right panel ── */
.device-block {
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.device-name {
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-name.empty { color: var(--mid); font-weight: 400; }

.status-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.status-dot {
  width: 8px;
  height: 8px;
  border: 2px solid var(--black);
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.live { background: var(--black); animation: blink 1s step-start infinite; }
.status-dot.err  { border-color: #bbbbbb; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.status-word {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

/* ── Stats ── */
.stats-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.stat-cell {
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-cell:nth-child(2n)   { border-right: none; }
.stat-cell:nth-child(n+3)  { border-bottom: none; }

.stat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: 0.02em;
}

.stat-lbl {
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--mid);
  margin-top: 4px;
}

/* ── Footer ── */
footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2rem;
  padding: 1.25rem 2rem;
}

.footer-note {
  font-size: 11px;
  color: var(--mid);
  line-height: 1.5;
}

.btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: var(--rule);
  background: var(--black);
  color: var(--white);
  padding: 0.75rem 2rem;
  white-space: nowrap;
  outline: none;
  transition: background 0.1s;
}

.btn:hover        { background: #333333; }
.btn:active       { transform: translateY(1px); }
.btn.stop         { background: var(--white); color: var(--black); }
.btn.stop:hover   { background: var(--off); }

/* ── Responsive ── */
@media (max-width: 580px) {
  main   { grid-template-columns: 1fr; }
  .panel-left { border-right: none; border-bottom: var(--rule); }
  header { grid-template-columns: 1fr; gap: 0.25rem; }
  footer { grid-template-columns: 1fr; }
  .btn   { width: 100%; text-align: center; }
}
