@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0A0A0D;
  --surface: #131316;
  --surface-2: #1C1C21;
  --border: #2A2A31;
  --border-active: #3A3A44;
  --text: #F5F1E6;
  --muted: #9A9AA5;
  --muted-2: #75757F;
  --faint: #4A4A52;
  --gold: #D4AF37;
  --gold-dark: #9C7A1F;
  --gold-bright: #F0C954;
  --sage: #6B8F71;
  --sage-bg: #1D2A1E;
  --sage-text: #8FB399;
  --terracotta: #C0704F;
  --lavender: #8B8ECC;
}

html.theme-light {
  --bg: #F7F3E9;
  --surface: #FFFFFF;
  --surface-2: #EFE8D6;
  --border: #E0D6BC;
  --border-active: #CBB98F;
  --text: #1E2340;
  --muted: #5C5540;
  --muted-2: #857A5C;
  --faint: #B3A886;
  --gold: #A5761F;
  --gold-dark: #7A5A18;
  --sage-bg: #E3EEE2;
  --sage-text: #4C6E4F;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  overflow: hidden;
}

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* La page Administration n'utilise pas #app-shell — elle défile normalement */
body.admin-page {
  overflow-y: auto;
  height: auto;
}

.font-display { font-family: 'Fraunces', serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a { color: var(--gold); }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-weight: 700; font-size: 14px;
  box-shadow: 0 0 12px #D4AF3744, 0 2px 4px rgba(0,0,0,.4);
}
.brand span { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted-2); }

.pill-group {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2);
}
.pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
  color: var(--muted-2); background: transparent; transition: background .15s, color .15s;
}
.pill.active { background: linear-gradient(135deg,var(--gold-bright),var(--gold)); color: var(--bg); box-shadow: 0 0 10px #D4AF3744; }

/* ---- layout ---- */
.layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
@media (max-width: 800px) { .layout { flex-direction: column; } }

.sidebar {
  width: 260px; padding: 16px; border-right: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0;
}
@media (max-width: 800px) { .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); } }

.search-box { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 0 4px; }
.search-box input {
  background: transparent; border: none; outline: none; width: 100%; font-size: 13px; color: var(--text);
}

.cat-btn {
  display: flex; justify-content: space-between; align-items: center;
  text-align: left; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; margin-bottom: 6px; background: transparent;
}
.cat-btn.active { background: var(--surface-2); border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.cat-btn .label { font-size: 13.5px; font-weight: 500; }
.cat-btn .sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.cat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-left: 8px; }

.mode-row { display: flex; gap: 6px; margin-top: 8px; }
.mode-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 10px; font-size: 12.5px; background: var(--surface-2); color: var(--muted-2);
}
.mode-btn.active-presente { background: var(--border-active); color: var(--text); }
.mode-btn.active-virtual { background: linear-gradient(135deg,var(--gold-bright),var(--gold)); color: var(--bg); box-shadow: 0 0 10px #D4AF3755; }

/* ---- song list ---- */
.main { flex: 1; padding: 16px 20px; overflow: hidden; }
.scroll-col { overflow-y: auto; height: 100%; padding-right: 4px; }
.cat-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 26px; margin-bottom: 4px; }
.cat-meta { font-size: 12.5px; color: var(--muted-2); margin-bottom: 16px; }

.song-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; background: var(--surface);
  border: 1px solid transparent; text-align: left; width: 100%;
}
.song-row.active { background: var(--surface-2); border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 14px #D4AF3733; }
.song-row .title { font-size: 14px; }
.song-row .meta { font-size: 11px; color: var(--muted-2); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.tag { padding: 1px 6px; border-radius: 4px; background: var(--border-active); }
.tag.instrumental { background: var(--sage-bg); color: var(--sage-text); }

/* ---- lyric viewer (tecladista) ---- */
.viewer { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 40px 24px; }
.sync-status { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted-2); margin-bottom: 32px; font-family: 'JetBrains Mono', monospace; }
.viewer-inner { width: 100%; max-width: 640px; }
.viewer h1 { font-family: 'Fraunces', serif; font-weight: 700; font-size: clamp(28px, 5vw, 40px); line-height: 1.1; margin: 8px 0 24px; }
.lyric-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; min-height: 220px; }
.lyric-card pre { font-family: 'Fraunces', serif; font-size: 20px; line-height: 1.7; white-space: pre-wrap; margin: 0; }

/* ---- misc ---- */
.audio-topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  min-height: 62px;
}
.audio-topbar .song-title { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; flex-shrink: 0; }
.audio-topbar .player-playpause { width: 42px; height: 42px; font-size: 16px; flex-shrink: 0; }
.audio-topbar .player-seek-wrap { flex: 1; min-width: 120px; }
.audio-topbar .player-seek-wrap input[type="range"] { width: 100%; height: 8px; }
.audio-topbar .player-volume { flex-shrink: 0; }
.audio-topbar .player-volume input[type="range"] { width: 170px; height: 8px; }
.audio-topbar #mute-btn { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); }
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .audio-topbar { flex-wrap: wrap; row-gap: 8px; }
  .audio-topbar .player-seek-wrap { min-width: 100%; order: 5; }
  .audio-topbar .player-volume input[type="range"] { width: 90px; }

  .main { flex-direction: column !important; overflow-y: auto !important; }
  #song-col { width: 100% !important; flex: 0 0 auto !important; max-height: 42vh; }
  #apercu-col { min-width: 0 !important; }
  .main > div[style*="width:1px"] { display: none; }
}

.footer-legend {
  padding: 10px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--faint); font-family: 'JetBrains Mono', monospace;
}
.badge-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); font-family: 'JetBrains Mono', monospace; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 12.5px;
}
.btn.gold { background: linear-gradient(135deg,var(--gold-bright),var(--gold)); color: var(--bg); font-weight: 600; box-shadow: 0 2px 8px #D4AF3733; }
.btn.danger { background: #3A2020; color: #E08A7A; }

/* ---- admin ---- */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; color: var(--muted-2); margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field textarea { min-height: 140px; font-family: 'Fraunces', serif; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

.login-box { max-width: 340px; margin: 12vh auto; text-align: center; }

.pin-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 28px; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-active);
  background: transparent; transition: background .15s, border-color .15s;
}
.pin-dot.filled { background: var(--gold); border-color: var(--gold); }
.pin-dot.error { background: #B5654A; border-color: #B5654A; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 260px; margin: 0 auto; }
.keypad-btn {
  aspect-ratio: 1; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 24px; font-family: 'Fraunces', serif; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.keypad-btn:active { background: var(--border-active); }
.keypad-btn.empty { background: transparent; border: none; }
.keypad-btn.backspace { font-size: 18px; color: var(--muted-2); }

.list-item {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
.list-item .order-btns { display: flex; gap: 4px; }
.list-item .order-btns button { padding: 4px 8px; background: var(--surface-2); border-radius: 6px; font-size: 11px; }

.player-controls {
  display: flex; align-items: center; gap: 14px; flex-wrap: nowrap;
  width: 100%; max-width: 640px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 20px; margin-top: 24px;
}
.player-controls .player-volume { flex: 0 0 auto; }
.player-playpause {
  width: 52px; height: 52px; border-radius: 12px; background: linear-gradient(135deg,var(--gold-bright),var(--gold)); color: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
  box-shadow: 0 2px 8px #D4AF3733;
}
.player-seek-wrap { flex: 1; min-width: 140px; }
.player-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted-2); font-family: 'JetBrains Mono', monospace; margin-top: 4px; }
.player-volume { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.player-volume input[type="range"] { width: 90px; }
input[type="range"] {
  accent-color: var(--gold);
  height: 6px;
  cursor: pointer;
  touch-action: pan-x;
  transition: filter .15s;
}
input[type="range"]:active { filter: brightness(1.15); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); cursor: pointer;
  border: 3px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  transition: transform .12s ease;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); cursor: pointer;
  border: 3px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  transition: transform .12s ease;
}
input[type="range"]:active::-moz-range-thumb { transform: scale(1.15); }
input[type="range"]::-moz-range-track { background: var(--border-active); height: 6px; border-radius: 3px; }

.player-playpause { transition: transform .1s ease, opacity .15s ease; }
.player-playpause:active { transform: scale(0.92); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border-active); padding: 10px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
