/* Solfavo – odtwarzacz w przeglądarce.  Komputer, iPad, tablet z Androidem. */
@font-face { font-family: "Bravura"; src: url("../fonts/Bravura.otf") format("opentype"); font-display: block; }

:root {
  --bg: #eef0f3;
  --bar: #ffffff;
  --bar2: #f7f8fa;
  --ink: #1b1e24;
  --muted: #646b78;
  --line: #d7dbe2;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --hover: rgba(47, 111, 222, .09);
  --menu-bg: #ffffff;
  --shadow: 0 10px 30px rgba(20, 24, 33, .18), 0 2px 6px rgba(20, 24, 33, .08);
  --tb-h: 36px;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c; --bar: #1f232b; --bar2: #1a1d24; --ink: #e8eaef; --muted: #9aa1ae; --line: #343a46;
    --accent: #5b8ff0; --hover: rgba(91, 143, 240, .16); --menu-bg: #262b34;
    --shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171c; --bar: #1f232b; --bar2: #1a1d24; --ink: #e8eaef; --muted: #9aa1ae; --line: #343a46;
  --accent: #5b8ff0; --hover: rgba(91, 143, 240, .16); --menu-bg: #262b34;
  --shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (pointer: coarse) { :root { --tb-h: 44px; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); overflow: hidden;
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
svg .f { fill: currentColor; stroke: none; }

.app {
  height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ─── górny pasek z menu ─── */
.topbar {
  display: flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px;
  background: var(--bar); border-bottom: 1px solid var(--line); flex: none;
}
.brand { font-weight: 700; letter-spacing: .2px; margin: 0 8px 0 4px; }
.song-title { margin-left: auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 12px; }
.menubar { display: flex; gap: 2px; }
.menubar > .mtop {
  border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: default;
}
.menubar > .mtop:hover, .menubar > .mtop[aria-expanded="true"] { background: var(--hover); }
.menu-toggle { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; min-width: var(--tb-h); height: var(--tb-h);
  border: 0; background: none; border-radius: 6px; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--hover); }

/* rozwijane menu */
.menu {
  position: fixed; z-index: 50; min-width: 240px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 60px);
  overflow: auto; background: var(--menu-bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px;
}
.mitem {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none;
  text-align: left; border-radius: 5px; cursor: default; white-space: nowrap;
}
.mitem:hover:not(:disabled), .mitem:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.mitem:disabled { opacity: .45; }
.mitem .check { width: 16px; text-align: center; flex: none; }
.mitem .sc { margin-left: auto; padding-left: 24px; opacity: .65; font-size: 12px; }
.mitem .arrow { margin-left: auto; opacity: .7; }
.msep { height: 1px; background: var(--line); margin: 4px 6px; }

/* szuflada menu na wąskich ekranach */
.menu-drawer {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .35);
}
.menu-drawer .panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(360px, 88vw); overflow: auto;
  background: var(--menu-bg); box-shadow: var(--shadow); padding: max(12px, env(safe-area-inset-top)) 10px 24px;
}
.menu-drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 16px 8px 4px; }
.menu-drawer .mitem { padding: 11px 10px; font-size: 15px; }

/* ─── pasek narzędzi ─── */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 6px 10px;
  background: var(--bar2); border-bottom: 1px solid var(--line); flex: none;
}
.tgroup { display: flex; align-items: center; gap: 6px; }
.tbtn {
  display: inline-grid; place-items: center; width: calc(var(--tb-h) + 2px); height: var(--tb-h);
  border: 1px solid var(--line); border-radius: 7px; background: var(--bar); cursor: pointer;
}
.tbtn:hover:not(:disabled) { border-color: var(--accent); }
.tbtn:disabled { opacity: .4; cursor: default; }
.tbtn.main { width: calc(var(--tb-h) + 12px); background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tbtn.main svg { width: 24px; height: 24px; }
.tbtn .i-pause { display: none; }
.tbtn.playing .i-play { display: none; }
.tbtn.playing .i-pause { display: block; }
.position { flex: 1 1 260px; min-width: 220px; }
.position input { flex: 1; min-width: 120px; }
.pos-label { min-width: 170px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.lbl { color: var(--muted); white-space: nowrap; }
#speed { width: 110px; }
#volume { width: 100px; }
.value-btn { border: 0; background: none; padding: 4px; min-width: 52px; cursor: pointer; font-variant-numeric: tabular-nums; }
.value-btn:hover { color: var(--accent); }
.vol-icon { display: inline-grid; place-items: center; width: 30px; height: 28px; border-radius: 6px; background: var(--bar); border: 1px solid var(--line); }
.vol-icon svg { width: 18px; height: 18px; }
#zoomSel { height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--bar); padding: 0 4px; }
input[type=range] { accent-color: var(--accent); height: var(--tb-h); }

/* ─── nuty ─── */
.sheet {
  position: relative; flex: none; height: 200px; overflow-y: auto; overflow-x: hidden; background: #fff;
  touch-action: pan-y; overscroll-behavior: contain; outline: none;
}
.sheet.fill { flex: 1 1 auto; }
.sheet-content { position: relative; }
.sheet-canvas { position: sticky; top: 0; display: block; }
.empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 4px;
  color: #444a55; background: #fff; padding: 16px;
}
.empty p { margin: 4px 0; }
.empty .hint { color: #7a818d; font-size: 13px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.has-score .empty { display: none; }

/* uchwyt między nutami a spadającymi nutami */
.grip {
  flex: none; height: 10px; cursor: ns-resize; touch-action: none; position: relative;
  background: var(--bar2); border-top: 1px solid var(--line); border-bottom: 1px solid #000;
}
.grip::after { content: ""; position: absolute; left: 50%; top: 3px; width: 46px; height: 3px; margin-left: -23px; border-radius: 2px; background: var(--muted); opacity: .6; }
.grip:hover::after, .grip.drag::after, .grip:focus-visible::after { opacity: 1; background: var(--accent); }
@media (pointer: coarse) { .grip { height: 18px; } .grip::after { top: 7px; } }

.piano { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; background: #28282e; }
.piano #fall { flex: 1 1 auto; min-height: 0; width: 100%; display: block; }
.piano #kbd { flex: none; height: 96px; width: 100%; display: block; }
.app.no-piano .grip, .app.no-piano .piano { display: none; }

/* ─── okna dialogowe ─── */
dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--menu-bg); color: var(--ink);
  box-shadow: var(--shadow); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgba(10, 12, 18, .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.dlg h2 { font-size: 16px; margin: 0; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.dlg .body { padding: 14px 18px; overflow: auto; }
.dlg .buttons { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg .buttons .left { margin-right: auto; }
.btn {
  min-height: 34px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--bar); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (pointer: coarse) { .btn { min-height: 44px; } }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px; }
legend { color: var(--muted); padding: 0 4px; font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pitch-grid { display: grid; grid-template-columns: repeat(6, auto auto); gap: 8px 6px; align-items: center; justify-content: space-between; }
.pitch-grid span { text-align: right; }
input[type=color] { width: 40px; height: 28px; padding: 0 2px; border: 1px solid var(--line); border-radius: 5px; background: none; }
fieldset:disabled { opacity: .45; }
.samples { display: flex; flex-direction: column; gap: 2px; }
.samples h3 { font-size: 13px; color: var(--muted); margin: 12px 4px 4px; }
.samples button { text-align: left; border: 0; background: none; padding: 8px 8px; border-radius: 6px; cursor: pointer; }
.samples button:hover, .samples button:focus-visible { background: var(--hover); outline: none; }
.dlg p { margin: 0 0 10px; }
.dlg .small { font-size: 12px; color: var(--muted); }
.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
kbd { font: 12px ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: var(--bar2); }

.tooltip {
  position: fixed; z-index: 70; pointer-events: none; max-width: 320px; padding: 5px 8px; border-radius: 5px;
  background: #2a2f3a; color: #fff; font-size: 12px; box-shadow: var(--shadow);
}
.drop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(47, 111, 222, .18);
  border: 3px dashed var(--accent); font-size: 20px; color: var(--ink);
}
.drop div { background: var(--menu-bg); padding: 16px 24px; border-radius: 12px; box-shadow: var(--shadow); }
.toast {
  position: fixed; z-index: 75; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a2f3a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* ─── układ responsywny ─── */
@media (max-width: 1099px) {
  .menubar { display: none; }
  .menu-toggle { display: inline-grid; }
  .zoom .lbl { display: none; }
}
@media (max-width: 760px) {
  .tempo .lbl { display: none; }
  .pos-label { min-width: 0; font-size: 12px; }
  #speed { width: 90px; }
  #volume { width: 80px; }
  .toolbar { gap: 4px 10px; }
}
@media (max-width: 520px) {
  .volume { display: none; }
  .brand { display: none; }
}
.menu-drawer .msub { color: var(--muted); font-size: 13px; padding: 10px 10px 2px 36px; }
/* atrybut hidden ma pierwszeństwo przed display z reguł powyżej */
[hidden] { display: none !important; }
.pos-label { white-space: pre; }
.pos-label { padding-right: 8px; }
.menu-drawer .mitem { white-space: normal; }
.menu-drawer .mitem .sc { white-space: nowrap; }

/* suwaki – jednakowy wygląd w Safari, Chrome i Firefoksie (Safari ignoruje accent-color dla suwaków) */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; margin: 0; }
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bar); box-shadow: 0 0 0 1px var(--accent);
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bar); }
@media (pointer: coarse) {
  input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10px; }
  input[type=range]::-moz-range-thumb { width: 22px; height: 22px; }
}
input[type=range]:disabled { opacity: .4; cursor: default; }
/* etykieta pozycji nie może się ściskać (Safari nakładał ją na „Tempo:”) – ściska się suwak */
.position .pos-label { flex: none; }
.position input { min-width: 80px; }

/* niski ekran (telefon poziomo): pasek narzędzi w jednym wierszu, niższa klawiatura;
   powiększanie zostaje w menu Widok i pod szczypaniem */
@media (max-height: 520px) {
  .zoom, .volume { display: none; }
  .tempo .lbl { display: none; }
  .topbar { min-height: 30px; }
  .toolbar { padding: 4px 8px; }
  .piano #kbd { height: 64px; }
  .pos-label { font-size: 12px; min-width: 0; }
}
/* telefon pionowo: przyciski odtwarzania i suwak pozycji w jednym wierszu, tempo z powiększeniem pod spodem */
@media (max-width: 520px) {
  .transport { gap: 4px; }
  .tbtn { width: var(--tb-h); }
  .tbtn.main { width: calc(var(--tb-h) + 6px); }
}
/* bez powiększania całej strony gestem – nuty powiększa szczypanie w programie i przyciski −/+ */
.app { touch-action: pan-x pan-y; }
.sheet { touch-action: pan-y; }

/* ═══ jeden wiersz sterowania (bez osobnego paska tytułu) poniżej 1100 px ═══ */
.pos-label { flex: none; }
.position { flex: 1 1 200px; min-width: 120px; }
@media (max-width: 1099px) {
  .topbar { display: none; }
  .toolbar { flex-wrap: nowrap; gap: 6px 10px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .menu-toggle { display: inline-grid; margin-right: 2px; }
  .tempo .lbl, .zoom .lbl { display: none; }
}
/* urządzenia dotykowe: głośność przyciskami urządzenia, powiększanie szczypaniem i w menu Widok */
@media (pointer: coarse) { .volume, .zoom { display: none; } }
@media (max-width: 1099px) and (pointer: fine) { .toolbar { flex-wrap: wrap; } }
/* telefon pionowo: wiersz 1 – menu, przyciski, opis; wiersz 2 – suwak pozycji i tempo */
@media (max-width: 520px) {
  :root { --tb-h: 34px; }
  .toolbar { flex-wrap: wrap; gap: 4px 8px; padding: 4px 8px; }
  #bStart { display: none; }
  .transport { gap: 4px; order: 1; }
  .menu-toggle { order: 0; min-width: 34px; }
  .pos-label { order: 2; margin-left: auto; font-size: 12px; min-width: 0; padding-right: 0; }
  .position { order: 3; flex: 1 1 150px; }
  .tempo { order: 4; }
  #speed { width: 80px; }
  .tbtn { width: 36px; }
  .tbtn.main { width: 44px; }
  .tbtn svg { width: 18px; height: 18px; }
}
/* telefon poziomo (niski ekran): wszystko w jednym wierszu, mniejsze przyciski */
@media (max-height: 520px) {
  :root { --tb-h: 32px; }
  .toolbar { flex-wrap: nowrap; padding: 3px 8px; gap: 6px; }
  .tbtn { width: 36px; }
  .tbtn.main { width: 42px; }
  .tbtn svg { width: 18px; height: 18px; }
  #speed { width: 80px; }
}
/* nagłówek szuflady menu: nazwa programu i utworu (na telefonie/tablecie nie ma paska tytułu) */
.drawer-head { padding: 4px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.drawer-head b { display: block; font-size: 16px; }
.drawer-head span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
/* telefon: krótki podpis tempa, żeby suwak tempa odróżniał się od suwaka pozycji */
@media (max-width: 520px), (max-height: 520px) {
  .tempo .lbl { display: inline; font-size: 12px; }
}

/* ═══ przełącznik trybów: Odtwarzacz | Edytor ═══ */
.modesw { gap: 0; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--bar); flex: none; }
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px; height: calc(var(--tb-h) - 6px); padding: 0 10px;
  border: 0; border-radius: 6px; background: none; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.mode-btn svg { width: 16px; height: 16px; }
.mode-btn:hover { color: var(--ink); }
.mode-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 760px), (max-height: 520px) { .mode-btn span { display: none; } .mode-btn { padding: 0 8px; } }

/* tryby: elementy odtwarzacza i edytora */
.app.mode-editor .ptoolbar, .app.mode-editor .sheet, .app.mode-editor .grip, .app.mode-editor .piano { display: none !important; }
.app:not(.mode-editor) .etoolbar, .app:not(.mode-editor) .editor, .app:not(.mode-editor) .estatus { display: none !important; }

/* ═══ edytor ═══ */
.etoolbar { gap: 4px 10px; flex-wrap: wrap; }
.egroup { display: flex; align-items: center; gap: 2px; }
.egroup + .egroup { padding-left: 8px; border-left: 1px solid var(--line); }
.ebtn {
  display: inline-grid; place-items: center; min-width: var(--tb-h); height: var(--tb-h); padding: 0 3px;
  border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--ink);
}
.ebtn:hover:not(:disabled) { background: var(--hover); }
.ebtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ebtn:disabled { opacity: .35; cursor: default; }
.ebtn.wide { padding: 0 10px; white-space: nowrap; }
.ebtn .gi { width: 28px; height: 28px; overflow: visible; }
.ebtn svg:not(.gi) { width: 20px; height: 20px; }
.editor {
  flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; outline: none;
  background: rgb(128, 128, 134); touch-action: pan-x pan-y; overscroll-behavior: contain;
}
.editor-content { position: relative; min-width: 100%; min-height: 100%; }
.editor-canvas { position: sticky; left: 0; top: 0; display: block; }
.estatus {
  flex: none; display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 2px 10px calc(2px + env(safe-area-inset-bottom, 0px));
  background: var(--bar2); border-top: 1px solid var(--line); font-size: 12.5px;
}
.etext { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: pre; text-overflow: ellipsis; }
.ezoom { display: flex; align-items: center; gap: 4px; flex: none; }
.ezoom .icon-btn { min-width: 28px; height: 26px; }
#eZoomSel { height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--bar); padding: 0 4px; }
@media (max-width: 1099px) {
  .etoolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .ezoom .lbl { display: none; }
}
@media (pointer: coarse) { .ezoom { display: none; } }
/* przełącznik trybów zajmuje miejsce – suwak pozycji ściska się pierwszy (pasek w jednym wierszu) */
@media (min-width: 1100px) { .ptoolbar .position { flex: 1 1 100px; min-width: 100px; } .ptoolbar { gap: 4px 10px; } }

/* ═══ edytor: klawiatura fortepianu, paleta dotykowa, panel oznaczeń ═══ */
.app:not(.mode-editor) .epalette, .app:not(.mode-editor) .epiano { display: none !important; }
.ebtn .ico { display: none; }
.ebtn .ico .gi { width: 26px; height: 26px; }
.epiano { position: relative; flex: none; height: 76px; background: #28282e; border-top: 1px solid #000; }
.epiano canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.app.no-epiano .epiano { display: none; }
.pk-btn {
  position: absolute; top: 0; bottom: 38%; z-index: 1; width: 30px; border: 0; padding: 0;
  background: rgba(31, 35, 43, .82); color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
}
.pk-btn:disabled { opacity: .35; }
.pk-prev { left: 0; border-radius: 0 8px 8px 0; }
.pk-next { right: 0; border-radius: 8px 0 0 8px; }
.epalette { display: none; }
.app.touch-ui .epalette {
  display: flex; flex: none; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px;
  padding: 4px 8px; background: var(--bar2); border-top: 1px solid var(--line);
}
.epalette .egroup + .egroup { padding-left: 0; border-left: 0; }
.app.touch-ui .ebtn { min-width: 44px; height: 44px; }
.app.touch-ui .epalette .ebtn { border-color: var(--line); background: var(--bar); }
.app.touch-ui .epalette .ebtn.on { background: var(--accent); border-color: var(--accent); }
.app.touch-ui .epalette .ebtn.wide { padding: 0 12px; }
.g-touch { display: none !important; }
.app.touch-ui .g-touch { display: flex !important; }
.app.touch-ui .etoolbar .g-dur, .app.touch-ui .etoolbar .g-rest, .app.touch-ui .etoolbar .g-acc,
.app.touch-ui .etoolbar .g-marks, .app.touch-ui .etoolbar .g-more { display: none; }
.app.touch-ui .etoolbar .g-undo { margin-left: auto; }
.app.touch-ui .etoolbar .txt, .etoolbar .ebtn .txt:empty { display: none; }
.app.touch-ui .etoolbar .ico { display: inline-grid; place-items: center; }
.app.touch-ui .etoolbar .ebtn.wide { padding: 0 3px; }
.app.touch-ui .epiano { height: 88px; }
@media (max-width: 760px) {
  .etoolbar .ebtn .txt { display: none; }
  .etoolbar .ebtn .ico { display: inline-grid; place-items: center; }
  .etoolbar .ebtn.wide { padding: 0 3px; }
}
.epop {
  position: fixed; z-index: 55; width: max-content; max-width: min(440px, calc(100vw - 16px)); max-height: calc(100dvh - 80px);
  overflow: auto; padding: 6px 10px 10px; background: var(--menu-bg); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.epop .egroup { flex-wrap: wrap; gap: 4px; padding: 0; border: 0; }
.epop .egroup.end { margin-top: 10px; }
.epop-h { font-size: 12px; color: var(--muted); margin: 8px 2px 4px; }
.epop .ebtn { border-color: var(--line); background: var(--bar); min-width: 44px; height: 44px; }
.epop .ebtn .txt { display: inline; }
.epop .txt.dyn { font: italic 700 17px "Times New Roman", serif; }
.epop .txt.finger { font-weight: 600; font-size: 16px; }
/* telefon pionowo: paleta w dwóch wierszach, niższa klawiatura */
@media (max-width: 520px) {
  .app.touch-ui .ebtn { min-width: 38px; height: 40px; }
  .app.touch-ui .etoolbar { gap: 4px 6px; }
  .app.touch-ui .etoolbar .egroup + .egroup { padding-left: 4px; }
  .app.touch-ui .epalette { gap: 4px 6px; padding: 4px 4px; }
  .app.touch-ui .epalette .egroup { gap: 3px; }
  .app.touch-ui .epiano { height: 72px; }
  .estatus { font-size: 11.5px; min-height: 24px; }
}
/* telefon poziomo: jeden wiersz palety, niska klawiatura */
@media (max-height: 520px) {
  .app.touch-ui .ebtn { min-width: 36px; height: 36px; }
  .app.touch-ui .epalette { flex-wrap: nowrap; overflow-x: auto; padding: 2px 6px; gap: 6px; justify-content: safe center; }
  .app.touch-ui .epalette .egroup { gap: 2px; }
  .app.touch-ui .epiano, .epiano { height: 54px; }
  .estatus { min-height: 22px; font-size: 11.5px; }
}
.app.touch-ui .etoolbar .g-voice { display: none; }
.ebtn sub { font-size: 11px; font-weight: 600; margin-left: -4px; align-self: end; }
#eVoice .ico { display: inline-flex !important; align-items: center; }
@media (max-width: 520px) {
  .app.touch-ui .etoolbar { padding-left: 6px; padding-right: 6px; gap: 2px 4px; }
  .app.touch-ui .etoolbar .ebtn { min-width: 36px; }
  .app.touch-ui .etoolbar .egroup + .egroup { padding-left: 3px; }
  .app.touch-ui .modesw .mode-btn { padding: 0 6px; }
}

/* ═══ okna edytora: formularze, pomoc ═══ */
.form { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
.form .flabel { color: var(--muted); white-space: nowrap; text-align: right; }
.form .fctl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.form .ffull { grid-column: 1 / -1; }
.form .frow { display: flex; align-items: center; gap: 6px; }
.form .suffix { color: var(--muted); white-space: nowrap; }
.form .small { margin: 2px 0; }
.form input[type=text], .form input[type=number], .form select {
  min-height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bar); color: var(--ink);
}
.form input[type=text] { width: 100%; min-width: 0; }
.form .fctl > input[type=text] { flex: 1; }
.form input[type=number] { width: 84px; }
.form select { max-width: 100%; }
.form input:focus-visible, .form select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.fcheck { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.fcheck input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-err { color: #d4483b; margin: 10px 0 0; white-space: pre-line; }
@media (pointer: coarse) { .form input[type=text], .form input[type=number], .form select { min-height: 40px; font-size: 16px; } }
@media (max-width: 520px) {
  .form { grid-template-columns: 1fr; gap: 4px; }
  .form .flabel { text-align: left; margin-top: 6px; }
}
dialog.help-dlg { width: min(800px, calc(100vw - 24px)); }
.help { font-size: 13.5px; }
.help h3 { font-size: 15px; margin: 14px 0 6px; }
.help table { border-collapse: collapse; }
.help td { padding: 3px 8px 3px 0; vertical-align: top; }
.help td:first-child { white-space: nowrap; }
.help .web-note { background: var(--hover); border-radius: 6px; padding: 8px 10px; }
@media (max-width: 520px) { .help td:first-child { white-space: normal; } }

/* ═══ edytor: odtwarzanie ═══ */
.ebtn.play .i-stop { display: none; }
.ebtn.play.playing .i-play { display: none; }
.ebtn.play.playing .i-stop { display: block; }
.ebtn.play { color: var(--accent); }
.ebtn.play.playing { background: var(--accent); color: var(--accent-ink); }
.app.touch-ui .etoolbar .g-play { display: none; }
/* telefon pionowo: paleta w dwóch wierszach (wartości + odtwarzanie | pauza, znaki, akord, kursor) */
@media (max-width: 520px) {
  .app.touch-ui .epalette { gap: 4px 4px; padding: 4px 2px; }
  .app.touch-ui .epalette .egroup { gap: 2px; }
  .app.touch-ui .epalette .ebtn { min-width: 37px; padding: 0 1px; }
  .app.touch-ui .epalette .ebtn.wide { padding: 0 6px; }
  .app.touch-ui .epalette .ebtn .gi { width: 25px; height: 25px; }
}
@media (max-width: 400px) {
  .app.touch-ui .epalette .ebtn { min-width: 34px; }
  .app.touch-ui .epalette .ebtn .gi { width: 23px; height: 23px; }
  .app.touch-ui .epalette .ebtn.wide { padding: 0 4px; }
}
#eMore { gap: 0; padding: 0 2px; }
#eMore .caret { width: 9px; height: 9px; margin-left: -1px; opacity: .8; }

/* ═══ rozpoznawanie nut ═══ */
dialog.omr-dlg { width: min(660px, calc(100vw - 24px)); }
.omr-dlg .body > p { white-space: pre-line; }
.omr-order { margin: 6px 0 12px; padding-left: 22px; max-height: 220px; overflow: auto; }
.omr-order li { display: flex; align-items: center; gap: 4px; }
.omr-order li span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omr-order .icon-btn { min-width: 30px; height: 30px; font-size: 15px; }
.omr-opts { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; font-size: 13px; }
.omr-stage { min-height: 2.6em; white-space: pre-line; margin: 6px 0; }
.omr-dlg progress { width: 100%; height: 10px; accent-color: var(--accent); }
.omr-logbox { margin-top: 10px; }
.omr-logbox summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.omr-log { max-height: 220px; overflow: auto; font: 11px/1.35 ui-monospace, Menlo, monospace; background: var(--bar2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; }
