/* Song-Werkstatt – Gestaltung angelehnt an Logic Pro: dunkles, ruhiges Grau, Farbe nur für Inhalte
 * (Blöcke, Töne, Akkorde). Touch-Ziele ≥ 40 px für Tablets. Keine externen Schriften (Datenschutz). */
:root {
  --bg: #1c1c1e; --bg2: #232325; --panel: #2a2a2d; --panel2: #333336; --line: #3d3d41; --line2: #4a4a4f;
  --ink: #e6e6e8; --muted: #9a9aa0; --dim: #6e6e74;
  --accent: #3b8cf0;          /* Auswahl (Logic-Blau) */
  --play: #35c35a; --cycle: #e8b923; --err: #e5534b; --ok: #35c35a;
  /* Spur-Farben wie die Region-Farben in Logic */
  --t-chords: #4caf50; --t-melody: #3b8cf0; --t-bass: #9b6ad8; --t-beat: #d9a72b;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.hint { color: var(--muted); }
.msg { min-height: 1.5em; font-weight: 600; color: #ffb4ab; }
.lic-link { display: inline-block; margin-top: 22px; color: var(--muted); font-size: 13px; }
a { color: #8ab8ff; }

/* Buttons */
.btn { border: 1px solid var(--line2); border-radius: 7px; padding: 8px 16px; min-height: 42px; background: var(--panel2); font-weight: 600; }
.btn:active { filter: brightness(1.25); }
.btn.small { min-height: 36px; padding: 4px 12px; }
.btn.big { min-height: 52px; padding: 10px 26px; font-size: 18px; }
.btn.play { background: #2f8f4a; border-color: #2f8f4a; color: #fff; }
.btn.danger { background: #a3332d; border-color: #a3332d; color: #fff; }
.mini-btn { border: 1px solid var(--line2); background: var(--panel2); border-radius: 6px; min-height: 34px; padding: 2px 10px; font-size: 14px; }
.mini-btn.danger { color: #ff8a80; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 14px; }

/* Login */
.screen { min-height: 100vh; }
#login, .pause { display: flex; align-items: center; justify-content: center; text-align: center; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 36px; }
.login-box h1 { font-size: 28px; margin: 0 0 6px; font-weight: 600; }
.code-dots { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.dot { width: 46px; height: 56px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line2); font-size: 28px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.dot.on { border-color: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 84px); gap: 10px; justify-content: center; }
.key { height: 70px; border: 1px solid var(--line2); border-radius: 10px; background: var(--panel2); font-size: 28px; font-weight: 500; }
.key:active { background: var(--line2); }
.key.ok { background: #2f8f4a; border-color: #2f8f4a; color: #fff; }
.key.back { color: #ff8a80; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* Pause */
.pause { background: var(--bg); }
.pause h1 { font-size: 36px; margin: 8px 0; font-weight: 600; }
.big-emoji { font-size: 96px; }

/* ---------- DAW-Layout ---------- */
.daw { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* Steuerleiste (Control Bar) */
.ctrl { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: linear-gradient(#3a3a3d, #2c2c2f); border-bottom: 1px solid #111; flex-wrap: wrap; }
.team-badge { font-size: 18px; font-weight: 600; white-space: nowrap; }
.song-title { flex: 1 1 160px; min-width: 120px; max-width: 320px; min-height: 36px; border: 1px solid var(--line2); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--bg); color: var(--ink); }
.song-title:focus { outline: none; border-color: var(--accent); }
.transport { display: flex; gap: 4px; margin-left: auto; }
.tbtn { min-width: 46px; height: 40px; border: 1px solid #151515; border-radius: 6px; background: linear-gradient(#4a4a4e, #38383b); font-size: 18px; color: var(--ink); }
.tbtn.small { min-width: 38px; height: 36px; font-size: 16px; }
.tbtn:active { filter: brightness(1.3); }
.tbtn.play.on { background: var(--play); color: #0b2a14; }
.tbtn.cycle.on { background: var(--cycle); color: #3a2c00; }
.lcd { display: flex; align-items: center; gap: 14px; background: #121214; border: 1px solid #000; border-radius: 6px; padding: 2px 12px; height: 40px; font-variant-numeric: tabular-nums; }
.lcd-pos { font-size: 22px; font-weight: 300; min-width: 4.6em; text-align: center; letter-spacing: .5px; }
.lcd-tempo { display: flex; align-items: center; gap: 4px; color: var(--ink); }
.lcd-tempo b { font-size: 20px; font-weight: 300; min-width: 2.2em; text-align: center; }
.lcd-tempo small { color: var(--muted); font-size: 11px; }
.lcd-tempo button { border: 0; background: #2a2a2d; border-radius: 4px; width: 30px; height: 30px; }
.zoom { display: flex; gap: 3px; }
.save-state { font-size: 13px; min-width: 2em; color: var(--muted); }
.save-state.ok { color: var(--ok); } .save-state.err { color: #ff8a80; font-weight: 700; } .save-state.busy { opacity: .7; }
.teacher-mode .ctrl { box-shadow: inset 0 -3px 0 #2f8f4a; }

/* Arrangement: Spur-Köpfe links (fixiert), Timeline rechts (waagrecht scrollbar) */
.arrange { flex: 1 1 auto; min-height: 140px; overflow: auto; background: var(--bg); position: relative; }
.arr-grid { position: relative; display: grid; grid-template-columns: var(--hw) 1fr; grid-auto-rows: 64px; min-height: 100%; }
.arr-grid > .corner, .arr-grid > .ruler { height: 34px; position: sticky; top: 0; z-index: 6; }
.arr-grid { grid-template-rows: 34px; }
.corner { left: 0; z-index: 8 !important; background: var(--panel); border-right: 1px solid #111; border-bottom: 1px solid #111; display: flex; align-items: center; padding: 0 8px; }
.ruler { background: var(--panel); border-bottom: 1px solid #111; position: relative; cursor: pointer; touch-action: none;
  background-image: repeating-linear-gradient(90deg, var(--line2) 0 1px, transparent 1px var(--bw)); }
.tick { position: absolute; bottom: 3px; padding-left: 4px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cycle-range { position: absolute; top: 2px; height: 12px; border-radius: 3px; background: rgba(232, 185, 35, .25); border: 1px solid rgba(232, 185, 35, .4); }
.cycle-range.on { background: var(--cycle); border-color: var(--cycle); }
.thead { position: sticky; left: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0; background: var(--panel); border-right: 1px solid #111; border-bottom: 1px solid var(--bg); }
.thead::before { content: ""; align-self: stretch; width: 5px; background: var(--tc); }
.type-chords { --tc: var(--t-chords); } .type-melody { --tc: var(--t-melody); } .type-bass { --tc: var(--t-bass); } .type-beat { --tc: var(--t-beat); }
.th-main { flex: 1; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; text-align: left; min-height: 56px; padding: 0 4px; border-radius: 6px; min-width: 0; }
.th-main:active { background: var(--panel2); }
.th-icon { font-size: 22px; }
.th-text { display: grid; min-width: 0; }
.th-text strong { font-weight: 600; font-size: 14px; }
.th-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-ms { display: flex; gap: 3px; }
.ms { width: 30px; height: 30px; border: 1px solid #151515; border-radius: 5px; background: #3a3a3d; font-size: 13px; font-weight: 700; color: var(--muted); }
.ms.m.on { background: #3b8cf0; color: #fff; } .ms.s.on { background: var(--cycle); color: #3a2c00; }
.lane { position: relative; border-bottom: 1px solid var(--bg2); touch-action: pan-x pan-y;
  background: repeating-linear-gradient(90deg, #2a2a2d 0 1px, transparent 1px var(--bw)), #202022; }
.lane.muted { opacity: .45; }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #f2f2f2; z-index: 4; pointer-events: none; box-shadow: 0 0 4px rgba(0,0,0,.6); }

/* Regionen (Blöcke) */
.region { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; overflow: hidden; touch-action: none; user-select: none;
  background: color-mix(in srgb, var(--tc) 55%, #1c1c1e); border: 1px solid color-mix(in srgb, var(--tc) 80%, #000); }
.region.sel { background: color-mix(in srgb, var(--tc) 80%, #1c1c1e); box-shadow: 0 0 0 2px #fff; }
.rg-head { height: 16px; padding: 0 6px; font-size: 11px; font-weight: 600; color: #fff; background: rgba(0,0,0,.22); white-space: nowrap; overflow: hidden; }
.rg-body { position: absolute; top: 16px; bottom: 0; left: 0; right: 0; }
.rg-bar { position: absolute; top: 0; bottom: 0; }
.rg-bar.rep { opacity: .5; }
.rg-bar.loop-start { border-left: 1px dashed rgba(255,255,255,.55); }
.mini-chord { position: absolute; left: 4px; top: 6px; padding: 1px 6px; border-radius: 4px; font-size: 13px; font-weight: 700; color: #fff; }
.mini-chord.dark { color: #1c1c1e; }
.mini-note { position: absolute; height: 4px; border-radius: 2px; }
.mini-bass { position: absolute; bottom: 30%; width: 6%; height: 30%; background: rgba(255,255,255,.75); border-radius: 2px; }
.mini-hit { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.85); }
.loop-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 26px; display: grid; place-items: center; font-size: 13px; color: #fff;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.35)); cursor: ew-resize; }

/* Unterer Bereich: Editor / Mixer */
.bottom { flex: 0 0 auto; height: 44vh; min-height: 260px; display: flex; flex-direction: column; background: var(--panel); border-top: 2px solid #0e0e0f; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--panel2); border-bottom: 1px solid #111; flex-wrap: wrap; }
.tabs [data-tab] { border: 1px solid #151515; background: #3a3a3d; border-radius: 6px; min-height: 34px; padding: 2px 14px; font-weight: 600; color: var(--muted); }
.tabs [data-tab].on { background: #5a5a5f; color: #fff; }
.region-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.tool-len { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tool-select, select { font: inherit; min-height: 34px; border-radius: 6px; background: var(--bg); color: var(--ink); border: 1px solid var(--line2); padding: 0 8px; }
.panel { flex: 1; overflow: auto; padding: 10px 12px; }
.panel-hint { color: var(--muted); max-width: 720px; line-height: 1.5; }
.ed-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ed-label { color: var(--muted); font-size: 13px; }
.ed-hint { color: var(--dim); font-size: 12px; }
.seg { display: inline-flex; border: 1px solid #151515; border-radius: 7px; overflow: hidden; }
.seg.vertical { flex-direction: column; }
.seg-btn { border: 0; border-right: 1px solid #151515; background: #3a3a3d; min-height: 36px; padding: 2px 12px; font-size: 14px; color: var(--ink); }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--accent); color: #fff; }
.len-ico { display: inline-block; height: 8px; border-radius: 2px; background: currentColor; vertical-align: middle; margin-right: 2px; }
.rhythm { position: relative; display: block; width: 72px; height: 16px; background: #1c1c1e; border-radius: 3px; }
.rhythm i { position: absolute; top: 4px; height: 8px; border-radius: 2px; background: var(--t-bass); }
.note-sym { font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Music", serif; font-size: 1.15em; }

/* Akkord-Bausteine */
.palette { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chord-block { --c: #888; min-width: 58px; height: 46px; border: 0; border-radius: 6px; background: var(--c); color: #fff;
  font-size: 20px; font-weight: 700; touch-action: none; user-select: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.chord-block.dark, .chord-slot.dark, .roll-note.dark, .roll-key.dark { color: #1c1c1e; }
.chord-block.moll, .chord-slot.filled.moll { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.22) 0 6px, transparent 6px 12px); }
.chord-block.in-hand { outline: 3px solid #fff; outline-offset: 2px; }
.chord-block.eraser { --c: transparent; border: 1px dashed var(--line2); box-shadow: none; }
.chord-block.ghost { position: fixed; pointer-events: none; z-index: 100; transform: translate(-50%, -60%) scale(1.15); opacity: .92; }
.chord-block.picked { outline: 3px solid #fff; outline-offset: 2px; }
.chord-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.chord-slot { --c: transparent; width: 120px; height: 76px; border: 1px dashed var(--line2); border-radius: 6px; background: var(--c); display: grid; place-items: center; align-content: center; gap: 2px; color: var(--dim); }
.chord-slot small { font-size: 11px; opacity: .8; }
.chord-slot span { font-size: 26px; font-weight: 700; }
.chord-slot.filled { border: 0; color: #fff; }
.chord-slots.has-hand .chord-slot { border-color: var(--accent); }
.chord-slot.over { outline: 3px solid #fff; }

/* Piano-Roll */
.roll { display: grid; grid-template-columns: 52px 1fr; min-width: 520px; }
.roll-keys { display: grid; }
.roll-key { --c: #888; height: 24px; border: 0; border-bottom: 1px solid var(--bg); background: var(--c); color: #fff; font-weight: 700; font-size: 13px; border-radius: 3px 0 0 3px; }
.roll-grid { position: relative; display: grid; cursor: crosshair;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 1px, transparent 1px calc(100% / var(--cols) * 8)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, transparent 1px calc(100% / var(--cols) * 2)); background-color: #202022; }
.roll-row { height: 24px; border-bottom: 1px solid #2b2b2e; }
.roll-row.c-row { border-bottom-color: #444449; }
.roll-note { --c: #888; position: absolute; border: 1px solid rgba(0,0,0,.4); border-radius: 4px; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; padding: 0 4px; text-align: left; margin-left: 1px; }
.roll-head { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; }

/* Step-Sequencer */
.steps { display: grid; grid-template-columns: 82px repeat(var(--n), minmax(26px, 1fr)); gap: 3px; min-width: 560px; }
.step-label { border: 1px solid #151515; background: #3a3a3d; border-radius: 5px; font-size: 13px; min-height: 34px; text-align: left; padding: 0 8px; }
.step { height: 34px; border: 1px solid #151515; border-radius: 4px; background: #3a3a3d; padding: 0; }
.step.beat { background: #46464a; }
.step.bar { margin-left: 4px; }
.step.on { background: var(--t-beat); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }

/* Mixer */
.mixer { display: flex; gap: 8px; align-items: stretch; min-height: 100%; }
.strip { width: 128px; flex: 0 0 auto; background: var(--panel2); border: 1px solid #151515; border-radius: 7px; padding: 8px; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.strip-name { font-weight: 600; font-size: 13px; padding-bottom: 4px; border-bottom: 3px solid var(--tc, #888); white-space: nowrap; }
.strip.master { --tc: #888; }
.knob { display: grid; grid-template-columns: 1fr auto; align-items: center; font-size: 11px; color: var(--muted); column-gap: 4px; }
.knob input { grid-column: 1 / -1; width: 100%; accent-color: #c8c8cc; height: 22px; margin: 0; }
.knob output { grid-row: 1; grid-column: 2; color: var(--ink); font-variant-numeric: tabular-nums; }
.knob input { grid-row: 2; }
.knob.fader { flex: 1; grid-template-rows: auto 1fr; }
.knob.fader input { writing-mode: vertical-lr; direction: rtl; height: 100%; min-height: 70px; width: 28px; justify-self: center; }
.knob-label { font-size: 11px; color: var(--muted); }
.strip .th-ms { justify-content: center; }

/* Dialoge */
.dialog { border: 1px solid var(--line2); border-radius: 12px; padding: 18px 22px; max-width: min(860px, 94vw); max-height: 90vh; background: var(--panel); color: var(--ink); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 { margin: 0 0 8px; font-size: 19px; font-weight: 600; } .dialog h3 { margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { border: 1px solid var(--line2); background: var(--panel2); border-radius: 8px; width: 104px; min-height: 80px; display: grid; place-items: center; padding: 6px; }
.choice.on { border-color: var(--accent); background: #24426b; }
.choice-icon { font-size: 26px; } .choice-name { font-size: 12px; font-weight: 600; text-align: center; }
.small-dialog .row { justify-content: center; }

.flash { position: fixed; left: 50%; bottom: 46vh; transform: translateX(-50%); background: #000c; border: 1px solid var(--line2); padding: 10px 16px; border-radius: 8px; z-index: 50; }

@media (max-width: 820px) {
  .ctrl { gap: 6px; }
  .song-title { order: 10; flex-basis: 100%; max-width: none; }
  .lcd-pos { font-size: 18px; }
  .bottom { height: 48vh; }
}

/* ---------- Paket 1: Workflow ---------- */
.edit-btns { display: flex; gap: 3px; }
.tbtn:disabled { opacity: .35; }
.lane.drop { box-shadow: inset 0 0 0 2px #fff; background-color: #2c2c30; }
.region.dragging { opacity: .85; z-index: 3; box-shadow: 0 6px 16px rgba(0,0,0,.5); }
.pasting .lane { cursor: copy; }
.pasting .lane:hover { background-color: #2a2d33; }
.paste-hint { position: fixed; left: 50%; top: 58px; transform: translateX(-50%); z-index: 40; display: flex; gap: 12px; align-items: center;
  background: #24426b; border: 1px solid var(--accent); padding: 6px 8px 6px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
/* Akkorde im Halbtakt */
.chord-bar { display: grid; gap: 3px; }
.chord-bar > small { font-size: 11px; color: var(--muted); padding-left: 2px; }
.chord-pair { display: flex; gap: 3px; }
.chord-pair .chord-slot { width: 84px; height: 66px; }
.chord-pair .chord-slot.second { width: 58px; }
.chord-pair .chord-slot.second:not(.filled) span { font-size: 18px; opacity: .6; }
/* Piano-Roll: gewählter Ton, Länge ziehen */
.roll-grid { touch-action: pan-x pan-y; }
.roll-note { touch-action: none; cursor: grab; overflow: hidden; white-space: nowrap; }
.roll-note::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; background: rgba(0,0,0,.18); border-radius: 0 4px 4px 0; }
.roll-note.sel { outline: 2px solid #fff; outline-offset: 1px; z-index: 2; }
.vel { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.vel input { width: 120px; accent-color: #c8c8cc; }
.vel output { color: var(--ink); min-width: 2em; font-variant-numeric: tabular-nums; }

/* Vorlagen */
.choice.tpl { width: 170px; min-height: 84px; gap: 2px; align-content: center; }
.tpl-name { font-size: 15px; }
.tpl-chords { font-size: 13px; color: var(--ink); font-weight: 600; }
.tpl-tempo { font-size: 11px; color: var(--muted); }

/* Tempo eingeben, Tonart, Kontextmenü */
.lcd-bpm { border: 0; background: transparent; color: var(--ink); font-size: 20px; font-weight: 300; min-width: 2.4em; text-align: center; border-radius: 4px; }
.lcd-bpm:hover, .lcd-key:hover { background: #2a2a2d; }
.lcd-key { border: 0; border-left: 1px solid #333; background: transparent; color: var(--ink); font-size: 14px; padding: 0 4px 0 12px; min-height: 30px; }
.tempo-pop { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.5); width: 260px; }
.tp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tp-row input { width: 90px; font: inherit; font-size: 20px; min-height: 40px; border: 1px solid var(--line2); border-radius: 6px; background: var(--bg); color: var(--ink); padding: 0 8px; }
.tp-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tp-chip { border: 1px solid #151515; background: #3a3a3d; border-radius: 6px; min-height: 44px; display: grid; place-items: center; padding: 2px; }
.tp-chip b { font-size: 16px; font-weight: 600; } .tp-chip small { font-size: 9px; color: var(--muted); }
.tp-chip.on { background: var(--accent); }
.ctx-menu { position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 4px; min-width: 220px; box-shadow: 0 12px 30px rgba(0,0,0,.55); display: grid; }
.ctx-item { border: 0; background: transparent; text-align: left; padding: 0 12px; min-height: 42px; border-radius: 6px; font-size: 15px; }
.ctx-item:hover:not(:disabled), .ctx-item:active:not(:disabled) { background: var(--accent); color: #fff; }
.ctx-item:disabled { opacity: .35; }
.choice.key { width: 96px; min-height: 48px; font-weight: 600; }
.chord-pick { display: grid; justify-items: center; gap: 2px; }
.chord-pick .fn { font-size: 11px; color: var(--muted); }
.more-chords { margin-top: 12px; } .more-chords summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
