/* ================= Śpiewnik — style ================= */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --border: #e3ddd0;
  --text: #26221c;
  --muted: #8a8375;
  --primary: #b5462f;
  --primary-ink: #ffffff;
  --accent: #2f7d6b;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
  --radius: 12px;

  /* zmienne edytowane w Ustawieniach */
  --song-font: 'Georgia', serif;
  --song-size: 18px;
  --song-line: 1.9;
  --chord-color: #e2564a;
  --lyric-color: var(--text);
  --chord-weight: 700;
}
[data-theme="dark"] {
  --bg: #17150f;
  --surface: #201d16;
  --surface-2: #262218;
  --border: #35301f;
  --text: #ece6d8;
  --muted: #9c9482;
  --primary: #d4694f;
  --accent: #4bbda3;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* -------- layout -------- */
#app { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px; gap: 18px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand-logo { font-size: 26px; }
.brand-name { letter-spacing: .3px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  text-align: left; background: none; border: none; cursor: pointer;
  padding: 10px 12px; border-radius: 8px; font-size: 15px; color: var(--text);
  transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.sidebar-section { display: flex; flex-direction: column; gap: 8px; }
.sidebar-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.sidebar-bottom { margin-top: auto; gap: 6px; }
.backend-status { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: #2ecc71; } .dot-off { background: #bbb; }
.dot-err { background: #e74c3c; }
.dot-sync { background: #f39c12; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  border-bottom: 1px solid var(--border); background: var(--surface); min-height: 60px;
}
.view-title { font-size: 20px; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.view { padding: 22px; overflow-y: auto; flex: 1; }

/* -------- przyciski -------- */
.btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.07); background: var(--primary); }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.07); background: var(--danger); }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 6px; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: underline; padding: 0; }
.only-mobile { display: none; }

/* -------- inputy -------- */
.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none; transition: border .15s;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; line-height: 1.5; }
.mono { font-family: 'Courier New', monospace; }
.title-input { font-size: 18px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.field-label.with-help { justify-content: space-between; }
.field-label.mt { margin-top: 8px; }

/* -------- toolbar / szukaj -------- */
.toolbar { margin-bottom: 12px; }
.search-input { max-width: 520px; }
.tagbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip-on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* -------- karty -------- */
.card-grid { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.song-card, .list-card {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow);
}
.song-card:hover, .list-card:hover { transform: translateY(-1px); border-color: var(--primary); }
.song-card-main { flex: 1; min-width: 0; }
.song-title, .list-title { font-size: 16px; font-weight: 700; }
.song-artist { color: var(--muted); font-size: 14px; }
.song-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; color: var(--muted); }
.pill-tag { color: var(--accent); }
.song-chords { font-family: 'Courier New', monospace; font-size: 12px; color: var(--chord-color); margin-top: 6px; letter-spacing: 1px; }
.song-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.muted-sm { font-size: 12px; color: var(--muted); }
.chev { font-size: 22px; color: var(--muted); }
.list-card-icon { font-size: 28px; }
.list-card-main { flex: 1; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-emoji { font-size: 48px; }

/* ============ Renderowanie utworu (ChordPro) ============ */
.reader { max-width: 860px; }
.reader-head { margin-bottom: 12px; }
.reader-title { margin: 0 0 2px; font-size: 26px; }
.reader-sub { color: var(--muted); font-size: 14px; }
.reader-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.ctrl-group { display: flex; align-items: center; gap: 6px; }
.ctrl-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.ctrl-val { min-width: 26px; text-align: center; font-weight: 700; }

.fix-chords { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.diagrams { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 20px; }
.diagram { width: 78px; }
.chord-svg { width: 100%; height: auto; color: var(--muted); }
.chord-name { fill: var(--text); font-size: 13px; font-weight: 700; font-family: sans-serif; }
.chord-fret { fill: var(--muted); font-size: 9px; font-family: sans-serif; }
.chord-mark { fill: var(--muted); font-size: 11px; font-family: sans-serif; }
.chord-finger { fill: #fff; font-size: 8px; font-family: sans-serif; }

.song-body {
  font-family: var(--song-font); font-size: var(--song-size); line-height: var(--song-line);
  color: var(--lyric-color);
}
.song-body.two-col { column-count: 2; column-gap: 40px; }
.cp-line { display: flex; flex-wrap: wrap; align-items: flex-end; margin: 2px 0; }
.cp-unit { display: inline-flex; flex-direction: column; }
.cp-chord {
  color: var(--chord-color); font-weight: var(--chord-weight); font-size: .72em;
  font-family: 'Segoe UI', sans-serif; line-height: 1.1; white-space: pre; min-height: 1.1em;
}
.cp-lyric { white-space: pre; }
.cp-nochord .cp-chord { display: none; }
.cp-blank { height: .7em; }
.cp-title { font-size: 1.3em; font-weight: 700; margin: 4px 0; }
.cp-subtitle { color: var(--muted); margin-bottom: 6px; }
.cp-comment { color: var(--accent); font-style: italic; font-size: .85em; margin: 10px 0 2px; font-family: 'Segoe UI', sans-serif; }
.cp-label { font-weight: 700; font-size: .8em; color: var(--muted); text-transform: uppercase; }
.cp-meta { color: var(--muted); font-size: .8em; }
.cp-chorus { border-left: 3px solid var(--primary); padding-left: 12px; margin: 6px 0; }
.cp-tab { font-family: 'Courier New', monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; line-height: 1.35; white-space: pre; }

.tabs-block, .notes-block { margin-top: 24px; }
.block-h { font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin: 20px 0 12px; }
.block-h.mt { margin-top: 26px; }
.tab-item { margin-bottom: 14px; }
.tab-item-title { font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* -------- edytor -------- */
.editor { max-width: 1100px; }
.editor-grid { display: grid; grid-template-columns: 2fr 2fr; gap: 0 16px; }
.editor-grid .field:nth-child(3), .editor-grid .field:nth-child(4), .editor-grid .field:nth-child(5) { grid-column: auto; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.editor-col { display: flex; flex-direction: column; gap: 6px; }
.editor-area { min-height: 380px; }
.cp-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.preview-frame { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-height: 200px; overflow-x: auto; }
.live-preview { min-height: 360px; }
.tabs-editor { display: flex; flex-direction: column; gap: 12px; }
.tab-editor-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.tab-editor-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tab-editor-head .input { flex: 1; }

/* -------- listy / setlista -------- */
.list-detail { max-width: 820px; }
.list-meta { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.setlist { display: flex; flex-direction: column; gap: 6px; }
.setlist-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.setlist-item.dragging { opacity: .4; }
.drag { cursor: grab; color: var(--muted); }
.setlist-num { color: var(--muted); font-weight: 700; min-width: 24px; }
.setlist-main { flex: 1; cursor: pointer; display: flex; flex-direction: column; min-width: 0; }
.setlist-title { font-weight: 600; }
.setlist-artist { font-size: 13px; color: var(--muted); }
.add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-row .input { flex: 1; min-width: 180px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }

/* -------- szukaj -------- */
.search-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; max-width: 900px; }
.search-intro { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.search-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.search-fields .input { flex: 1; min-width: 160px; }
.search-result { max-width: 900px; }
.searching { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 16px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 10px 0; }
.notice-warn { background: #fdf0e6; color: #a05a1a; border: 1px solid #f0d0a8; }
.notice-ok { background: #e8f6ef; color: #1d7a53; border: 1px solid #b6e2cc; }
[data-theme="dark"] .notice-warn { background: #3a2a15; color: #e0a566; border-color: #5a3f1c; }
[data-theme="dark"] .notice-ok { background: #16342a; color: #6bd3a8; border-color: #23543f; }
.found-preview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.found-fields { display: flex; gap: 8px; margin-bottom: 12px; }
.found-fields .input { flex: 1; }
.found-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.found-split textarea { min-height: 260px; }
.found-actions { margin-top: 14px; }

/* lista wyników wyszukiwarki */
.mb { margin-bottom: 10px; }
.result-list { display: flex; flex-direction: column; gap: 8px; }
.result-card { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: all .15s; color: var(--text); }
.result-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.result-main { flex: 1; min-width: 0; }
.result-title { font-weight: 600; font-size: 15px; }
.result-snippet { font-size: 13px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-source { font-size: 12px; color: var(--accent); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.result-actions-top { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

/* poczekalnia */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; font-size: 11px; font-weight: 700; border-radius: 9px; background: var(--primary); color: #fff; }
.nav-item.active .nav-badge { background: #fff; color: var(--primary); }
.inbox-list { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.inbox-item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.inbox-main { flex: 1; min-width: 0; }
.inbox-fields { display: flex; gap: 8px; margin-bottom: 6px; }
.inbox-fields .input { flex: 1; }
.inbox-meta { display: flex; gap: 10px; align-items: center; min-width: 0; }
.inbox-link { font-size: 12px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-link:hover { text-decoration: underline; }
.inbox-actions { display: flex; flex-direction: column; gap: 6px; white-space: nowrap; }

/* propozycje */
.suggest-section { margin-bottom: 22px; max-width: 1000px; }
.suggest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.suggest-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.suggest-main { flex: 1; min-width: 0; }
.suggest-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.suggest-artist { color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.suggest-actions { display: flex; flex-direction: column; gap: 6px; white-space: nowrap; }
.match-badge { color: #e0a417; font-size: 13px; }
.pill-ok { color: #1d7a53; border-color: #b6e2cc; background: #e8f6ef; }
[data-theme="dark"] .pill-ok { color: #6bd3a8; border-color: #23543f; background: #16342a; }

/* transpozycja w setliście */
.setlist-tr { display: inline-flex; align-items: center; gap: 3px; }
.tr-val { min-width: 24px; text-align: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }

/* -------- ustawienia -------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1000px; }
.settings-panel, .settings-preview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-label { display: flex; flex-direction: column; }
.set-label small { font-size: 12px; }
.set-row .input, .set-row select { max-width: 200px; }
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range { width: 160px; }
.range-val { font-size: 13px; color: var(--muted); min-width: 42px; }
.color { width: 44px; height: 30px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: var(--surface); cursor: pointer; }
.mt { margin-top: 14px; }
.about { margin-top: 20px; }
.about h4 { margin: 0 0 6px; }
.muted { color: var(--muted); }

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* -------- modal / toast -------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-wide { max-width: 700px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.help pre, .help code { background: var(--surface-2); border-radius: 6px; padding: 2px 6px; font-family: monospace; }
.help pre { padding: 10px; overflow-x: auto; }

.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #222; color: #fff; padding: 10px 18px; border-radius: 24px; font-size: 14px; opacity: 0; transform: translateY(10px); transition: all .3s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #1d7a53; }
.toast-error { background: var(--danger); }

/* -------- tryb występu -------- */
.perf-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 150; display: flex; flex-direction: column; }
.perf-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.perf-spacer { flex: 1; }
.perf-pos { font-weight: 700; color: var(--muted); }
.perf-val { min-width: 74px; text-align: center; font-size: 13px; color: var(--muted); }
.perf-content { flex: 1; overflow-y: auto; padding: 30px 6vw; }
.perf-content .song-body { font-size: calc(var(--song-size) * var(--stage-scale, 1.25)); }
body.perf-mode { overflow: hidden; }

/* długie linie nie uciekają poza ekran (ważne na telefonie) */
.song-body { overflow-wrap: break-word; }
.cp-unit { max-width: 100%; }
.cp-lyric { overflow-wrap: anywhere; }

/* -------- responsywność -------- */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .only-mobile { display: inline-flex; }
  .editor-split, .found-split, .settings, .editor-grid { grid-template-columns: 1fr; }
  .song-body.two-col { column-count: 1; }
  .view { padding: 16px; }
}

/* -------- druk -------- */
@media print {
  .sidebar, .topbar, .no-print, .reader-controls, .diagrams { display: none !important; }
  #app { display: block; height: auto; }
  .main { overflow: visible; }
  .view { overflow: visible; padding: 0; }
  body { background: #fff; }
  .song-body { color: #000; }
  .cp-chord { color: #000 !important; }
}
