:root {
  --bg: #eef1f5; --surface: #ffffff; --ink: #1b2330; --muted: #5d6878;
  --line: #d4dae3; --chord: #1f5fa8; --chord-soft: #e3ecf7; --danger: #a8322a; --ok: #23784a;
  --ui: "Atkinson Hyperlegible", system-ui, sans-serif;
  --lyric: "Literata", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171e; --surface: #1a2029; --ink: #e4e9f0; --muted: #96a1b0;
    --line: #2c3542; --chord: #7fb2ec; --chord-soft: #1f2c3d; --danger: #ef8a80; --ok: #6fd39b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--ui); }
a { color: var(--chord); }
:focus-visible { outline: 3px solid var(--chord); outline-offset: 2px; }

.top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .8rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.user { color: var(--muted); font-size: .95rem; }
main { max-width: 52rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 4rem; }
main.wide { max-width: 80rem; }

button, .btn { font: inherit; font-size: .95rem; padding: .45rem .9rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--chord); border-color: var(--chord); color: var(--surface); }
.btn-danger { color: var(--danger); }
.inline { display: inline; margin: 0; }

input, textarea { font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; width: 100%; }
.flash { background: var(--chord-soft); padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }

/* seznam */
.search { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.songs { list-style: none; padding: 0; margin: 0; }
.songs li { border-bottom: 1px solid var(--line); }
.songs a { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .25rem; text-decoration: none; color: var(--ink); }
.songs a:hover .t { color: var(--chord); }
.songs .t { font-weight: 700; }
.songs .a { color: var(--muted); }
.empty { color: var(--muted); padding: 2rem 0; }

/* píseň */
.song-head h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 .25rem; }
.song-head p { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1.25rem 0 1.75rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.transpose { display: inline-flex; align-items: center; gap: .35rem; }
.transpose output { min-width: 2.5ch; text-align: center; font-weight: 700; color: var(--chord); }
.spacer { flex: 1; }
label.check { display: inline-flex; gap: .35rem; align-items: center; color: var(--muted); font-size: .95rem; }
label.check input { width: auto; }

/* ChordPro výstup – akordy jsou hlavní postava */
.sheet { font: 1.1rem/1.35 var(--lyric); }
.cp-line { min-height: 1.4em; }
.cp-plain { white-space: pre-wrap; }
.cp-has-chords { display: flex; flex-wrap: wrap; margin-top: .2rem; }
.cp-word { display: inline-flex; max-width: 100%; }
.cp-seg { display: inline-flex; flex-direction: column; white-space: pre; }
.cp-chord { font: 700 .95rem/1.2 var(--ui); color: var(--chord); padding-right: .5em; }
.cp-gap { height: 1.1rem; }
.cp-label { font: 700 .95rem/1.4 var(--ui); color: var(--muted); margin: .6rem 0 .1rem; }
.cp-chorus { border-left: 3px solid var(--chord); padding-left: 1rem; margin: .4rem 0; }
.sheet.no-chords .cp-chord { display: none; }

/* rytmus */
.cp-strum { margin: .8rem 0 .6rem; font-family: var(--ui); }
.strum-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .75rem; margin-bottom: .35rem; }
.strum-title { font-weight: 700; font-size: .95rem; color: var(--muted); }
.strum-meta { font-size: .9rem; color: var(--muted); }
.strum-tempo-l { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; color: var(--muted); }
.strum-tempo { width: 4.5rem; padding: .2rem .4rem; font-size: .9rem; }
.strum-play { padding: .25rem .75rem; font-size: .9rem; }
.strum-grid { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 2.2rem; max-width: 100%; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.strum-cell { display: grid; justify-items: center; padding: .3rem 0 .2rem; border-left: 1px solid transparent; }
.strum-cell.beat { border-left-color: var(--line); }
.strum-cell.now { background: var(--chord-soft); }
.strum-hit { font: 700 1.35rem/1.2 var(--ui); color: var(--chord); height: 1.65rem; }
.strum-hit.light { font-size: 1rem; opacity: .55; }
.strum-hit.x { color: var(--ink); }
.strum-count { font-size: .75rem; line-height: 1.2; color: var(--muted); min-height: .9rem; }
.sheet.no-chords .cp-strum { display: none; }
.print-only { display: none; }

/* editor */
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.fields { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.fields label, .edit-grid label { font-size: .9rem; color: var(--muted); display: grid; gap: .25rem; }
textarea { font: .95rem/1.5 ui-monospace, "Cascadia Code", Menlo, monospace; min-height: 60vh; resize: vertical; }
.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; overflow-x: auto; max-height: 70vh; }
.hint { color: var(--muted); font-size: .9rem; margin: .5rem 0 0; }
.hint code { background: var(--chord-soft); padding: 0 .3em; border-radius: 4px; }
.actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* stránka písně: text vlevo, diagramy vpravo */
main.song { max-width: 66rem; }
.toolbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding-top: .75rem; }
.toolbar select { font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: .4rem .5rem; }
.scroll-ctl { display: inline-flex; align-items: center; gap: .4rem; }
.scroll-ctl input { width: 6rem; padding: 0; accent-color: var(--chord); }
button[aria-pressed="true"] { background: var(--chord); border-color: var(--chord); color: var(--surface); }
.song-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: start; }
.chord-panel { position: sticky; top: var(--panel-top, 6rem); display: grid; grid-template-columns: repeat(2, auto);
  gap: .75rem 1rem; max-height: calc(100vh - var(--panel-top, 6rem) - 1rem); overflow-y: auto; padding-bottom: .5rem; }
.chord-panel[hidden] { display: none; }
.sheet.has-diagrams .cp-chord { cursor: help; }

/* diagram akordu */
.cd { margin: 0; text-align: center; }
.cd-name { font: 700 .95rem/1.3 var(--ui); color: var(--chord); }
.cd svg { display: block; margin: 0 auto; }
.cd-fret, .cd-string { stroke: var(--muted); stroke-width: 1; }
.cd-dot { fill: var(--ink); }
.cd-open { fill: none; stroke: var(--ink); stroke-width: 1.3; }
.cd-mark, .cd-pos { fill: var(--muted); font: 11px var(--ui); }
.cd-none { color: var(--muted); font-size: .8rem; max-width: 6rem; }
.chord-pop { position: fixed; z-index: 30; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .7rem; box-shadow: 0 6px 20px rgb(0 0 0 / .18); pointer-events: none; }

/* ladička */
.tuner { width: min(26rem, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); padding: 1rem 1.25rem 1.25rem; }
.tuner::backdrop { background: rgb(0 0 0 / .45); }
.tuner-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.tuner-head h2 { margin: 0; font-size: 1.2rem; }
.tuner-head button { font-size: 1.3rem; line-height: 1; padding: .2rem .6rem; }
.tuner select { font: inherit; width: 100%; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: .4rem .5rem; }
.tuner-strings { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0 1rem; }
.tuner-strings button { flex: 1 1 0; min-width: 0; padding: .45rem .2rem; font-weight: 700; }
.tuner-strings button[data-i="auto"] { flex-grow: 1.6; }
.tuner-strings small, .tuner-note small { font-size: .6em; font-weight: 400; color: var(--muted); margin-left: 1px; }
.tuner-strings button.near { border-color: var(--chord); color: var(--chord); }
.tuner-note { text-align: center; font-size: 4rem; font-weight: 700; line-height: 1.1; min-height: 4.4rem; }
.tuner-note.in-tune { color: var(--ok); }
.tuner-meter { position: relative; height: 2.25rem; margin-top: .5rem; border-bottom: 2px solid var(--line); }
.tuner-zone { position: absolute; left: 45%; width: 10%; top: 0; bottom: 0; background: var(--chord-soft); border-radius: 4px 4px 0 0; }
.tuner-needle { position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; border-radius: 2px;
  background: var(--chord); transition: left .08s linear; }
.tuner-needle.in-tune { background: var(--ok); }
.tuner-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.tuner-info { text-align: center; margin: .75rem 0 0; font-weight: 700; min-height: 1.5em; }
.tuner-info #tuner-hz { color: var(--muted); font-weight: 400; margin-left: .4rem; }
.tuner-status { color: var(--muted); font-size: .9rem; text-align: center; margin: .5rem 0 0; }
@media (prefers-reduced-motion: reduce) { .tuner-needle { transition: none; } }

.scroll-fab { display: none; }
@media (max-width: 760px) {
  .toolbar { position: static; }            /* na mobilu by lišta zabrala půl displeje */
  .scroll-fab:not([hidden]) { display: block; position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 20; padding: .7rem 1.1rem; background: var(--chord); border-color: var(--chord); color: var(--surface);
    box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
  .song-body { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .chord-panel { position: static; order: -1; display: flex; overflow-x: auto; max-height: none; }
  .cd { flex: none; }
}

@media (max-width: 760px) {
  .edit-grid, .fields { grid-template-columns: 1fr; }
  textarea { min-height: 40vh; }
}
@media print {
  .top, .toolbar, .no-print, .chord-panel, .chord-pop, .tuner { display: none !important; }
  .song-body { display: block; }
  .print-only { display: inline; }
  .strum-hit { color: #000; }
  .strum-grid { border-color: #999; }
  body { background: #fff; color: #000; }
  .cp-chord { color: #000; }
}
