/* ═══════════════════════════════════════════════════════════════════════
   W:\ Player – Mobile-First, aufgeräumt
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: rgba(255, 255, 255, 0.07);
  --accent: #1ed760;
  --accent-dim: rgba(30, 215, 96, 0.12);
  --dim: #555;
  --text: #e8e8e8;
  --sub: #888;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --bar-h: 90px;
  --nav-h: 65px;
  --radius: 10px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }
input, button { -webkit-appearance: none; appearance: none; }

/* ══════════════ Layout-Basis (Mobile) ══════════════ */
.app {
  display: grid;
  grid-template-rows: 1fr var(--bar-h) var(--nav-h);
  height: 100dvh;
  padding-bottom: var(--safe-bottom);
}

.sidebar, .playlists { display: none; }

.content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

.section-header { margin-bottom: 16px; }
.section-label {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.section-sub { font-size: 0.72rem; color: var(--sub); margin-top: 4px; }

/* ── Track-Liste ── */
.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-row {
  display: grid;
  grid-template-columns: 32px 1fr 36px;
  align-items: center;
  padding: 12px 10px;
  border-radius: 8px;
  cursor: pointer;
  gap: 12px;
  transition: background 0.12s;
  min-height: 58px;
}
.track-row:hover { background: rgba(255, 255, 255, 0.04); }
.track-row.active { background: var(--accent-dim); }
.track-row.active .t-title { color: var(--accent); }
.t-num { font-size: 0.85rem; color: var(--dim); text-align: right; }
.t-info { min-width: 0; overflow: hidden; }
.t-title {
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-artist {
  font-size: 0.85rem;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.t-num-val.active-num::before { content: "▶ "; color: var(--accent); }
.track-row.active .t-num-val { display: none; }
.track-row.active .t-num::after { content: "▶"; font-size: 0.7rem; color: var(--accent); }

/* ── Empty / Loading ── */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.7;
}
.empty strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  color: var(--sub);
  margin-bottom: 6px;
}

/* ── Player-Bar (Mobile) ── */
.player-bar {
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  padding: 8px 12px 6px;
  gap: 4px;
  padding-bottom: calc(6px + var(--safe-bottom));
}
.vol-row { display: none; }
.now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.thumb {
  width: 52px; height: 52px;
  background: var(--surface);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { fill: var(--dim); }
.np-info { min-width: 0; flex: 1; }
.np-title {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.np-artist {
  font-size: 0.8rem;
  color: var(--sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.controls { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.ctrl-row { display: flex; align-items: center; gap: 14px; }
.ctrl-btn {
  background: none; border: none;
  color: var(--sub);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  transition: color 0.15s, transform 0.1s;
  border-radius: 50%;
}
.ctrl-btn:hover { color: var(--text); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.shuffle.active { color: var(--accent); }
.play {
  width: 48px; height: 48px;
  background: var(--accent);
  color: #000;
}
.play:hover { background: #23f066; color: #000; }
.play svg { fill: #000; }

.progress-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 100%;
}
.time { font-size: 0.75rem; color: var(--dim); width: 36px; flex-shrink: 0; }
.time.right { text-align: right; }
.rail {
  flex: 1; height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}
.rail::before {
  content: "";
  position: absolute;
  inset: -7px 0; /* unsichtbare Touch-Fläche (~17px), Bar bleibt 3px dünn */
  background: transparent;
}
.rail:hover .fill, .rail:active .fill { background: var(--accent); }
.fill { height: 100%; width: 0%; background: #fff; border-radius: 3px; transition: background 0.2s; pointer-events: none; }

/* ── Mobile-Bottom-Nav ── */
.mobile-nav {
  display: flex;
  background: #0d0d0d;
  border-top: 1px solid var(--border);
}
.mob-nav-btn {
  flex: 1;
  background: none; border: none;
  color: var(--sub);
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
  transition: color 0.15s;
  min-height: 52px;
}
.mob-nav-btn svg { fill: currentColor; }
.mob-nav-btn.active { color: var(--accent); }

/* ══════════════ Playlist-Grid (Mobile) ══════════════ */
.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.pl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  overflow: hidden;
}
.pl-card:hover { background: var(--surface-2); }
.pl-card:active { transform: scale(0.98); }
.pl-card-icon {
  width: 100%;
  aspect-ratio: 1/1;
  background: var(--surface-2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.pl-card-icon svg { fill: var(--dim); }
.pl-card-name {
  font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-card-count { font-size: 0.65rem; color: var(--sub); margin-top: 2px; }

/* ── Search-Wrap (wiederverwendbar) ── */
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px 10px 10px 32px;
  outline: none;
  transition: border-color 0.2s;
  min-height: 40px;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); fill: var(--sub); }

/* ══════════════ DESKTOP (>= 768px) ══════════════ */
@media (min-width: 768px) {
  .app {
    grid-template-rows: 1fr var(--bar-h);
    grid-template-columns: 240px 220px 1fr;
    grid-template-areas:
      "sidebar playlists content"
      "player  player    player";
  }
  .sidebar    { grid-area: sidebar;    display: flex; flex-direction: column; }
  .playlists  { grid-area: playlists;  display: flex; flex-direction: column; }
  .content    { grid-area: content;    padding: 24px 28px; }
  .player-bar { grid-area: player;     grid-template-columns: 260px 1fr 260px; padding: 0 20px; gap: 0; }
  .mobile-nav { display: none; }
  .vol-row    { display: flex; }

  /* Sidebar-Inhalte */
  .sidebar { padding: 24px 14px; gap: 4px; overflow-y: auto; gap: 4px; }
  .logo {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem; font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--accent);
    margin-bottom: 20px;
    padding: 0 8px;
  }
  .logo span { color: var(--sub); }
  .nav-section {
    font-size: 0.6rem; color: var(--dim);
    padding: 14px 10px 4px;
    letter-spacing: 1px; text-transform: uppercase;
  }
  .nav-btn {
    background: none; border: none;
    color: var(--sub);
    font-size: 0.75rem;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    display: flex; align-items: center; gap: 9px;
    transition: background 0.15s, color 0.15s;
    width: 100%;
    letter-spacing: 0.3px;
  }
  .nav-btn:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
  .nav-btn.active { background: var(--accent-dim); color: var(--accent); }
  .nav-btn svg { flex-shrink: 0; fill: currentColor; }

  .meta-pill {
    font-size: 0.68rem; color: var(--sub);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 20px; padding: 4px 10px;
    display: inline-flex; align-items: center; gap: 6px;
    margin: 6px 0;
  }
  .meta-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

  .reload-btn {
    margin-top: auto;
    background: none; border: 1px solid var(--border);
    color: var(--sub); font-size: 0.7rem;
    padding: 8px 14px; border-radius: 6px; cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    letter-spacing: 0.5px;
  }
  .reload-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* Playlists (Desktop) */
  .playlists { padding: 24px 0; overflow-y: auto; background: var(--surface); }
  .playlists-title {
    font-family: 'Syne', sans-serif; font-size: 0.75rem; font-weight: 800;
    color: var(--sub); letter-spacing: 1px; text-transform: uppercase;
    padding: 0 16px 14px;
  }
  .playlist-item {
    padding: 10px 16px; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    transition: background 0.15s;
    border-left: 2px solid transparent;
  }
  .playlist-item:hover { background: rgba(255, 255, 255, 0.04); }
  .playlist-item.active { background: var(--accent-dim); border-left-color: var(--accent); }
  .playlist-item.active .pl-name { color: var(--accent); }
  .pl-icon {
    width: 32px; height: 32px; border-radius: 5px;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; border: 1px solid var(--border);
  }
  .pl-icon svg { fill: var(--dim); }
  .playlist-item.active .pl-icon { background: var(--accent-dim); border-color: rgba(30, 215, 96, 0.3); }
  .playlist-item.active .pl-icon svg { fill: var(--accent); }
  .pl-name {
    font-size: 0.78rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text);
  }
  .pl-count { font-size: 0.65rem; color: var(--dim); margin-top: 1px; }

  .section-label { font-size: 1.5rem; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
}

/* ── Scrollbar ── */
/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal.is-open { display: flex; }
.modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: fadeIn 0.2s;
}
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem; font-weight: 800;
  margin-bottom: 16px;
  color: var(--accent);
}
.modal form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.75rem;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal form input, .modal form select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px;
  margin-top: 4px;
  outline: none;
  text-transform: none;
}
.modal form input:focus, .modal form select:focus {
  border-color: var(--accent);
}
.modal-actions {
  display: flex; gap: 10px;
  margin-top: 16px;
}
.btn-primary, .btn-secondary {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  font-weight: 500;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: #23f066; }
.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }
.submit-status {
  margin-top: 12px;
  font-size: 0.8rem;
  text-align: center;
  color: var(--accent);
  min-height: 1.2em;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Listen-Animation ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.content > * { animation: fadeIn 0.2s ease-out; }

/* ══════════════ LOGIN-SCREEN ══════════════ */
.login-screen {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(30, 215, 96, 0.08), transparent 60%),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  animation: fadeIn 0.25s ease-out;
}
.login-logo {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-align: center;
}
.login-logo span { color: var(--sub); }
.login-sub {
  font-size: 0.75rem; color: var(--sub);
  text-align: center; margin: 6px 0 24px;
}
.login-label {
  display: block;
  font-size: 0.7rem; color: var(--sub);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 14px 0 6px;
}
.login-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit; font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--accent); }
.login-error {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.8rem;
  color: #ff6b6b;
  text-align: center;
}
.login-btn {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: #000;
  border: none; border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem; font-weight: 700;
  padding: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.login-btn:hover { background: #23f066; }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-hint {
  font-size: 0.7rem; color: var(--dim);
  text-align: center; margin-top: 16px;
}

/* ── Logout-Button ── */
.logout-btn {
  background: none; border: none;
  color: var(--dim); font-family: inherit; font-size: 0.65rem;
  cursor: pointer; margin-left: 4px;
  padding: 2px 6px; border-radius: 4px;
  transition: color 0.15s;
  text-decoration: underline;
}
.logout-btn:hover { color: #ff6b6b; }
