/* Takt Joe – Stylesheet (mobile first) */
:root {
  --bg: #f4f5f8; --card: #ffffff; --text: #1d2130; --muted: #6b7185; --line: #e2e5ee;
  --primary: #1f2a44; --primary-text: #ffffff; --accent: #f6c453; --accent-text: #1d2130;
  --ok: #2e8b57; --warn: #d9822b; --danger: #c73e3e; --info: #2f6fdd;
  --radius: 12px; --shadow: 0 1px 3px rgba(20, 25, 40, .08), 0 4px 16px rgba(20, 25, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
.muted { font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; background: var(--primary); color: var(--primary-text); padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.brand { color: var(--primary-text); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; display: flex; align-items: center; gap: .4rem; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.4rem; line-height: 1; }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; margin-left: auto; }
.nav a { color: rgba(255,255,255,.85); padding: .4rem .65rem; border-radius: 8px; font-size: .95rem; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.nav-toggle { display: none; margin-left: auto; background: transparent; border: 0; color: #fff; font-size: 1.5rem; padding: .2rem .5rem; cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--primary); flex-direction: column; padding: .5rem; box-shadow: 0 8px 16px rgba(0,0,0,.25); }
  .nav.open { display: flex; }
  .nav a { padding: .7rem 1rem; font-size: 1.05rem; }
}

/* Live-Leiste (global) */
.live-bar { position: sticky; top: 0; z-index: 29; background: var(--accent); color: var(--accent-text); padding: .5rem 1rem; display: flex; align-items: center; gap: .75rem; font-weight: 600; cursor: pointer; }
.live-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; flex: none; }
.live-bar .lb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-bar .lb-part { font-weight: 400; opacity: .85; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Layout */
.app { max-width: 1100px; margin: 0 auto; padding: 1rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
.app.wide { max-width: none; padding: 0; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; flex: 1; min-width: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card.tight { padding: .65rem .85rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 10px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; background: #e9ebf2; color: var(--text); line-height: 1.2; transition: filter .15s; text-decoration: none; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger.ghost { color: var(--danger); background: transparent; border-color: rgba(199,62,62,.4); }
.btn.sm { padding: .35rem .65rem; font-size: .85rem; border-radius: 8px; }
.btn.xs { padding: .2rem .45rem; font-size: .78rem; border-radius: 6px; }
.btn.big { padding: 1rem 1.5rem; font-size: 1.15rem; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { padding: .45rem .55rem; }

/* Formulare */
label.field { display: block; margin-bottom: .75rem; }
label.field > span, .field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,221,.35); border-color: var(--info); }
textarea { min-height: 80px; resize: vertical; }
select.inline, input.inline { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.checks label { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.form-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.error { color: var(--danger); font-weight: 600; }
.hint { font-size: .85rem; color: var(--muted); }

/* Listen & Tabellen */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: .88rem; }
.list a.rowlink { color: inherit; display: block; }
.list a.rowlink:hover { text-decoration: none; color: var(--info); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: #fff8e3; }

/* Badges & Chips */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e9ebf2; color: var(--text); vertical-align: middle; white-space: nowrap; }
.badge.ok { background: #dff3e6; color: #1f6b3d; }
.badge.warn { background: #fdebd6; color: #9a5310; }
.badge.danger { background: #f9dcdc; color: #8f2626; }
.badge.info { background: #dfe9fb; color: #1e4c9e; }
.badge.accent { background: var(--accent); color: var(--accent-text); }
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .78rem; background: #eef0f6; color: var(--muted); margin: .1rem .15rem .1rem 0; }
.role { text-transform: capitalize; }

/* Toasts & Modal */
.toasts { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 100; width: min(92vw, 420px); }
.toast { background: #2a2f3f; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); animation: fadein .2s; font-weight: 500; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; background: rgba(15,18,30,.55); z-index: 90; display: flex; align-items: flex-end; justify-content: center; padding: 0; animation: fadein .15s; }
@media (min-width: 640px) { .modal-back { align-items: center; padding: 1rem; } }
.modal { background: var(--card); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 1.1rem; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal.wide { max-width: 860px; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* Login */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .logo { font-size: 3rem; text-align: center; color: var(--primary); }
.auth h1 { text-align: center; }

/* Startseite */
.hero { background: linear-gradient(135deg, var(--primary), #33456f); color: #fff; border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.hero h2 { margin: 0 0 .25rem; color: var(--accent); font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; }
.hero .big { font-size: 1.5rem; font-weight: 700; }
.hero a { color: #fff; }
.hero .btn { background: var(--accent); color: var(--accent-text); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; }
.tile { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: .7rem .9rem; }
.tile .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .82rem; }

/* Dropzone */
.dropzone { border: 2px dashed #b9bfd0; border-radius: var(--radius); padding: 1.5rem 1rem; text-align: center; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone.over { background: #eef3ff; border-color: var(--info); color: var(--info); }
.dropzone input { display: none; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.progress > div { height: 100%; background: var(--info); width: 0; transition: width .2s; }

/* Setlist-Editor */
.block { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; background: var(--card); }
.block-head { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: #f0f2f7; border-radius: var(--radius) var(--radius) 0 0; }
.block-head input { font-weight: 700; background: transparent; border-color: transparent; }
.block-head input:focus { background: #fff; }
.item { display: flex; align-items: center; gap: .5rem; padding: .45rem .75rem; border-top: 1px solid var(--line); }
.item.break { background: #fbf6ea; }
.item .idx { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; font-size: .85rem; }
.item .main { flex: 1; min-width: 0; }
.item.current { background: #fff3c4; box-shadow: inset 4px 0 0 var(--accent); }
.item.current .title::before { content: "▶ "; color: var(--warn); }
.item .ctrls { display: flex; gap: .2rem; }
.item.done { opacity: .6; }

/* Live-Modus */
.live-banner { background: linear-gradient(160deg, #1f2a44, #2f3f66); color: #fff; border-radius: 18px; padding: 1.5rem; text-align: center; box-shadow: var(--shadow); }
.live-banner .block-name { color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; font-weight: 700; }
.live-banner .song { font-size: 1.9rem; font-weight: 800; line-height: 1.15; margin: .4rem 0 .15rem; }
.live-banner .composer { opacity: .8; }
.live-banner .mypart { margin: 1rem 0 .5rem; font-size: 1.1rem; }
.live-banner .mypart strong { font-size: 1.35rem; }
.live-banner select { width: auto; max-width: 100%; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.live-banner select option { color: #000; }
.live-banner .btn.big { margin-top: .75rem; width: 100%; max-width: 420px; }
.countdown { font-size: 3.5rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .04em; line-height: 1; margin: .5rem 0; }
.countdown.over { color: var(--danger); }
.control-panel .navbtns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.att-user { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--line); font-size: .93rem; }
.att-user:first-child { border-top: 0; }
.att-user .st { width: 1.5em; text-align: center; }
.att-summary { display: flex; flex-wrap: wrap; gap: .4rem; }
.att-summary .badge { font-size: .82rem; padding: .25rem .6rem; }

/* PDF-Viewer */
.viewer { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: #2b2e38; color: #fff; }
.viewer-toolbar { display: flex; align-items: center; gap: .35rem; padding: .4rem .6rem; background: #1c1f28; flex-wrap: wrap; position: relative; z-index: 5; padding-top: calc(.4rem + env(safe-area-inset-top)); }
.viewer-toolbar .title { flex: 1; min-width: 120px; font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-toolbar .title small { display: block; font-weight: 400; opacity: .7; font-size: .78rem; }
.viewer-toolbar .btn { background: #343846; color: #fff; padding: .4rem .6rem; font-size: .88rem; }
.viewer-toolbar .btn.on { background: var(--accent); color: var(--accent-text); }
.viewer-toolbar .btn.warnbg { background: var(--warn); }
.viewer-tools { display: flex; align-items: center; gap: .35rem; padding: .35rem .6rem; background: #252833; flex-wrap: wrap; font-size: .85rem; }
.viewer-tools .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.viewer-tools .swatch.on { border-color: #fff; box-shadow: 0 0 0 2px #252833 inset; }
.viewer-pages { flex: 1; overflow: auto; padding: .5rem; -webkit-overflow-scrolling: touch; scroll-snap-type: y mandatory; scroll-padding-top: .5rem; }
.viewer-pages.drawing { touch-action: none; }
/* Seitenweises Scrollen: jede Scroll-Geste springt zur nächsten Seite; ist eine Seite höher als der Bildschirm, kann innerhalb frei gescrollt werden */
.page { position: relative; margin: 0 auto .6rem; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.4); scroll-snap-align: start; scroll-snap-stop: always; }
.page canvas { display: block; }
.page canvas.overlay { position: absolute; inset: 0; pointer-events: none; }
.page.drawing canvas.overlay { pointer-events: auto; touch-action: none; cursor: crosshair; }
.viewer .notice { background: var(--accent); color: var(--accent-text); padding: .45rem .8rem; font-size: .9rem; display: flex; gap: .5rem; align-items: center; }
.viewer .notice.info { background: #2f6fdd; color: #fff; }
.viewer .notice a { color: inherit; font-weight: 700; }
.lockinfo { font-size: .82rem; opacity: .85; }

/* Scan */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.thumb { position: relative; border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 3/4; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 0 .4rem; border-radius: 4px; }
.thumb .ctrls { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.55); }
.thumb .ctrls button { background: transparent; border: 0; color: #fff; padding: .25rem .5rem; cursor: pointer; }

/* Sonstiges */
.kbd { font-family: monospace; background: #eef0f6; padding: 0 .3rem; border-radius: 4px; }
.searchbox { position: relative; }
.searchbox input { padding-left: 2.2rem; }
.searchbox::before { content: "🔍"; position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); font-size: .9rem; opacity: .6; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.filters select, .filters label { width: auto; }
.song-card { display: flex; gap: .75rem; align-items: center; }
.song-card .main { flex: 1; min-width: 0; }
.song-card .title { font-weight: 700; font-size: 1.05rem; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: .75rem 0 .25rem; display: flex; gap: .5rem; justify-content: flex-end; }
.version-list { font-size: .85rem; margin: .3rem 0 0 1rem; color: var(--muted); }
@media (max-width: 600px) { .hide-sm { display: none !important; } }
@media print { .topbar, .live-bar, .toasts { display: none; } }

/* Sichtbarkeits-Umschalter auf der Liedseite */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 0; margin: 1rem 0 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); max-width: 100%; }
.segmented button { border: 0; background: transparent; padding: .4rem .85rem; font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--primary); color: var(--primary-text); }

/* Besetzungsstruktur (Drag & Drop) */
.struct-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; margin-top: .75rem; }
.struct-col, .struct-pool { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; background: #f8f9fc; }
.struct-pool { margin-top: .5rem; border-style: dashed; }
.struct-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; flex-wrap: wrap; }
.struct-reg { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: .45rem .5rem; margin-top: .5rem; }
.struct-handle { cursor: grab; font-weight: 600; touch-action: none; user-select: none; -webkit-user-select: none; }
.struct-parts { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.6rem; }
.struct-chip { display: inline-block; padding: .25rem .6rem; border-radius: 999px; background: #e9ebf2; font-size: .82rem; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.struct-chip.inactive { opacity: .5; text-decoration: line-through; }
.dragging { opacity: .35; }
.drop-over { outline: 2px dashed var(--info); outline-offset: 2px; background: #eef4ff; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: translate(-50%, -60%); box-shadow: var(--shadow); opacity: .95; background: var(--accent); border-radius: 999px; padding: .25rem .6rem; font-size: .82rem; }
