/* === UI v2 — nowy wygląd (etap 1: motyw, przyciski, pola, zakładki, pasek) ===
   Tylko motyw ciemny; jasny (e-ink) zostaje bez zmian. */
html[data-theme="dark"] {
  --bg: #0b101c;        --surface: #10172a;   --surface-2: #141c33;  --surface-3: #18234a;
  --border: #222b45;    --border-2: #2c3757;
  --text: #e8ecf5;      --muted: #97a3bf;     --text-2: #cfd7ee;
  --accent: #d93a57;    --accent-hover: #e24a66; --accent-soft: #3a1722; --accent-text: #ffb3c1;
  --ok: #7fd8a4;        --warn: #f6c76a;
  --radius: 8px;        --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

html[data-theme="dark"] body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }

/* Pasek górny */
html[data-theme="dark"] header { background: var(--surface); border-bottom: 1px solid var(--border); }
html[data-theme="dark"] header h1 { color: var(--text); font-weight: 700; letter-spacing: .2px; }
html[data-theme="dark"] #page-info { color: var(--muted); }
html[data-theme="dark"] .toolbar-group { background: transparent; border: 0; padding: 0 2px; }
html[data-theme="dark"] .toolbar-tools { border-top: 1px solid var(--border); }

/* Przyciski */
html[data-theme="dark"] .btn, html[data-theme="dark"] .btn-sm {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius); font-family: inherit; font-weight: 500;
  transition: background .15s, border-color .15s, filter .15s;
}
html[data-theme="dark"] .btn:hover, html[data-theme="dark"] .btn-sm:hover { background: #1c2745; border-color: #3a4a80; }
html[data-theme="dark"] .btn:focus-visible, html[data-theme="dark"] .btn-sm:focus-visible,
html[data-theme="dark"] .tab:focus-visible, html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] input:focus-visible { outline: 2px solid #7a9bff; outline-offset: 1px; }
html[data-theme="dark"] .btn:disabled { opacity: .45; }
html[data-theme="dark"] .btn-secondary { background: transparent; border-color: var(--border-2); }
html[data-theme="dark"] .btn-secondary:hover { background: var(--surface-2); }
html[data-theme="dark"] .btn-primary { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; font-weight: 600; }
html[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: var(--accent-hover) !important; }
html[data-theme="dark"] .btn-danger { background: var(--accent-soft); border-color: #7a2a3c; color: var(--accent-text); }
html[data-theme="dark"] .btn-danger:hover { background: #4a1c2a; }
html[data-theme="dark"] .btn-record { background: var(--accent); border-radius: var(--radius-lg); }
html[data-theme="dark"] .btn-close { color: var(--muted); }
html[data-theme="dark"] .btn-close:hover { color: var(--accent-text); }

/* Pola */
html[data-theme="dark"] input[type="text"], html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"], html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] select, html[data-theme="dark"] #auth-modal input[type="text"],
html[data-theme="dark"] #auth-modal input[type="email"], html[data-theme="dark"] #auth-modal input[type="password"] {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius); font-family: inherit;
}
html[data-theme="dark"] input[type="range"], html[data-theme="dark"] input[type="checkbox"], html[data-theme="dark"] input[type="radio"] { accent-color: var(--accent); }

/* Panel boczny i zakładki */
html[data-theme="dark"] #sidebar { background: #0f1628; border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.45); }
html[data-theme="dark"] .tabs { background: transparent; border-bottom: 1px solid var(--border); padding: 0 4px; }
html[data-theme="dark"] .tab { color: var(--muted); font-family: inherit; font-weight: 500; padding: 12px 6px; }
html[data-theme="dark"] .tab:hover { color: var(--text); }
html[data-theme="dark"] .tab.active { color: #fff; font-weight: 600; border-bottom-color: var(--accent); }
html[data-theme="dark"] .tab-content { padding: 16px; }

/* Karty i wiersze */
html[data-theme="dark"] .voice-row, html[data-theme="dark"] .volume-row, html[data-theme="dark"] .staff-row, html[data-theme="dark"] .note-item {
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 10px;
}
html[data-theme="dark"] .staff-row:hover { background: #1c2745; }
html[data-theme="dark"] .staff-row.selected { background: var(--surface-3); outline: 1px solid #3a4a80; }
html[data-theme="dark"] .voice-row select { background: var(--surface); border-color: var(--border-2); }
html[data-theme="dark"] .volume-row .vol-mute { border-color: var(--border-2); color: var(--text-2); border-radius: 6px; }
html[data-theme="dark"] .volume-row .vol-mute.muted { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

/* Obszar partytury */
html[data-theme="dark"] #pdf-container { background: #080c15; }
html[data-theme="dark"] #pdf-placeholder { border: 2px dashed #2c3757; color: var(--muted); border-radius: 16px; }
html[data-theme="dark"] #pdf-wrapper.dragover #pdf-placeholder { border-color: var(--accent); background: var(--surface-2); }
html[data-theme="dark"] #progress-bar { background: var(--surface-2); }

/* Okna i panele rozpoznawania */
html[data-theme="dark"] .omr-pop, html[data-theme="dark"] .omr-panel { background: var(--bg); border-color: var(--border-2); border-radius: var(--radius-lg); }
html[data-theme="dark"] .omr-tab { background: var(--surface-2); border-color: var(--border-2); border-radius: 7px; color: var(--text-2); }
html[data-theme="dark"] .omr-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .omr-sel, html[data-theme="dark"] .voice-editor { background: #0f1628; border-color: var(--border-2); border-radius: 10px; }

/* Paski przewijania */
html[data-theme="dark"] * { scrollbar-width: thin; scrollbar-color: #2c3757 transparent; }

/* Poprawki układu (wszystkie motywy) */
label.btn { flex-direction: row; align-items: center; gap: 4px; white-space: nowrap; }
#pdf-placeholder { max-width: calc(100vw - 32px); }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1 0 auto; padding-left: 7px; padding-right: 7px; white-space: nowrap; font-size: 12px; }

/* === Etap 2: stały panel utworów (lewy) + zadokowany panel narzędzi (prawy) — szerokie ekrany === */
#songs-panel { display: none; }
@media (min-width: 1100px) {
  #songs-panel { display: flex; flex-direction: column; flex: none; width: 290px; border-right: 1px solid var(--border, #444); background: #0f1628; min-height: 0; }
  #sidebar { position: relative; top: auto; right: auto; height: auto; flex: none; transform: none !important; box-shadow: none !important; }
  #sidebar.collapsed { display: none; }
  #btn-songs, .tab[data-tab="songs"] { display: none !important; }   /* lista jest stale widoczna po lewej */
  #pdf-container { min-width: 0; }
}
.sp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.sp-head h2 { font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #97a3bf; }
.sp-search { padding: 0 16px 10px; }
.sp-search input { width: 100%; height: 36px; padding: 0 10px; }
.sp-filters { display: flex; gap: 6px; padding: 0 16px 12px; flex-wrap: wrap; }
.sp-chip { height: 28px; padding: 0 9px; border-radius: 999px; border: 1px solid #2c3757; background: transparent; color: #b6c0d9; font: 500 12px/1 inherit; font-family: inherit; cursor: pointer; }
.sp-chip.active { background: #26335a; border-color: #26335a; color: #fff; font-weight: 600; }
#sp-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; font-size: 13px; color: #97a3bf; }
#sp-list > div { border: 1px solid transparent; border-radius: 9px; padding: 10px !important; color: #e8ecf5; background: transparent !important; border-bottom: 1px solid #1a2340 !important; }
#sp-list > div:hover { background: #141c33 !important; }
html[data-theme="light"] #songs-panel { background: #fff; border-right: 2px solid #000; }
html[data-theme="light"] #sp-list > div { color: #000; border-bottom: 1px solid #aaa !important; }
html[data-theme="light"] .sp-chip { border-color: #000; color: #000; }
html[data-theme="light"] .sp-chip.active { background: #000; color: #fff; }

/* === Etap 3: dolny pasek odtwarzania === */
#transport { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--surface, #10172a); border-top: 1px solid var(--border, #444); min-height: 56px; }
.tp-play { width: 40px; height: 40px; border-radius: 999px; border: 0; background: #d93a57; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.tp-play:hover:not(:disabled) { filter: brightness(1.12); }
.tp-play:disabled { opacity: .4; cursor: default; }
.tp-play.playing { background: #2c3757; }
.tp-play:focus-visible { outline: 2px solid #7a9bff; outline-offset: 2px; }
#tp-status { font-size: 13px; color: #cfd7ee; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-spacer { flex: 1; }
.tp-field { flex-direction: row; align-items: center; gap: 8px; font-size: 12px; color: #97a3bf; width: auto; }
.tp-field input, .tp-field select { width: auto; height: 32px; }
.tp-field input { width: 64px; }
html[data-theme="light"] #transport { background: #f2f2f2; border-top: 2px solid #000; }
html[data-theme="light"] .tp-play { background: #000; }
html[data-theme="light"] #tp-status, html[data-theme="light"] .tp-field { color: #000; }
@media (max-width: 820px) { #transport { padding: 6px 10px; gap: 8px; } .tp-inst { display: none; } .tp-field { font-size: 11px; } }

.tp-track { flex: 1; height: 6px; border-radius: 3px; background: #222b45; overflow: hidden; min-width: 40px; }
#tp-progress-fill { height: 100%; width: 0; background: #d93a57; transition: width .3s linear; }
html[data-theme="light"] .tp-track { background: #ccc; border: 1px solid #000; }
html[data-theme="light"] #tp-progress-fill { background: #000; }

/* === Etap 4: ikony SVG, pasek edycji, tryb prosty / zaawansowany === */
.btn .ic, .btn-sm .ic { vertical-align: -3px; flex: none; }
#center-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#center-col #pdf-container { flex: 1; min-height: 0; }
#edit-bar { display: none; align-items: center; gap: 10px; padding: 6px 16px; background: #0f1628; border-bottom: 1px solid #222b45; }
html[data-mode="advanced"] #edit-bar { display: flex; }
.eb-seg { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #141c33; border: 1px solid #222b45; }
.eb-btn { height: 28px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; color: #b6c0d9; font: 500 12px/1 inherit; font-family: inherit; cursor: pointer; }
.eb-btn:hover:not(:disabled) { background: #1c2745; color: #fff; }
.eb-btn.active { background: #26335a; color: #fff; font-weight: 600; }
.eb-btn:disabled { opacity: .4; cursor: default; }
html[data-theme="light"] #edit-bar { background: #f2f2f2; border-bottom: 2px solid #000; }
html[data-theme="light"] .eb-seg { background: #fff; border-color: #000; }
html[data-theme="light"] .eb-btn { color: #000; }
html[data-theme="light"] .eb-btn.active { background: #000; color: #fff; }
/* tryb prosty: tylko to, co potrzebne do rozpoznania i odtwarzania */
html[data-mode="simple"] #btn-toggle-tools, html[data-mode="simple"] #toolbar-tools,
html[data-mode="simple"] #btn-songs,
html[data-mode="simple"] .tab[data-tab="voices"], html[data-mode="simple"] .tab[data-tab="record"], html[data-mode="simple"] .tab[data-tab="notes"] { display: none !important; }

/* === Okno ustawień (koło zębate) === */
#settings-pop { position: fixed; z-index: 80; width: 260px; max-width: calc(100vw - 16px); padding: 14px; border-radius: 12px;
  background: #10172a; border: 1px solid #2c3757; box-shadow: 0 12px 36px rgba(0,0,0,.55); color: #e8ecf5; display: flex; flex-direction: column; gap: 12px; }
#settings-pop[style*="display: none"] { display: none !important; }
.sp-title { font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #97a3bf; }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.st-label { font-size: 13px; }
.st-row .btn, .st-row .btn-sm { white-space: nowrap; }
.st-row .lbl { display: inline !important; }
.st-row label.btn-sm { border: 0 !important; background: transparent !important; padding: 0 !important; }
.st-row label.btn-sm .lbl { display: none !important; }
.st-row select { min-width: 120px; }
.st-hint { font-size: 11px; color: #97a3bf; line-height: 1.4; }
html[data-theme="light"] #settings-pop { background: #fff; border: 2px solid #000; color: #000; }
html[data-theme="light"] .st-hint, html[data-theme="light"] .sp-title { color: #333; }

/* === iPhone / iOS Safari === */
@supports (height: 100dvh) {
  body, #app { height: 100dvh; }                 /* pasek adresu Safari nie zasłania dolnego paska */
}
/* Aplikacja z ikony na pulpicie (tryb pełnoekranowy, treść pod wycięciem/Dynamic Island): odsunięcie od góry, dół bliżej krawędzi */
#app { box-sizing: border-box; padding-top: env(safe-area-inset-top); }
#transport { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
@supports (padding-bottom: max(1px, 2px)) {
  #transport { padding-bottom: max(8px, calc(env(safe-area-inset-bottom) - 12px)); }   /* pasek domowy nie potrzebuje całych 34px pustki */
}
header { padding-left: max(12px, env(safe-area-inset-left)) !important; padding-right: max(12px, env(safe-area-inset-right)) !important; }
@media (max-width: 820px) {
  /* okno ustawień jako dolny arkusz */
  #settings-pop { left: 8px !important; right: 8px !important; top: auto !important; width: auto; max-width: none;
    bottom: calc(8px + env(safe-area-inset-bottom)); padding: 16px; gap: 20px; }
  #settings-pop .st-row { min-height: 44px; }
  #settings-pop .btn, #settings-pop .btn-sm, #settings-pop select { min-height: 44px; font-size: 16px !important; padding: 0 14px !important; }
  #settings-pop select { min-width: 150px; }
}
/* iOS powiększa stronę przy polach <16px — wyłącz */
@media (max-width: 820px) { input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea { font-size: 16px; } }

/* === Telefon: jeden wiersz ikon; reszta w oknie ustawień === */
.st-phone { display: none; }
@media (max-width: 820px) {
  header #btn-login, header #btn-logout, header #btn-repertoire, header #btn-done, header #btn-close, header #btn-songs, header #user-info { display: none !important; }
  .st-phone { display: flex; flex-direction: column; gap: 8px; }
  .st-sub { font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #97a3bf; margin-top: 4px; }
  .st-phone .btn { justify-content: center; text-align: center; width: 100%; }
  #settings-pop { max-height: calc(100dvh - 24px); overflow-y: auto; }
  #page-info { max-width: 48px; text-align: center; }
  header { flex-wrap: nowrap !important; }
  header .toolbar { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  header .toolbar::-webkit-scrollbar { display: none; }
}
html[data-theme="light"] .st-sub { color: #333; }

/* przycisk ▶ w dolnym pasku: szary, dopóki nie ma czego odtwarzać */
.tp-play:disabled { background: #2c3757; color: #8794b5; opacity: 1; }
html[data-theme="light"] .tp-play:disabled { background: #ccc; color: #666; }

/* === Telefon: wiersz 1 = ikony, wiersz 2 = nazwa utworu na całą szerokość === */
#song-title { display: none; }
@media (max-width: 820px) {
  header { flex-wrap: wrap !important; row-gap: 2px !important; }
  header .toolbar { flex: 1 1 100%; }
  #song-title { display: block; flex: 1 1 100%; order: 3; min-width: 0; padding: 0 4px 4px; font-size: 15px; font-weight: 600;
    color: #e8ecf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #song-title.empty { color: #97a3bf; font-weight: 400; font-size: 13px; }
  html[data-theme="light"] #song-title { color: #000; }
}

/* Dotyk: przewijanie jednym palcem, powiększanie obsługuje aplikacja (zoom partytury), nie przeglądarka */
html, body { touch-action: pan-x pan-y; }
#pdf-container { touch-action: pan-x pan-y; overscroll-behavior: contain; }

#page-toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  padding: 8px 14px; border-radius: 999px; background: rgba(16,23,42,.92); border: 1px solid #2c3757; color: #e8ecf5; font-size: 13px;
  pointer-events: none; opacity: 0; transition: opacity .2s; }
#page-toast.show { opacity: 1; }
html[data-theme="light"] #page-toast { background: #fff; color: #000; border: 2px solid #000; }

.omr-scan-wrap, .omr-pdf-pages { touch-action: pan-x pan-y; }

/* === Spójne ikony === */
.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; display: inline-block; }
.ic-gap { margin-right: 6px; }
.tab .ic { width: 14px; height: 14px; vertical-align: -2px; }
.btn-sm .ic, .sp-chip .ic { width: 14px; height: 14px; }
.btn-close .ic { width: 15px; height: 15px; }
.btn, .btn-sm, .tab { display: inline-flex; align-items: center; justify-content: center; gap: 0; }
.tabs .tab { display: flex; }

/* === Lista utworów: wiersze z ikonami === */
.song-row { display: flex; align-items: center; gap: 2px; border-radius: 10px; border: 1px solid transparent; padding: 2px; }
.song-row:hover { background: #141c33; }
.song-row.current { background: #18234a; border-color: #3a4a80; }
.song-main { flex: 1; min-width: 0; text-align: left; background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.song-title { font-weight: 600; font-size: 14px; color: #e8ecf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #97a3bf; flex-wrap: wrap; }
.song-badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.song-badge.ok { background: #12301f; color: #7fd8a4; }
.song-badge.wip { background: #3a2a10; color: #f6c76a; }
.song-badge.info { background: #14284a; color: #8db7ff; }
.song-act { width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 0; background: transparent; color: #97a3bf; cursor: pointer; }
.song-act:hover { background: #1c2745; color: #fff; }
.song-act.danger:hover { background: #3a1722; color: #ffb3c1; }
#sp-list > .song-row, #songs-list > .song-row { background: transparent; border-bottom: 0 !important; padding: 2px !important; }
#sp-list > .song-row.current { background: #18234a !important; }
#sp-list > .song-row:hover { background: #141c33 !important; }
html[data-theme="light"] .song-title { color: #000; }
html[data-theme="light"] .song-row.current { background: #eee; border-color: #000; }
html[data-theme="light"] .song-badge { border: 1px solid #000; background: #fff !important; color: #000 !important; }
#undo-toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: none; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 12px; background: #10172a; border: 1px solid #2c3757; color: #e8ecf5; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#undo-toast.show { display: flex; }
#undo-toast button { background: transparent; border: 0; color: #8db7ff; font: 600 13px inherit; font-family: inherit; cursor: pointer; padding: 4px 6px; }

.ic + .lbl { margin-left: 6px; }
#page-info .ic { margin-right: 4px; }

#omr-run { width: 100%; justify-content: center; }

/* === Nagłówek: wiersz 1 = ikony, wiersz 2 = nazwa utworu (każda szerokość) === */
header { flex-wrap: wrap !important; row-gap: 2px !important; }
#song-title { display: block !important; flex: 1 1 100%; order: 3; min-width: 0; padding: 0 4px 4px; font-size: 14px; font-weight: 600;
  color: #e8ecf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#song-title.empty { color: #97a3bf; font-weight: 400; }
html[data-theme="light"] #song-title { color: #000; }
#page-info { max-width: 56px; text-align: center; }
/* strefa ostrożności: ponowne rozpoznawanie */
.omr-danger { margin-top: 18px; padding: 10px 12px; border: 1px solid #5a2433; border-radius: 10px; background: rgba(217,58,87,.06); }
.omr-danger summary { cursor: pointer; font-size: 13px; color: #ffb3c1; }
.omr-danger p { font-size: 13px; color: #cfd7ee; margin: 10px 0; line-height: 1.45; }
.omr-danger .btn { margin-top: 10px; }
html[data-theme="light"] .omr-danger { border: 2px solid #000; background: #fff; }
html[data-theme="light"] .omr-danger summary, html[data-theme="light"] .omr-danger p { color: #000; }

/* === Telefon: dolny pasek w rozmiarze ikon z góry, mieści się w całej szerokości === */
.tp-inst-ic { display: none; }
@media (max-width: 820px) {
  #page-info { display: none !important; }              /* numery stron tylko w dymku przy przesuwaniu */
  #transport { gap: 8px; padding: 6px 8px max(6px, calc(env(safe-area-inset-bottom) - 12px)); min-height: 0; }
  .tp-play { width: 34px; height: 34px; }
  .tp-play svg { width: 16px; height: 16px; }
  #tp-status { font-size: 12px; flex: 0 1 auto; max-width: 30%; }
  .tp-track { min-width: 24px; }
  .tp-field { font-size: 0; gap: 0; }                    /* bez podpisów „Tempo” i „BPM” */
  .tp-field input { width: 54px; height: 34px; font-size: 14px; text-align: center; padding: 0 4px; }
  .tp-inst { display: flex; position: relative; width: 34px; height: 34px; flex: none; border: 1px solid #2c3757; border-radius: 8px; background: #141c33; align-items: center; justify-content: center; color: #e8ecf5; }
  .tp-inst .tp-inst-ic { display: flex; pointer-events: none; }
  .tp-inst select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
  html[data-theme="light"] .tp-inst { background: #fff; border: 1px solid #000; color: #000; }
}

/* ikony w tekście (statusy, komunikaty, nagłówek) */
h1 .ic { width: 18px; height: 18px; margin-right: 6px; color: #d93a57; vertical-align: -3px; }
#song-title .ic, #tp-status .ic, .omr-stage .ic, .omr-summary .ic, .omr-warn .ic, #recording-status .ic, #playback-status .ic { width: 14px; height: 14px; vertical-align: -2px; }
.omr-warn .ic { color: #e0a030; }
.omr-stage .ic { animation: ic-pulse 1.6s ease-in-out infinite; }
@keyframes ic-pulse { 50% { opacity: .45; } }

/* dodawanie nut i tekstu */
.omr-add { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px dashed #2c3757; border-radius: 9px; }
.omr-add-label { font-size: 12px; color: #97a3bf; }
.omr-add .btn.active { background: #14b8a6; border-color: #14b8a6; color: #06201d; font-weight: 600; }
.omr-add select { height: 28px; font-size: 12px; padding: 0 6px; }
.omr-scan-inner rect.a { cursor: default; }
html[data-theme="light"] .omr-add { border-color: #000; }
html[data-theme="light"] .omr-add .btn.active { background: #000; color: #fff; }

.omr-sw-purple { border-color: #8b6cf6; background: rgba(139,108,246,.3); }
#omr-sel .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }

/* podgląd nut: biała kartka z czarnymi nutami (nie czarne tło) */
.omr-osmd { background: #fff; color: #000; border-radius: 6px; padding: 12px; min-height: 120px; overflow-x: auto; }
.omr-osmd svg { background: #fff; }
.omr-pdf-pages { background: #fff !important; }

/* === Widok TV (poziom): przełącznik widoczny tylko w poziomie; mniejszy interfejs, strona na cały ekran === */
#btn-tv { display: none; }
@media (orientation: landscape) { #btn-tv { display: inline-flex; } }
#btn-tv.active { background: #14b8a6; border-color: #14b8a6; color: #06201d; }
.omr-modes .btn { opacity: .75; }
html[data-theme] .omr-modes .btn.active, html[data-theme] .omr-modes .btn.active:hover { opacity: 1; background: #14b8a6; border-color: #5eead4; color: #06201d; font-weight: 700; box-shadow: 0 0 0 2px rgba(20,184,166,.35); }
html[data-theme="light"] .omr-modes .btn.active { background: #0f766e; border-color: #000; color: #fff; }
@media (orientation: landscape) {
  html[data-view="tv"] header { flex-wrap: nowrap !important; align-items: center !important; padding: 2px 8px !important; gap: 6px !important; row-gap: 0 !important; }
  html[data-view="tv"] header h1 { display: none; }
  html[data-view="tv"] #song-title { order: 1; flex: 0 1 26% !important; padding: 0 !important; font-size: 12px; }
  html[data-view="tv"] header .toolbar { order: 2; flex: 1 1 0 !important; min-width: 0; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; gap: 3px !important; }
  html[data-view="tv"], html[data-view="tv"] body { overflow-x: hidden; }
  html[data-view="tv"] .btn, html[data-view="tv"] .btn-sm { font-size: 11px !important; padding: 3px 6px !important; }
  html[data-view="tv"] .btn .ic, html[data-view="tv"] .btn-sm .ic { width: 13px; height: 13px; }
  html[data-view="tv"] header .lbl { display: none; }
  html[data-view="tv"] #page-info, html[data-view="tv"] #btn-songs, html[data-view="tv"] #btn-done, html[data-view="tv"] #btn-close { display: none !important; }
  html[data-view="tv"] header .toolbar-group { display: contents !important; }
  html[data-view="tv"] header .spacer { display: block; flex: 1; }
  html[data-view="tv"] #songs-panel, html[data-view="tv"] #sidebar, html[data-view="tv"] #edit-bar { display: none !important; }
  html[data-view="tv"] #pdf-container { padding: 4px; }
  html[data-view="tv"] #transport { min-height: 0; padding: 3px 8px; gap: 8px; }
  html[data-view="tv"] .tp-play { width: 26px; height: 26px; }
  html[data-view="tv"] .tp-play svg { width: 13px; height: 13px; }
  html[data-view="tv"] #tp-status { font-size: 11px; }
  html[data-view="tv"] .tp-field input, html[data-view="tv"] .tp-field select { height: 24px; font-size: 11px; }
  html[data-view="tv"] .omr-panel { padding: 4px 8px; gap: 4px; }
  html[data-view="tv"] .omr-tab { padding: 3px 8px; font-size: 11px; }
  html[data-view="tv"] .omr-scan-tools { font-size: 11px; gap: 6px; }
  html[data-view="tv"] .omr-scan-wrap { min-height: 0; }
  html[data-view="tv"] .omr-sel { padding: 3px 8px; font-size: 11px; }
  html[data-view="tv"] .omr-hint { display: none; }
  html[data-view="tv"] #page-toast, html[data-view="tv"] #undo-toast { bottom: 40px; }
}

/* linia odtwarzania: element HTML na GPU (bez przerysowywania skanu) */
#omr-playhead { position: absolute; left: 0; top: 0; width: 3px; margin-left: -1.5px; background: #d93a57; border-radius: 2px; pointer-events: none; will-change: transform; box-shadow: 0 0 8px rgba(217,58,87,.75); z-index: 5; }

/* ukryte opcje nad skanem: więcej miejsca na nuty */
#omr-panel.omr-opts-hidden .omr-scan-tools, #omr-panel.omr-opts-hidden #omr-sel, #omr-panel.omr-opts-hidden #omr-accepted,
#omr-panel.omr-opts-hidden .omr-warn, #omr-panel.omr-opts-hidden .omr-hint, #omr-panel.omr-opts-hidden #omr-pdf-status { display: none !important; }
#omr-toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; max-width: min(90vw, 560px);
  padding: 8px 14px; border-radius: 12px; background: rgba(16,23,42,.95); border: 1px solid #2c3757; color: #e8ecf5; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#omr-toast.show { opacity: 1; }
#omr-toast.err { border-color: #e03030; color: #ffb3c1; }
html[data-theme="light"] #omr-toast { background: #fff; color: #000; border: 2px solid #000; }

/* === Tryb pełnoekranowy: tylko partytura (PDF lub skan z rozpoznanymi nutami) i pasek ikon === */
#btn-fplay { display: none; }
html[data-focus="1"] #btn-fplay { display: inline-flex; }
html[data-focus="1"] #transport, html[data-focus="1"] #song-title, html[data-focus="1"] #songs-panel, html[data-focus="1"] #sidebar,
html[data-focus="1"] #edit-bar, html[data-focus="1"] .toolbar-tools, html[data-focus="1"] .omr-bar, html[data-focus="1"] .omr-scan-tools,
html[data-focus="1"] #omr-sel, html[data-focus="1"] #omr-accepted, html[data-focus="1"] .omr-hint, html[data-focus="1"] .omr-warn,
html[data-focus="1"] #omr-pdf-status, html[data-focus="1"] #page-info { display: none !important; }
html[data-focus="1"] #pdf-container { padding: 4px; }
html[data-focus="1"] .omr-panel { padding: 2px 4px; gap: 2px; }
html[data-focus="1"] .omr-scan-wrap { border: 0; border-radius: 0; }
html[data-focus="1"] header { padding-bottom: 2px !important; }
html[data-focus="1"] #btn-focus.active { background: #14b8a6; border-color: #14b8a6; color: #06201d; }
/* logo w nagłówku tylko na szerokich ekranach — na telefonie zajmowało osobny wiersz */
@media (max-width: 820px) { header h1 { display: none !important; } }
html[data-focus="1"] header h1 { display: none !important; }

/* === Obrót ekranu (iOS): nic nie może wystawać poza widok ani być przewijalne w bok === */
html { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; top: 0; left: 0; right: 0; width: 100%; max-width: 100%; overflow: hidden; overscroll-behavior: none; }
#app { width: 100%; max-width: 100%; overflow: hidden; }
#sidebar.collapsed { display: none !important; }   /* zwinięty panel nie leży już poza ekranem po prawej */

/* Pełny ekran bez Fullscreen API (iPhone): strona ma zapas przewijania — przeciągnięcie po pasku ikon chowa pasek przeglądarki */
html[data-focus="1"][data-scrollhide="1"] { overflow-y: auto; overflow-x: hidden; height: auto; overscroll-behavior-y: auto; }
html[data-focus="1"][data-scrollhide="1"] body { position: static; height: auto; min-height: calc(100dvh + 160px); overflow: visible; }
html[data-focus="1"][data-scrollhide="1"] #app { position: sticky; top: 0; height: 100dvh; }
html[data-focus="1"][data-scrollhide="1"] #pdf-container, html[data-focus="1"][data-scrollhide="1"] .omr-scan-wrap { overscroll-behavior: contain; }

/* panel przy nucie (tryb edycji): wysokość ▲▼ i od razu widoczny wybór długości (nuty) */
#omr-pad { position: absolute; z-index: 8; width: 258px; padding: 8px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(16,23,42,.97); border: 1px solid #3a4a80; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.55); touch-action: manipulation; }
#omr-pad button { display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; border-radius: 10px; cursor: pointer; padding: 0; font: inherit; }
#omr-pad button:hover { background: #26335a; }
#omr-pad button:active { background: #3a4a80; }
.pad-top { display: grid; grid-template-columns: 56px 1fr 56px; gap: 6px; }
.pad-top button { height: 44px; }
.pad-name { display: flex; align-items: center; justify-content: center; color: #fff; }
.pad-name b { font-size: 20px; }
.pad-durs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.pad-durs button { flex-direction: column; gap: 0; height: 62px; }
.pad-durs .nt { font-family: 'Bravura', serif; font-size: 30px; line-height: 38px; height: 38px; }
.pad-durs small { font-size: 11px; color: #97a3bf; }
.pad-durs button.on { background: #14b8a6; border-color: #14b8a6; color: #06201d; }
.pad-durs button.on small { color: #06201d; font-weight: 700; }
.pad-bot { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pad-bot button { height: 38px; font-size: 13px; }
#omr-pad button.danger:hover { background: #3a1722; color: #ffb3c1; }
html[data-theme="light"] #omr-pad { background: #fff; border: 2px solid #000; }
html[data-theme="light"] #omr-pad button { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] .pad-name, html[data-theme="light"] .pad-durs small { color: #000; }
html[data-theme="light"] .pad-durs button.on { background: #000; color: #fff; }
.omr-scan-inner #omr-pad svg { position: static; left: auto; top: auto; width: 20px; height: 20px; }
/* glif Bravura ma bardzo wysoką linię — nie może wystawać poza przycisk i przechwytywać kliknięć */
.pad-durs button { overflow: hidden; position: relative; }
.pad-durs .nt { display: block; width: 100%; text-align: center; overflow: hidden; pointer-events: none; }
.pad-durs small { pointer-events: none; display: block; }
#omr-pad .pad-durs button.on { background: #14b8a6; border-color: #14b8a6; color: #06201d; }
#omr-pad .pad-durs button.on small { color: #06201d; font-weight: 700; }
html[data-theme="light"] #omr-pad .pad-durs button.on { background: #000; border-color: #000; color: #fff; }
html[data-theme="light"] #omr-pad .pad-durs button.on small { color: #fff; }

/* przezroczyste nuty: widać skan spod spodu (suwak w opcjach) */
.omr-scan-inner svg text.nh, .omr-scan-inner svg line.prob, .omr-scan-inner svg text.acc, .omr-scan-inner svg circle.prob, .omr-scan-inner svg text.flag, .omr-scan-inner svg text.rest { opacity: var(--nop, .55); }
.omr-scan-inner svg text.prob:not(.acc):not(.flag):not(.rest) { opacity: .9; }
.omr-op input[type=range] { width: 90px; vertical-align: middle; }
/* przyciski bez podpisów (nazwa po przytrzymaniu) */
.icon-only .lbl { display: none !important; }
#omr-play { display: none !important; }   /* odtwarzanie jest w dolnym pasku */
/* lista długości jak „przewijak”: przyciąganie do środka */
#omr-pad .pad-durs { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 0; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; touch-action: pan-x; }
#omr-pad .pad-durs::-webkit-scrollbar { display: none; }
#omr-pad .pad-durs button { flex: 0 0 62px; scroll-snap-align: center; height: 66px; opacity: .55; transform: scale(.9); transition: opacity .12s, transform .12s; }
#omr-pad .pad-durs button.on { opacity: 1; transform: scale(1.08); }
.pad-name { touch-action: none; cursor: ns-resize; user-select: none; }
.pad-name::after { content: '⇅'; margin-left: 6px; font-size: 12px; color: #97a3bf; }
#omr-pad .pad-sug { height: auto; min-height: 36px; padding: 6px 8px; text-align: left; justify-content: flex-start; font-size: 12px; line-height: 1.3; background: #3a2a10; border-color: #8a6a20; color: #ffe2a0; }
#omr-pad .pad-sug b { color: #ffd166; }
/* karta podpowiedzi przy czerwonym takcie */
#omr-sug { position: absolute; z-index: 9; width: 280px; max-width: calc(100% - 8px); padding: 8px; display: flex; flex-direction: column; gap: 6px; background: rgba(16,23,42,.97); border: 1px solid #8a6a20; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.55); }
#omr-sug .sug-h { font-size: 12px; font-weight: 700; color: #ffd166; }
#omr-sug .sug-n { font-size: 12px; color: #cfd7ee; }
#omr-sug button { text-align: left; border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer; }
#omr-sug button:hover { background: #26335a; }
#omr-sug .sug-x { text-align: center; color: #97a3bf; }
.st-sync { display: flex; align-items: center; gap: 8px; }
.st-sync input[type=range] { width: 130px; }
.st-sync span { font-size: 12px; min-width: 52px; text-align: right; color: #97a3bf; }
html[data-theme="light"] #omr-sug { background: #fff; border: 2px solid #000; }
html[data-theme="light"] #omr-sug button { background: #fff; border-color: #000; color: #000; }

/* wynik bez zapisanego skanu: ukryj narzędzia skanu i pokaż wyjaśnienie */
.omr-noscan-box { padding: 14px; border: 1px solid #8a6a20; border-radius: 12px; background: rgba(246,199,106,.08); display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.omr-noscan-box b { color: #ffd166; }
.omr-noscan-box p { margin: 0; font-size: 13px; line-height: 1.5; color: #cfd7ee; }
#omr-tab-scan.omr-noscan .omr-scan-tools, #omr-tab-scan.omr-noscan .omr-scan-wrap, #omr-tab-scan.omr-noscan #omr-sel, #omr-tab-scan.omr-noscan #omr-accepted { display: none !important; }
html[data-theme="light"] .omr-noscan-box { border: 2px solid #000; background: #fff; }
html[data-theme="light"] .omr-noscan-box b, html[data-theme="light"] .omr-noscan-box p { color: #000; }

/* zakładki wyniku: same ikony (nazwa po przytrzymaniu) */
.omr-tab.icon-only { min-width: 44px; height: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; }
.omr-tab.icon-only .ic { width: 18px; height: 18px; margin: 0; }

/* na ekranach dotykowych strony zmienia się gestami — przyciski ‹ › są zbędne */
@media (pointer: coarse) { #btn-prev, #btn-next, #omr-prev, #omr-next { display: none !important; } }

.pad-gray { font-size: 12px; line-height: 1.35; color: #cfd7ee; background: rgba(155,155,180,.12); border: 1px dashed #6b6b88; border-radius: 9px; padding: 6px 8px; }
#omr-pad .pad-add { background: #14b8a6; border-color: #14b8a6; color: #06201d; font-weight: 700; }
#omr-pad .pad-add:hover { background: #2dd4bf; }
html[data-theme="light"] .pad-gray { color: #000; border-color: #000; background: #fff; }
html[data-theme="light"] #omr-pad .pad-add { background: #000; border-color: #000; color: #fff; }

.omr-sw-amber { border-color: #f59e0b; background: rgba(245,158,11,.35); }
.pad-infer { border-color: #f59e0b; background: rgba(245,158,11,.12); }
.pad-infer b { color: #fbbf24; }
html[data-theme="light"] .pad-infer { border-color: #000; background: #fff; }


.omr-sw-p0 { border-color: #7c3aed; background: rgba(124,58,237,.3); }
.omr-sw-p1 { border-color: #0d9488; background: rgba(13,148,136,.3); }
.omr-sw-p2 { border-color: #2563eb; background: rgba(37,99,235,.3); }
.omr-sw-p3 { border-color: #92400e; background: rgba(146,64,14,.3); }

.pad-voices { display: flex; gap: 6px; justify-content: center; padding: 4px 0 2px; }
#omr-pad .pad-voices button { min-width: 36px; height: 36px; border-radius: 999px; border: 2px solid var(--pc); background: transparent; color: var(--pc); font-weight: 700; font-size: 14px; }
#omr-pad .pad-voices button.on { background: var(--pc); color: #fff; }
html[data-theme="dark"] .pad-voices button:not(.on) { background: rgba(255,255,255,.06); }

.pad-acc { display: flex; gap: 6px; justify-content: center; padding: 2px 0 4px; }
#omr-pad .pad-acc button { min-width: 44px; height: 34px; font-size: 18px; line-height: 1; border-radius: 10px; }
#omr-pad .pad-acc button.on { background: #14b8a6; border-color: #14b8a6; color: #06201d; font-weight: 700; }
html[data-theme="light"] #omr-pad .pad-acc button.on { background: #000; color: #fff; }

.ns-back { position: fixed; inset: 0; background: rgba(5,8,16,.6); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 16px; }
.ns-box { background: #10172a; border: 1px solid #2c3757; border-radius: 14px; padding: 18px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; color: #e8ecf5; max-height: 100%; overflow: auto; }
.ns-box h3 { margin: 0 0 4px; font-size: 17px; }
.ns-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #97a3bf; }
.ns-box input, .ns-box select { height: 40px; font-size: 15px; }
.ns-act { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.ns-err { color: #ffb3c1; font-size: 13px; min-height: 1em; }
html[data-theme="light"] .ns-box { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] .ns-box label { color: #000; }

.omr-legend { display: flex; flex-direction: column; gap: 12px; padding: 10px 2px; font-size: 14px; }
.omr-legend .omr-chk { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; }
.omr-legend .omr-op input { width: min(220px, 60vw); }
.omr-sw-gray { border-color: #9b9bb4; background: rgba(155,155,180,.4); }
.omr-legend .omr-chk, .omr-legend label { font-size: 14px; }

#omr-tpad { position: absolute; z-index: 9; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: rgba(16,23,42,.97); border: 1px solid #3a4a80; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.55); color: #e8ecf5; touch-action: manipulation; }
#omr-tpad .tp-head { font-size: 13px; color: #97a3bf; }
#omr-tpad .tp-head b { color: #e8ecf5; }
#omr-tpad .tp-top { display: flex; align-items: flex-start; gap: 8px; }
#omr-tpad .tp-top .tp-head { flex: 1; min-width: 0; }
#omr-tpad .tp-top button.tp-x { flex: none; width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
#omr-tpad .tp-top button.tp-x svg { position: static; width: 18px; height: 18px; }
#omr-tpad input { width: 100%; height: 42px; font-size: 16px; box-sizing: border-box; }
#omr-tpad .tp-info { font-size: 12px; color: #97a3bf; }
#omr-tpad .tp-act { display: flex; gap: 8px; }
#omr-tpad button { flex: 1; height: 42px; border-radius: 10px; border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; font: inherit; cursor: pointer; }
#omr-tpad button.tp-ok { background: #14b8a6; border-color: #14b8a6; color: #06201d; font-weight: 600; }
html[data-theme="light"] #omr-tpad { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] #omr-tpad .tp-head, html[data-theme="light"] #omr-tpad .tp-info { color: #000; }
html[data-theme="light"] #omr-tpad button { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] #omr-tpad button.tp-ok { background: #000; color: #fff; }

.omr-sw-measure { border-color: #4a6cf7; border-style: dashed; background: transparent; }
#omr-tpad .tp-chk { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: #97a3bf; }
#omr-tpad .tp-chk input { width: auto; height: auto; }
html[data-theme="light"] #omr-tpad .tp-chk { color: #000; }

#omr-pad .pad-meas { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; font-size: 13px; color: #97a3bf; }
#omr-pad .pad-meas label { display: flex; align-items: center; gap: 6px; flex: 1; }
#omr-pad .pad-meas input { width: 64px; height: 34px; font-size: 15px; text-align: center; }
#omr-pad .pad-meas button { min-width: 48px; height: 34px; }
html[data-theme="light"] #omr-pad .pad-meas { color: #000; }

#omr-pad .pad-bot.three { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 6px; }
#omr-pad .pad-bot.three button span { font-size: 13px; }

#omr-pad .pad-durs::before, #omr-pad .pad-durs::after { content: ''; flex: 0 0 calc(50% - 37px); }   /* odstępy po bokach: pierwszą i ostatnią pozycję da się wycentrować także w Safari */

/* pasek wyniku: wszystkie ikony (zakładki, zapis, schowaj opcje, wróć do PDF) w jednym wierszu */
.omr-bar { flex-wrap: nowrap; gap: 6px; }
.omr-bar .omr-tabs { flex-wrap: nowrap; gap: 6px; flex: 0 0 auto; }
.omr-bar .omr-actions { flex-wrap: nowrap; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.omr-bar .omr-tab.icon-only, .omr-bar .omr-actions .icon-only { width: 44px; min-width: 0; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 460px) { .omr-bar { gap: 4px; } .omr-bar .omr-tabs, .omr-bar .omr-actions { gap: 4px; } .omr-bar .omr-tab.icon-only, .omr-bar .omr-actions .icon-only { width: 40px; height: 40px; } }

#omr-tpad .tp-clear { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #97a3bf; }
#omr-tpad .tp-clear button { flex: 0 0 auto; width: 40px; height: 34px; }
#omr-tpad .tp-clear button#omr-range-btn, #omr-tpad .tp-clear button#omr-drop-empty { flex: 1 1 auto; width: 100%; height: auto; min-height: 34px; padding: 6px 10px; }
#omr-tpad .tp-clear button[data-delm="all"] { width: auto; padding: 0 8px; }
html[data-theme="light"] #omr-tpad .tp-clear { color: #000; }

#omr-pad { opacity: 1; position: fixed; z-index: 60; background: #10172a; }   /* okienko nuty: nieprzezroczyste, stałe w rogu widoku — nuta obok niego pozostaje widoczna */

#omr-pad.rest-pad { width: 240px; }
#omr-pad .rest-name { text-align: center; padding: 4px 0; }
#omr-pad .pad-info { font-size: 12px; color: #97a3bf; text-align: center; }
#omr-pad .pad-durs.simple { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; overflow: visible; padding: 0; scroll-snap-type: none; }
#omr-pad .pad-durs.simple::before, #omr-pad .pad-durs.simple::after { display: none; }
#omr-pad .pad-durs.simple button { flex: none; height: 56px; opacity: 1; transform: none; }
#omr-pad .pad-durs.simple button.on { transform: none; }
html[data-theme="light"] #omr-pad .pad-info { color: #000; }

#omr-pad .step { display: inline-flex; align-items: center; gap: 3px; }
#omr-pad .step button { width: 30px; min-width: 30px; height: 34px; font-size: 18px; line-height: 1; padding: 0; }
#omr-pad .step input { width: 54px; }
#omr-tpad .step.big { display: flex; align-items: center; gap: 6px; }
#omr-tpad .step.big button { flex: 0 0 48px; width: 48px; height: 42px; font-size: 22px; line-height: 1; }
#omr-tpad .step.big input { flex: 1; text-align: center; }
#omr-pad .pad-acc button[data-dotbtn] { font-size: 26px; font-weight: 700; }

.omr-sw-yellow { border-color: #eab308; background: rgba(234,179,8,.35); }
.omr-scan-inner svg text.orphan { opacity: var(--nop, .55); }

/* okno AI: przesuwane, zwijane do paska, zamykane */
#omr-aiwin { position: absolute; z-index: 10; display: flex; flex-direction: column; background: rgba(16,23,42,.97); border: 1px solid #3a4a80; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.55); color: #e8ecf5; max-width: calc(100% - 8px); }
#omr-aiwin .ai-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#omr-aiwin .ai-title { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#omr-aiwin .ai-bar button { flex: none; width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; cursor: pointer; }
#omr-aiwin .ai-bar button svg, .omr-scan-inner #omr-aiwin svg { position: static; left: auto; top: auto; width: 18px; height: 18px; }
#omr-aiwin .ai-bar .ai-move { cursor: grab; touch-action: none; }
#omr-aiwin .ai-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 10px; max-height: 60vh; overflow-y: auto; }
#omr-aiwin .tp-head { font-size: 13px; color: #97a3bf; }
#omr-aiwin .tp-head b { color: #e8ecf5; }
#omr-aiwin textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; padding: 8px; border-radius: 8px; }
#omr-aiwin .tp-act { display: flex; gap: 8px; }
#omr-aiwin .tp-act button { flex: 1; height: 42px; border-radius: 10px; border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; font: inherit; cursor: pointer; }
#omr-aiwin .tp-act button.tp-ok { background: #14b8a6; border-color: #14b8a6; color: #06201d; font-weight: 600; }
html[data-theme="light"] #omr-aiwin { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] #omr-aiwin .tp-head, html[data-theme="light"] #omr-aiwin .tp-head b { color: #000; }

/* krótki komunikat z numerem załadowanej wersji (znika sam) */
#ver-toast { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 200; padding: 6px 12px; border-radius: 999px; background: rgba(16,23,42,.92); border: 1px solid #3a4a80; color: #e8ecf5; font-size: 12px; pointer-events: none; transition: opacity .5s; }
html[data-theme="light"] #ver-toast { background: #fff; color: #000; border-color: #000; }
#ver-badge { position: fixed; right: 8px; top: calc(4px + env(safe-area-inset-top)); z-index: 60; font-size: 11px; color: #97a3bf; opacity: .85; pointer-events: none; font-variant-numeric: tabular-nums; }
html[data-theme="light"] #ver-badge { color: #333; }
/* własne miejsce na numer wersji, żeby nie nachodził na ostatni przycisk paska */
header, html[data-view="tv"] header { padding-right: calc(40px + env(safe-area-inset-right)) !important; }

/* przytrzymanie głowicy (przeciąganie nuty): bez menu systemowego i zaznaczania tekstu */
#omr-scan-svg rect.h, #omr-scan-svg .drag-ghost { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* głowice w trybie edycji: przeciąganie nuty po przytrzymaniu nie może przewijać skanu */
#omr-scan-svg rect.h { touch-action: none; }
#omr-scan-svg .selmark .ring { animation: sel-pulse 1.1s ease-in-out infinite; }
@keyframes sel-pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .35; } }
@media (prefers-reduced-motion: reduce) { #omr-scan-svg .selmark .ring { animation: none; } }
#omr-savebadge { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 10000; max-width: 92vw; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; color: #fff; background: #334155; box-shadow: 0 6px 20px rgba(0,0,0,.45); pointer-events: none; opacity: 0; visibility: hidden; }
#omr-savebadge.show { opacity: .96; visibility: visible; }
#omr-savebadge.busy { background: #92600a; }
#omr-savebadge.ok { background: #0f6b52; }
#omr-savebadge.err { background: #a11d33; }
/* skan i wszystko, co na nim narysowane, nie daje się zaznaczać ani „porywać” przez przeglądarkę: jej własne przeciąganie zaznaczenia przejmowało mysz i nuta się nie przesuwała */
#omr-scan-img, #omr-scan-svg, #omr-scan-svg * { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }

/* Tryb „Zaznacz kilka nut”: warstwa łapiąca gesty, okno zaznaczania, pasek przenoszenia */
#omr-scan-svg rect.selcatch { touch-action: none; cursor: crosshair; }
#omr-multibar { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 60; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; max-width: calc(100vw - 16px); width: max-content; padding: 8px 12px; background: rgba(16,23,42,.97); color: #e8ecf5; border: 1px solid #00c2e0; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.55); font-size: 13px; }
#omr-multibar button { border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; border-radius: 9px; padding: 8px 12px; font: inherit; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
#omr-multibar button:hover:not(:disabled) { background: #26335a; }
#omr-multibar button:disabled { opacity: .4; cursor: default; }
#omr-multibar .mb-num { display: inline-flex; gap: 6px; align-items: center; }
#omr-multibar input { width: 4.5em; border: 1px solid #00c2e0; background: #0d1430; color: #e8ecf5; border-radius: 9px; padding: 7px 8px; font: inherit; font-size: 16px; text-align: center; }
html[data-theme="light"] #omr-multibar input { background: #fff; color: #000; border: 2px solid #000; }
html[data-theme="light"] #omr-multibar { background: #fff; color: #000; border: 2px solid #000; }
html[data-theme="light"] #omr-multibar button { background: #fff; border-color: #000; color: #000; }

/* Zakładka „Odtwarzanie”: wybór i głośność głosów nad skanem */
.omr-mix { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid #2c3757; border-radius: 10px; background: rgba(16,23,42,.9); color: #e8ecf5; font-size: 13px; flex: 0 0 auto; max-height: 45vh; overflow-y: auto; }
.omr-mix button { border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; border-radius: 9px; padding: 7px 10px; font: inherit; cursor: pointer; }
.omr-mix button.on { background: #14b8a6; border-color: #14b8a6; color: #04211d; font-weight: 700; }
.omr-mix .mix-row { display: grid; grid-template-columns: minmax(78px, 130px) auto 1fr 44px; gap: 8px; align-items: center; }
.omr-mix .mix-row .mix-on { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omr-mix .mix-row input { width: 100%; min-width: 0; accent-color: #14b8a6; }
.omr-mix .mix-row.off input, .omr-mix .mix-row.off .mix-val { opacity: .4; }
.omr-mix .mix-val { text-align: right; font-variant-numeric: tabular-nums; }
html[data-theme="light"] .omr-mix { background: #fff; color: #000; border: 2px solid #000; }
html[data-theme="light"] .omr-mix button { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] .omr-mix button.on { background: #000; color: #fff; }
#omr-multibar .mb-voices { display: inline-flex; gap: 6px; align-items: center; }
#omr-multibar button.on { background: #14b8a6; border-color: #14b8a6; color: #04211d; font-weight: 700; }
html[data-theme="light"] #omr-multibar button.on { background: #000; color: #fff; }
#omr-tpad .tp-meter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#omr-tpad .tp-meter select { font: inherit; font-size: 16px; padding: 6px 8px; border-radius: 8px; }
.omr-mix .mix-tempo { display: grid; grid-template-columns: auto auto 1fr auto 34px auto; gap: 8px; align-items: center; }
.omr-mix .mix-tempo input { width: 100%; min-width: 0; accent-color: #14b8a6; }
.omr-mix .mix-who:empty { display: none; }
.omr-mix .mix-who { display: flex; flex-direction: column; gap: 8px; }
.omr-mix .who-help { opacity: .8; }
.omr-mix .who-sys { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid #2c3757; }
.omr-mix .who-range { flex: 1 0 100%; font-weight: 700; }
.omr-mix .who-sys label { display: flex; gap: 4px; align-items: center; }
.omr-mix .who-sys select { border: 1px solid #2c3757; background: #18234a; color: #e8ecf5; border-radius: 9px; padding: 7px 6px; font: inherit; font-size: 16px; }
html[data-theme="light"] .omr-mix .who-sys select { background: #fff; border-color: #000; color: #000; }
html[data-theme="light"] .omr-mix .who-sys { border-color: #000; }

/* zapis częściowy w trakcie rozpoznawania */
.omr-partial { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.omr-partial-pages { display: flex; flex-direction: column; gap: 10px; }
.omr-partial-pages svg { width: 100%; height: auto; background: #fff; border-radius: 8px; }
.omr-partial-head { fill: rgba(20, 184, 166, .45); stroke: #0f766e; stroke-width: 3; }
