:root {
  --stage:      #161312;
  --stage-2:    #201b18;
  --paper:      #efe6d8;
  --paper-dim:  #ddd2bf;
  --ink:        #201b18;
  --amber:      #e8a33d;
  --tape:       #f2c744;
  --string-red: #b3402f;
  --mastered:   #6b8f71;
  --muted:      #9c948a;
  --font-display: 'Anton', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-body: 'IBM Plex Sans', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--stage);
  color: var(--paper);
  font-family: var(--font-body);
  background-image:
    radial-gradient(circle at 20% -10%, rgba(232,163,61,0.10), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(179,64,47,0.08), transparent 40%);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(239,230,216,0.12);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 28px; color: var(--amber);
  transform: rotate(-8deg); display: inline-block;
}
.brand h1 {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: 26px;
  margin: 0;
  line-height: 1;
}
.brand-sub {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
  border-radius: 3px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--amber); color: var(--ink); }
.btn-primary:hover { background: var(--tape); }
.btn-outline { background: transparent; color: var(--paper); border-color: rgba(239,230,216,0.35); }
.btn-outline:hover { border-color: var(--amber); color: var(--amber); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--paper); }
.btn-danger { background: transparent; color: var(--string-red); border-color: var(--string-red); }
.btn-danger:hover { background: var(--string-red); color: var(--paper); }
.btn-timer { background: var(--string-red); color: var(--paper); }
.btn-timer.running { background: var(--mastered); }

/* ---------- Stage / draw section ---------- */
.stage { padding: 28px clamp(16px, 4vw, 48px) 8px; }
.stage-inner {
  border: 1px dashed rgba(232,163,61,0.4);
  border-radius: 6px;
  padding: 28px clamp(16px, 3vw, 36px);
  text-align: center;
  background: linear-gradient(180deg, rgba(232,163,61,0.06), transparent 60%);
}
.stage-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--amber);
  margin-bottom: 16px;
}
.draw-card {
  max-width: 520px;
  margin: 0 auto 20px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 22px;
  border-radius: 4px;
}
.draw-card--empty {
  color: var(--muted);
  font-size: 14px;
  border: 1px solid rgba(239,230,216,0.15);
}
.draw-card--result {
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  animation: spotlight-in 0.35s ease;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.draw-card--result .dc-title {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.05;
  margin: 0 0 2px;
}
.draw-card--result .dc-artist { color: #5b5248; font-size: 14px; margin: 0 0 10px; }
.draw-card--result .dc-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #6a6155;
  display: flex; gap: 14px; flex-wrap: wrap;
}
@keyframes spotlight-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.stage-controls { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.checkbox { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* ---------- Toolbar ---------- */
main { padding: 20px clamp(16px, 4vw, 48px) 60px; }
.toolbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
#search {
  flex: 1; min-width: 200px;
  background: var(--stage-2);
  border: 1px solid rgba(239,230,216,0.15);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 3px;
  font-family: var(--font-body);
}
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(239,230,216,0.2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { background: var(--amber); color: var(--ink); border-color: var(--amber); font-weight: 600; }

/* ---------- Song grid / cards ---------- */
.songs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.song-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  padding: 16px 18px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-left: 5px solid var(--amber);
}
.song-card[data-status="w_trakcie"] { border-left-color: var(--string-red); }
.song-card[data-status="opanowany"] { border-left-color: var(--mastered); }
.song-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,0.3); }
.song-card h3 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 2px;
  letter-spacing: 0.01em;
}
.song-card .sc-artist { font-size: 13px; color: #5b5248; margin: 0 0 10px; }
.song-card .sc-stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6a6155;
  display: flex; justify-content: space-between;
}
.song-card .sc-priority { letter-spacing: 2px; color: var(--string-red); }

.empty-state { text-align: center; color: var(--muted); margin-top: 60px; font-family: var(--font-mono); }

/* ---------- Modals ---------- */
.modal {
  border: none; border-radius: 6px; padding: 0;
  background: var(--stage-2); color: var(--paper);
  width: min(560px, 92vw);
}
.modal-wide { width: min(880px, 94vw); }
.modal-wide .modal-form { max-height: 92vh; overflow-y: auto; padding: 30px clamp(20px, 4vw, 40px); }
.modal::backdrop { background: rgba(10,8,7,0.7); }
.modal-form { padding: 26px clamp(18px, 4vw, 30px); display: flex; flex-direction: column; gap: 12px; }
.modal-form > * { flex-shrink: 0; }
.modal-form h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 22px; }
.modal-form label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; color: var(--muted); display: flex; flex-direction: column; gap: 5px; text-transform: uppercase; }
.field-hint { font-family: var(--font-body); font-size: 12px; color: var(--muted); margin: -4px 0 0; text-transform: none; letter-spacing: normal; }
.modal-form input[type=text], .modal-form input[type=url], .modal-form select, .modal-form textarea {
  font-family: var(--font-body);
  background: var(--stage);
  border: 1px solid rgba(239,230,216,0.18);
  color: var(--paper);
  padding: 9px 11px;
  border-radius: 3px;
  font-size: 14px;
  text-transform: none;
}
.modal-form input[type=range] { accent-color: var(--amber); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Detail view ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head h2 { font-family: var(--font-display); font-size: 26px; margin: 0; }
.detail-artist { color: var(--muted); margin: 2px 0 0; }
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  margin: 14px 0;
  border-radius: 5px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}
.video-fallback { font-size: 13px; color: var(--muted); }
.video-fallback span { font-family: var(--font-mono); font-size: 11px; }

.section-label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em;
  color: var(--muted); text-transform: uppercase; margin: 16px 0 6px;
}
.lyrics-chords-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}
.text-col { min-width: 0; }
.chords-block {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  max-height: 50vh;
  overflow-y: auto;
}

.chord-tag {
  color: var(--amber);
  cursor: pointer;
  border-bottom: 1px dotted var(--amber);
  font-weight: 600;
}
.chord-tag:hover { color: var(--tape); background: rgba(232,163,61,0.12); }

.modal-chord { background: transparent; width: auto; }
.modal-chord::backdrop { background: rgba(10,8,7,0.75); }
.chord-popup {
  position: relative;
  background: var(--stage-2);
  border-radius: 12px;
  padding: 26px 24px 20px;
  width: 300px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.chord-close-x {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; line-height: 1;
}
.chord-close-x:hover { color: var(--paper); }
.chord-popup h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 4px;
}
.chord-approx-note {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  margin: 0 0 6px;
}
.chord-diagram-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.chord-svg-holder { width: 220px; min-height: 190px; display: flex; align-items: center; justify-content: center; }
.chord-svg-holder svg { width: 100%; height: auto; }
.chord-loading { color: var(--muted); font-size: 13px; }
.chord-nav {
  background: none; border: none; color: var(--muted);
  font-size: 26px; cursor: pointer; padding: 4px 6px; line-height: 1;
}
.chord-nav:hover { color: var(--amber); }
.chord-pos-indicator { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 6px 0 0; }

.chord-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.chord-mini-card {
  background: var(--paper);
  border-radius: 6px;
  padding: 8px 6px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.chord-mini-card:hover { transform: translateY(-2px); }
.chord-mini-svg svg { width: 100%; height: auto; display: block; }
.chord-mini-label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  margin-top: 2px;
}

.detail-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.detail-links a {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--amber); text-decoration: none;
  border: 1px solid rgba(232,163,61,0.4);
  padding: 6px 11px; border-radius: 999px;
}
.detail-links a:hover { background: rgba(232,163,61,0.12); }
.detail-notes { white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--paper-dim); }

.timer-box {
  display: flex; align-items: center; gap: 16px;
  background: var(--stage); border-radius: 5px; padding: 16px;
  margin: 14px 0;
}
.timer-display { font-family: var(--font-mono); font-size: 32px; letter-spacing: 0.03em; min-width: 110px; }
.session-log { max-height: 160px; overflow-y: auto; font-family: var(--font-mono); font-size: 12px; }
.session-log div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(239,230,216,0.08); }
.detail-footer { display: flex; justify-content: space-between; margin-top: 16px; }
.stat-pills { display: flex; gap: 16px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-pills b { color: var(--paper); }

@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 12px; }
}
