@font-face {
  font-family: "Source Sans 3"; font-weight: 400; font-display: block;
  src: url(vendor/fonts/source-sans-3-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+266D, U+266F;
}
@font-face {
  font-family: "Source Sans 3"; font-weight: 400; font-display: block;
  src: url(vendor/fonts/source-sans-3-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3"; font-weight: 700; font-display: block;
  src: url(vendor/fonts/source-sans-3-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+266D, U+266F;
}
@font-face {
  font-family: "Source Sans 3"; font-weight: 700; font-display: block;
  src: url(vendor/fonts/source-sans-3-latin-ext-700-normal.woff2) format("woff2");
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #1d1f23;
  --muted: #6b6f78;
  --line: #e2ded6;
  --accent: #c2410c;
  --chord: #b4410a;
  --chorus: #f1ece2;
  --danger: #b91c1c;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --panel: #1d2026;
  --text: #ecebe8;
  --muted: #9aa0ab;
  --line: #2e323a;
  --accent: #fb923c;
  --chord: #fdba74;
  --chorus: #23272e;
  --danger: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 16px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

#offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; text-align: center;
  background: #854d0e; color: #fff; font-size: 13px; padding: 2px;
}
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: calc(100% - 32px);
}

/* ---------- Grundbausteine ---------- */

.page { max-width: 960px; margin: 0 auto; padding: 16px 16px 80px; }
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.topbar h1 { font-size: 22px; margin: 0; flex: 1; min-width: 120px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs .spacer { flex: 1; }
.tabs a.logout { color: var(--muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  text-decoration: none;
  min-width: 40px; min-height: 40px; border: 0; background: none; cursor: pointer; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text);
}
.icon-btn:active { background: var(--line); }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
}
textarea { font-family: var(--mono); font-size: 14px; line-height: 1.5; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 120px; }
.row > .field.narrow { flex: 0 0 90px; min-width: 90px; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 8px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.badge {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px;
  background: var(--chorus); color: var(--muted); white-space: nowrap;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips.cats { margin-top: -4px; }
.chips.cats .chip { font-size: 13px; padding: 2px 10px; }
.profile { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.profile h3 { margin: 0 0 8px; font-size: 15px; }
.profile select { margin-bottom: 8px; }

.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.login h1 { font-size: 28px; margin-bottom: 4px; }

/* ---------- Listen ---------- */

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; cursor: pointer;
}
.list .item:active { background: var(--chorus); }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .key { font-family: var(--mono); color: var(--chord); font-weight: 600; min-width: 3ch; text-align: right; }
.list .pos { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------- Editor ---------- */

.editor { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .page.wide { max-width: 1400px; }
  .editor { grid-template-columns: 1fr 1fr; }
  .editor .preview { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
}
.editor textarea { min-height: 50vh; }
.preview { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---------- Song-Darstellung ---------- */

.song { font-family: "Source Sans 3", var(--font); font-size: var(--size, 20px); line-height: 1.25; }
.song-head { margin-bottom: .8em; break-inside: avoid; }
.song-head .t { font-size: 1.3em; font-weight: 700; }
.song-head .a { color: var(--muted); }
.song-head .m { color: var(--muted); font-size: .8em; margin-top: .2em; }
.song-head .m b { color: var(--chord); }
.block { margin-bottom: .9em; break-inside: avoid; }
.block.chorus { background: var(--chorus); border-left: 3px solid var(--accent); padding: .3em .6em; border-radius: 4px; }
.block.tab pre { font-family: var(--mono); font-size: .75em; margin: 0; white-space: pre; overflow: hidden; }
.block .label { font-weight: 700; font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .2em 0; }
.line { display: flex; flex-wrap: wrap; align-items: flex-end; min-height: 1.25em; }
.seg { display: inline-flex; flex-direction: column; white-space: pre; position: relative; }
.line.has-chords .seg.float { padding-top: 1.2em; }
.line.has-chords .seg.float .c { position: absolute; top: 0; left: 0; white-space: nowrap; }
.seg.tail .c { padding-left: .4em; }
.seg .c.sym { color: var(--muted); font-weight: 400; }
.seg .c { color: var(--chord); font-weight: 700; padding-right: .35em; min-height: 1.2em; }
.line:not(.has-chords) .seg .c { display: none; }
.line.chords-only .seg .l { display: none; }

/* ---------- Spielansicht ---------- */

.player { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 10; }
.player-bar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto;
}
.player-bar .title { flex: 1; min-width: 80px; padding: 0 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.player-bar .title small { font-weight: 400; color: var(--muted); }
.player-bar .val { font-family: var(--mono); min-width: 3ch; text-align: center; font-size: 14px; }
.player-bar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
.player.hide-bar .player-bar { display: none; }
.stage { position: relative; flex: 1; overflow: hidden; margin: 16px 16px max(4px, env(safe-area-inset-bottom)); }
.device { position: absolute; top: 0; transform-origin: top left; }
.frame { position: absolute; top: 0; overflow: hidden; transform-origin: top left; }
/* Vorschau: simulierter Bildschirm mit Rahmen */
.player.previewing .stage { background: repeating-linear-gradient(45deg, transparent 0 10px, var(--line) 10px 11px); }
.player.previewing .device { background: var(--bg); outline: 2px solid var(--accent); outline-offset: 8px; border-radius: 4px; }
.preview-sel { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13px; margin-left: 4px; }
.icon-btn:disabled { opacity: .35; }
.sheet { height: 100%; column-gap: 32px; column-fill: auto; transition: transform .18s ease-out; }
.sheet .end { display: block; height: 0; }
.pdf-pages { height: 100%; display: flex; gap: 16px; justify-content: center; align-items: flex-start; }
.pdf-pages canvas { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); max-height: 100%; }
.status {
  position: absolute; right: 0; bottom: 0; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.flash {
  position: absolute; top: 50%; transform: translateY(-50%); font-size: 48px; color: var(--accent); opacity: 0;
  pointer-events: none; transition: opacity .3s;
}
.flash.show { opacity: .7; transition: none; }
.flash.next { right: 12px; }
.flash.prev { left: 12px; }
.next-up { position: absolute; left: 0; bottom: 0; font-size: 12px; color: var(--muted); pointer-events: none; }

/* ---------- Notizen ---------- */

.note {
  display: inline-block; align-self: flex-end; margin: 0 0 .1em .5em; padding: 0 .45em; border-radius: 4px;
  font-size: .72em; font-weight: 700; line-height: 1.5; color: #1a1a1a; white-space: pre-wrap; cursor: pointer;
}
.note small { font-weight: 400; opacity: .75; }
.note.private { outline: 1.5px dashed rgba(0,0,0,.45); outline-offset: -1.5px; }
.note.c-yellow { background: #fde047; }
.note.c-red { background: #fca5a5; }
.note.c-blue { background: #93c5fd; }
.note.c-green { background: #86efac; }
.block.tab .note { margin: .2em .5em 0 0; }
.player.note-mode .sheet [data-b] { cursor: copy; border-radius: 4px; }
.player.note-mode .sheet [data-b]:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.player.note-mode .stage { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 6px; }
.icon-btn.on { background: var(--accent); color: #fff; }

/* ---------- Dialog ---------- */

.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 420px; }
.modal h2 { margin: 0 0 12px; font-size: 17px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }
.swatches { display: flex; gap: 8px; margin: 4px 0 12px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }

/* ---------- Freihand ---------- */

.ink { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.player.draw-mode .ink { pointer-events: auto; touch-action: none; cursor: crosshair; }
.player.draw-mode .stage { box-shadow: inset 0 0 0 2px #2563eb; border-radius: 6px; }
.pdf-page { position: relative; line-height: 0; }
.drawbar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 8px;
}
.drawbar .sep { width: 1px; height: 22px; background: var(--line); }
.swatch.small { width: 26px; height: 26px; }
.check.small { font-size: 13px; gap: 4px; }

/* ---------- Übungsplayer ---------- */

.practice {
  border-top: 1px solid var(--line); background: var(--panel); padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
}
.practice .row1, .practice .row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.practice .seek { flex: 1; min-width: 140px; accent-color: var(--accent); }
.practice .time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.practice .rec-sel { width: auto; max-width: 260px; min-height: 32px; padding: 2px 8px; font-size: 14px; }
.practice .grp { display: inline-flex; gap: 4px; align-items: center; font-size: 14px; margin-right: 8px; }
.practice .pct { min-width: 4.5ch; text-align: center; font-variant-numeric: tabular-nums; }
.practice .play { min-width: 44px; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.recs { margin-top: 16px; }
body:has(.practice:not([hidden])) #toast { bottom: 120px; }

.offline-info { margin: 0 0 12px; font-size: 14px; }
.offline-info.ok { color: #16a34a; }
:root[data-theme="dark"] .offline-info.ok { color: #4ade80; }
