/* Farbwelt Hannover 96: Grün · Schwarz · Weiß */
:root {
  --bg: #0b0c0c;
  --surface: #161918;
  --surface2: #202523;
  --line: #2c3330;
  --text: #f3f5f4;
  --muted: #95a09b;
  --accent: #00a651;      /* 96-Grün (Ansehen) */
  --accent-ink: #ffffff;
  --edit: #ffffff;        /* Weiß (Bearbeiten) */
  --edit-ink: #000000;
  --danger: #ff5a52;
  --ok: #2fd27a;
  --d: #ff7eb3;           /* Damen */
  --h: #62b3ff;           /* Herren */
  --g: var(--d);
  --f-dev: #ff8c2e;       /* Abweichung im Video */
  --f-rev: #b57bff;       /* Definition überarbeiten */
  --f-cmt: #3fd0d0;       /* Kommentar (Zeile mit ?) */
  --cw: 44px;
  --r: 14px;
  color-scheme: dark;
}
:root[data-gender="h"] { --g: var(--h); }

* { box-sizing: border-box; }
/* kein Zoomen durch schnelles Doppeltippen (stört z. B. bei Pfeiltasten); Zoomen mit zwei Fingern bleibt */
* { touch-action: manipulation; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body { overscroll-behavior: none; }
a { color: var(--accent); }
body.mode-edit a { color: #fff; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; }

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 3px solid var(--accent);
  background: #000;
  transition: border-color .2s;
}
body.mode-edit .topbar { border-bottom-color: var(--edit); }
.brand-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.brand { font-weight: 800; white-space: nowrap; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.choreo-btn {
  display: flex; align-items: center; gap: 4px; max-width: 100%; border: 0; background: none; padding: 0;
  color: var(--muted); font-size: 12.5px; cursor: pointer; text-align: left;
}
.choreo-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choreo-btn i { font-style: normal; font-size: 10px; opacity: .7; }
.choreo-btn:hover { color: var(--text); }

.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; gap: 2px; flex-shrink: 0; }
.seg a, .seg button {
  border: 0; background: none; color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
@media (max-width: 400px) { .seg a, .seg button { padding: 7px 10px; } }
.seg .on { background: var(--surface2); color: var(--text); }
.mode a.on[data-mode="view"] { background: var(--accent); color: var(--accent-ink); }
.mode a.on[data-mode="edit"] { background: var(--edit); color: var(--edit-ink); }
.gender .on[data-g="d"] { background: var(--d); color: #2b0015; }
.gender .on[data-g="h"] { background: var(--h); color: #001a33; }

main { min-height: 0; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; }
main.fill { overflow: hidden; }

/* Choreo-Auswahl (Menü) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center;
  padding: calc(56px + env(safe-area-inset-top)) 12px 12px;
}
.sheet {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.sheet-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.sheet-item {
  text-align: left; border: 1px solid var(--line); background: var(--surface2); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.sheet-item b, .sheet-item small { display: block; }
.sheet-item small { color: var(--muted); font-size: 12.5px; }
.sheet-item.on { border-color: var(--accent); }

/* ---------- Tab-Leiste (nur Bearbeiten) ---------- */
.tabbar { display: none; }
body.mode-edit .tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 6px; color: var(--muted) !important; text-decoration: none; font-size: 11.5px; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--edit) !important; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--text) !important;
  padding: 10px 16px; border-radius: 12px; font-weight: 650; text-decoration: none; cursor: pointer;
  min-height: 44px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink) !important; }
body.mode-edit .btn.primary { background: var(--edit); color: var(--edit-ink) !important; }
.btn.danger { color: var(--danger) !important; }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 52px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); font-size: 18px; cursor: pointer; display: inline-grid; place-items: center; flex-shrink: 0;
}
.icon-btn.sm { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.linkish { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0 4px; }
body.mode-edit .linkish { color: #fff; }
.input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px;
}
.input.big { font-size: 18px; font-weight: 700; }
.input.sm { width: 76px; padding: 7px 8px; font-size: 16px; }
.input:focus, textarea:focus, select:focus { outline: 2px solid var(--edit); outline-offset: 0; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .5px; }
.card > .lbl:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0; }
.warn { color: #ff8a7a; }
.ok { color: var(--ok); }
.check { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check.sm { padding: 0; font-size: 14px; }
.check.sm input { width: 18px; height: 18px; }
.chip {
  border: 1px solid var(--line); background: var(--surface2); border-radius: 99px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip b { color: var(--accent); margin-right: 4px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--bg); overflow: hidden; margin-top: 10px; }
.progress i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); transition: width .2s; }
.progress span { position: relative; display: block; line-height: 26px; padding: 0 10px; font-size: 12.5px; font-weight: 600; }

/* ---------- Seiten ---------- */
.page { padding: 14px 14px 28px; display: flex; flex-direction: column; gap: 12px; }
.page-head { display: flex; align-items: center; gap: 10px; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head .input.title { font-size: 18px; font-weight: 700; padding: 8px 10px; }
.back { color: var(--muted) !important; text-decoration: none; white-space: nowrap; font-weight: 600; padding: 8px 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
details.card > summary { cursor: pointer; font-weight: 650; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸ "; color: var(--muted); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: 10px; }
details.help ol { padding-left: 20px; margin: 6px 0; }
details.help li { margin: 4px 0; }
details.help p { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.sec { margin: 8px 2px 0; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sec small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.step { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step span {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px;
}
.empty { padding: 48px 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.empty-icon { font-size: 44px; color: var(--accent); }
.empty h2 { margin: 8px 0; font-size: 20px; }
.empty p { color: var(--muted); margin-bottom: 20px; }
.num {
  width: 28px; height: 28px; border-radius: 8px; background: var(--surface2); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.file-btn {
  display: flex; align-items: center; justify-content: center; min-height: 64px;
  border: 2px dashed var(--line); border-radius: 12px; color: var(--edit); font-weight: 650; cursor: pointer; text-align: center; padding: 10px;
}
.file-info:not(:empty) { margin-top: 10px; }
.preview { display: flex; gap: 12px; align-items: flex-start; }
.preview video { width: 96px; height: 170px; object-fit: cover; border-radius: 10px; background: #000; flex-shrink: 0; }
.preview b { display: block; word-break: break-all; }
.preview small { display: block; color: var(--muted); margin-top: 4px; }

/* Zählweise */
.struct-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.struct-grp { display: inline-flex; align-items: center; gap: 6px; }
.struct-row input, .struct-row select {
  width: 60px; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; font: inherit; font-size: 16px; text-align: center;
}
.struct-row .icon-btn { margin-left: auto; }
.struct-sum { color: var(--muted); font-size: 13px; }
.struct-preview {
  font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 6px 8px;
  margin: 2px 0 8px; overflow-wrap: anywhere;
}

/* ---------- Aufbau ---------- */
.music-head { display: flex; align-items: center; gap: 10px; }
.music-play { background: var(--accent); border-color: transparent; color: #fff; }
.music-name { min-width: 0; }
.music-name b, .music-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-name small { color: var(--muted); font-size: 12.5px; }
.music-wave { position: relative; margin-top: 10px; }
.music-wave canvas { display: block; width: 100%; height: 64px; background: var(--bg); border-radius: 8px; cursor: pointer; }
.mw-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }
.parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.part { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.part.open { border-color: var(--edit); }
.part-head { display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; }
.part-main { flex: 1; min-width: 0; }
.part-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-main small { display: block; color: var(--muted); font-size: 12.5px; }
.part-video { opacity: .25; filter: grayscale(1); font-size: 16px; }
.part-video.has { opacity: 1; filter: none; }
.chev { color: var(--muted); width: 16px; text-align: center; }
.part-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.part-actions { margin-top: 14px; }

/* Passwortschutz */
.lock-screen {
  position: fixed; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center;
  padding: 20px; border-top: 3px solid var(--accent);
}
.pw-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.pw-form h2 { margin: 0; font-size: 20px; }
.pw-form .hint { margin: 0; }
.pw-icon { font-size: 40px; }
.pw-page { align-items: center; padding-top: 48px; }
.tabbar a.pw-locked span::after { content: " 🔒"; font-size: 10px; }
.pw-sheet { max-height: calc(100vh - 80px); overflow: auto; }
.pw-block { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.pw-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pw-head span { font-size: 12.5px; }
.sheet-foot { border-top: 1px solid var(--line); padding-top: 10px; }
.span-row { margin-top: 10px; }

/* Sperre & Sicherungen */
.lock-card { border-color: var(--line); }
.lock-card.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.lock-head { display: flex; align-items: center; gap: 10px; }
.lock-icon { font-size: 22px; }
.lock-text { flex: 1; min-width: 0; }
.lock-text b, .lock-text small { display: block; }
.lock-text small { color: var(--muted); font-size: 12.5px; }
.backups { margin-top: 10px; }
.backups summary { cursor: pointer; font-weight: 650; font-size: 14px; }
.backup-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.backup-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg); border-radius: 10px; }
.backup-list li > div { flex: 1; min-width: 0; }
.backup-list b, .backup-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-list small { color: var(--muted); font-size: 12px; }
.build.locked .part-head { cursor: pointer; }
.music-stats { margin: 8px 0 0; }
.split-ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.split-ctl select.input.sm { width: 64px; }

/* Schlagraster-Editor */
.beated { display: flex; flex-direction: column; gap: 8px; }
.be-top { display: flex; align-items: center; gap: 10px; }
.be-view canvas { display: block; width: 100%; height: 110px; background: var(--bg); border-radius: 8px; touch-action: none; cursor: grab; }
.be-nav { display: flex; align-items: center; gap: 8px; }
.be-nav .range { margin: 0; }
.be-sel { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 36px; }
.be-selinfo { color: var(--muted); font-size: 13px; }
.be-selbtns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.be-bpc button { font-size: 12.5px; padding: 6px 10px; }
.be-bpc button.on { background: var(--edit); color: var(--edit-ink); }
.be-tools { border-top: 1px solid var(--line); padding-top: 8px; }
.be-tools summary { cursor: pointer; font-weight: 650; font-size: 14px; margin-bottom: 6px; }
.be-tools .al-line { margin-top: 6px; }
.be-tap-pad .btn { width: 100%; min-height: 80px; font-size: 20px; }
.be-info { margin: 0; }
.be-mode { border: 2px solid var(--f-dev); border-radius: 12px; padding: 8px 10px; background: color-mix(in srgb, var(--f-dev) 8%, var(--surface)); }
.beated.mode-iv .be-mode { border-color: var(--h); background: color-mix(in srgb, var(--h) 8%, var(--surface)); }
.be-mode p { margin: 0 0 6px; font-size: 13.5px; }
.be-mode .al-line + .al-line { margin-top: 6px; }
.beated.mode-end .be-view canvas, .beated.mode-iv .be-view canvas { cursor: crosshair; }
.be-block { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.be-block .al-lbl { width: 64px; }
.be-sel .hint { margin: 0; font-size: 12.5px; }
.vclip { display: block; font-size: 12.5px; color: var(--muted) !important; text-decoration: none; padding: 2px 0; }

/* Musik-Abgleich (Wiedergabe-Zähler) */
.al-top { display: flex; align-items: center; gap: 10px; }
.al-count { flex: 1; display: flex; align-items: baseline; gap: 8px; }
.al-count b {
  min-width: 52px; text-align: center; font-size: 28px; font-weight: 850; line-height: 1.1; border-radius: 10px; padding: 2px 6px;
  transition: background .06s;
}
.al-count b.flash { background: rgba(255,255,255,.25); }
.al-count b.one { background: var(--accent); }
.al-count small { color: var(--muted); font-variant-numeric: tabular-nums; }
.al-wave { position: relative; }
.al-wave span { position: absolute; left: 6px; bottom: 3px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; pointer-events: none; }
.al-wave canvas { display: block; width: 100%; height: 76px; background: var(--bg); border-radius: 8px; }
.al-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ffcf40; pointer-events: none; }
.al-ctrl { display: flex; flex-direction: column; gap: 8px; }
.al-line { display: flex; align-items: center; gap: 6px; }
.al-line.wrap { flex-wrap: wrap; }
.al-lbl { width: 54px; color: var(--muted); font-size: 13px; }
.al-line .input.sm { width: 88px; text-align: center; }

/* ---------- Videos ---------- */
.vlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vrow {
  display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); flex-wrap: wrap;
}
.vmain { flex: 1; min-width: 110px; }
.vmain b, .vmain small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmain small { color: var(--muted); font-size: 12.5px; }
.vrow select.input.sm { width: auto; max-width: 140px; font-size: 14px; }
.pick-parts { display: flex; flex-direction: column; gap: 6px; }
.pick-part { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); cursor: pointer; }
.pick-part input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.pick-part b, .pick-part small { display: block; }
.pick-part small { color: var(--muted); font-size: 12.5px; }
.assign-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assign-row .lbl { margin: 0; }
.assign-row select.input.sm { width: auto; max-width: 60%; font-size: 14px; }

/* ---------- Taktleiste ---------- */
.beatbar { position: relative; height: 74px; background: var(--surface); border-block: 1px solid var(--line); user-select: none; -webkit-user-select: none; }
.bb-scroll {
  height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
}
.bb-scroll::-webkit-scrollbar { display: none; }
.bb-track { display: flex; height: 100%; width: max-content; }
.bb-sp { flex: 0 0 auto; }
.bb-cell {
  flex: 0 0 var(--cw); width: var(--cw); position: relative; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 20px;
  cursor: pointer; border-left: 1px solid transparent;
}
.bb-cell.main { border-left-color: rgba(255,255,255,.06); }
.bb-cell.barstart { border-left: 1px solid rgba(255,255,255,.3); }
.bb-cell.groupstart { border-left: 3px solid var(--accent); }
.bb-cell.dim { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.035) 6px 12px); }
.bb-cell.dim .bb-lbl { opacity: .35; }
.bb-cell.inrange { background-color: rgba(0,166,81,.12); }
.bb-lbl { font-weight: 800; font-size: 20px; line-height: 1; transition: color .1s, transform .1s; }
.bb-cell.half .bb-lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.bb-cell.active .bb-lbl { color: var(--accent); transform: scale(1.15); }
.bb-group {
  position: absolute; top: 4px; left: 5px; font-size: 11px; font-weight: 700; color: var(--accent);
  white-space: nowrap; pointer-events: none;
}
.bb-bar { position: absolute; top: 19px; left: 5px; font-size: 10.5px; color: var(--muted); pointer-events: none; }
.bb-dot { display: none; position: absolute; bottom: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--g); }
.bb-cell.marked .bb-dot { display: block; }
.calib .bb-dot { background: var(--edit); border-radius: 2px; transform: rotate(45deg); }
.bb-flags { position: absolute; left: 3px; right: 3px; bottom: 0; height: 4px; display: none; border-radius: 2px 2px 0 0; }
.bb-cell.f-dev .bb-flags, .bb-cell.f-rev .bb-flags { display: block; }
.bb-cell.f-dev .bb-flags { background: var(--f-dev); }
.bb-cell.f-rev .bb-flags { background: var(--f-rev); }
.bb-cell.f-dev.f-rev .bb-flags { background: linear-gradient(90deg, var(--f-dev) 50%, var(--f-rev) 50%); }
.bb-q {
  display: none; position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--f-cmt); color: #002b2b; font-size: 10px; font-weight: 900; font-style: normal; line-height: 14px; text-align: center;
}
.bb-cell.commented .bb-q { display: block; }
.bb-pic { display: none; position: absolute; bottom: 7px; right: 4px; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 2px; }
.bb-cell.pictured .bb-pic { display: block; }
.bb-needle {
  position: absolute; top: 3px; bottom: 3px; left: 50%; width: var(--cw); transform: translateX(-50%);
  border: 2px solid var(--accent); border-radius: 12px; pointer-events: none;
}
body.mode-edit .bb-needle { border-color: var(--edit); }
.beatbar::before, .beatbar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40px; z-index: 1; pointer-events: none;
}
.beatbar::before { left: 0; background: linear-gradient(90deg, var(--surface), transparent); }
.beatbar::after { right: 0; background: linear-gradient(-90deg, var(--surface), transparent); }

/* ---------- Player ---------- */
.player { display: flex; flex-direction: column; height: 100%; }
.stage { position: relative; flex: 1; min-height: 160px; background: #000; overflow: hidden; }
.stage video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; background: #000;
}
.stage video.on { visibility: visible; }
.blackout {
  position: absolute; inset: 0; background: #000; display: none; align-items: center; justify-content: center;
  color: #4a4d55; font-size: 12px;
}
.blackout.on { display: flex; }
.hud { position: absolute; left: 12px; top: 10px; pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.8); z-index: 2; max-width: 60%; }
.hud-dance {
  display: inline-block; font-size: 12px; font-weight: 700; background: rgba(0,0,0,.5); padding: 3px 9px; border-radius: 99px;
  margin-bottom: 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: auto; border: 0; color: #fff; cursor: pointer;
}
.hud-dance:hover { background: rgba(0,0,0,.7); }
.hud-count { font-size: 46px; font-weight: 850; line-height: 1; color: #fff; }
.hud-bar { font-size: 13px; color: #ddd; font-weight: 600; }
.hud-flags { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 6px; }
.flag-pill {
  display: inline-block; font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: 6px; color: #111; text-shadow: none;
}
.flag-pill.f-dev { background: var(--f-dev); }
.flag-pill.f-rev { background: var(--f-rev); }

.stage-tools { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 3; }
.tool {
  border: 0; background: rgba(0,0,0,.55); color: #fff; border-radius: 99px; padding: 6px 11px; font-weight: 700;
  font-size: 13px; cursor: pointer; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.tool.pic-open { background: rgba(255,255,255,.92); color: #000; }
.tool.pic-open.fresh { background: var(--accent); color: #fff; }

.transport {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; z-index: 3;
}
.tp {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer;
  display: grid; place-items: center; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.tp svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.tp.play { width: 58px; height: 58px; background: var(--accent); }
.tp.play svg { width: 26px; height: 26px; }
.tp .i-pause, .playing .tp .i-play { display: none; }
.playing .tp .i-pause { display: block; }
.playing .transport { opacity: .55; }
.playing .transport:hover { opacity: 1; }

.panel {
  position: absolute; z-index: 5; left: 10px; right: 10px; top: 10px; max-height: calc(100% - 20px); overflow: auto;
  background: rgba(22,25,24,.97); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dance-jumps { display: flex; flex-direction: column; gap: 6px; }
.dj {
  display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface2);
  border-radius: 12px; padding: 10px; cursor: pointer; font-weight: 600;
}
.dj span {
  width: 26px; height: 26px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 13px; flex-shrink: 0;
}
.dj.on { border-color: var(--accent); }
.dj.on span { background: var(--accent); color: #fff; }
.play-mode { display: flex; width: 100%; margin-bottom: 10px; }
.play-mode button { flex: 1; }
.play-mode button.on { background: var(--accent); color: #fff; }
.tempo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tempo-row div { text-align: center; }
.big-val { display: block; font-size: 32px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.tempo-row small { color: var(--muted); font-size: 12px; }
.range { width: 100%; margin: 12px 0 6px; accent-color: var(--accent); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.loop-box { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.loop-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.loop-row span { width: 28px; color: var(--muted); }
.loop-row b { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loop-row b small { color: var(--muted); font-weight: 400; }
.lead-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.lead-row span { color: var(--muted); }
.lead-row .range { flex: 1; margin: 0; }
.lead-row b { min-width: 96px; text-align: right; font-weight: 600; }

.ctrl-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 8px 12px; }
.mark-chips { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; margin-left: auto; }
.mchip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 8px; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--text);
}
.mchip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.mchip.k-comment::before { background: var(--f-cmt); }
.mchip.k-dev::before { background: var(--f-dev); }
.mchip.k-rev::before { background: var(--f-rev); }

.notes {
  display: grid; grid-template-columns: 46px 1fr 46px; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  height: 170px; touch-action: pan-y; flex-shrink: 0;
}
.editable .notes { height: 200px; }
body.mode-edit .notes { padding-bottom: 10px; }
.nav {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px 2px;
}
.nav span { font-size: 26px; line-height: 1; color: var(--g); }
.nav small { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.nav:disabled { opacity: .3; cursor: default; }
.note-card {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line);
  border-radius: 14px; padding: 8px 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow: hidden;
  transition: border-color .2s, background .2s; position: relative;
}
.note-card.filled { border-top-color: var(--g); background: color-mix(in srgb, var(--g) 9%, var(--surface)); }
.note-card.f-dev { box-shadow: inset 4px 0 0 var(--f-dev); }
.note-card.f-rev { box-shadow: inset 4px 0 0 var(--f-rev); }
.note-card.f-dev.f-rev { box-shadow: inset 4px 0 0 var(--f-dev), inset 8px 0 0 var(--f-rev); }
.note-card.pop { animation: pop .32s ease-out; }
@keyframes pop {
  from { transform: translateY(10px) scale(.97); opacity: .4; }
  to { transform: none; opacity: 1; }
}
.note-head { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.note-head b { color: var(--text); font-size: 17px; }
.note-head span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-tag { font-style: normal; font-weight: 700; color: var(--g); font-size: 11.5px; }
.note-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.flag-btn, .pic-tag {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: var(--surface2); border-radius: 8px; padding: 3px 8px; cursor: pointer;
  font-size: 12.5px; line-height: 1.3; flex-shrink: 0; color: var(--muted);
}
.flag-btn i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; }
.flag-btn.f-dev { --fc: var(--f-dev); }
.flag-btn.f-rev { --fc: var(--f-rev); }
.flag-btn.f-dev i, .flag-btn.f-rev i { border-color: var(--fc); }
.flag-btn.on { background: var(--fc, #fff); border-color: var(--fc, #fff); color: #111; font-weight: 700; }
.flag-btn.on i { background: #111; border-color: #111; }
.tool-pic.on, .pic-tag { background: #fff; color: #000; border-color: #fff; font-weight: 700; }
.note-body { flex: 1; min-height: 0; overflow: auto; }
.note-text { font-size: 15.5px; line-height: 1.4; }
.note-text > div { white-space: pre-wrap; }
.note-text .cmt { color: var(--f-cmt); font-style: italic; }
.note-empty { color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 3px; opacity: .8; }
.note-empty small { font-size: 12px; opacity: .8; }
/* Textfeld mit hervorgehobenen Kommentar-Zeilen (Spiegel-Ebene hinter dem Text) */
.ta-wrap { position: relative; height: 100%; min-height: 60px; }
.ta-wrap textarea, .ta-mirror {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 16px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: break-word; overflow: auto; letter-spacing: normal;
}
.ta-mirror { color: transparent; background: var(--bg); pointer-events: none; }
.ta-mirror mark { color: transparent; background: color-mix(in srgb, var(--f-cmt) 26%, transparent); border-radius: 3px; }
.ta-wrap textarea { background: transparent; color: var(--text); resize: none; caret-color: var(--text); }
.note-card.filled .ta-wrap textarea { border-color: color-mix(in srgb, var(--g) 50%, var(--line)); }

/* ---------- Übersichtsleiste der Tänze ---------- */
.overview {
  position: relative; height: 30px; margin: 0 10px 8px; border-radius: 8px; overflow: hidden;
  background: var(--surface); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ov-segs { display: flex; height: 100%; gap: 2px; }
.ov-seg {
  min-width: 4px; background: var(--surface2); display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 4px; overflow: hidden; transition: flex .35s ease, background .25s;
}
.ov-seg:nth-child(odd) { background: #26302b; }
.ov-seg b { font-size: 10.5px; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.ov-seg span { display: none; font-size: 12px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-seg.cur { background: color-mix(in srgb, var(--accent) 30%, var(--surface2)); justify-content: flex-start; padding: 0 8px; }
.ov-seg.cur b { color: #fff; background: var(--accent); border-radius: 5px; padding: 0 5px; }
.ov-seg.cur span { display: block; }
body.mode-edit .ov-seg.cur { background: color-mix(in srgb, #fff 16%, var(--surface2)); }
body.mode-edit .ov-seg.cur b { background: #fff; color: #000; }
.ov-loop { position: absolute; top: 0; bottom: 0; background: rgba(0,166,81,.28); border-inline: 2px solid var(--accent); pointer-events: none; }
.ov-pos {
  position: absolute; top: 0; bottom: 0; left: 0; width: 3px; margin-left: -1.5px; background: var(--accent); border-radius: 2px;
  will-change: transform;
  box-shadow: 0 0 0 2px rgba(0,0,0,.5); pointer-events: none;
}
body.mode-edit .ov-pos { background: var(--edit); }

/* ---------- Kalibrierung ---------- */
.calib { display: flex; flex-direction: column; gap: 10px; margin: 0 -14px; }
.calib-stage { flex: none; height: 48vh; height: 48dvh; min-height: 260px; }
.calib-stage video { visibility: visible; }
.anchor-badge {
  position: absolute; right: 12px; top: 12px; background: var(--accent); color: #fff; font-weight: 700;
  font-size: 12px; padding: 4px 10px; border-radius: 99px; z-index: 2;
}
/* visuelles Metronom */
.vm {
  position: absolute; left: 50%; bottom: 8px; width: 110px; margin-left: -55px; z-index: 2; pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.9));
}
.vm svg { display: block; width: 100%; height: auto; overflow: visible; }
.vm-arc { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1.2; }
.vm-mark { stroke: rgba(255,255,255,.6); stroke-width: 2; stroke-linecap: round; transition: stroke .08s; }
.vm-mark.hit { stroke: #fff; }
.vm-mark.one { stroke: var(--accent); stroke-width: 3; }
.vm-needle line { stroke: rgba(255,255,255,.85); stroke-width: 1.6; stroke-linecap: round; }
.vm-needle circle { fill: #fff; }
.vm-pivot { fill: rgba(255,255,255,.7); }
.time-row { display: flex; align-items: center; gap: 6px; padding: 0 14px; }
.time-row .play { background: var(--accent); color: #fff; border-color: transparent; }
.time-row .sound.off { opacity: .55; }
.time-row .time { margin-left: auto; font-size: 16px; font-weight: 600; }
@media (max-width: 400px) { .time-row .icon-btn { width: 40px; } .time-row .time { font-size: 14px; } }
.scrub { margin: 0 14px; accent-color: var(--accent); height: 28px; }
.bb-label { padding: 0 14px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: -6px; }
.anchor-row { display: flex; gap: 8px; padding: 0 14px; }
.anchor-row .set { flex: 1; min-height: 50px; }
.calib-status { padding: 0 14px; color: var(--muted); font-size: 13.5px; }
.calib-status b { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.chips:empty { display: none; }

/* ---------- Bildbetrachter & Seitenauswahl ---------- */
.pic-overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.96); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.pic-head { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 3px solid var(--accent); }
.pic-title { flex: 1; min-width: 0; }
.pic-title b { display: block; font-size: 17px; }
.pic-title small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pic-scroll { flex: 1; overflow: auto; display: grid; place-items: center; padding: 10px; touch-action: pan-x pan-y pinch-zoom; }
.pic-scroll img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 4px; cursor: zoom-in; }
.pic-overlay.zoom .pic-scroll { place-items: start; }
.pic-overlay.zoom .pic-scroll img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.pic-msg { color: var(--muted); text-align: center; padding: 20px; }
.pic-msg:empty { display: none; }
.pic-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; }
.pp-carousel {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.pp-carousel::-webkit-scrollbar { display: none; }
.pp-slide {
  flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 12px 16px; cursor: pointer;
}
.pp-sheet { height: 100%; max-width: 100%; aspect-ratio: 1 / 1.414; background: #fff; border-radius: 6px; overflow: hidden; border: 3px solid transparent; }
.pp-sheet.on { border-color: var(--accent); }
.pp-sheet img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pp-used {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: 90%;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pp-bar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 4px 10px; }
.pp-ind { font-weight: 700; min-width: 120px; text-align: center; }
.pp-hint { text-align: center; margin: 0; padding: 0 12px; }
.pp-body { flex: 1; overflow: auto; padding: 12px; }
.pp-num { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pp-num span { color: var(--muted); }
.pp-num .input.sm { width: 76px; text-align: center; }

/* ---------- Bilderplan (Aufbau-Seite) ---------- */
.plan { display: flex; flex-direction: column; gap: 8px; }
.plan-file { display: flex; align-items: center; gap: 12px; }
.plan-file b, .plan-file small { display: block; }
.plan-file small { color: var(--muted); }
.plan-icon {
  width: 42px; height: 50px; border-radius: 6px; background: #fff; color: #000; font-weight: 900; font-size: 12px;
  display: grid; place-items: end center; padding-bottom: 8px; border-bottom: 6px solid var(--accent); flex-shrink: 0;
}
.plan .file-btn { min-height: 52px; }
.pic-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.pic-list li {
  display: flex; gap: 12px; align-items: center; padding: 6px 10px;
  background: var(--bg); border-radius: 10px; font-size: 14px; border: 1px solid transparent;
}
.pic-list li.has-issue { border-color: #ff8a7a55; }
.pl-page { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.pl-page .input.sm { width: 64px; text-align: center; }
.pl-where { min-width: 0; }
.pl-where b, .pl-where small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-where small { color: var(--muted); font-size: 12.5px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #2a2e38; color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); z-index: 50; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #4a1f22; }

@media (min-width: 721px) {
  #app { border-inline: 1px solid var(--line); }
}
@media (max-height: 640px) {
  .notes { height: 140px; }
  .editable .notes { height: 170px; }
  .hud-count { font-size: 36px; }
}

/* ---------- Team-Betrieb ---------- */
.brand .sync-state {
  display: inline-block; margin-left: 8px; vertical-align: 2px; font-size: 11px; font-weight: 600; letter-spacing: 0;
  color: var(--muted); line-height: 1;
}
.brand .sync-state:empty { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); opacity: .8; }
.brand .sync-state[data-state="busy"] { color: var(--f-dev); }
.brand .sync-state[data-state="off"] { color: var(--danger); }
.update-banner {
  position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; border-radius: 12px;
  background: var(--surface2); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.5); font-size: 14px;
}
.conflict-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 8px; padding: 8px 10px;
  border-radius: 10px; background: rgba(255, 140, 46, .14); border: 1px solid var(--f-dev); font-size: 13px;
}
.conflict-bar span { flex: 1 1 100%; }
.import-box .progress { margin-top: 10px; }
/* Während der Wiedergabe kein Weichzeichner hinter den Knöpfen: er müsste mit jedem Videobild neu berechnet werden */
.player.playing .tool, .player.playing .tp { backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Leistung (v. a. Safari): Bereiche unabhängig voneinander berechnen – ändert sich der Text im
   Definitionsfeld oder in der Anzeige, muss die Taktleiste nicht neu berechnet werden. */
.beatbar { contain: strict; }
.bb-cell { contain: layout style; }
.hud, .notes, .overview, .ctrl-row { contain: layout style; }
