:root {
  color-scheme: dark;
  --bg: #060608;
  --card: rgba(255, 255, 255, .045);
  --card-border: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .12);
  --accent: #a855f7;
  --accent-soft: #c4b5fd;
  --red: #c95835;
  --text: #f3f1f8;
  --muted: #c9c6d4;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 4%, rgba(255, 255, 255, .55), transparent 0.6%),
    radial-gradient(circle at 78% 12%, rgba(255, 255, 255, .4), transparent 0.5%),
    radial-gradient(circle at 45% 30%, rgba(255, 255, 255, .35), transparent 0.5%),
    radial-gradient(circle at 90% 55%, rgba(255, 255, 255, .3), transparent 0.5%),
    radial-gradient(circle at 10% 65%, rgba(255, 255, 255, .3), transparent 0.5%),
    radial-gradient(circle at 60% -10%, rgba(168, 85, 247, .22), transparent 42%),
    linear-gradient(180deg, #0a0a0d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

button, input { font: inherit; }

button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

header { text-align: center; margin: 2px 0 20px; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-soft);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(1.65rem, 7vw, 2.15rem); letter-spacing: -.035em; }

.sub { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }

.card {
  width: 100%;
  margin: 0 0 14px;
  padding: 17px;
  overflow: hidden;
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  border-radius: 19px;
  box-shadow: var(--shadow);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 13px; }

.section-head h2 { margin: 0; font-size: .92rem; letter-spacing: .02em; }

.section-head p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }

.library-badge, .meter-badge {
  padding: 5px 9px;
  color: var(--accent-soft);
  background: rgba(168, 85, 247, .12);
  border: 1px solid rgba(168, 85, 247, .3);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
}

.meter-badge { min-width: 45px; text-align: center; font-size: .8rem; }

.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.pattern-row { margin-top: 9px; }

.style-btn {
  min-height: 67px;
  padding: 11px 9px;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.style-btn strong, .style-btn small { display: block; }

.style-btn strong { font-size: .9rem; }

.style-btn small { margin-top: 3px; color: var(--muted); font-size: .8rem; line-height: 1.3; }

.style-btn.active {
  color: var(--accent-soft);
  background: rgba(168, 85, 247, .14);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(168, 85, 247, .18);
}

.style-btn.active small { color: #ede7ff; }

.transport-card { padding-top: 12px; }

.beat-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 38px; margin-bottom: 7px; }

.beat-dot {
  width: 25px;
  height: 25px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: transform .08s ease, background .08s ease, box-shadow .08s ease;
}

.beat-dot.sam { width: 31px; height: 31px; border-color: rgba(201, 88, 53, .65); }

.beat-dot.division { border-color: rgba(168, 85, 247, .38); }

.beat-dot.lit { background: var(--accent); transform: scale(1.18); box-shadow: 0 0 17px rgba(168, 85, 247, .6); }

.beat-dot.sam.lit { background: var(--red); box-shadow: 0 0 19px rgba(201, 88, 53, .65); }

.tempo-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px 72px; align-items: center; gap: 8px; margin-top: 4px; }

.tempo-step {
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--accent-soft);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 800;
}

.tempo-step:active { transform: scale(.96); }

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

.tempo-val { min-width: 72px; color: var(--accent-soft); font-size: 1.35rem; font-weight: 850; text-align: right; }

.tempo-val small { display: block; margin-top: -2px; color: var(--muted); font-size: .7rem; letter-spacing: .1em; }

.tempo-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -3px 80px 8px 52px; }

.range-hint { color: var(--muted); font-size: .78rem; text-align: right; white-space: nowrap; }

.pitch-lock { color: #ddc8ff; font-size: .78rem; font-weight: 750; letter-spacing: .02em; white-space: nowrap; }

.transport { display: grid; grid-template-columns: 1fr 112px; gap: 10px; }

.transport-tools { display: grid; grid-template-rows: 1fr 1fr; gap: 7px; }

.transport-tools button { min-height: 0; }

.transport button {
  min-height: 61px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  font-weight: 850;
}

.play { background: linear-gradient(135deg, #d5643f, #8d3922); box-shadow: 0 0 26px rgba(213, 100, 63, .35); }

.play.playing { background: rgba(255, 255, 255, .07); box-shadow: none; }

.tap, .variation { background: rgba(255, 255, 255, .05); color: var(--text) !important; font-size: .85rem; border: 1px solid var(--card-border); }

.variation { border-color: rgba(168, 85, 247, .28) !important; }

.status { min-height: 20px; margin: 9px 0 2px; color: var(--text); font-size: .9rem; font-weight: 600; text-align: center; }

.volume-row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 12px; margin-top: 7px; }

.volume-row label { color: var(--text); font-size: .88rem; }

.companion-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }

.companion-block { margin-bottom: 9px; }

.companion-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 67px;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.companion-check {
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.companion-btn:has(.companion-check:checked) { background: rgba(168, 85, 247, .14); border-color: var(--accent); }

.instrument-icon { display: grid; width: 34px; height: 34px; place-items: center; background: rgba(168, 85, 247, .12); border-radius: 50%; font-size: 1.05rem; }

.companion-btn strong, .companion-btn small { display: block; }

.companion-btn strong { font-size: .92rem; }

.companion-btn small { margin-top: 2px; color: var(--muted); font-size: .8rem; }

.tamb-block { margin-top: 9px; }

.tamb-btn { width: 100%; margin-bottom: 8px; }

.tamb-interval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 44px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.tamb-block .tamb-interval-row + .tamb-interval-row,
.karatal-block .tamb-interval-row + .tamb-interval-row { margin-top: 8px; }

.tamb-interval-row span { flex: 0 0 auto; color: var(--text); font-size: .88rem; }

.tamb-interval-row select {
  min-height: 44px;
  padding: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  flex: 1 1 205px;
  min-width: 0;
  font-size: .88rem;
  font-weight: 700;
}

.karatal-block { margin-top: 9px; }

.karatal-btn { width: 100%; margin-bottom: 8px; }

.karatal-block .tamb-interval-row { margin-bottom: 8px; }

.segment-label { margin-bottom: 6px; color: var(--text); font-size: .88rem; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.segmented button {
  min-height: 44px;
  padding: 8px 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: .74rem;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] {
  color: var(--accent-soft);
  background: rgba(168, 85, 247, .14);
  border-color: var(--accent);
}

.companion-volume { margin-top: 10px; }

/* Meine Presets */

.preset-row { display: flex; align-items: center; gap: 8px; }

.preset-row select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 700;
}

.preset-menu-btn {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  color: var(--accent-soft);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 800;
}

.preset-menu {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: #1a1420;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.preset-menu[hidden] { display: none; }

.preset-menu button {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: .85rem;
}

.preset-menu button:hover, .preset-menu button:focus-visible { border-color: var(--accent); }

#presetDeleteBtn { color: #f29a8a; }

.preset-save-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  padding: 10px 14px;
  color: #fff;
  background: linear-gradient(135deg, #9d4edd, #6a2fb0);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 800;
}

.preset-hint { margin: 8px 0 0; color: var(--muted); font-size: .8rem; text-align: center; }

.preset-dialog {
  width: min(90vw, 360px);
  padding: 18px;
  color: var(--text);
  background: #1a1420;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.preset-dialog::backdrop { background: rgba(0, 0, 0, .6); }

.preset-dialog h3 { margin: 0 0 12px; font-size: 1rem; }

.preset-dialog p { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }

.preset-dialog input[type="text"] {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: .9rem;
}

.preset-dialog-error { color: #f29a8a !important; font-size: .74rem !important; }

.preset-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.preset-dialog-actions button {
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
}

.preset-dialog-primary { color: #fff; background: linear-gradient(135deg, #9d4edd, #6a2fb0); }

.preset-dialog-secondary { color: var(--text); background: rgba(255, 255, 255, .08); }

.preset-dialog-danger { color: #fff; background: #c95835; }

footer { padding: 10px 4px 0; color: var(--muted); font-size: .8rem; text-align: center; }
.app-version { display: inline-block; margin-top: 6px; padding: 3px 10px; color: var(--text); background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 700px) {
  .app-shell { padding-top: 36px; }
}

@media (max-width: 370px) {
  .card { padding: 14px; }
  .beat-dot { width: 22px; height: 22px; }
  .beat-dot.sam { width: 27px; height: 27px; }
  .companion-btn { padding-inline: 8px; }
  .instrument-icon { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.style-btn small.style-range { margin-top: 2px; color: var(--accent-soft); font-weight: 700; }

/* Live session: calm, high-contrast controls within one phone viewport. */
:root { --bg:#101917; --card:#19241f; --card-border:#35443b; --line:#526057; --accent:#c9ed9b; --accent-soft:#d4edb5; --text:#f2f4ed; --muted:#b7c3b8; --shadow:none; }
body { background:radial-gradient(ellipse at 50% 0, #23382d 0, #101917 65%); }
.app-shell { width:min(100%, 960px); padding:24px 24px 30px; }
header { display:flex; justify-content:space-between; align-items:center; gap:16px; text-align:left; margin:0 0 20px; }
h1 { font-size:28px; letter-spacing:-.05em; }
.eyebrow { font-size:10px; letter-spacing:.23em; margin-bottom:7px; }
.live-badge { display:inline-block; vertical-align:middle; margin-left:10px; padding:5px 7px; border:1px solid #78916a; border-radius:5px; color:var(--accent); font-size:10px; letter-spacing:.12em; }
button, select, summary { touch-action:manipulation; }
button { cursor:pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline:3px solid #e3fbc6; outline-offset:4px; }
button:disabled { opacity:.5; cursor:default; }
#liveLock { min-height:44px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; background:#233027; color:var(--text); font-size:12px; }
#liveLock[aria-pressed="true"] { background:var(--accent); color:#172414; }
.session-status { display:flex; justify-content:space-between; gap:8px; margin-bottom:14px; color:var(--muted); font-size:12px; }
#sessionState { color:var(--accent); font-weight:700; }
.live-surface { display:grid; grid-template-columns:1.2fr 1fr; gap:16px; }
.card { background:var(--card); border-radius:20px; padding:20px; backdrop-filter:none; margin:0; }
.panel-label { margin:0; color:var(--muted); font-size:11px; font-weight:700; letter-spacing:.18em; }
.transport-card { position:relative; }
.beat-row { position:absolute; top:18px; right:20px; min-height:16px; gap:5px; }
.beat-dot, .beat-dot.sam { width:8px; height:8px; border-radius:3px; border-color:#697b64; }
.beat-dot:nth-child(5) { margin-left:6px; }
.beat-dot.lit, .beat-dot.sam.lit { background:var(--accent); box-shadow:none; }
.tempo-row { grid-template-columns:64px 1fr 64px; gap:10px; margin:12px 0 0; }
.tempo-step { width:64px; height:64px; border-radius:18px; font-size:32px; background:#26352b; }
.tempo-val { grid-column:2; grid-row:1; text-align:center; font-size:76px; line-height:1; letter-spacing:-.07em; font-variant-numeric:tabular-nums; color:var(--text); }
.tempo-val small { font-size:11px; letter-spacing:.18em; margin-top:7px; }
#tempoUp { grid-column:3; grid-row:1; }
#tempo { grid-column:1 / -1; grid-row:2; min-height:28px; margin:0; }
.tempo-meta { margin:0 0 16px; gap:4px; }
.pitch-lock, .range-hint { color:var(--muted); font-size:11px; font-weight:400; }
.transport { grid-template-columns:1fr 100px; gap:10px; }
.transport button { min-height:88px; border-radius:16px; }
.play { background:var(--accent); color:#162211 !important; box-shadow:none; font-size:25px; }
.play.playing { background:#d9e8cc; color:#162211 !important; }
.transport-tools { display:block; }
.transport-tools button { height:100%; width:100%; border:1px solid var(--line); background:#26352b; }
.status { font-size:12px; min-height:32px; margin:12px 0 0; line-height:1.4; font-weight:400; color:var(--muted); }
.section-head { margin-bottom:12px; }
.section-head h2 { font-size:14px; }
.library-badge { background:none; border:0; padding:0; font-size:10px; color:var(--muted); }
.styles { gap:10px; }
.style-btn { min-height:116px; border-radius:14px; padding:14px; background:#202e25; }
.style-btn strong { font-size:17px; }
.style-btn small { font-size:11px; }
.style-btn.active { background:#31442b; box-shadow:inset 0 0 0 1px var(--accent); border-color:var(--accent); }
.style-btn.active small { color:#d2e3c7; }
.style-btn small.style-range { margin-top:10px; color:var(--muted); font-size:10px; }
#emergencyStop { display:flex; justify-content:center; align-items:center; gap:16px; width:100%; min-height:52px; margin:16px 0; border:1px solid #a36255; border-radius:12px; background:#38251f; color:#ffd0c3; font-weight:750; font-size:16px; }
#emergencyStop span { font-size:12px; font-weight:400; }
.settings { border-top:1px solid var(--card-border); }
.settings summary { min-height:56px; padding:16px 2px; cursor:pointer; color:var(--text); font-size:14px; font-weight:600; }
.settings summary span { float:right; color:var(--muted); font-size:12px; font-weight:400; }
.settings-content { display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:4px 0 16px; }
.companions { grid-column:1 / -1; }
#variationBtn { min-height:48px; width:100%; margin-top:10px; border:1px solid var(--line); border-radius:10px; }
.preset-save-btn, .preset-dialog-primary { background:var(--accent); color:#162211; }
.preset-dialog, .preset-menu { background:#1c2b22; }
.companion-btn:has(.companion-check:checked) { background:#31442b; }
.instrument-icon { background:#31442b; }
footer { font-size:11px; line-height:1.8; padding-top:16px; }
[hidden] { display:none !important; }
@media(max-width:650px) {
 .app-shell { max-width:460px; padding:16px 16px 22px; }
 header { margin-bottom:14px; gap:8px; }
 h1 { font-size:25px; }
 #liveLock { width:100px; font-size:11px; }
 .live-badge { font-size:8px; margin-left:7px; padding:4px; }
 .live-surface { display:flex; flex-direction:column; gap:12px; }
 .card { padding:16px; border-radius:16px; }
 .tempo-row { margin-top:9px; }
 .tempo-val { font-size:68px; }
 .tempo-meta { margin-bottom:12px; }
 .transport button { min-height:76px; }
 .status { min-height:18px; margin-top:9px; }
 .styles { gap:8px; }
 .style-btn { min-height:58px; padding:8px 12px; }
 .style-btn strong { font-size:15px; }
 .style-btn small { font-size:10px; margin-top:2px; }
 .style-btn small.style-range { display:none; }
 .style-card .section-head { margin-bottom:8px; }
 .settings-content { grid-template-columns:1fr; }
 #emergencyStop { margin:12px 0 4px; }
 footer { padding-top:8px; }
}
@media(max-height:720px) and (max-width:650px) {
 .app-shell { padding-top:10px; }
 header { margin-bottom:8px; }
 .eyebrow { display:none; }
 .session-status { margin-bottom:8px; }
 .tempo-val { font-size:54px; }
 .tempo-step { height:56px; }
 .transport button { min-height:64px; }
 .card { padding:12px; }
 .tempo-meta { margin-bottom:8px; }
 .live-surface { gap:8px; }
 .style-btn { min-height:52px; }
 .style-btn small { font-size:10px; }
 .settings summary { min-height:48px; padding:14px 2px; }
}
@media(max-width:370px) {
 .tempo-val { font-size:48px; }
 .tempo-row { grid-template-columns:56px 1fr 56px; }
 .tempo-step { width:56px; }
 .transport { grid-template-columns:1fr 86px; }
 .library-badge { font-size:9px; }
 .style-btn { padding:7px 8px; }
 .style-btn small { white-space:nowrap; font-size:9px; }
 .session-status { font-size:10px; }
 h1 { font-size:22px; }
}
@media(max-height:600px) and (max-width:650px) {
 .transport-card { padding:10px 12px; }
 .panel-label { font-size:10px; }
 .tempo-row { margin-top:5px; }
 .tempo-val { font-size:44px; }
 .tempo-step { height:48px; }
 #tempo { min-height:22px; }
 .transport button { min-height:56px; }
 .tempo-meta { margin-bottom:6px; }
 .status { margin-top:5px; }
 .style-btn { min-height:44px; }
 .style-card { padding:10px 12px; }
 #emergencyStop { min-height:48px; margin-top:8px; }
}
#emergencyStop { position:sticky; top:8px; z-index:10; }
.variation { border-color:var(--line) !important; }
.beat-dot.division { border-color:#78916a; }
