@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: #12162A;
  --surface: #161B32;
  --surface-2: #1E2540;
  --border: #242B4A;
  --border-active: #2E3660;
  --text: #F5F1E6;
  --muted: #8B93B8;
  --muted-2: #6B7299;
  --faint: #4E5480;
  --gold: #C9A24B;
  --gold-dark: #8B6D2E;
  --sage: #6B8F71;
  --sage-bg: #243024;
  --sage-text: #8FB399;
  --terracotta: #B5654A;
  --lavender: #7C7FB0;
}

* { box-sizing: border-box; }

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

.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), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-weight: 700; font-size: 14px;
}
.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: var(--gold); color: var(--bg); }

/* ---- layout ---- */
.layout { display: flex; flex: 1; min-height: calc(100vh - 56px); }
@media (max-width: 800px) { .layout { flex-direction: column; } }

.sidebar {
  width: 260px; padding: 16px; border-right: 1px solid var(--border);
}
@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(--border-active); }
.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: var(--gold); color: var(--bg); }

/* ---- song list ---- */
.main { flex: 1; padding: 16px 20px; }
.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: #C9A24B55; }
.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 ---- */
.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: var(--gold); color: var(--bg); font-weight: 600; }
.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; }
.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; }

.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; }
