:root {
  --bg: #07080c;
  --panel: rgba(14, 16, 24, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --fg: #eef1f7;
  --muted: #9aa3b5;
  --left: #7cf5c8;
  --right: #ff9df0;
  --accent: #8fb4ff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}

#cam, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#cam {
  transform: scaleX(-1);
  filter: saturate(0.55) brightness(0.55) contrast(1.05);
}

#overlay { pointer-events: none; }

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

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.hands { display: flex; gap: 6px; margin-left: auto; }

.dot {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  transition: 0.15s;
}
.dot.left.is-on  { color: #06251b; background: var(--left);  border-color: var(--left); }
.dot.right.is-on { color: #2a0723; background: var(--right); border-color: var(--right); }

.icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}
.icon:hover { border-color: var(--accent); }

/* ------------------------------------------------------------- readout */

.readout {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  pointer-events: none;
}

.chord-name {
  font-size: clamp(48px, 14vw, 104px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.7);
}

.chord-notes {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.06em;
  min-height: 1.4em;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0 12px;
}
.facts > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  backdrop-filter: blur(8px);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.facts dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.facts dd { margin: 0; font-size: 13px; font-weight: 600; }

/* ------------------------------------------------------------- controls */

.controls {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 180px; }
.field > span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.field em { font-style: normal; color: var(--fg); }

select, input[type="range"] {
  accent-color: var(--accent);
  background: rgba(0, 0, 0, 0.45);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
}
input[type="range"] { padding: 0; border: 0; background: none; width: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--fg); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #06122e; font-weight: 650; }

.field.toggle { flex-direction: row; align-items: center; gap: 7px; }
.field.toggle span { font-size: 11px; text-transform: none; letter-spacing: 0; color: var(--muted); }

.status {
  position: relative;
  z-index: 2;
  margin: 8px 14px calc(10px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.status.is-error { color: #ff8a8a; }

/* ------------------------------------------------------------- overlays */

.start-screen, .help {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 5, 9, 0.88);
  backdrop-filter: blur(10px);
  overflow: auto;
}
.start-screen.is-hidden { display: none; }
.help { display: none; }
.help.is-open { display: grid; }

.start-card, .help-card {
  position: relative;
  width: min(720px, 100%);
  background: #0d1018;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
}
.start-card { max-width: 420px; text-align: center; }
.start-card h2, .help-card h2 { margin: 0 0 10px; font-size: 22px; }
.start-card p { color: var(--muted); margin: 0 0 18px; }

.primary {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 13px 18px;
  background: var(--accent);
  color: #06122e;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.primary:disabled { opacity: 0.55; cursor: default; }

.fineprint { font-size: 11px; margin: 14px 0 0 !important; }

.close { position: absolute; top: 16px; right: 16px; }

.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 620px) { .help-cols { grid-template-columns: 1fr; } }

.help-card h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0.04em; }
.help-card h3.left { color: var(--left); }
.help-card h3.right { color: var(--right); }
.help-card h4 {
  margin: 14px 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.help-card ul { margin: 0; padding-left: 18px; }
.help-card li { font-size: 13px; }
.note { color: var(--muted); font-size: 12px; margin: 16px 0 0; }

/* ------------------------------------------------------------- drums */

.chips {
  /* eight presets do not fit a phone; scroll them instead of stacking rows */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }

.drums {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9;
  display: none;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
}
.drums.is-open { display: block; }

.drums-card {
  background: rgba(10, 12, 18, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(16px);
  max-height: 72vh;
  overflow-y: auto;
}

.drums-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.drums-head .field { flex: 1 1 130px; }
.drums-head .icon { margin-left: auto; align-self: flex-start; }

.primary.compact { width: auto; padding: 9px 20px; flex: 0 0 auto; }
.primary.is-playing { background: var(--left); color: #06251b; }

.grid-scroll { overflow-x: auto; scrollbar-width: thin; }

.steps-head, .lane {
  display: grid;
  grid-template-columns: 118px repeat(16, minmax(20px, 1fr));
  gap: 4px;
  align-items: center;
  min-width: 560px;
}
.steps-head { margin-bottom: 6px; }
.lane { margin-bottom: 6px; }

.tick {
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tick.is-beat { color: var(--fg); font-weight: 700; }
.tick.is-now { color: var(--accent); }

.lane-name {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.lane-name button {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: var(--muted);
  border-radius: 7px;
  font: inherit;
  font-size: 11px;
  padding: 4px 7px;
  cursor: pointer;
  white-space: nowrap;
}
.lane-name button.is-muted { opacity: 0.4; text-decoration: line-through; }
.lane-name .load { position: relative; overflow: hidden; }
.lane-name .load input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.lane-name .sample {
  font-size: 10px;
  color: var(--left);
  max-width: 46px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, border-color 0.1s;
}
.step:nth-child(4n + 2) { background: rgba(255, 255, 255, 0.08); }
.step.is-on { background: var(--accent); border-color: var(--accent); }
.step.is-now { box-shadow: inset 0 0 0 2px var(--fg); }
