/* ═══════════════════════════════════════════════════════════
   Setlist Metronom — Bühnen-Design
   Dunkel wie ein Bühnenrand, ablesbar aus zwei Metern Entfernung.
   Amber = Puls (Tally-Licht), Rot-Orange = die Eins.
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:        #0C0E13;
  --panel:     #151922;
  --panel-hi:  #1C2230;
  --line:      #262E40;
  --text:      #EDECE4;
  --muted:     #8A93A6;
  --pulse:     #FFB100;   /* Tally-Amber: der Beat */
  --one:       #FF5436;   /* die Eins */
  --go:        #35D07A;   /* Start */
  --stop:      #E5484D;   /* Stop  */
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  user-select: none;
}

/* ── Kopfzeile ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 10px color-mix(in srgb, var(--pulse) 70%, transparent);
}
.brand-name {
  font-family: var(--mono);
  font-size: 14px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.sync-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-family: var(--mono);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-chip.online .sync-dot  { background: var(--go); }
.sync-chip.dirty  .sync-dot  { background: var(--pulse); }
.sync-chip.error  .sync-dot  { background: var(--stop); }

/* ── Hauptbereich / Ansichten ──────────────────────────────── */
#main { flex: 1; overflow-y: auto; padding: 16px; }
.view { display: none; max-width: 560px; margin: 0 auto; }
.view.active { display: block; }
.hidden { display: none !important; }

.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.view-head h2 { margin: 0; font-size: 18px; letter-spacing: .04em; }
.detail-title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Song-Kontext (Setlist-Modus) ──────────────────────────── */
.song-context {
  display: flex; align-items: stretch; gap: 8px; margin-bottom: 12px;
}
.ctx-nav {
  width: 56px; font-size: 28px; line-height: 1;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.ctx-nav:active { background: var(--panel-hi); }
.ctx-info { flex: 1; text-align: center; padding: 8px 4px; min-width: 0; }
.ctx-setlist { font-size: 11px; font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ctx-song { font-size: 17px; font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Die Puls-Lampe ────────────────────────────────────────── */
.lamp {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 16px 26px;
  text-align: center;
  transition: background-color 60ms linear, box-shadow 60ms linear;
}
.lamp.flash {
  background: color-mix(in srgb, var(--pulse) 26%, var(--panel));
  box-shadow: 0 0 34px -6px color-mix(in srgb, var(--pulse) 55%, transparent);
}
.lamp.flash-one {
  background: color-mix(in srgb, var(--one) 32%, var(--panel));
  box-shadow: 0 0 40px -4px color-mix(in srgb, var(--one) 60%, transparent);
}

.beat-dots {
  display: flex; justify-content: center; gap: 12px;
  min-height: 16px; margin-bottom: 14px;
}
.beat-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--line);
  transition: background-color 80ms linear, transform 80ms linear;
}
.beat-dot.on { background: var(--pulse); transform: scale(1.35); }
.beat-dot.on.one { background: var(--one); }

.bpm-display { line-height: 1; }
.bpm-value {
  font-family: var(--mono);
  font-size: clamp(72px, 22vw, 128px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: none; border: none; color: var(--text);
  width: 100%; text-align: center; padding: 0;
  appearance: textfield; -moz-appearance: textfield;
}
.bpm-value::-webkit-inner-spin-button { display: none; }
.bpm-value:focus { outline: none; color: var(--pulse); }
.bpm-label {
  font-family: var(--mono); font-size: 13px;
  letter-spacing: .32em; text-transform: uppercase;
  color: var(--muted); margin-top: 6px;
}

/* ── Tempo-Regler & Stepper ────────────────────────────────── */
.bpm-slider {
  width: 100%; margin: 18px 0 4px; accent-color: var(--pulse);
  height: 32px; cursor: pointer;
}
.bpm-steppers { display: flex; gap: 8px; }
.step {
  flex: 1; padding: 14px 0;
  font-family: var(--mono); font-size: 17px; font-weight: 600;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.step:active { background: var(--panel-hi); }

/* ── Auswahlfelder ─────────────────────────────────────────── */
.row-selects { display: flex; gap: 8px; margin-top: 12px; }
.select-wrap { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.select-wrap span {
  font-size: 11px; font-family: var(--mono);
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
select, input[type=text], input[type=number], textarea {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%;
}
select { appearance: none; }
textarea { resize: vertical; font-family: var(--mono); font-size: 14px; line-height: 1.55; }

/* ── Song-Notizen (Ablauf & Akkorde) ───────────────────────── */
.song-info {
  margin-top: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px;
}
.song-info-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 600; margin-bottom: 8px;
}
.key-badge {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--pulse); border: 1px solid color-mix(in srgb, var(--pulse) 45%, transparent);
  border-radius: 999px; padding: 3px 12px; white-space: nowrap;
}
.song-notes {
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  user-select: text;
}
.song-notes .note-head {
  color: var(--pulse); font-weight: 700; letter-spacing: .06em;
  margin-top: 10px;
}
.song-notes .note-head:first-child { margin-top: 0; }
.song-notes .note-line { white-space: pre-wrap; word-break: break-word; }
.song-notes .note-gap { height: 8px; }

/* ── Transport ─────────────────────────────────────────────── */
.transport { display: flex; gap: 10px; margin-top: 16px; }
.btn-tap, .btn-play {
  border: none; border-radius: 16px; cursor: pointer;
  font-family: var(--mono); font-weight: 700; letter-spacing: .12em;
  padding: 24px 0; font-size: 20px;
  touch-action: manipulation;
}
.btn-tap {
  flex: 1; background: var(--panel-hi); color: var(--text);
  border: 1px solid var(--line);
}
.btn-tap:active { background: var(--pulse); color: #14100A; }
.btn-play { flex: 1.4; background: var(--go); color: #06130C; }
.btn-play.playing { background: var(--stop); color: #1A0708; }

/* ── Buttons allgemein ─────────────────────────────────────── */
.btn-ghost {
  display: block; width: 100%; margin-top: 14px;
  background: none; border: 1px dashed var(--line);
  color: var(--muted); border-radius: 12px;
  padding: 13px; font: inherit; cursor: pointer;
}
.btn-ghost:active { color: var(--text); border-color: var(--muted); }
.btn-small {
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px;
  padding: 9px 14px; font: inherit; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
.btn-small:active { background: var(--panel-hi); }
.btn-primary {
  background: var(--pulse); color: #14100A; border: none;
  border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer;
}

/* ── Listen (Songs / Setlists) ─────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.list-item.dragging { opacity: .4; }
.li-main { flex: 1; min-width: 0; cursor: pointer; }
.li-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub {
  font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 3px;
}
.li-bpm {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  color: var(--pulse); min-width: 62px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.li-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: none; border: 1px solid transparent;
  color: var(--muted); font-size: 17px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--panel-hi); color: var(--text); }
.drag-handle { cursor: grab; touch-action: none; font-size: 19px; }

.list-item.playing-now { border-color: var(--pulse); }
.list-item.playing-now .li-name { color: var(--pulse); }

.empty-hint { color: var(--muted); font-size: 14px; line-height: 1.5; text-align: center; padding: 28px 20px; }

/* ── Tab-Leiste ────────────────────────────────────────────── */
.tabbar {
  display: flex; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
}
.tab {
  flex: 1; padding: 15px 0 13px;
  background: none; border: none; border-top: 2px solid transparent;
  color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.tab.active { color: var(--pulse); border-top-color: var(--pulse); }

/* ── Dialoge ───────────────────────────────────────────────── */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 0; width: min(92vw, 420px);
}
dialog::backdrop { background: rgba(5, 6, 10, .75); }
.dlg-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-form h3 { margin: 0; font-size: 17px; }
.dlg-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.dlg-row { display: flex; gap: 10px; }
.dlg-row label { flex: 1; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.pick-list { max-height: 50vh; overflow-y: auto; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 78px);
  transform: translateX(-50%);
  background: var(--panel-hi); border: 1px solid var(--line);
  color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 50; max-width: 88vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ── Fokus & reduzierte Bewegung ───────────────────────────── */
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--pulse); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
