:root {
  /* Polder Radio: donker navy met limoengroen, zoals Polder Studio */
  --bg: #050c18; --panel: #0a1120; --panel2: #111b2e; --line: #1c283f; --text: #e0e6f0; --muted: #8ea6cc;
  --accent: #7bd400; --accent-ink: #06260a; --green: #7bd400; --red: #e0674f; --amber: #f2b33d; --sel: #16294a; --blue: #8ea6cc;
  --radius: 12px; --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --head: "Montserrat", "Manrope", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; }
input, select, button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.login-card { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 16px; color: var(--text); }
.error { color: var(--red); font-size: 13px; min-height: 1em; }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 800; font-size: 17px; white-space: nowrap; letter-spacing: .2px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 6px; }
.brand.big img { width: 64px; height: 64px; border-radius: 14px; }
.brand.big small { display: block; font-family: var(--font); font-weight: 500; font-size: 13px; color: var(--muted); }

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 44px; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
#sync.busy { color: var(--amber); }
.menu-btn, .clock.mobile, .pl-name-mobile { display: none; }
.menu { display: contents; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; letter-spacing: 1px; white-space: nowrap; }
.pl-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-bar select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 260px; }
.auto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.auto input { width: 18px; height: 18px; accent-color: var(--green); }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; touch-action: manipulation; }
.btn:active { transform: translateY(1px); filter: brightness(1.15); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.danger { color: var(--red); }
.btn.icon { padding: 6px 10px; border-radius: 8px; }
.btn.big { font-size: 17px; padding: 14px 18px; flex: 1; }
.btn.play { background: var(--green); border-color: transparent; color: var(--accent-ink); }
.btn.play.playing { background: var(--amber); color: #2a1d00; }
.btn.stop { background: var(--red); border-color: transparent; color: #fff; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; transition: border-color .15s; min-width: 0; }
.card.playing { border-color: var(--green); }
.card.ending { border-color: var(--red); }
.card.dropping { border-color: var(--accent); background: #10251a; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-letter { font-family: var(--head); font-size: 22px; font-weight: 900; width: 36px; height: 36px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; }
.card.playing .card-letter { background: var(--green); color: var(--accent-ink); }
.card-state { color: var(--muted); font-size: 13px; flex: 1; }
.card-body { display: flex; gap: 12px; align-items: center; min-width: 0; }
.card-text { min-width: 0; flex: 1; }
.card-cover { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--panel2); flex: 0 0 64px; }
.card-cover.none { visibility: hidden; width: 0; flex-basis: 0; margin-left: -12px; }
.row .thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--panel2); flex: 0 0 36px; display: block; }
.row .thumb.none { background: var(--panel2); }
.card-title { font-family: var(--head); font-size: clamp(17px, 2.2vw, 24px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-artist { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.card-times .t-intro { color: var(--amber); font-size: 15px; align-self: center; }
.card.ending .t-remain { color: var(--red); }
.bar { position: relative; height: 10px; background: var(--panel2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.card.playing .bar-fill { background: var(--green); }
.card.ending .bar-fill { background: var(--red); }
.bar-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff8; display: none; }
.card-buttons { display: flex; gap: 8px; }
.btn.pfl { padding: 10px 12px; }
/* jingle path */
.jingles { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 8px; }
.jp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.jp-title { font-family: var(--head); font-weight: 800; font-size: 14px; }
.jp-head select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; max-width: 200px; }
.jp-head #jpToggle { margin-left: auto; }
.jingles.collapsed .jp-grid { display: none; }
.jp-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.jp-slot { position: relative; min-height: 54px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; text-align: left; cursor: pointer; display: grid; gap: 2px; align-content: start; overflow: hidden; font-weight: 600; font-size: 12px; touch-action: manipulation; }
.jp-slot .jp-nr { color: var(--muted); font-size: 10px; }
.jp-slot .jp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jp-slot .jp-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--green); }
.jp-slot.empty { color: var(--muted); border-style: dashed; font-weight: 400; }
.jp-slot.off { opacity: .35; }
.jp-slot.playing { border-color: var(--green); background: #16301a; }
.jp-slot.dropping { border-color: var(--accent); background: #10251a; }
.jp-slot .jp-edit { display: none; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); }
.jingles.editing .jp-slot .jp-edit { display: flex; }
.jp-slot .jp-edit input { width: 14px; height: 14px; accent-color: var(--accent); }
.jp-slot .jp-edit .pl { border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; cursor: pointer; }
.jp-slot .jp-edit .pl.on { color: var(--accent); border-color: var(--accent); }
.jp-slot .jp-edit .x { margin-left: auto; color: var(--red); cursor: pointer; padding: 0 4px; }
/* voorluisteren */
.pfl { display: flex; align-items: center; gap: 10px; background: #2a2440; border: 1px solid #5a4a9a; border-radius: var(--radius); padding: 6px 12px; font-size: 13px; }
.pfl .pfl-title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pfl .pfl-time { font-variant-numeric: tabular-nums; }
.row .pflrow { font-size: 14px; }
@media (max-width: 820px) {
  .jp-grid { grid-template-columns: repeat(5, 1fr); }
  .row .pflrow { display: none; }
}
.vu { position: relative; height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: -2px; }
.vu-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green) 0 70%, var(--amber) 70% 88%, var(--red) 88%); }
.vu-peak { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: 0; opacity: .8; }
.row .time { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 12px; width: 52px; text-align: right; }
.row.played .time { color: var(--muted); }
.sound-rows { display: grid; gap: 6px; margin-bottom: 8px; }
.sound-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel2); border-radius: 8px; font-size: 13px; }
.sound-row .lbl { width: 70px; font-weight: 600; }
.sound-row select { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.sound-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- lower panels ---------- */
.tabs { display: none; gap: 6px; }
.tab { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-weight: 600; }
.tab.active { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.lower { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 0; flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-rows: auto auto auto 1fr; min-height: 0; overflow: hidden; }
.panel.library { grid-template-rows: auto auto auto 1fr; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-family: var(--head); font-size: 15px; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head input[type=search] { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 16px; min-width: 0; -webkit-appearance: none; }
.filters { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.filters select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; flex: 0 0 auto; max-width: 150px; }
.filters select.on { border-color: var(--accent); color: var(--accent); }
.row-actions { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row-actions:not(.enabled) .btn { opacity: .35; pointer-events: none; }
.list { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.playlist .list { touch-action: pan-y; }

.row { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 0; min-height: 44px; border-bottom: 1px solid #262e3a; position: relative; touch-action: pan-y; }
.row .color { width: 6px; align-self: stretch; background: var(--line); flex: 0 0 6px; }
.row .num { width: 26px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .main { flex: 1; min-width: 0; padding: 6px 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .len { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.row .handle { width: 34px; height: 44px; display: grid; place-items: center; color: var(--muted); font-size: 18px; touch-action: none; cursor: grab; }
.row .playrow { background: #16301a; border-color: #2d5a2d; color: var(--green); font-size: 15px; }
.row .trash { font-size: 15px; color: var(--muted); }
.row .trash:active { color: var(--red); }
.row .add { width: 38px; height: 38px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 20px; cursor: pointer; }
.row.selected { background: var(--sel); }
.row.played { opacity: .45; }
.row.playing { background: #16301a; }
.row.playing .num { color: var(--green); font-weight: 700; }
.row.next-up .num { color: var(--amber); font-weight: 700; }
.row.swiping { transition: none; }
.row.drop-before::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: var(--accent); }
.row.drop-after::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }
.list .empty { padding: 30px 16px; color: var(--muted); text-align: center; line-height: 1.5; }
.list .more { padding: 12px; text-align: center; color: var(--accent); cursor: pointer; }

.drag-ghost { position: fixed; z-index: 100; pointer-events: none; background: var(--panel2); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-weight: 600; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 8px 30px #0008; transform: translate(-50%, -50%); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 90; font-size: 14px; max-width: 90vw; }

/* ---------- smaller screens (iPad portrait, telefoon) ---------- */
@media (max-width: 820px) {
  /* hamburger: playlistbalk en beheerknoppen in een uitklapmenu */
  .top { position: relative; flex-wrap: nowrap; gap: 8px; }
  .brand { font-size: 15px; }
  .brand img { width: 28px; height: 28px; }
  .pl-name-mobile { display: block; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .clock.mobile { display: block; font-size: 15px; }
  .menu-btn { display: block; font-size: 18px; padding: 6px 12px; }
  .top .menu { display: none; }
  .top.open .menu { display: flex; flex-direction: column; gap: 8px; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 12px 40px #000b; max-height: 80vh; overflow-y: auto; }
  .top.open .pl-bar, .top.open .right { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0; }
  .top.open .right { border-top: 1px solid var(--line); padding-top: 8px; }
  .top.open .pl-bar select, .top.open .pl-bar .btn, .top.open .right .btn { width: 100%; max-width: none; text-align: left; }
  .top.open .right .clock { display: none; }
  .top.open .auto { padding: 4px 0; }
  .top.open #plSaved { font-size: 12px; }
  /* compacte cards */
  .cards { gap: 8px; }
  .card { padding: 8px 10px; gap: 4px; }
  .card-head { gap: 6px; }
  .card-letter { width: 26px; height: 26px; font-size: 15px; }
  .card-state { font-size: 11px; }
  .card-cover { width: 40px; height: 40px; flex-basis: 40px; }
  .card-body { gap: 8px; }
  .card-title { font-size: 15px; }
  .card-artist { font-size: 12px; }
  .card-times { font-size: 15px; }
  .card-times .t-intro { font-size: 12px; }
  .bar { height: 6px; }
  .vu { height: 4px; }
  .card-buttons { gap: 6px; }
  .btn.big { font-size: 14px; padding: 9px 8px; }
  .btn.pfl { padding: 8px 10px; font-size: 14px; }
  .btn.icon.eject { padding: 4px 8px; font-size: 12px; }
  .tabs { display: flex; }
  .lower { grid-template-columns: 1fr; }
  .lower .panel:not(.active) { display: none; }
  .card-times { font-size: 18px; }
  .btn.big { font-size: 15px; padding: 12px; }
  .btn.next { display: none; }
  #sync.busy { color: var(--amber); }
.clock { font-size: 16px; }
}
@media (max-width: 520px) {
  /* telefoon: de pagina scrollt gewoon; playlist en databank krijgen vaste ruimte */
  html, body { height: auto; overflow: auto; }
  .app { height: auto; min-height: 100%; gap: 8px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .card { gap: 3px; padding: 6px 8px; }
  .card-artist { display: none; }
  .card-cover { width: 32px; height: 32px; flex-basis: 32px; }
  .card-title { font-size: 13px; }
  .card-times { font-size: 13px; }
  .card-times .t-intro { display: none; }
  .card-buttons .btn.big { padding: 8px 4px; font-size: 13px; }
  .btn.pfl { display: none; }
  .btn.next { display: none; }
  .card-head .card-state { display: none; }
  .lower { flex: none; min-height: 70vh; }
  .panel { min-height: 70vh; }
  /* smalle rijen: titel houdt ruimte; slepen via ▲▼, voorluisteren via de cards */
  .row .pflrow, .row .handle { display: none !important; }
  .row .time { width: 44px; font-size: 11px; }
  .row .num { width: 18px; }
  .row .len { font-size: 11px; }
  .row .add { width: 32px; height: 32px; font-size: 16px; }
  .jp-grid { grid-template-columns: repeat(5, 1fr); }
  .jp-slot { min-height: 46px; font-size: 11px; }
  .pl-bar select { max-width: 160px; }
}

/* ---------- beheer ---------- */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal-card { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2, .modal h3 { font-family: var(--head); font-weight: 800; }
.modal h3 { font-size: 14px; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; color: var(--text); }
.field input[type=number] { width: 90px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-row input { flex: 1 1 150px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; min-width: 0; }
.users { display: grid; gap: 4px; margin-bottom: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel2); border-radius: 8px; }
.user .name { flex: 1; font-weight: 600; }
.user .tag { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 1px 6px; }
.modal p { font-size: 13px; line-height: 1.4; margin-top: 8px; }

/* ---------- formats ---------- */
.fm { display: grid; gap: 10px; }
.fm > input[name=name] { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; }
.fm-rule { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px; background: var(--panel2); border-radius: 8px; }
.fm-rule .fm-tools { margin-left: auto; display: flex; gap: 4px; }
.fm-rule .nr { width: 22px; color: var(--muted); font-size: 12px; }
.fm-rule details.crit { position: relative; }
.fm-rule details.crit summary { list-style: none; cursor: pointer; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-rule details.crit summary::-webkit-details-marker { display: none; }
.fm-rule details.crit.on summary { border-color: var(--accent); color: var(--accent); }
.fm-rule details.crit .opts { position: absolute; z-index: 5; top: 100%; left: 0; margin-top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 2px; min-width: 200px; max-height: 260px; overflow-y: auto; box-shadow: 0 10px 30px #000a; }
.fm-rule details.crit .opts label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.fm-rule details.crit .opts label:hover { background: var(--panel2); }
.fm-rule details.crit .opts input { width: 18px; height: 18px; accent-color: var(--accent); }
.fm-rule select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font-size: 12px; max-width: 130px; }
.fm-rule select.on { border-color: var(--accent); color: var(--accent); }
.form-row.small { font-size: 13px; color: var(--muted); }
.form-row.small input[type=number] { width: 64px; flex: 0 0 64px; padding: 6px; font-size: 14px; }
.row .tag-auto { font-size: 10px; color: var(--amber); border: 1px solid var(--amber); border-radius: 5px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.pl-bar select#fillSelect { max-width: 190px; padding: 6px 8px; font-size: 13px; }
