:root {
  --bg: #111418;
  --card: #1a1f26;
  --card2: #232a33;
  --text: #eef2f6;
  --muted: #8b97a6;
  --line: #2c3540;
  --accent: #ff9f1c;
  --ok: #2ecc71;
  --off: #ff5d5d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) 0 calc(96px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

button, input, select { font: inherit; color: inherit; }

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--card2);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button.primary { background: var(--accent); color: #1b1203; font-weight: 700; }
button.ghost { background: var(--card2); }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px 4px;
}
.topbar h1 { font-size: 19px; margin: 0; }

main { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--card); border-radius: 16px; padding: 14px; }
.label { font-size: 14px; font-weight: 500; color: var(--muted); margin: 0 0 8px; }

/* Tempo */
.tempo { text-align: center; }
.bpm { font-size: 76px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.bpm .unit { font-size: 20px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.tempo-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.tempo-row input { flex: 1; accent-color: var(--accent); min-width: 0; }
.step { width: 44px; height: 44px; padding: 0; font-size: 24px; flex: none; }

/* Schläge */
.beats { transition: background-color 0.25s ease-out; }
.beats.flash-accent { animation: flashA 0.22s ease-out; }
.beats.flash-normal { animation: flashN 0.18s ease-out; }
@keyframes flashA { from { background-color: rgba(255, 159, 28, 0.55); } to { background-color: var(--card); } }
@keyframes flashN { from { background-color: rgba(238, 242, 246, 0.18); } to { background-color: var(--card); } }

.dots {
  --cols: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}
.dot {
  width: min(52px, calc((100% - (var(--cols) - 1) * 8px) / var(--cols)));
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card2);
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  position: relative;
}
.dot.accent { border-color: var(--accent); color: var(--accent); }
.dot.normal { color: var(--text); }
.dot.mute { color: var(--muted); border-style: dashed; opacity: 0.55; }
.dot.mute span { text-decoration: line-through; }
.dot.now { animation: pop 0.2s ease-out; }
.dot.now.accent { background: var(--accent); color: #1b1203; }
.dot.now.normal { background: var(--text); color: var(--bg); }
.dot.now.mute { background: #3a4550; opacity: 1; }
@keyframes pop { from { transform: scale(1.18); } to { transform: scale(1); } }
.hint { text-align: center; font-size: 12px; margin: 4px 0 0; }

/* Taktart */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border-radius: 999px; padding: 8px 14px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); color: #1b1203; font-weight: 600; }

.meter-row { display: flex; align-items: center; gap: 6px; }
.meter-row .step { width: 40px; height: 40px; font-size: 22px; }
.meter-label { min-width: 48px; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-row .seg { margin-left: auto; flex: 0 1 110px; min-width: 84px; }

.seg {
  display: grid;
  background: var(--bg);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.seg2 { grid-template-columns: 1fr 1fr; }
.seg4 { grid-template-columns: repeat(4, 1fr); }
.seg button { background: transparent; padding: 9px 4px; border-radius: 10px; font-size: 15px; }
.seg button.on { background: var(--card2); color: var(--accent); font-weight: 600; }

.slider-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-top: 12px; }
.slider-row input { flex: 1; accent-color: var(--accent); min-width: 0; }

/* Optionen */
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; gap: 8px; }
.opt input { margin-left: auto; }
input[type=checkbox][role=switch] {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--card2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}
input[type=checkbox][role=switch]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
input[type=checkbox][role=switch]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox][role=switch]:checked::after { transform: translateX(18px); }
input[type=checkbox][role=switch]:disabled { opacity: 0.4; cursor: default; }

/* Untere Leiste */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(17, 20, 24, 0.96);
  border-top: 1px solid var(--line);
  max-width: 560px;
  margin: 0 auto;
}
.actions { display: flex; gap: 8px; }
.bottombar button { padding: 16px; font-size: 18px; }
#btnTap { flex: 1; }
#btnTap.hit { animation: tapHit 0.15s ease-out; }
@keyframes tapHit { from { background: #3a4550; } to { background: var(--card2); } }
#btnStart { flex: 2; }
#btnStart.running { background: var(--off); color: #fff; }
