/* ═══════════════════════════════════════════════════════════
   eduAudioSchmiede – Design System
   Monospace · Schwarz/Weiß · Kein border-radius · Werkstatt-Look
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --font: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;

  /* Kern-Farben */
  --c-bg:            #ffffff;
  --c-fg:            #111111;
  --c-accent:        #e8360a;
  --c-rec:           #e8360a;

  /* Ränder – strukturell stark, intern weich */
  --c-border:        #c6c0b8;   /* warm-grau für Karten, Listen */
  --c-border-strong: #1a1a1a;   /* fast-schwarz für Toolbar, Panels */

  /* Flächen */
  --c-muted:         #888880;
  --c-light:         #f2ede8;   /* warmes Hellgrau */
  --c-bg-panel:      #f7f4f0;   /* Bibliothek, Sidebars */
  --c-hover-bg:      #1a1a1a;
  --c-hover-fg:      #ffffff;
  --c-active:        #1a1a1a;

  /* Kategorie-Farben (Tabs, Slots, Clips) */
  --c-cat-tiere:     #2e7d32;
  --c-cat-natur:     #1565c0;
  --c-cat-haushalt:  #c85a0a;
  --c-cat-stadt:     #6a1b9a;
  --c-cat-menschen:  #b71c1c;
  --c-cat-fantasie:  #00838f;
  --c-cat-loops:     #1565c0;   /* Blau – Musik/Loops */
  --c-cat-eigene:    #5d4037;

  --border:          1px solid var(--c-border);
  --border-lg:       2px solid var(--c-border-strong);

  --space-1:    4px;
  --space-2:    8px;
  --space-3:    12px;
  --space-4:    16px;
  --space-5:    24px;
  --space-6:    32px;
  --space-8:    48px;

  --toolbar-h:  48px;
  --library-w:  280px;
  --slot-min:   80px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  height: 100%;
  min-height: -webkit-fill-available;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  background: var(--c-bg);
  color: var(--c-fg);
  overflow: hidden; /* Scrollen nur in Panels */
}

a {
  color: inherit;
  text-decoration: underline;
}

a:hover { color: var(--c-accent); }

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100svh; /* iOS 15.4+: browser chrome excluded */
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* ── Buttons – Basis ──────────────────────────────────────── */
button {
  font-family: var(--font);
  font-size: 13px;
  font-weight: normal;
  cursor: pointer;
  border: var(--border);
  background: var(--c-bg);
  color: var(--c-fg);
  padding: var(--space-2) var(--space-4);
  line-height: 1.3;
  border-radius: 5px;
  transition: background 80ms, color 80ms, border-color 80ms;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: left;
  white-space: nowrap;
}

button:hover  { background: var(--c-hover-bg); color: var(--c-hover-fg); }
button:active { opacity: 0.7; }

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
button:disabled:hover {
  background: var(--c-bg);
  color: var(--c-fg);
}

button:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Varianten */
.btn       { display: inline-block; }
.btn-sm    { padding: var(--space-1) var(--space-2); font-size: 11px; }
.btn-icon  { border: none; background: transparent; padding: var(--space-2) var(--space-3); }
.btn-icon:hover { background: var(--c-hover-bg); color: var(--c-hover-fg); }

/* ── Inputs ───────────────────────────────────────────────── */
input[type="search"],
input[type="text"] {
  font-family: var(--font);
  font-size: 13px;
  border: var(--border);
  background: var(--c-bg);
  color: var(--c-fg);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="search"]:focus,
input[type="text"]:focus {
  border-color: var(--c-accent);
  outline: none;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  cursor: pointer;
}

/* ── Start-Screen ─────────────────────────────────────────── */
#screen-start {
  justify-content: space-between;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.start-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-6);
}

.start-logo {
  text-align: center;
}

.logo-mark {
  font-size: 48px;
  line-height: 1;
  margin-bottom: var(--space-3);
  letter-spacing: -2px;
}

.logo-title {
  font-size: clamp(28px, 6vw, 52px);
  font-weight: bold;
  line-height: 1;
  letter-spacing: -1px;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.logo-sub {
  font-size: 13px;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  width: 100%;
  max-width: 100%;
}

.btn-mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space-5);
  border: var(--border-lg);
  background: var(--c-bg);
  color: var(--c-fg);
  gap: var(--space-2);
  position: relative;
  min-height: 160px;
  transition: background 80ms, color 80ms;
}

.btn-mode:hover {
  background: var(--c-fg);
  color: var(--c-bg);
}

.btn-mode .mode-icon {
  font-size: 28px;
  line-height: 1;
}

.btn-mode .mode-name {
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 1px;
}

.btn-mode .mode-desc {
  font-size: 12px;
  color: var(--c-muted);
  line-height: 1.5;
}

.btn-mode:hover .mode-desc {
  color: #aaa;
}

.btn-mode .mode-hint {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-muted);
  margin-top: auto;
}

.btn-mode:hover .mode-hint {
  color: #999;
}

/* "Kommt bald"-Badge */
/* Link als Mode-Button (Sprechende Bilder navigiert zu Sub-URL) */
a.btn-mode { text-decoration: none; cursor: pointer; }

/* Geteilte Kachel: oben Editor, unten Viewer – zwei eigene Klick-Flächen */
.btn-mode--split {
  padding: 0;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}
.btn-mode--split:hover { background: var(--c-bg); color: var(--c-fg); }

.split-half {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  color: var(--c-fg);
  text-decoration: none;
  cursor: pointer;
  transition: background 80ms, color 80ms;
}
.split-half:first-child { flex: 1; }
.split-half:hover { background: var(--c-fg); color: var(--c-bg); }

.split-half .mode-icon { font-size: 24px; line-height: 1; }
.split-half .mode-name { font-size: 15px; font-weight: bold; letter-spacing: 1px; }
.split-half .mode-desc { font-size: 12px; color: var(--c-muted); line-height: 1.45; }
.split-half:hover .mode-desc { color: #aaa; }
.split-half .mode-hint {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--c-muted); margin-top: auto;
}
.split-half:hover .mode-hint { color: #999; }

/* Trennlinie zwischen Editor- und Viewer-Hälfte */
.split-half--viewer { border-top: var(--border-lg); }

.btn-mode--soon {
  opacity: 0.6;
  cursor: default;
}

.btn-mode--soon:hover {
  background: var(--c-bg);
  color: var(--c-fg);
}

.mode-soon-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 2px var(--space-2);
  border: var(--border);
  background: var(--c-fg);
  color: var(--c-bg);
}

/* ── Mini-Credits in Live/Studio-Screens ─────────────────── */
.screen-credits {
  flex-shrink: 0;
  padding: 1px var(--space-4);
  font-size: 8px;
  color: var(--c-muted);
  opacity: 0.5;
  text-align: right;
  direction: rtl;          /* rechtsbündig auch wenn Text überläuft */
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.screen-credits a {
  color: inherit;
  text-decoration: none;
}
.screen-credits a:hover {
  text-decoration: underline;
  opacity: 1;
}

/* ── PWA Install-Button ──────────────────────────────────── */
.btn-install {
  font-size: 12px;
  padding: var(--space-2) var(--space-5);
  border: var(--border);
  border-radius: 20px;     /* Pill-Form – hebt sich von den eckigen Buttons ab */
  color: var(--c-muted);
  background: transparent;
  letter-spacing: 0.5px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.btn-install:hover {
  background: var(--c-light);
  color: var(--c-fg);
  border-color: var(--c-fg);
}

/* ── iOS-Install-Hinweis (Safari kennt kein beforeinstallprompt) ── */
.ios-install-hint {
  position: relative;
  max-width: 420px;
  margin: var(--space-4) auto 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border);
  border-radius: 10px;
  background: var(--c-light);
  text-align: left;
}

.ios-install-hint[hidden] { display: none; }

.ios-install-hint__title {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.ios-install-hint__body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-muted);
}

.ios-install-hint__icon {
  display: inline-block;
  border: var(--border);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.3;
  color: var(--c-fg);
}

.ios-install-hint__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 12px;
  line-height: 1;
  padding: 4px;
  color: var(--c-muted);
  background: transparent;
}

.ios-install-hint__close:hover { color: var(--c-fg); }

/* ── Update-Toast (persistent, mit Reload-Button) ──────── */
.toast-update {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--c-fg);
  color: var(--c-bg);
  padding: var(--space-2) var(--space-3);
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  /* persistent – keine animation */
}
.toast-update .btn-reload {
  font-size: 11px;
  padding: 3px 10px;
  border-color: var(--c-bg);
  background: transparent;
  color: var(--c-bg);
  flex-shrink: 0;
  border-radius: 4px;
}
.toast-update .btn-reload:hover {
  background: var(--c-bg);
  color: var(--c-fg);
}

/* ── App-Footer ───────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: var(--border);
  font-size: 11px;
  color: var(--c-muted);
}

.footer-sep {
  opacity: 0.4;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--toolbar-h);
  padding: 0 var(--space-2);
  padding-left: calc(var(--space-2) + env(safe-area-inset-left));
  padding-right: calc(var(--space-2) + env(safe-area-inset-right));
  border-bottom: var(--border-lg);
  background: var(--c-bg);
  flex-shrink: 0;
  overflow: hidden;
}

.toolbar-title {
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 2px;
  white-space: nowrap;
  padding: 0 var(--space-3);
}

.toolbar-spacer {
  flex: 1;
}

/* ── REC-Bereich ──────────────────────────────────────────── */
.rec-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-rec {
  background: var(--c-bg);
  color: var(--c-rec);
  border: 2px solid var(--c-rec);
  font-weight: bold;
  font-size: 13px;
  padding: var(--space-1) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: background 80ms, color 80ms;
}

.btn-rec:hover {
  background: var(--c-rec);
  color: var(--c-bg);
}

.btn-rec.is-recording {
  background: var(--c-rec);
  color: var(--c-bg);
  animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.rec-dot {
  font-size: 10px;
}

.rec-timer {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 1px;
  min-width: 44px;
  text-align: right;
}

.rec-timer.is-recording {
  color: var(--c-rec);
}

/* ── Live-Layout ──────────────────────────────────────────── */
.live-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Soundboard ───────────────────────────────────────────── */
.soundboard-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  padding-left: calc(var(--space-4) + env(safe-area-inset-left));
  padding-right: calc(var(--space-4) + env(safe-area-inset-right));
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.soundboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  width: 100%;
  max-width: 720px;
}

/* Auf kleinen Hochformat-Displays: 3 Spalten */
@media (max-width: 480px) and (orientation: portrait) {
  .soundboard {
    grid-template-columns: repeat(3, 1fr);
  }
}

.soundboard-hint {
  margin-top: var(--space-4);
  font-size: 12px;
  color: var(--c-muted);
  text-align: center;
  max-width: 400px;
}

/* ── Soundboard-Slot ──────────────────────────────────────── */
.sound-slot {
  border: var(--border);
  border-radius: 8px;
  background: var(--c-bg);
  color: var(--c-fg);
  padding: var(--space-3);
  min-height: var(--slot-min);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 80ms, color 80ms, border-color 80ms;
  -webkit-tap-highlight-color: transparent;
}

/* Leerer Slot */
.sound-slot.is-empty {
  border-style: dashed;
  color: var(--c-muted);
  cursor: default;
}

.sound-slot.is-empty.assign-target {
  border-style: solid;
  border-color: var(--c-accent);
  cursor: pointer;
  animation: slot-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes slot-pulse {
  from { background: var(--c-bg); }
  to   { background: #fff5f3; }
}

/* Slot mit Sound */
.sound-slot.has-sound:hover {
  background: var(--c-fg);
  color: var(--c-bg);
}

.sound-slot.has-sound:active {
  background: #222;
  color: var(--c-bg);
}

/* Wird gerade abgespielt */
.sound-slot.is-playing {
  background: var(--c-fg);
  color: var(--c-bg);
  border-style: solid;
}

.sound-slot.is-playing::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--c-accent);
  animation: play-bar 0.3s ease-out;
}

@keyframes play-bar {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); }
}

/* Fehler beim Laden */
.sound-slot.has-error {
  border-color: var(--c-accent);
  color: var(--c-accent);
}

/* Slot-Inhalte */
.slot-number {
  font-size: 10px;
  opacity: 0.4;
  line-height: 1;
}

.slot-name {
  font-size: 12px;
  font-weight: bold;
  line-height: 1.3;
  word-break: break-word;
}

.slot-cat {
  font-size: 10px;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slot-play-hint {
  font-size: 20px;
  opacity: 0.15;
  line-height: 1;
  align-self: flex-end;
}

.sound-slot.is-playing .slot-play-hint {
  opacity: 0.85;
}

.slot-empty-label {
  font-size: 20px;
  opacity: 0.15;
  align-self: center;
  justify-self: center;
  margin: auto;
}

/* Löschen-Button am Slot (sichtbar nur bei hover / Keyboard) */
.slot-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 11px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 80ms;
  cursor: pointer;
  line-height: 1;
}

.sound-slot:hover .slot-remove,
.sound-slot:focus-within .slot-remove {
  opacity: 0.5;
}

.slot-remove:hover {
  opacity: 1 !important;
  background: var(--c-accent) !important;
  color: #fff !important;
}

/* ── Bibliotheks-Panel ────────────────────────────────────── */
.library-panel {
  width: var(--library-w);
  border-left: var(--border-lg);
  background: var(--c-bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.library-panel[hidden] {
  display: none;
}

/* Auf kleinen Displays: Overlay */
@media (max-width: 680px) {
  .library-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    box-shadow: -4px 0 0 0 var(--c-border);
  }
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.library-title {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
}

.library-search-wrap {
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.library-search {
  font-size: 12px;
}

/* Kategorie-Tabs */
.library-cats {
  display: flex;
  overflow-x: auto;
  border-bottom: var(--border);
  flex-shrink: 0;
  scrollbar-width: none;
}

.library-cats::-webkit-scrollbar { display: none; }

.cat-tab {
  border: none;
  border-right: var(--border);
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--c-muted);
  font-size: 11px;
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
  letter-spacing: 0.5px;
  cursor: pointer;
  flex-shrink: 0;
  text-transform: uppercase;
}

.cat-tab:hover {
  background: var(--c-light);
  color: var(--c-fg);
}

.cat-tab.is-active {
  background: var(--c-bg);
  color: var(--c-fg);
  font-weight: bold;
  border-bottom-color: var(--c-fg);
}

/* Geräusch-Liste */
.library-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--space-1) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.library-list::-webkit-scrollbar {
  width: 4px;
}

.library-list::-webkit-scrollbar-thumb {
  background: var(--c-border);
}

.sound-item {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-bottom: var(--border);
  background: transparent;
  cursor: pointer;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
}

.sound-item:last-child { border-bottom: none; }

.sound-item:hover {
  background: var(--c-light);
  color: var(--c-fg);
}

/* ── Kategorie-Tabs mit Farbe ─────────────────────────────── */
.cat-tab[data-cat="tiere"].is-active    { color: var(--c-cat-tiere);    border-bottom-color: var(--c-cat-tiere); }
.cat-tab[data-cat="natur"].is-active    { color: var(--c-cat-natur);    border-bottom-color: var(--c-cat-natur); }
.cat-tab[data-cat="haushalt"].is-active { color: var(--c-cat-haushalt); border-bottom-color: var(--c-cat-haushalt); }
.cat-tab[data-cat="stadt"].is-active    { color: var(--c-cat-stadt);    border-bottom-color: var(--c-cat-stadt); }
.cat-tab[data-cat="menschen"].is-active { color: var(--c-cat-menschen); border-bottom-color: var(--c-cat-menschen); }
.cat-tab[data-cat="fantasie"].is-active { color: var(--c-cat-fantasie); border-bottom-color: var(--c-cat-fantasie); }
.cat-tab[data-cat="loops"].is-active    { color: var(--c-cat-loops);    border-bottom-color: var(--c-cat-loops); }
.cat-tab[data-cat="eigene"].is-active   { color: var(--c-cat-eigene);   border-bottom-color: var(--c-cat-eigene); }

/* ── Sound-Items: farbige Kategorie-Linie links ──────────── */
.sound-item[data-cat="tiere"]    { border-left: 3px solid var(--c-cat-tiere); }
.sound-item[data-cat="natur"]    { border-left: 3px solid var(--c-cat-natur); }
.sound-item[data-cat="haushalt"] { border-left: 3px solid var(--c-cat-haushalt); }
.sound-item[data-cat="stadt"]    { border-left: 3px solid var(--c-cat-stadt); }
.sound-item[data-cat="menschen"] { border-left: 3px solid var(--c-cat-menschen); }
.sound-item[data-cat="fantasie"] { border-left: 3px solid var(--c-cat-fantasie); }
.sound-item[data-cat="loops"]    { border-left: 3px solid var(--c-cat-loops); }
.sound-item[data-cat="eigene"]   { border-left: 3px solid var(--c-cat-eigene); }

/* ── Soundboard-Slots mit Kategorie-Farbe ────────────────── */
.sound-slot[data-cat].has-sound  { border-left-width: 4px; }
.sound-slot[data-cat="tiere"]    { border-left-color: var(--c-cat-tiere); }
.sound-slot[data-cat="natur"]    { border-left-color: var(--c-cat-natur); }
.sound-slot[data-cat="haushalt"] { border-left-color: var(--c-cat-haushalt); }
.sound-slot[data-cat="stadt"]    { border-left-color: var(--c-cat-stadt); }
.sound-slot[data-cat="menschen"] { border-left-color: var(--c-cat-menschen); }
.sound-slot[data-cat="fantasie"] { border-left-color: var(--c-cat-fantasie); }
.sound-slot[data-cat="loops"]    { border-left-color: var(--c-cat-loops); }
.sound-slot[data-cat="eigene"]   { border-left-color: var(--c-cat-eigene); }

/* ── Timeline-Clips: Kategorie als Hintergrundfarbe ─────── */
.timeline-clip[data-cat="tiere"]    { background: var(--c-cat-tiere); }
.timeline-clip[data-cat="natur"]    { background: var(--c-cat-natur); }
.timeline-clip[data-cat="haushalt"] { background: var(--c-cat-haushalt); }
.timeline-clip[data-cat="stadt"]    { background: var(--c-cat-stadt); }
.timeline-clip[data-cat="menschen"] { background: var(--c-cat-menschen); }
.timeline-clip[data-cat="fantasie"] { background: var(--c-cat-fantasie); }
.timeline-clip[data-cat="loops"]    { background: var(--c-cat-loops); }
.timeline-clip[data-cat="eigene"]   { background: var(--c-cat-eigene); }

/* ── Import-Button ───────────────────────────────────────── */
.library-import-section {
  padding: var(--space-2) var(--space-3);
  border-top: var(--border);
  flex-shrink: 0;
}

.btn-import {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--c-border);
  background: transparent;
  color: var(--c-muted);
  font-family: var(--font);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 80ms, color 80ms, border-color 80ms;
}

.btn-import:hover {
  background: var(--c-light);
  color: var(--c-fg);
  border-color: var(--c-fg);
  border-style: solid;
}

.sound-import-input {
  display: none;
}

.sound-item.is-selected {
  background: var(--c-fg);
  color: var(--c-bg);
}

.sound-item-name {
  flex: 1;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-item-dur {
  font-size: 10px;
  color: var(--c-muted);
  flex-shrink: 0;
}

.sound-item.is-selected .sound-item-dur {
  color: #aaa;
}

.sound-item-preview {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: inherit;
  padding: 2px 4px;
  font-size: 12px;
  opacity: 0.5;
  cursor: pointer;
}

.sound-item-preview:hover {
  opacity: 1;
  background: transparent !important;
  color: inherit !important;
}

.sound-item.is-selected .sound-item-preview {
  opacity: 0.7;
}

/* Fehler in Library-Liste */
.library-error {
  padding: var(--space-4);
  color: var(--c-accent);
  font-size: 12px;
}

.library-empty {
  padding: var(--space-4);
  color: var(--c-muted);
  font-size: 12px;
}

/* Zuweisungs-Hinweis am unteren Rand des Panels */
.library-assign-hint {
  padding: var(--space-3);
  border-top: var(--border-lg);
  border-color: var(--c-accent);
  background: #fff5f3;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  flex-shrink: 0;
}

.library-assign-hint[hidden] { display: none; }

.library-assign-hint span {
  flex: 1;
  color: var(--c-fg);
}

/* ── Modals ───────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}

.modal[hidden] { display: none; }

.modal-box {
  background: var(--c-bg);
  border: var(--border-lg);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4);
}

.modal-footer {
  padding: var(--space-3) var(--space-4);
  border-top: var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Hilfe-Schritte */
.help-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.help-step {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
}

.help-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: var(--border);
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Toasts ───────────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--c-fg);
  color: var(--c-bg);
  padding: var(--space-2) var(--space-4);
  font-size: 12px;
  border: var(--border);
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toast-in 0.15s ease-out, toast-out 0.2s ease-in var(--toast-delay, 2.5s) forwards;
}

.toast--error {
  background: var(--c-accent);
  border-color: var(--c-accent);
}

.toast--warn {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: var(--c-bg);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Loading-State für Slots ──────────────────────────────── */
.sound-slot.is-loading .slot-name::after {
  content: '…';
  animation: loading-dots 1s steps(3, end) infinite;
}

@keyframes loading-dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '…'; }
}

/* ── Keyboard-Kürzel-Badge auf Slots ─────────────────────── */
.slot-key {
  position: absolute;
  bottom: var(--space-1);
  right: var(--space-2);
  font-size: 10px;
  opacity: 0.2;
  line-height: 1;
}

/* ── Drag-über-Slot Highlight ─────────────────────────────── */
.sound-slot.drag-over {
  border-style: solid;
  border-color: var(--c-accent);
  background: #fff5f3;
}

/* ── Utility ──────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --toolbar-h: 44px;
    --library-w: 100%;   /* Live-Library (overlay) */
    --slot-min: 70px;
  }

  /* Studio-Library bleibt schmal, auch auf Mobile */
  .studio-lib {
    width: 180px;
    min-width: 0;
  }

  .toolbar-title { display: none; }

  .btn-library-toggle { font-size: 12px; }

  .soundboard {
    gap: var(--space-1);
    padding: var(--space-2);
  }

  .sound-slot {
    padding: var(--space-2);
    min-height: var(--slot-min);
  }

  .slot-name { font-size: 11px; }

  /* Inhalt von oben beginnen, damit Scroll auf iOS korrekt funktioniert */
  .soundboard-wrap {
    justify-content: flex-start;
    padding-top: var(--space-3);
  }

  /* Toolbar-Buttons kompakter, damit alle in die schmale Toolbar passen */
  .toolbar .btn-icon {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .rec-timer { display: none; }
}

/* Touch: keine Hover-States die beim Tippen stecken bleiben */
@media (hover: none) {
  .sound-slot.has-sound:hover {
    background: var(--c-bg);
    color: var(--c-fg);
  }

  button:hover {
    background: var(--c-bg);
    color: var(--c-fg);
  }

  .btn-mode:hover {
    background: var(--c-bg);
    color: var(--c-fg);
  }

  .btn-rec:hover {
    background: var(--c-bg);
    color: var(--c-rec);
  }
}

/* Touch: aktive Zustände explizit */
@media (hover: none) {
  .sound-slot.has-sound:active {
    background: var(--c-fg);
    color: var(--c-bg);
  }

  button:active {
    background: var(--c-hover-bg);
    color: var(--c-hover-fg);
  }
}

/* Landscape auf kleinen Geräten */
@media (max-height: 400px) {
  .start-logo { display: none; }
  .start-main { padding: var(--space-3); gap: var(--space-3); }
}

/* ── Studio-Modus ────────────────────────────────────────── */
.project-name-input {
  font-family: var(--font);
  font-size: 13px;
  font-weight: bold;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--c-fg);
  padding: 2px var(--space-2);
  min-width: 0;
  width: 180px;
  outline: none;
}
.project-name-input:hover  { border-bottom-color: var(--c-muted); }
.project-name-input:focus  { border-bottom-color: var(--c-fg); }

.studio-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Library (Studio) */
.studio-lib {
  width: var(--library-w);
  border-right: var(--border-lg);
  background: var(--c-bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}


.studio-lib-hint {
  padding: var(--space-3);
  font-size: 11px;
  color: var(--c-muted);
  border-top: var(--border);
  flex-shrink: 0;
}

.studio-lib-hint.is-active {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: #fff5f3;
}

/* Timeline-Bereich */
.studio-timeline-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.studio-timeline-scroll {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Timeline-Zeilen */
.timeline-row {
  display: flex;
  position: relative;
}

.timeline-ruler-row {
  height: 28px;
  border-bottom: var(--border-lg);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--c-bg);
}

/* Track-Label (sticky links) */
.track-label {
  width: 148px;
  min-width: 148px;
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--c-bg-panel);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-1) var(--space-2);
  gap: var(--space-1);
  flex-shrink: 0;
}

.track-label-top {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
}

.track-label-vol {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
}

.track-vol-icon {
  font-size: 10px;
  flex-shrink: 0;
  opacity: 0.7;
  line-height: 1;
}

/* Lautstärke-Slider */
.track-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border: none;
  border-radius: 2px;
  background: var(--c-border);
  cursor: pointer;
  outline: none;
}
.track-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-fg);
  cursor: pointer;
  border: 2px solid var(--c-bg);
  box-shadow: 0 0 0 1px var(--c-border);
}
.track-vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-fg);
  cursor: pointer;
  border: 2px solid var(--c-bg);
}
.track-vol-slider:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Spur hinzufügen */
.add-track-row {
  display: flex;
  height: 40px;
  border-bottom: var(--border);
}

.btn-add-track {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-size: 12px;
  text-align: left;
  padding: 0 var(--space-3);
  border-radius: 0;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 80ms, color 80ms;
}
.btn-add-track:hover {
  background: var(--c-light);
  color: var(--c-fg);
}

.track-label--ruler {
  border-bottom: none;
  z-index: 6;
  font-size: 10px;
  color: var(--c-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.track-name {
  flex: 1;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-btn {
  border: var(--border);
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  line-height: 1.4;
  flex-shrink: 0;
  min-width: 20px;
  text-align: center;
}

.track-btn.is-active {
  background: var(--c-fg);
  color: var(--c-bg);
}

.track-btn.btn-mute.is-active  { background: var(--c-accent); border-color: var(--c-accent); }
.track-btn.btn-rec-track               { color: var(--c-muted); border-color: var(--c-border); }
.track-btn.btn-rec-track.is-armed      { color: var(--c-accent); border-color: var(--c-accent); }
.track-btn.btn-rec-track.is-recording  {
  background: var(--c-accent);
  color: var(--c-bg);
  border-color: var(--c-accent);
  animation: rec-pulse 1.2s ease-in-out infinite;
}

/* Ruler-Markierungen */
.timeline-ruler-content {
  flex: 1;
  position: relative;
  height: 100%;
  cursor: pointer;
}

.ruler-mark {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  padding-bottom: 3px;
  pointer-events: none;
}

.ruler-mark::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 50%;
  background: var(--c-border);
}

.ruler-mark--major::before { top: 0; height: 100%; opacity: 0.3; }

.ruler-mark-label {
  font-size: 9px;
  color: var(--c-muted);
  padding-left: 3px;
  white-space: nowrap;
}

/* Track-Inhalt */
.track-row {
  height: 80px;
  border-bottom: var(--border);
}

.track-row.is-muted .track-content { opacity: 0.35; }
.track-row.drop-target .track-content { background: #f5f5f5; }

.track-content {
  flex: 1;
  position: relative;
  overflow: visible;
  cursor: crosshair;
}

/* Clip */
.timeline-clip {
  position: absolute;
  top: 6px;
  height: calc(100% - 12px);
  background: var(--c-fg);
  color: var(--c-bg);
  display: flex;
  align-items: center;
  padding: 0 var(--space-2);
  cursor: grab;
  user-select: none;
  border: 1px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  min-width: 4px;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.timeline-clip:active { cursor: grabbing; }

.timeline-clip.is-selected {
  border-color: var(--c-accent);
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
}

.timeline-clip.is-mic {
  background: #333;
  border-color: var(--c-accent);
}

.timeline-clip.is-dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.clip-name {
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  flex: 1;
}

/* ── Trim-Handles (Clip-Ränder ziehen) ───────────────────── */
.clip-trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  cursor: ew-resize;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clip-trim-handle::after {
  content: '';
  width: 2px;
  height: 60%;
  background: rgba(255,255,255,0.55);
  border-radius: 1px;
}
.clip-trim-left  { left:  0; border-radius: 5px 0 0 5px; }
.clip-trim-right { right: 0; border-radius: 0 5px 5px 0; }
.clip-trim-handle:hover::after { background: rgba(255,255,255,0.9); }

/* Scissors-Button */
.btn-split {
  font-size: 16px;
  min-width: 36px;
}
.btn-split:disabled { opacity: 0.3; }
.btn-split.is-active {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}

/* Schere-Werkzeug aktiv: Clips per Klick schneiden */
.studio-timeline-scroll.scissors-mode .timeline-clip {
  cursor: crosshair;
}
.studio-timeline-scroll.scissors-mode .timeline-clip:active {
  cursor: crosshair;
}

.clip-delete {
  position: absolute;
  right: 2px;
  top: 2px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 9px;
  padding: 1px 3px;
  opacity: 0;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}

.timeline-clip:hover .clip-delete { opacity: 0.6; }
.clip-delete:hover { opacity: 1 !important; background: var(--c-accent) !important; color: #fff !important; }

/* Ghost-Clip beim Drag über Track */
.clip-ghost {
  position: absolute;
  top: 4px;
  height: calc(100% - 8px);
  background: rgba(0,0,0,0.15);
  border: 2px dashed var(--c-border);
  pointer-events: none;
  z-index: 3;
}

/* Playhead */
.studio-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--c-accent);
  pointer-events: none;
  z-index: 10;
}

.studio-playhead::before {
  content: '▼';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--c-accent);
  line-height: 1;
}

/* Transport-Leiste (jetzt oben, unter Toolbar) */
.transport-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 var(--space-3);
  border-bottom: var(--border-lg);
  background: var(--c-light);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.transport-bar::-webkit-scrollbar { display: none; }

.btn-transport {
  border: var(--border);
  border-radius: 5px;
  padding: var(--space-1) var(--space-3);
  font-size: 14px;
  min-width: 36px;
  text-align: center;
}

/* Großer, klarer Play-Button */
.btn-play-main {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px;
  background: var(--c-fg);
  color: var(--c-bg);
  border: 2px solid var(--c-fg);
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  min-width: 110px;
  justify-content: center;
  letter-spacing: 0.5px;
  transition: background 80ms, color 80ms, transform 60ms;
}
.btn-play-main:hover  { background: #333; border-color: #333; }
.btn-play-main:active { transform: scale(0.97); }
.btn-play-main.is-playing {
  background: var(--c-cat-natur);
  border-color: var(--c-cat-natur);
}
.play-btn-icon { font-size: 16px; line-height: 1; }
.play-btn-label { font-size: 12px; }

.transport-sep {
  width: 1px;
  height: 20px;
  background: var(--c-border);
  flex-shrink: 0;
  opacity: 0.3;
}

.transport-spacer { flex: 1; }

.transport-time {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  white-space: nowrap;
}

.transport-slash {
  opacity: 0.4;
  margin: 0 2px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.zoom-label {
  font-size: 11px;
  min-width: 52px;
  text-align: center;
  color: var(--c-muted);
}

.btn-studio-rec { font-size: 12px; }

/* ── Spur-Typ-Auswahl-Modal ──────────────────────────────── */
.modal-box--narrow {
  max-width: 360px;
}

.modal-track-choice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-5);
}

.btn-track-choice {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  border: var(--border-lg);
  background: var(--c-bg);
  color: var(--c-fg);
  cursor: pointer;
  text-align: center;
  transition: background 80ms, color 80ms;
  white-space: normal;
}

.btn-track-choice:hover {
  background: var(--c-fg);
  color: var(--c-bg);
}

.track-choice-icon {
  font-size: 28px;
  line-height: 1;
}

.track-choice-label {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.track-choice-desc {
  font-size: 11px;
  opacity: 0.6;
  line-height: 1.4;
}

.btn-track-choice:hover .track-choice-desc {
  opacity: 0.75;
}

/* ── Setup-Modal ──────────────────────────────────────────── */
.setup-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-muted);
  display: block;
  margin-bottom: var(--space-2);
}

.setup-save-section {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: var(--border);
}

.setup-save-row {
  display: flex;
  gap: var(--space-2);
}

.setup-name-input {
  flex: 1;
  min-width: 0; /* verhindert Überlauf in Flex */
}

.setup-list-section {
  min-height: 60px;
}

.setup-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: var(--space-1);
}

.setup-entry {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: var(--border);
  background: var(--c-bg);
}

.setup-entry-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-entry-date {
  font-size: 10px;
  color: var(--c-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.setup-entry-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.setup-entry-actions .btn-sm {
  white-space: nowrap;
}

.setup-entry-actions .btn-delete {
  color: var(--c-accent);
  border-color: var(--c-accent);
}

.setup-entry-actions .btn-delete:hover {
  background: var(--c-accent);
  color: var(--c-bg);
  border-color: var(--c-accent);
}

.setup-empty {
  font-size: 12px;
  color: var(--c-muted);
  padding: var(--space-3) 0;
}
