/* KRUMDIT — minimal, monochrome UI; one accent hue reserved for tracking + sound response */

:root {
  --bg: #0e0f11;
  --surface: #16181b;
  --surface-2: #1d2024;
  --line: #2a2e33;
  --ink: #d8d9d6;
  --ink-dim: #7d8288;
  --accent: #8ce6c2;        /* tracking + response only */
  --accent-hot: #c6ffe9;
  --danger: #e6748c;
  font-size: 15px;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.wordmark {
  font-weight: 700;
  letter-spacing: 0.35em;
  font-size: 0.95rem;
  color: var(--ink);
  user-select: none;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group:last-child { margin-left: auto; }

.ctl-label {
  color: var(--ink-dim);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

select, input[type="number"] {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  outline: none;
}
select:focus, input[type="number"]:focus { border-color: var(--ink-dim); }
select { cursor: pointer; }
input[type="number"] { width: 4.2rem; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
}

.btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-dim); }
.btn.active { border-color: var(--ink); background: var(--surface-2); }
.btn.recording { border-color: var(--danger); color: var(--danger); }

.btn-big { font-size: 1rem; padding: 0.8rem 1.6rem; }
.btn-close { border: none; background: none; font-size: 1.1rem; padding: 0.2rem 0.4rem; }

.bpm-hint {
  padding: 0.35rem 1.2rem;
  color: var(--ink-dim);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

/* ---------- stage ---------- */

#stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 1.2rem;
  gap: 0.6rem;
}

#video-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);          /* mirror — behave like a mirror, not a photo */
  filter: saturate(0.35) brightness(0.75);
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* camera gate */
#camera-gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 5;
}
.gate-inner { text-align: center; max-width: 30rem; padding: 1rem; }
.gate-title {
  font-size: 1.6rem;
  letter-spacing: 0.5em;
  margin-bottom: 1rem;
  color: var(--ink);
}
.gate-inner p { color: var(--ink-dim); line-height: 1.6; margin-bottom: 1.4rem; font-size: 0.9rem; }
.gate-note { font-size: 0.72rem !important; margin-top: 1.2rem; }

/* ---------- feedback strip ---------- */

#feedback-strip {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 2.6rem;
}

#guide-line {
  flex: 1;
  color: var(--ink-dim);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

#timing-meter {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
#timing-meter.hidden { display: none; }

.meter-track {
  position: relative;
  width: 220px;
  height: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.meter-center {
  position: absolute;
  left: 50%;
  top: -3px;
  width: 1px;
  height: 12px;
  background: var(--ink-dim);
}
#meter-marker {
  position: absolute;
  top: -2px;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.6s;
}
#timing-readout {
  font-size: 0.78rem;
  color: var(--ink-dim);
  min-width: 12rem;
}
#timing-readout .ontime { color: var(--accent); }

/* ---------- panels ---------- */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.8rem;
  overflow-y: auto;
}
.panel.hidden { display: none; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
}

.panel-note { color: var(--ink-dim); font-size: 0.72rem; line-height: 1.5; }

.setting-row { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.setting-row label { font-size: 0.8rem; }
.setting-note { color: var(--ink-dim); font-size: 0.7rem; line-height: 1.45; }
.setting-row input[type="range"] { width: 100%; }

/* sessions */
.session-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--bg);
}
.session-item .s-name { font-size: 0.75rem; color: var(--ink); }
.session-item audio { width: 100%; height: 32px; }
.session-actions { display: flex; gap: 0.5rem; }
.session-actions .btn { font-size: 0.72rem; padding: 0.25rem 0.55rem; }

/* mapping */
#mapping-toggle {
  position: fixed;
  bottom: 1rem;
  left: 1.2rem;
  z-index: 15;
}
#mapping-toggle.hidden { display: none; }

.mapping-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
}
.mapping-row label { font-size: 0.78rem; color: var(--ink); white-space: nowrap; }
.mapping-row select { flex: 1; font-size: 0.78rem; }

.hidden { display: none !important; }
