:root {
    color-scheme: light;
    --bg: #f8fafc;
    --panel: #ffffff;
    --panel-soft: #eef2f7;
    --content-bg: #ffffff;
    --line: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --green: #16a34a;
    --yellow: #ca8a04;
    --red: #dc2626;
    --chord: #dc2626;
    --heading: #1d4ed8;
    --button-bg: #334155;
    --button-text: #ffffff;
    --schola-font-size: 24px;
    --schola-render-font-size: 24px;
    --schola-column-gap: 34px;
}

body.dark-theme {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #172033;
    --panel-soft: #1e293b;
    --content-bg: #0b1220;
    --line: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-soft: #172554;
    --green: #22c55e;
    --yellow: #facc15;
    --red: #ef4444;
    --chord: #f87171;
    --heading: #93c5fd;
    --button-bg: #334155;
    --button-text: #ffffff;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
html, body { margin: 0; min-height: 100%; color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); transition: background .18s ease, color .18s ease; }
button { border: 0; border-radius: 8px; padding: 9px 12px; background: var(--button-bg); color: var(--button-text); font-weight: 700; cursor: pointer; touch-action: manipulation; white-space: nowrap; }
button:active { transform: scale(.98); }
button:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }
.hidden { display: none !important; }

.schola-header {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.schola-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.schola-brand > div { min-width: 0; display: flex; flex-direction: column; }
.schola-brand strong { white-space: nowrap; }
.schola-brand small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
.schola-live-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 18%, transparent); flex: 0 0 auto; }
body.master-online .schola-live-dot { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent); }
body.network-offline .schola-live-dot { background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 18%, transparent); }
.schola-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.follow-master-btn.active { background: #15803d; }
.follow-master-btn.paused { background: #a16207; }

.schola-option-switch {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-soft);
}
.schola-option-switch button {
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    opacity: .55;
    box-shadow: none;
    transition: background .15s ease, color .15s ease, opacity .15s ease, transform .08s ease;
}
.schola-option-switch button + button { margin-left: 2px; }
.schola-option-switch button.active {
    background: var(--accent);
    color: #fff;
    opacity: 1;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 28%, transparent);
}
.schola-option-switch button:active { transform: scale(.98); }
body.dark-theme .schola-option-switch { background: #111827; }


.schola-update-notice {
    position: sticky;
    top: 62px;
    z-index: 38;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 9px 12px;
    background: #854d0e;
    color: #fef9c3;
    border-bottom: 1px solid #facc15;
    font-weight: 700;
}
.schola-update-notice button { background: #facc15; color: #422006; padding: 6px 9px; }

.schola-app { width: min(1480px, 100%); margin: 0 auto; flex: 1; padding: 18px 20px 80px; }
.schola-waiting { min-height: 65vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--muted); }
.waiting-icon { font-size: 64px; margin-bottom: 8px; }
.schola-waiting h1 { margin: 0 0 12px; color: var(--text); }
.schola-waiting p { max-width: 600px; line-height: 1.55; }
.schola-waiting small { color: var(--muted); }

.schola-song-view { min-width: 0; }
.schola-song-topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 0 0; }
.schola-current-info { display: flex; gap: 12px; min-width: 0; }
.schola-position { min-width: 58px; padding: 7px 9px; border-radius: 9px; background: var(--accent); color: #fff; text-align: center; font-weight: 900; align-self: flex-start; }
.schola-current-info h1 { margin: 0; font-size: clamp(22px, 3vw, 36px); line-height: 1.1; overflow-wrap: anywhere; }
.schola-repertoire { margin-top: 6px; color: var(--heading); font-size: 14px; }
.schola-next-info { color: var(--muted); text-align: right; font-size: 14px; padding-top: 8px; }

.schola-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; background: var(--panel-soft); border: 1px solid var(--line); border-top: 0; }
.schola-meta-row > span { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; }
.schola-meta-row small { color: var(--muted); }
.schola-strumming { flex: 1 1 260px; min-width: 180px; font-weight: 800; }
.strum-down { color: #ef4444; font-size: 1.5em; }
.strum-up { color: #10b981; font-size: 1.5em; }
.strum-space { color: var(--muted); }
body.schola-lyrics-view .schola-meta-row { display: none; }

.schola-intro, .schola-note { margin-top: 10px; padding: 10px 14px; border-radius: 10px; }
.schola-intro { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); font-weight: 800; }
.schola-note { background: #fef3c7; border: 1px solid #ca8a04; color: #713f12; }
body.dark-theme .schola-note { background: #422006; color: #fef3c7; }
.intro-chord { color: var(--chord); margin-right: 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 900; cursor: pointer; text-decoration: underline dotted transparent; text-underline-offset: 3px; }
.intro-chord:hover { text-decoration-color: currentColor; }

.schola-view-toolbar { position: sticky; top: 62px; z-index: 25; display: flex; flex-direction: column; gap: 7px; padding: 10px 0; background: linear-gradient(var(--bg) 78%, color-mix(in srgb, var(--bg) 0%, transparent)); }
.schola-toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.schola-view-switch, .schola-layout-controls, .schola-font-controls, .schola-scroll-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.schola-view-switch { padding:3px; border:1px solid var(--line); border-radius:10px; background:var(--panel-soft); gap:2px; }
.schola-view-switch button { background:transparent; color:var(--muted); opacity:.55; }
.schola-view-switch button.active { background:var(--accent); color:#fff; opacity:1; }
.schola-view-switch button.active, .schola-layout-controls button.active { background: var(--accent); }
.schola-font-controls strong, .schola-scroll-controls strong { min-width: 42px; text-align: center; color: var(--heading); }
.schola-scroll-controls small { color: var(--muted); }
#autoScrollBtn.active { background: #15803d; }

.schola-repertoire-panel { margin: 0 0 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: 0 8px 24px rgba(15, 23, 42, .12); }
.schola-repertoire-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.schola-repertoire-panel-header button { padding: 5px 8px; }
.schola-repertoire-panel ol { margin: 8px 0 0; padding-left: 34px; columns: 2; column-gap: 36px; }
.schola-repertoire-panel li { break-inside: avoid; padding: 5px 7px; margin: 0 0 4px; border-radius: 6px; color: var(--muted); }
.schola-repertoire-panel li.current { background: var(--accent-soft); color: var(--text); font-weight: 900; }

.schola-content {
    min-height: 50vh;
    padding: 24px 22px 40px;
    background: var(--content-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow-wrap: break-word;
    font: var(--schola-render-font-size)/1.62 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    transition: font-size .12s ease, background .18s ease;
}
.schola-content.lyrics-mode { font-family: Georgia, "Times New Roman", serif; line-height: 1.72; }
.schola-content.wrap-mode .section-body { white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.schola-content.fit-mode .section-body { white-space: pre; overflow: visible; overflow-wrap: normal; word-break: normal; }
.schola-content.two-columns { column-count: 2; column-gap: var(--schola-column-gap); column-rule: 1px solid var(--line); }
.schola-content .section-block { display: inline-block; width: 100%; margin: 0 0 .9em; break-inside: avoid-column; page-break-inside: avoid; vertical-align: top; }
.schola-content .section-body { display: block; min-width: 0; }
.schola-content .section-heading { display: block; margin: .25em 0 .18em; color: var(--heading); font-weight: 900; font-family: system-ui, sans-serif; font-size: .78em; text-transform: none; }
.schola-content .chord-bracket { color: var(--muted); font-weight: 800; }
.schola-content .chord { color: var(--chord); font-weight: 900; cursor: pointer; text-decoration: underline dotted transparent; text-underline-offset: 3px; }
.schola-content .chord:hover, .schola-content .chord:focus { text-decoration-color: currentColor; outline: none; }
.schola-content .local-shift { display: block; width: fit-content; padding: 2px 7px; margin: 4px 0; border-left: 3px solid #8b5cf6; color: #7c3aed; background: rgba(139, 92, 246, .12); font: 12px/1.4 system-ui, sans-serif; }
body.dark-theme .schola-content .local-shift { color: #c4b5fd; }
.schola-empty-lyrics { display: block; padding: 12px; margin-bottom: 18px; border: 1px dashed var(--muted); border-radius: 9px; color: var(--muted); font: 14px/1.45 system-ui, sans-serif; break-inside: avoid; }

.schola-chord-tooltip {
    position: fixed;
    z-index: 1000;
    width: 166px;
    min-height: 186px;
    padding: 8px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #94a3b8;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .35);
    color: #0f172a;
}
.schola-chord-tooltip svg { display: block; margin: 0 auto; }
.schola-chord-tooltip .missing-diagram { padding: 24px 10px; text-align: center; color: #dc2626; font-weight: 800; }

.schola-footer { min-height: 38px; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
#scholaOfflineBadge { color: #15803d; }
body.network-offline #scholaOfflineBadge { color: var(--red); }
body.schola-fullscreen .schola-footer { display: none; }
body.schola-fullscreen .schola-app { padding-bottom: 18px; }

@media (max-width: 900px) {
    .schola-header { align-items: flex-start; }
    .schola-header-actions { max-width: 62%; }
    .follow-master-btn { max-width: 100%; font-size: 12px; padding: 8px; }
    .schola-option-switch button, #fullscreenBtn { font-size: 12px; padding: 8px; }
    .schola-app { padding: 10px 10px 70px; }
    .schola-song-topbar { padding: 11px; gap: 8px; }
    .schola-position { min-width: 48px; padding: 6px; }
    .schola-next-info { display: none; }
    .schola-meta-row { padding: 8px; gap: 5px; }
    .schola-meta-row > span { padding: 4px 6px; font-size: 13px; }
    .schola-strumming { flex-basis: 100%; }
    .schola-view-toolbar { top: 62px; }
    .schola-toolbar-main, .schola-toolbar-secondary { align-items: stretch; }
    .schola-view-switch { width: 100%; }
    .schola-view-switch button { flex: 1; }
    .schola-layout-controls { width: 100%; }
    .schola-layout-controls button { flex: 1 1 auto; }
    .schola-scroll-controls, .schola-font-controls { flex: 1 1 auto; }
    .schola-content { padding: 18px 12px 34px; border-radius: 10px; }
}

@media (max-width: 640px) {
    .schola-header { flex-direction: column; align-items: stretch; }
    .schola-header-actions { max-width: none; width: 100%; display: flex; flex-wrap: wrap; justify-content: stretch; }
    .schola-follow-switch { flex:1 1 190px; }
    .schola-theme-switch { flex:1 1 155px; }
    .schola-header-actions > .schola-option-switch button { flex:1; }
    .schola-brand small { max-width: 88vw; }
    .schola-view-toolbar { top: 104px; }
    .schola-update-notice { top: 104px; }
    .schola-repertoire-panel ol { columns: 1; }
    .schola-content.two-columns { column-count: 1; }
    #columnsSwitch { display: none; }
    .schola-toolbar-secondary { flex-direction: column; align-items: stretch; }
    .schola-scroll-controls, .schola-font-controls { justify-content: center; }
}

@media (orientation: landscape) and (min-width: 700px) {
    .schola-content.two-columns { column-count: 2; }
}


/* 9.8.4 — stan połączenia LAN */
.schola-lan-badge { display:inline-flex; align-items:center; padding:7px 10px; border-radius:999px; background:#e2e8f0; color:#334155; border:1px solid #cbd5e1; font-size:12px; font-weight:800; white-space:nowrap; }
.schola-lan-badge.active { background:#ede9fe; color:#5b21b6; border-color:#a78bfa; }
body.dark-theme .schola-lan-badge { background:#334155; color:#e2e8f0; border-color:#475569; }
body.dark-theme .schola-lan-badge.active { background:#4c1d95; color:#ede9fe; border-color:#8b5cf6; }
body.lan-only .schola-live-dot { background:#a855f7; box-shadow:0 0 0 5px rgba(168,85,247,.18); }
@media(max-width:760px){ .schola-lan-badge { font-size:10px; padding:6px 8px; } }


/* 9.8.10 — Dopasuj korzysta z faktycznej szerokości kolumny. */
.schola-content.fit-mode { overflow-x:hidden; }
.schola-content.fit-mode .section-body { max-width:100%; }
