:root {
  --bg: #fbfaf7; --fg: #1d1b18; --muted: #6f6a62; --line: #e4e0d8; --panel: #ffffff;
  --accent: #9a3412; --chord: #c2410c; --chip: #f1ede6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --fg: #ece8e1; --muted: #a29c92; --line: #2e2b27; --panel: #1f1d1a;
    --accent: #fb923c; --chord: #fdba74; --chip: #2a2723;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --fg: #ece8e1; --muted: #a29c92; --line: #2e2b27; --panel: #1f1d1a;
  --accent: #fb923c; --chord: #fdba74; --chip: #2a2723;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }

.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 1.15rem; margin: 0; line-height: 1.2; }
.bar .ttl { flex: 1; min-width: 0; }
.bar .ttl h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sub { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg);
  text-decoration: none; font-size: .95rem; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { background: var(--chip); }

/* Seznam */
.search { padding: 12px 16px 4px; }
.search input {
  width: 100%; height: 44px; padding: 0 14px; font: inherit; color: var(--fg);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.list { list-style: none; margin: 0; padding: 0 0 24px; }
.list .letter { padding: 14px 16px 4px; font-weight: 700; color: var(--accent); font-size: .9rem; }
.list a { display: block; padding: 10px 16px; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); }
.list a .a { display: block; font-size: .85rem; color: var(--muted); }
.list .empty { padding: 24px 16px; color: var(--muted); }
.foot { padding: 8px 16px 32px; color: var(--muted); font-size: .8rem; line-height: 1.8; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* Píseň */
.song { padding: 14px 16px 16px; font-size: var(--fs, 18px); max-width: 760px; }
.source { padding: 0 16px 90px; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }

.ctl {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 6px;
  padding: 8px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.ctl .grp { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ctl .row { display: flex; align-items: center; gap: 3px; }
.ctl small { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ctl .val { min-width: 1.8em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.ctl .btn { min-width: 38px; height: 44px; padding: 0 4px; }
.ctl .back { padding: 0 14px; }
.ctl .play.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 10;
  background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: .9rem;
}

/* Píseň: lišty se schovávají, aby byl vidět co největší kus textu */
.songbar { position: fixed; left: 0; right: 0; top: 0; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; transition: transform .2s ease; }
.songbar .btn { height: 36px; min-width: 36px; }
.songview .song { padding-top: calc(58px + env(safe-area-inset-top)); touch-action: pan-x pan-y; }
.ctl { transition: transform .2s ease; }
.chrome-off .songbar { transform: translateY(-100%); }
.chrome-off .ctl { transform: translateY(100%); }

/* Telefon: bez tisku, užší okraje, menší lišty */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
  .print-link { display: none; }
}
@media (max-width: 700px) {
  .song { padding-left: 8px; padding-right: 8px; }
  .song .blk { grid-template-columns: 1.55em 1fr; margin-bottom: .55em; }
  .source { padding-left: 8px; padding-right: 8px; }
  .songbar { padding-left: 8px; padding-right: 8px; gap: 8px; }
  .songbar h1 { font-size: 1rem; }
  .songbar .sub { font-size: .75rem; }
  .ctl { padding: 4px 6px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .ctl small { display: none; }
  .ctl .btn { height: 40px; }
}
