/* ── KAOS — dark music-production theme ── */

:root {
  --bg:       #0e0e14;
  --surface:  #18181f;
  --surface2: #22222c;
  --border:   #2e2e3e;
  --accent:   #7c6af7;
  --accent2:  #a87fff;
  --green:    #2dba6a;
  --red:      #e05252;
  --yellow:   #f0c040;
  --teal:     #40b0c0;
  --text:     #e6e6f0;
  --muted:    #7a7a9a;
  --radius:   10px;
  --card-pad: 18px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--accent);
}

.logo-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}

/* Status pill */

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  border: 1px solid transparent;
}

.pill-idle    { background: var(--surface2); color: var(--muted); }
.pill-running { background: #142a1e; color: var(--green);  border-color: var(--green); }
.pill-hand    { background: #1a1436; color: var(--accent); border-color: var(--accent); }
.pill-muted   { background: #2a1414; color: var(--red);    border-color: var(--red); }

/* ── Main ── */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

/* ── Stats row ── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}

.stat-card.accent {
  border-color: var(--accent);
  background: #151230;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1.1;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 5px;
}

/* ── CC bar ── */

.cc-bar-wrap {
  margin-bottom: 20px;
}

.cc-bar-track {
  height: 12px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
}

.cc-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 6px;
  transition: width 0.05s linear;
}

.cc-bar-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}

/* ── Control grid ── */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-pad);
}

.card-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn.wide { width: 100%; margin-bottom: 10px; }

/* Active state (MIDI active, preview on) */
.btn-active {
  background: #1a1536;
  border-color: var(--accent);
  color: var(--accent);
}

/* Muted state */
.btn-muted-state {
  background: #2a1414;
  border-color: var(--red);
  color: var(--red);
}

/* Toggle: off */
.btn-toggle {
  flex: 1;
  color: var(--muted);
}
/* Toggle: on */
.btn-toggle-on {
  background: #1a1536;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary {
  flex: 1;
  border-color: #3a3a50;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
}
.btn-secondary small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 11px;
}
.btn-ghost:hover { color: var(--red); border-color: transparent; }

.btn-pair {
  display: flex;
  gap: 10px;
}

.toggle-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

/* ── Field layout ── */

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.field label {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Segmented control ── */

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  flex: 1;
  padding: 6px 10px;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s, color 0.12s;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover:not(.seg-active) { background: var(--surface2); color: var(--text); }
.segmented button.seg-active {
  background: var(--accent);
  color: #fff;
}

.unit { font-size: 11px; color: var(--muted); }

.hand-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
  min-width: 36px;
}

/* ── Calibration indicator ── */

.cal-uncal,
.cal-partial,
.cal-ready {
  border-radius: 6px;
  font-size: 11px;
  padding: 8px 12px;
  line-height: 1.5;
}

.cal-uncal   { background: #272710; color: var(--yellow); border: 1px solid #4a4410; }
.cal-partial { background: #102727; color: var(--teal);   border: 1px solid #205555; }
.cal-ready   { background: #102710; color: var(--green);  border: 1px solid #205510; }

/* ── Select / Number input ── */

select,
input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

select { flex: 1; }
input[type="number"] { width: 70px; }

/* ── Sliders ── */

.slider-group {
  margin-bottom: 14px;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.val {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-hints {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--border);
  margin-top: 3px;
}

/* ── Pitch meter ── */

.pitch-meter-wrap {
  margin-bottom: 4px;
}

.pitch-meter-track {
  position: relative;
  height: 12px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
}

/* vertical centre line */
.pitch-meter-center {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--border);
  transform: translateX(-50%);
}

/* the moving fill — grows left or right from centre */
.pitch-meter-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #e05252, #a87fff, #2dba6a);
  border-radius: 6px;
  transition: left 0.04s linear, width 0.04s linear;
}

/* ── Hint text ── */

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Footer ── */

footer {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
}

.btn-quit {
  font-size: 11px;
  padding: 3px 10px;
  opacity: 0.6;
}
.btn-quit:hover { opacity: 1; }

/* ── Responsive ── */

@media (max-width: 620px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
