:root {
  color-scheme: light;
  --parchment: #f7efe0;
  --parchment-deep: #eee0c4;
  --paper: #fffcf5;
  --wood-900: #2b1c12;
  --ink: #2b2013;
  --ink-muted: #7a6650;
  --gold: #b9822f;
  --gold-bright: #d6a545;
  --line: rgba(43, 32, 19, 0.18);
  --shadow: 0 10px 28px rgba(43, 32, 19, 0.14);
  --overlay: rgba(185, 130, 47, 0.16);
  --overlay-playing: rgba(185, 130, 47, 0.34);
  --stop-icon-bg: #b3432f;

  /* Kleuren die je per passage kan kiezen (beheer + weergave + export) */
  --color-geel: #c9a227;
  --color-geel-bg: rgba(201, 162, 39, 0.16);
  --color-geel-bg-active: rgba(201, 162, 39, 0.34);
  --color-groen: #4f7a3d;
  --color-groen-bg: rgba(79, 122, 61, 0.16);
  --color-groen-bg-active: rgba(79, 122, 61, 0.34);
  --color-rood: #b23a2e;
  --color-rood-bg: rgba(178, 58, 46, 0.16);
  --color-rood-bg-active: rgba(178, 58, 46, 0.34);
  --color-blauw: #3f6a96;
  --color-blauw-bg: rgba(63, 106, 150, 0.16);
  --color-blauw-bg-active: rgba(63, 106, 150, 0.34);
  --color-bruin: #6b4a30;
  --color-bruin-bg: rgba(107, 74, 48, 0.16);
  --color-bruin-bg-active: rgba(107, 74, 48, 0.34);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --parchment: #1c1712;
    --parchment-deep: #241a12;
    --paper: #2a2118;
    --wood-900: #0e0906;
    --ink: #f3e9d8;
    --ink-muted: #b8a488;
    --gold: #c98a3d;
    --gold-bright: #eac06a;
    --line: rgba(243, 233, 216, 0.16);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    --overlay: rgba(201, 138, 61, 0.22);
    --overlay-playing: rgba(201, 138, 61, 0.4);

    --color-geel: #ddb948;
    --color-geel-bg: rgba(221, 185, 72, 0.22);
    --color-geel-bg-active: rgba(221, 185, 72, 0.4);
    --color-groen: #74a660;
    --color-groen-bg: rgba(116, 166, 96, 0.22);
    --color-groen-bg-active: rgba(116, 166, 96, 0.4);
    --color-rood: #cf6152;
    --color-rood-bg: rgba(207, 97, 82, 0.22);
    --color-rood-bg-active: rgba(207, 97, 82, 0.4);
    --color-blauw: #6996c2;
    --color-blauw-bg: rgba(105, 150, 194, 0.22);
    --color-blauw-bg-active: rgba(105, 150, 194, 0.4);
    --color-bruin: #96775a;
    --color-bruin-bg: rgba(150, 119, 90, 0.22);
    --color-bruin-bg-active: rgba(150, 119, 90, 0.4);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--parchment);
  color: var(--ink);
  font-family: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

.serif {
  font-family: "Lora", Georgia, "Times New Roman", serif;
}

/* ---------- Staff-line decorative band ---------- */

.staff-band {
  position: relative;
  overflow: hidden;
  background: var(--parchment-deep);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1.4px, transparent 1.4px 15px);
  background-size: 100% 200px;
  background-repeat: repeat-x;
  background-position: 0 30px;
}

.staff-band .note-watermark {
  position: absolute;
  top: -40px;
  right: -10px;
  opacity: 0.06;
  transform: rotate(-8deg);
  pointer-events: none;
}

/* ---------- Header (shared) ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 4vw, 48px);
  flex-wrap: wrap;
  gap: 10px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo svg {
  flex-shrink: 0;
}

.app-logo-text {
  font-weight: 600;
  font-size: 1.25rem;
}

.app-header-meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ---------- Homepage hero ---------- */

.hero {
  padding: 34px clamp(20px, 4vw, 48px) 40px;
}

.hero h1 {
  margin: 0;
  font-weight: 600;
  font-style: italic;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  max-width: 560px;
  position: relative;
}

.hero p {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
  max-width: 480px;
  position: relative;
}

/* ---------- Piece grid & cards ---------- */

.piece-grid {
  padding: 0 clamp(20px, 4vw, 48px) 56px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.piece-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 14px;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.piece-card:hover {
  transform: translateY(-2px);
}

.piece-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.piece-card-staff {
  height: 30px;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1.2px, transparent 1.2px 7px);
}

.piece-card-body {
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.piece-card-title {
  font-weight: 600;
  font-size: 1.15rem;
}

.piece-card-meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 3px;
}

.voice-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.voice-chip {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fffdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.66rem;
  font-weight: 700;
}

.voice-chip.s { background: oklch(62% 0.1 35); }
.voice-chip.a { background: oklch(62% 0.1 85); }
.voice-chip.t { background: oklch(56% 0.09 150); }
.voice-chip.b { background: oklch(50% 0.08 265); }
.voice-chip.solo { background: var(--gold); padding: 0 8px; }

.piece-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.piece-card-footer svg {
  flex-shrink: 0;
  color: var(--gold);
}

/* ---------- Viewer header ---------- */

.viewer-header {
  padding: 20px clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
}

.back-link:hover {
  color: var(--gold);
}

.overview-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px 9px 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1.5px solid var(--gold);
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 700;
  width: fit-content;
  transition: background 0.12s ease, color 0.12s ease;
}

.overview-link:hover,
.overview-link:focus-visible {
  background: var(--gold);
  color: #fffdf8;
  outline: none;
}

.viewer-footer {
  display: flex;
  justify-content: center;
  padding: 8px clamp(16px, 4vw, 48px) 56px;
}

.viewer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-export[hidden] {
  display: none;
}

.btn-export {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.btn-export:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-export:disabled {
  opacity: 0.6;
  cursor: default;
}

.viewer-title {
  font-weight: 600;
  font-style: italic;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  position: relative;
}

.viewer-subtitle {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-top: 2px;
  position: relative;
}

/* ---------- PDF pages ---------- */

.viewer-main {
  padding: 24px clamp(16px, 4vw, 48px) 160px;
  display: flex;
  justify-content: center;
}

.pdf-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 1000px;
}

.status {
  color: var(--ink-muted);
  padding: 40px 0;
}

.page-wrapper {
  position: relative;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 100%;
}

.page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.page-overlay {
  position: absolute;
  inset: 0;
}

.passage-button {
  position: absolute;
  background: var(--overlay);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 6px;
  transition: background 0.15s ease, filter 0.15s ease;
}

.passage-button:hover,
.passage-button:focus-visible {
  filter: brightness(1.1);
  outline: none;
}

.passage-button.playing {
  background: var(--overlay-playing);
}

.passage-button.color-geel { border-color: var(--color-geel); background: var(--color-geel-bg); }
.passage-button.color-geel.playing { background: var(--color-geel-bg-active); }
.passage-button.color-groen { border-color: var(--color-groen); background: var(--color-groen-bg); }
.passage-button.color-groen.playing { background: var(--color-groen-bg-active); }
.passage-button.color-rood { border-color: var(--color-rood); background: var(--color-rood-bg); }
.passage-button.color-rood.playing { background: var(--color-rood-bg-active); }
.passage-button.color-blauw { border-color: var(--color-blauw); background: var(--color-blauw-bg); }
.passage-button.color-blauw.playing { background: var(--color-blauw-bg-active); }
.passage-button.color-bruin { border-color: var(--color-bruin); background: var(--color-bruin-bg); }
.passage-button.color-bruin.playing { background: var(--color-bruin-bg-active); }
.passage-button.color-goud { border-color: var(--gold); background: var(--overlay); }
.passage-button.color-goud.playing { background: var(--overlay-playing); }

.passage-button.note-only .play-icon {
  background: var(--ink-muted);
}

.play-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.passage-button.playing .play-icon {
  background: var(--stop-icon-bg);
}

/* ---------- Nu-speelt balk ---------- */

.player-bar[hidden] {
  display: none;
}

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--wood-900);
  color: #f7efe0;
  padding: 12px clamp(16px, 4vw, 32px) 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
}

.player-nav-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-close {
  position: absolute;
  top: 8px;
  right: 10px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(247, 239, 224, 0.3);
  color: #f7efe0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.player-close:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.player-edge-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(247, 239, 224, 0.16);
  border: 1.5px solid rgba(247, 239, 224, 0.3);
  color: #fffdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.player-edge-btn:hover {
  background: rgba(247, 239, 224, 0.3);
  border-color: rgba(247, 239, 224, 0.5);
}

.player-edge-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.player-info {
  min-width: 0;
  width: 100%;
  text-align: center;
  padding: 0 40px;
}

.player-title {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-desc {
  font-size: 0.78rem;
  color: #cbb99a;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-audio-controls[hidden] {
  display: none;
}

.player-audio-controls {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.player-btn {
  flex-shrink: 0;
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(247, 239, 224, 0.16);
  border: 1.5px solid rgba(247, 239, 224, 0.3);
  color: #fffdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.player-btn svg {
  display: block;
  flex-shrink: 0;
}

.player-btn:hover {
  background: rgba(247, 239, 224, 0.3);
  border-color: rgba(247, 239, 224, 0.5);
}

.player-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.player-btn-main {
  width: 46px;
  height: 46px;
  min-width: 46px;
  background: var(--gold);
  border-color: var(--gold);
  color: var(--wood-900);
}

.player-btn-main:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}

.player-btn-main svg {
  width: 20px;
  height: 20px;
}

.player-rates {
  display: flex;
  gap: 4px;
  background: rgba(247, 239, 224, 0.14);
  border: 1.5px solid rgba(247, 239, 224, 0.25);
  border-radius: 999px;
  padding: 3px;
}

.rate-btn {
  border: none;
  background: transparent;
  color: #f0e2c8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.rate-btn.active {
  background: var(--gold);
  color: var(--wood-900);
}
