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

html,
body {
  height: 100%;
  background: #050508;
  color: #c8c8d0;
  font-family: "JetBrains Mono", "Consolas", "Courier New", monospace;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.split {
  display: flex;
  flex: 1;
  min-height: 0;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  border-right: 1px solid #1a1a24;
}

.panel:last-child {
  border-right: none;
}

.panel-label {
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6a6a78;
  border-bottom: 1px solid #1a1a24;
  background: #0c0c10;
}

.panel-label.trace {
  color: #5a9a6a;
}

.panel-label.echo {
  color: #6a7aaa;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  background: #0a0a0c;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.panel-desc {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  font-size: 0.65rem;
  color: #4a4a58;
  line-height: 1.5;
  pointer-events: none;
}

.panel-desc kbd {
  padding: 0.1em 0.35em;
  border: 1px solid #3a3a48;
  border-radius: 2px;
  background: #141418;
  color: #7a7a88;
  font-size: 0.9em;
}

.debug-panel {
  display: none;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
  width: 320px;
  max-height: calc(100% - 1rem);
  background: rgba(6, 6, 10, 0.96);
  border: 1px solid #3a5a44;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.65);
  pointer-events: auto;
  overflow: hidden;
  flex-direction: column;
}

.debug-panel.visible {
  display: flex;
}

.debug-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.debug-section {
  border-bottom: 1px solid #1a1a24;
}

.debug-section-title {
  padding: 0.3rem 0.5rem;
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  color: #8aba8a;
  background: #0a120e;
}

.debug-section canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}

.debug-readout {
  margin: 0;
  padding: 0.45rem 0.5rem;
  font-size: 0.5rem;
  line-height: 1.45;
  color: #a8a8b8;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "JetBrains Mono", "Consolas", monospace;
  max-height: 220px;
  overflow-y: auto;
  background: #08080c;
}

.debug-header {
  padding: 0.35rem 0.5rem;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: #6aba7a;
  background: #0f1a14;
  border-bottom: 1px solid #2a4a34;
  flex-shrink: 0;
}

.debug-hint {
  padding: 0.25rem 0.5rem;
  font-size: 0.48rem;
  color: #4a5a4a;
  flex-shrink: 0;
  border-top: 1px solid #1a1a24;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #0c0c10;
  border-top: 1px solid #1a1a24;
}

button {
  background: #1a1a24;
  border: 1px solid #2a2a38;
  color: #b0b0bc;
  padding: 0.45rem 1rem;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) {
  background: #242430;
  border-color: #3a3a4a;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-start {
  color: #7aba8a;
  border-color: #3a5a44;
}

#btn-calibrate {
  color: #aaaacc;
}

#btn-record {
  color: #c88888;
  border-color: #5a3030;
}

#btn-record.recording {
  color: #fff;
  background: #8a2020;
  border-color: #c04040;
  animation: rec-pulse 1s ease-in-out infinite;
}

@keyframes rec-pulse {
  50% { opacity: 0.7; }
}

.hud {
  display: none;
  flex: 1;
  gap: 1.2rem;
  font-size: 0.65rem;
  color: #5a5a68;
  justify-content: flex-end;
}

.hud.visible {
  display: flex;
}

.hud span {
  white-space: nowrap;
}

#webcam {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.divider {
  width: 2px;
  background: linear-gradient(180deg, #1a3a2a 0%, #1a2a4a 100%);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .split {
    flex-direction: column;
  }

  .divider {
    width: 100%;
    height: 2px;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid #1a1a24;
  }
}
