* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f0f0f; --surface: #1a1a1a; --surface2: #252525;
  --border: #333; --accent: #e8c27a; --text: #f0f0f0;
  --text-muted: #888; --radius: 10px;
}
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ── */
#login-overlay {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 500; display: flex; align-items: center; justify-content: center;
}
#login-overlay.hidden { display: none; }
.login-box {
  background: var(--surface); border-radius: 16px;
  padding: 36px 32px; width: 320px; text-align: center;
}
.login-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-box h2 span { color: var(--accent); }
.login-box p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-box input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 18px; letter-spacing: 4px;
  padding: 12px; outline: none; text-align: center; margin-bottom: 12px;
}
.login-box input:focus { border-color: var(--accent); }
.login-error { color: #e87a7a; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.btn-primary {
  width: 100%; background: var(--accent); border: none; border-radius: 8px;
  color: #000; cursor: pointer; font-size: 15px; font-weight: 600;
  padding: 12px; transition: opacity 0.15s; -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: 0.8; }

/* ── HEADER ── */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,15,0.92); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border);
  padding: 16px 20px 12px;
}
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
h1 span { color: var(--accent); }
.header-actions { display: flex; gap: 8px; align-items: center; }
#count-badge {
  background: var(--surface2); color: var(--text-muted);
  font-size: 13px; padding: 4px 10px; border-radius: 20px;
}
.btn-icon {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 5px 10px; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}
input[type="search"] {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px;
  padding: 9px 12px 9px 34px; outline: none; -webkit-appearance: none;
}
input[type="search"]:focus { border-color: var(--accent); }
select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
  padding: 9px 12px; outline: none; cursor: pointer; -webkit-appearance: none;
}
select:focus { border-color: var(--accent); }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 6px 14px; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
#progress-bar { height: 2px; background: var(--accent); width: 0%; transition: width 0.3s; margin-top: 8px; }

/* ── MOOD PANEL ── */
#mood-panel {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
.mood-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.mood-input-row { display: flex; gap: 8px; }
#mood-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
  padding: 9px 12px; outline: none;
}
#mood-input:focus { border-color: var(--accent); }
.btn-mood {
  background: var(--accent); border: none; border-radius: 8px;
  color: #000; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 9px 16px; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn-mood:disabled { opacity: 0.5; cursor: default; }
.mood-loading { display: none; align-items: center; gap: 10px; margin-top: 12px; color: var(--text-muted); font-size: 13px; }
.mood-loading.show { display: flex; }
.mood-spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
#mood-results { margin-top: 14px; display: none; }
.mood-results-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.suggestions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.suggestion-card {
  background: var(--surface2); border-radius: 10px; display: flex; gap: 12px;
  padding: 12px; cursor: pointer; border: 1px solid var(--border);
  transition: background 0.15s; -webkit-tap-highlight-color: transparent;
}
.suggestion-card:active { background: #2e2e2e; }
.suggestion-thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--border); flex-shrink: 0; }
.suggestion-info { min-width: 0; }
.suggestion-artist { color: var(--accent); font-size: 11px; font-weight: 600; }
.suggestion-title { font-size: 13px; font-weight: 500; margin: 2px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-reason { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── GRID ── */
main { padding: 20px; }
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
@media (min-width: 768px)  { #grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
@media (min-width: 1024px) { #grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.15s; -webkit-tap-highlight-color: transparent; }
.card:active { transform: scale(0.97); }
.cover-wrap { position: relative; aspect-ratio: 1; background: var(--surface2); overflow: hidden; }
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.3s; }
.cover-wrap img.lazy { opacity: 0; }
.cover-wrap img.loaded { opacity: 1; }
.format-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px); border-radius: 6px; color: var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; padding: 3px 7px; text-transform: uppercase;
}
.no-cover { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--surface2); }
.no-cover svg { opacity: 0.2; }
.card-info { padding: 10px 12px 12px; }
.card-artist { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.3px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title { color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-year { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.card-stars { font-size: 13px; margin-top: 5px; letter-spacing: 1px; color: var(--accent); }

/* ── MODAL ── */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
#modal-overlay.open { display: flex; }
#modal { background: var(--surface); border-radius: 16px; max-width: 540px; width: 100%; overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; }
#modal-img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface2); }
#modal-body { padding: 20px; overflow-y: auto; }
#modal-artist { color: var(--accent); font-size: 14px; font-weight: 600; margin-bottom: 4px; }
#modal-title { font-size: 22px; font-weight: 700; line-height: 1.2; margin-bottom: 8px; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.meta-chip { background: var(--surface2); border-radius: 6px; color: var(--text-muted); font-size: 12px; padding: 4px 10px; }
.rating-section, .note-section { margin-bottom: 16px; }
.rating-label, .note-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stars { display: flex; gap: 6px; }
.star { font-size: 28px; cursor: pointer; color: var(--border); transition: color 0.1s, transform 0.1s; -webkit-tap-highlight-color: transparent; user-select: none; }
.star.filled { color: var(--accent); }
.star:active { transform: scale(1.2); }
textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit; padding: 10px 12px; outline: none; resize: vertical; min-height: 80px; line-height: 1.5; }
textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.btn-save { background: var(--accent); border: none; border-radius: 8px; color: #000; cursor: pointer; font-size: 14px; font-weight: 600; padding: 10px 20px; transition: opacity 0.15s; -webkit-tap-highlight-color: transparent; }
.btn-save:active { opacity: 0.8; }
.save-status { font-size: 13px; color: var(--text-muted); opacity: 0; transition: opacity 0.3s; }
.save-status.show { opacity: 1; }
.discogs-link { color: var(--accent); text-decoration: none; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
#modal-close { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,0.6); border: none; border-radius: 50%; color: #fff; cursor: pointer; font-size: 20px; height: 36px; width: 36px; line-height: 36px; text-align: center; -webkit-tap-highlight-color: transparent; }

/* ── TRACKLIST ── */
#modal-tracklist { margin: 16px 0 12px; }
.tracklist-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.tracklist-loading { font-size: 13px; color: var(--text-muted); }
.track-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.track-row:last-child { border-bottom: none; }
.track-pos { font-size: 11px; color: var(--text-muted); min-width: 24px; flex-shrink: 0; text-align: right; }
.track-title { flex: 1; line-height: 1.3; }
.track-title.highlight { color: var(--accent); }
.track-duration { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.track-heading { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding: 8px 0 2px; flex: 1; }
.track-play-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 15px; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: color 0.15s, background 0.15s; -webkit-tap-highlight-color: transparent;
}
.track-play-btn:hover { color: var(--accent); background: rgba(232,194,122,0.1); }
.track-play-btn.playing { color: var(--accent); }
.track-play-btn.loading { color: var(--text-muted); animation: spin 1s linear infinite; }

/* ── AUDIO BAR ── */
#audio-bar {
  position: sticky; bottom: 0; background: var(--surface2); border-top: 1px solid var(--border);
  padding: 10px 16px; display: none; align-items: center; gap: 10px; margin: 0 -20px -20px;
}
#audio-bar.show { display: flex; }
#audio-bar-title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#audio-bar-artist { font-size: 11px; color: var(--text-muted); }
#audio-stop { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; flex-shrink: 0; }
#audio-progress { flex: 1; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
#audio-progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.5s linear; }

/* ── PIN-VERWALTUNG MODAL ── */
#pw-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); z-index: 300; align-items: center; justify-content: center; padding: 20px; }
#pw-overlay.open { display: flex; }
.pw-box { background: var(--surface); border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 420px; }
.pw-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.pw-box .pw-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.pin-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.pin-row { display: flex; align-items: center; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.pin-value { flex: 1; font-size: 16px; letter-spacing: 3px; font-family: monospace; }
.pin-role-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: 20px; flex-shrink: 0;
}
.pin-role-badge.admin { background: rgba(232,194,122,0.15); color: var(--accent); border: 1px solid rgba(232,194,122,0.3); }
.pin-role-badge.user  { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.pin-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 0 4px; line-height: 1; -webkit-tap-highlight-color: transparent; }
.pin-delete:hover { color: #e87a7a; }
.pin-delete:disabled { opacity: 0.25; cursor: default; }
.pw-box label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 6px; }
.pw-add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.pw-add-row input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 16px; padding: 10px 12px; outline: none; }
.pw-add-row input:focus { border-color: var(--accent); }
.pw-role-toggle { display: flex; gap: 6px; margin-bottom: 16px; }
.pw-role-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted); cursor: pointer; font-size: 13px;
  transition: all 0.15s; -webkit-tap-highlight-color: transparent;
}
.pw-role-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.btn-add-pin { background: var(--accent); border: none; border-radius: 8px; color: #000; cursor: pointer; font-size: 20px; font-weight: 700; padding: 0 16px; -webkit-tap-highlight-color: transparent; }
.pw-actions { display: flex; gap: 10px; }
.btn-cancel { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 14px; padding: 10px; -webkit-tap-highlight-color: transparent; }
.pw-error { color: #e87a7a; font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ── LOADING ── */
#loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 80px 20px; color: var(--text-muted); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#progress-text { font-size: 13px; color: var(--text-muted); }
#empty { display: none; text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ── DUPLIKATE MODAL ── */
#dup-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); z-index: 200;
  align-items: flex-start; justify-content: center; padding: 20px;
  overflow-y: auto;
}
#dup-overlay.open { display: flex; }
#dup-modal {
  background: var(--surface); border-radius: 16px;
  width: 100%; max-width: 680px; margin: auto; overflow: hidden;
}
.dup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.dup-header h2 { font-size: 18px; font-weight: 700; }
.dup-header span { color: var(--text-muted); font-size: 13px; margin-left: 10px; }
#dup-close {
  background: var(--surface2); border: none; border-radius: 50%;
  color: var(--text); cursor: pointer; font-size: 18px;
  height: 32px; width: 32px; line-height: 32px; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.dup-group { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.dup-group:last-child { border-bottom: none; }
.dup-group-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.dup-group-artist { font-size: 12px; color: var(--accent); margin-bottom: 12px; font-weight: 600; }
.dup-entries { display: flex; flex-direction: column; gap: 8px; }
.dup-entry {
  background: var(--surface2); border-radius: 8px;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
}
.dup-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--border); flex-shrink: 0; }
.dup-entry-info { flex: 1; min-width: 0; }
.dup-entry-format { font-size: 13px; font-weight: 500; }
.dup-entry-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.dup-physical { display: flex; align-items: center; gap: 7px; flex-shrink: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.dup-checkbox {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.dup-checkbox-icon { color: #000; font-size: 13px; }
.dup-physical-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.dup-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
