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

:root {
  --bg:        #fef9f0;
  --bg2:       #fdf3e3;
  --card:      #fffdf8;
  --border:    #e0c88a;
  --text:      #2c1810;
  --muted:     #8b6b3d;
  --accent:    #c2610a;
  --accent-dk: #9a4f08;
  --accent-lt: #fef3c7;
  --header:    #2c1810;
  --green:     #15803d;
  --red:       #b91c1c;
  --radius:    12px;
  --shadow:    0 2px 10px rgba(44,24,16,.12);
  --shadow-sm: 0 1px 4px  rgba(44,24,16,.08);
  --header-h:  58px;
  --search-h:  52px;
  --tabs-h:    46px;
  --top-h:     156px;
}

html, body {
  height: 100%;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Header ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: var(--header-h);
  background: var(--header);
  background-image: repeating-linear-gradient(
    transparent, transparent 9px,
    rgba(255,255,255,.04) 9px, rgba(255,255,255,.04) 10px
  );
  color: #f5e6c8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
.app-title {
  font-size: 1.25rem;
  font-weight: normal;
  letter-spacing: 1px;
  color: #f5e6c8;
}
.app-title span { color: #d97706; font-weight: bold; }

.btn-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  color: #f5e6c8;
  font-size: 1.3rem; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-icon:active { background: rgba(255,255,255,.25); }

.btn-add-song {
  background: var(--accent);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: .9rem;
  font-weight: bold;
  font-family: inherit;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-add-song:active { background: var(--accent-dk); }

/* ===== Zoekbalk ===== */
.search-wrap {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 10;
  height: var(--search-h);
  background: #3d2010;
  padding: 8px 12px;
  display: flex; align-items: center;
}
.search-inner {
  position: relative; width: 100%;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: .95rem; pointer-events: none; color: var(--muted);
}
#search {
  width: 100%; height: 36px;
  border: none; border-radius: 20px;
  padding: 0 16px 0 34px;
  font-size: .95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
#search::placeholder { color: #b09060; }

/* ===== Tabs ===== */
.tabs {
  position: fixed; top: calc(var(--header-h) + var(--search-h)); left: 0; right: 0; z-index: 10;
  height: var(--tabs-h);
  background: var(--card);
  border-bottom: 2px solid var(--border);
  display: flex;
}
.tab {
  flex: 1; border: none; background: none;
  font-size: .95rem; font-weight: normal;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  padding-bottom: 2px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: bold; }
.tab-count {
  display: inline-block;
  background: var(--accent-lt);
  color: var(--accent-dk);
  font-size: .72rem;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 5px;
  font-family: Georgia, serif;
}
.tab.active .tab-count { background: var(--accent); color: #fff; }

/* ===== Hoofdlijst ===== */
.view {
  margin-top: var(--top-h);
  padding: 12px;
  min-height: calc(100vh - var(--top-h));
}

/* ===== Categorie-filter strip ===== */
.cat-filter {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 0 0 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-filter::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.cat-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== Accordion ===== */
.cat-block {
  margin-bottom: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: var(--bg2);
  cursor: pointer; user-select: none;
  font-weight: bold; font-size: .95rem;
  letter-spacing: .3px;
  transition: background .15s;
}
.cat-header:active { background: #f7e8c8; }
.cat-left { display: flex; align-items: center; gap: 9px; }
.cat-icon { font-size: 1.1rem; }
.cat-count {
  font-weight: normal;
  font-size: .78rem;
  color: var(--muted);
  background: var(--accent-lt);
  border-radius: 10px;
  padding: 1px 7px;
}
.cat-arrow {
  font-size: .8rem;
  color: var(--muted);
  transition: transform .25s ease;
}
.cat-block.open .cat-arrow { transform: rotate(90deg); }

.cat-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.cat-block.open .cat-items { max-height: 4000px; }

/* ===== Style-rij ===== */
.style-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px;
  background: var(--card);
  border-top: 1px solid #eeddb0;
  cursor: pointer;
  transition: background .12s;
}
.style-row:active { background: #fef3c7; }
.style-naam { font-size: .95rem; }
.style-meta {
  font-size: .78rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  margin-left: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 8px;
}

/* ===== Song-rij ===== */
.song-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; margin-bottom: 8px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.song-row:active { background: #fef3c7; box-shadow: none; }
.song-titel { font-weight: bold; font-size: .98rem; }
.song-artiest { font-size: .84rem; color: var(--muted); margin-top: 2px; font-style: italic; }
.song-arrow { color: var(--border); font-size: 1.2rem; }

/* ===== Overlay ===== */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  overflow-y: auto;
  display: flex; flex-direction: column;
  animation: slideUp .22s ease;
}
.overlay.hidden { display: none; }

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.overlay-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--header);
  background-image: repeating-linear-gradient(
    transparent, transparent 9px,
    rgba(255,255,255,.04) 9px, rgba(255,255,255,.04) 10px
  );
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: var(--header-h);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.overlay-title {
  color: #f5e6c8;
  font-size: 1rem;
  font-weight: normal;
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-back {
  background: none; border: none;
  color: #d97706; font-size: .95rem;
  font-family: inherit;
  cursor: pointer; padding: 8px 0;
  white-space: nowrap; letter-spacing: .3px;
}
.overlay-body { padding: 16px; }

/* ===== Detail-kaart ===== */
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.detail-naam {
  font-size: 1.55rem;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--text);
  line-height: 1.2;
}
.detail-artiest {
  font-size: 1rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 12px;
}
.badge {
  display: inline-block;
  background: var(--accent-lt);
  color: var(--accent-dk);
  font-size: .78rem;
  border-radius: 20px;
  padding: 3px 11px;
  margin-right: 6px; margin-bottom: 6px;
  border: 1px solid #f0c060;
  font-family: inherit;
}
.badge-loc {
  background: #f0fdf4; color: var(--green);
  border-color: #bbf7d0;
  font-size: .82rem; font-weight: bold;
  padding: 4px 12px;
}
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 14px;
}
.detail-field label {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 3px;
  font-family: Georgia, serif;
}
.detail-field span { font-size: 1.05rem; font-weight: bold; }

.detail-divider {
  border: none; border-top: 1px solid var(--border);
  margin: 14px 0;
}

.detail-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: .9rem;
  text-decoration: none; margin-top: 8px;
}
.detail-link:hover { text-decoration: underline; }

.detail-notes {
  font-size: .88rem; color: var(--muted);
  font-style: italic; line-height: 1.6;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: bold;
  margin: 18px 0 8px;
  padding-left: 2px;
}

/* ===== Gekoppelde rij (in detail) ===== */
.linked-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; margin-bottom: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background .12s;
}
.linked-row:active { background: #fef3c7; }
.linked-naam { font-size: .97rem; font-weight: bold; }
.linked-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; font-style: italic; }

.empty-msg {
  color: var(--muted);
  font-style: italic;
  font-size: .9rem;
  padding: 12px 4px;
}

/* ===== Songtekst ===== */
.lyrics-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.lyrics-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: bold;
  color: var(--accent);
  user-select: none;
  list-style: none;
}
.lyrics-toggle::-webkit-details-marker { display: none; }
.lyrics-toggle::after {
  content: '▶';
  font-size: .7rem;
  margin-left: auto;
  color: var(--muted);
  transition: transform .2s;
}
details[open] .lyrics-toggle::after { transform: rotate(90deg); }
.lyrics-body {
  padding: 4px 16px 16px;
  font-size: .92rem;
  line-height: 1.85;
  color: var(--text);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
}
.lyrics-empty {
  color: var(--muted);
  font-style: italic;
  font-size: .85rem;
  padding: 10px 4px 6px;
  display: flex; align-items: center; gap: 6px;
}
.lyrics-placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: .88rem;
  line-height: 1.6;
}
.lyrics-input { min-height: 220px; line-height: 1.75; }

/* ===== Songtekst zoeklinks ===== */
.lyrics-search {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.lyrics-search-label {
  font-size: .8rem; color: var(--muted); font-style: italic;
}
.btn-lyrics-link {
  padding: 5px 13px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--accent-dk);
  font-size: .82rem; font-weight: bold;
  font-family: inherit;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-lyrics-link:active { background: var(--accent-lt); border-color: var(--accent); }

/* ===== Detail-acties ===== */
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  padding: 10px 20px;
  border-radius: 8px; border: none;
  font-size: .9rem; font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--red); border: 1px solid #fca5a5; }

/* ===== Formulier ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: .85rem; font-weight: bold;
  margin-bottom: 6px; color: var(--text);
  letter-spacing: .2px;
}
.form-group input,
.form-group textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ===== Tag-input (style selector) ===== */
.tag-input-wrap { position: relative; }
.tag-wrap {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 6px 8px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 44px;
  transition: border-color .15s;
}
.tag-wrap:focus-within { border-color: var(--accent); }
.tag {
  display: flex; align-items: center; gap: 4px;
  background: var(--accent-lt);
  color: var(--accent-dk);
  border: 1px solid #f0c060;
  border-radius: 16px; padding: 4px 10px;
  font-size: .82rem; font-weight: bold;
}
.tag-remove {
  background: none; border: none; cursor: pointer;
  color: var(--accent-dk); font-size: 1rem; line-height: 1; padding: 0 2px;
}
.tag-input-field {
  border: none; outline: none;
  font-size: .9rem; flex: 1; min-width: 120px;
  background: transparent;
  font-family: Georgia, serif;
  color: var(--text);
}
.style-dropdown {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--card);
  border: 1.5px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px;
  z-index: 30; max-height: 230px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.style-dropdown.hidden { display: none; }
.dropdown-item {
  padding: 10px 14px; cursor: pointer;
  border-top: 1px solid #eeddb0;
  font-size: .9rem; transition: background .1s;
}
.dropdown-item:first-child { border-top: none; }
.dropdown-item:hover,
.dropdown-item:active { background: #fef3c7; }
.di-sub { font-size: .76rem; color: var(--muted); font-style: italic; }

.form-save {
  width: 100%; padding: 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 1rem; font-weight: bold;
  font-family: inherit;
  cursor: pointer; margin-top: 6px;
  letter-spacing: .3px;
  transition: background .15s;
}
.form-save:active { background: var(--accent-dk); }

/* ===== Loading / leeg ===== */
.loading {
  text-align: center; padding: 50px 20px;
  color: var(--muted); font-style: italic; font-size: 1rem;
}
.spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tablet layout ===== */
@media (min-width: 640px) {
  .view        { max-width: 700px; margin-left: auto; margin-right: auto; padding: 16px; }
  .overlay-body { max-width: 700px; margin: 0 auto; }
  .detail-grid { grid-template-columns: repeat(4, 1fr); }
  .detail-naam { font-size: 1.8rem; }
}
