:root {
  --bg: #0d0d0d; --panel: #171717; --panel2: #202020; --line: #2c2c2c;
  --text: #ececec; --muted: #9a9a9a; --gold: #c9a84c; --gold2: #e0c46e;
  --ok: #4caf7a; --bad: #d9534f; --warn: #e0a030;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: .5em .7em; width: 100%;
}
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--gold); }
label { display: block; color: var(--muted); font-size: .85rem; margin: .6em 0 .25em; }
.btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: .45em .9em; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #111; border-color: var(--gold); font-weight: 600; }
.btn.primary:hover { background: var(--gold2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25em .6em; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, Menlo, monospace; }

/* Kopfzeile */
header {
  display: flex; align-items: center; gap: 1em; padding: .7em 1.2em;
  border-bottom: 1px solid var(--line); background: #0a0a0a; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand span { color: var(--gold); }
header select { width: auto; max-width: 14em; }
nav { display: flex; gap: .3em; padding: .6em 1.2em; border-bottom: 1px solid var(--line); overflow-x: auto; }
nav .btn { border-color: transparent; background: none; }
nav .btn.active { color: var(--gold); border-color: var(--gold); }
main { padding: 1.2em; max-width: 1200px; margin: 0 auto; }

/* Login */
.login { max-width: 340px; margin: 12vh auto; background: var(--panel);
  padding: 2em; border-radius: var(--r); border: 1px solid var(--line); }
.login .brand { font-size: 1.4rem; margin-bottom: 1em; text-align: center; }

/* Karten */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1em; margin-bottom: 1em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1em;
  display: flex; flex-direction: column; gap: .5em; }
.card .name { font-weight: 600; font-size: 1.05rem; }
.dot { display: inline-block; width: .65em; height: .65em; border-radius: 50%; background: var(--bad); margin-right: .4em; }
.dot.on { background: var(--ok); }
.badge { font-size: .75rem; padding: .1em .5em; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.badge.play { color: var(--ok); border-color: var(--ok); }
.badge.err { color: var(--bad); border-color: var(--bad); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.now { min-height: 2.6em; }
.now .ch { color: var(--gold); }
.allbar { display: flex; gap: .5em; flex-wrap: wrap; align-items: center; margin-bottom: 1em; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5em .4em; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }

/* Dialog */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 1em; z-index: 20; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  width: 100%; max-width: 560px; padding: 1.2em; }
.modal .head { display: flex; align-items: center; margin-bottom: .8em; }
.modal .head h2 { margin: 0; flex: 1; }
.list { display: flex; flex-direction: column; gap: .3em; max-height: 55vh; overflow-y: auto; }
.item { display: flex; align-items: center; gap: .7em; padding: .5em .6em; border-radius: 8px;
  background: var(--panel2); cursor: pointer; border: 1px solid transparent; }
.item:hover { border-color: var(--gold); }
.item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: #000; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2em 1em; font-size: .9rem; }
.kv div:nth-child(odd) { color: var(--muted); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.4rem; color: var(--gold); letter-spacing: .08em; }
.days label { display: inline-flex; gap: .25em; align-items: center; margin-right: .6em; color: var(--text); }

.listenbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; gap: .8em; align-items: center;
  padding: .7em 1.2em; background: #111; border-top: 1px solid var(--gold); }
.listenbar audio { height: 36px; max-width: 45vw; }
body:has(.listenbar) main { padding-bottom: 6em; }
.toast { position: fixed; bottom: 1.2em; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--gold); padding: .6em 1.1em; border-radius: 8px; z-index: 30; }
.toast.err { border-color: var(--bad); }

@media (max-width: 640px) {
  header { flex-wrap: wrap; padding: .6em .8em; }
  main { padding: .8em; }
  .grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
}

/* Ladeanzeige */
body.busy { cursor: progress; }
body.busy::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 40%; z-index: 1000;
  background: var(--gold); animation: busybar 1s ease-in-out infinite; }
@keyframes busybar { 0% { left: -40%; } 100% { left: 100%; } }
body.blocking .modal button, body.blocking main button, body.blocking nav button { pointer-events: none; }
body.blocking.busy .modal button, body.blocking.busy main button { opacity: .7; }

/* Uhr in der Kopfzeile */
.clockbox { text-align: center; }
.clock { font-variant-numeric: tabular-nums; font-size: 1.05rem; letter-spacing: .04em; color: var(--text); }

/* Ein/Aus-Schalter */
.switch { display: inline-flex; align-items: center; gap: .6em; cursor: pointer; user-select: none; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: relative; width: 2.6em; height: 1.45em; flex: none; border-radius: 99px;
  background: var(--panel2); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.switch .slider::after { content: ""; position: absolute; top: .14em; left: .16em; width: 1.05em; height: 1.05em;
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--gold); border-color: var(--gold); }
.switch input:checked + .slider::after { transform: translateX(1.12em); background: #111; }
.switch input:focus-visible + .slider { outline: 2px solid var(--gold2); outline-offset: 2px; }
.switch-label { color: var(--text); }
tr.inactive td:not(:first-child) { opacity: .45; }

/* Logo */
.brand .logo { width: 28px; height: 28px; margin-right: .5em; vertical-align: middle; position: relative; top: -2px; }
.login-logo { display: block; width: 84px; height: 84px; margin: 0 auto .6em; }

/* Play/Stop-Knopf zeigt den aktuellen Zustand */
.btn.on { color: var(--gold); border-color: var(--gold); background: rgba(201, 168, 76, .12); }
.card:has(.dot:not(.on)) .now { opacity: .55; }

/* Player-Details: Reiter */
.tabs { display: flex; gap: .35em; overflow-x: auto; padding-bottom: .5em; margin-bottom: .8em;
  border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs .btn { white-space: nowrap; flex: none; }
.tabs .btn.active { color: var(--gold); border-color: var(--gold); }
.tabbody { min-height: 12em; }
.notice { border: 1px solid var(--warn); color: var(--warn); border-radius: 8px; padding: .6em .8em;
  margin-bottom: 1em; font-size: .9rem; display: flex; flex-direction: column; gap: .3em; }
.field { margin-bottom: .9em; }
.field label { margin-top: 0; }
.field .muted.small { margin-top: .3em; }
.kv div:nth-child(even) { overflow-wrap: anywhere; }
table.compact td, table.compact th { padding: .4em .3em; font-size: .88rem; }
.modal .head h2 .dot { margin-right: .45em; vertical-align: middle; }
.panel { overflow-x: auto; }

/* Handy hochkant */
@media (max-width: 640px) {
  .backdrop { padding: .6em .4em; }
  .modal { padding: .9em; }
  .modal .head h2 { font-size: 1.1rem; }
  .kv { grid-template-columns: minmax(7em, max-content) 1fr; font-size: .88rem; }
  .card .row .btn { padding-left: .8em; padding-right: .8em; }
  header select { max-width: 9em; }
  .clockbox { order: 3; flex-basis: 100%; text-align: left; font-size: .95rem; }
  .listenbar { flex-wrap: wrap; padding: .6em .8em; }
  .listenbar audio { max-width: 100%; flex: 1 1 100%; order: 3; }
  th, td { padding: .45em .3em; }
  .allbar select { max-width: 100%; }
}

/* Handy hochkant: Tabellen als gestapelte Karten, Navigation umbrechen */
@media (max-width: 640px) {
  header { row-gap: .5em; }
  header .brand { order: 1; }
  .clockbox { order: 2; flex: 1 1 auto; flex-basis: auto; text-align: right; font-size: .95rem; }
  header > .row { order: 3; flex-basis: 100%; }
  nav { flex-wrap: wrap; overflow-x: visible; padding: .5em .8em; }
  nav .btn { padding: .35em .7em; font-size: .92rem; }
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: .3em .8em;
    padding: .6em 0; border-bottom: 1px solid var(--line); }
  table.stack tr:has(th) { display: none; }
  table.stack td { display: block; border: 0; padding: 0; }
  table.stack td:last-child { flex-basis: 100%; }
  table.stack td:last-child .row { justify-content: flex-start !important; }
  table.stack td[style*="text-align:right"] { text-align: left !important; }
  .modal select, main select { max-width: 100%; }
}

/* Synchrone Gruppe als Block */
.syncgroup { border: 1px solid rgba(201, 168, 76, .45); background: rgba(201, 168, 76, .05);
  border-radius: calc(var(--r) + 4px); padding: .9em; margin-bottom: 1.2em; }
.sghead { display: flex; gap: .8em; align-items: center; flex-wrap: wrap; margin-bottom: .8em; }
.sgname { font-weight: 600; color: var(--gold); font-size: 1.05rem; }
.syncgroup .card { background: var(--panel); }
.chip { display: inline-block; padding: 0 .5em; border: 1px solid var(--gold); border-radius: 99px;
  font-size: .78rem; line-height: 1.5; }
@media (max-width: 640px) { .syncgroup { padding: .6em; } }

/* Wochenpläne (Etappe 1: Liste pro Tag) */
.planweek { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5em; }
.planday { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: .5em; min-height: 6em; }
.planday .btn.small { padding: .1em .45em; }
.planitem { border-radius: 6px; padding: .3em .4em; margin-top: .35em; font-size: .85em; cursor: pointer; border-left: 3px solid var(--gold); background: rgba(201,168,76,.10); }
.planitem.event { border-left-color: var(--muted); background: rgba(255,255,255,.04); }
.planitem.series { border-left-color: var(--warn); background: rgba(224,160,48,.10); }
.planitem:hover { filter: brightness(1.25); }
.planline { margin-top: .2em; }
@media (max-width: 900px) { .planweek { grid-template-columns: 1fr; } .planday { min-height: 0; } }

/* Wochenraster (Etappe 2) */
.wg { user-select: none; -webkit-user-select: none; }
.wg-palette { display: flex; flex-wrap: wrap; gap: .4em; align-items: center; margin-bottom: .8em; }
.chipbtn { display: inline-flex; align-items: center; gap: .4em; padding: .3em .7em; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 18%, transparent); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); color: var(--text); }
.chipbtn.sel { border: 2px solid var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); font-weight: 600; }
.chipbtn img { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; }
.chipbtn .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.wg-head, .wg-body { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); gap: 0 5px; }
.wg-dayname { display: flex; align-items: center; gap: .3em; padding: 0 .2em .4em; font-weight: 600; min-height: 2em; }
.wg-dayname .btn.small { padding: .05em .45em; font-weight: 400; }
.wg-scroll { height: max(520px, calc(100vh - 330px)); overflow-y: auto; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.wg-axis { position: relative; }
.wg-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: .75em; color: var(--muted); }
.wg-hour:first-child { transform: none; }
.wg-day { position: relative; background: var(--panel2);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 48px); }
.wg-day.today { outline: 1px solid rgba(201,168,76,.4); }
.wg-lane { position: absolute; top: 0; bottom: 0; }
.wg-lane.music { left: 0; right: 24%; }
.wg-lane.extra { right: 0; width: 22%; border-left: 1px dashed var(--line); background: rgba(255,255,255,.015); }
.wg-lane.music.editable { cursor: crosshair; }
.wg-lane.extra.editable { cursor: copy; }
.wg-block, .wg-series, .wg-ghost { position: absolute; left: 3px; right: 3px; border-radius: 7px; overflow: hidden; line-height: 1.25; }
.wg-block { --c: var(--gold); background: color-mix(in srgb, var(--c) 28%, var(--panel2)); border: 1px solid var(--c);
  border-left-width: 4px; color: var(--text); padding: 4px 6px; cursor: grab; font-size: .85em; touch-action: none; }
.wg-block.drag { cursor: grabbing; z-index: 4; box-shadow: 0 4px 14px rgba(0,0,0,.5); opacity: .92; }
.wg-block .wg-t { font-weight: 600; display: flex; align-items: center; gap: .35em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-block .wg-t img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; flex: none; }
.wg-block .wg-s { color: var(--muted); font-size: .9em; margin-top: 1px; }
.wg-grip { position: absolute; left: 0; right: 0; bottom: 0; height: 9px; cursor: ns-resize; }
.wg-grip.top { top: 0; bottom: auto; }
.wg-grip:not(.top)::after { content: ""; position: absolute; left: 38%; right: 38%; bottom: 3px; height: 3px; border-radius: 2px; background: var(--c); opacity: .8; }
.wg-series { background: repeating-linear-gradient(135deg, rgba(224,160,48,.28) 0 6px, rgba(224,160,48,.10) 6px 12px); border: 1px solid var(--warn); cursor: pointer; padding: 3px; font-size: .78em; }
.wg-series .wg-t { white-space: nowrap; }
.wg-pin { position: absolute; right: 2px; padding: 0 6px; height: 20px; border-radius: 0 10px 10px 10px; border-top: 2px solid var(--gold); background: var(--panel); border: 1px solid var(--muted); font-size: .74em; line-height: 18px; white-space: nowrap; cursor: pointer; z-index: 2; }
.wg-hint { position: absolute; right: 2px; padding: 0 6px; height: 20px; border-radius: 0 10px 10px 10px; border: 1px dashed var(--gold); color: var(--gold); font-size: .74em; line-height: 18px; white-space: nowrap; pointer-events: none; z-index: 1; }
.wg-ghost { --c: var(--gold); background: color-mix(in srgb, var(--c) 35%, transparent); border: 1px dashed var(--c); padding: 4px 6px; pointer-events: none; font-size: .85em; }
.wg-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--bad); z-index: 3; pointer-events: none; }
.wg.ro { opacity: .55; }
.wg.ro .wg-block, .wg.ro .wg-series, .wg.ro .wg-pin { cursor: default; }
.wg-block:hover, .wg-series:hover, .wg-pin:hover { filter: brightness(1.15); }
.chipbtn .x { margin-left: .2em; padding: 0 .3em; border-radius: 50%; color: var(--muted); }
.chipbtn .x:hover { color: var(--bad); background: rgba(217,83,79,.15); }
.langsw { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.langsw button { border: 0; background: transparent; color: var(--muted); padding: .25em .6em; font-size: .8rem; cursor: pointer; }
.langsw button.on { background: var(--gold); color: #111; font-weight: 600; }
