:root {
    --bg: #0f1216;
    --bg-2: #171b22;
    --card: #1c2129;
    --card-2: #232935;
    --line: #2c333f;
    --text: #e6e9ee;
    --muted: #8b95a5;
    --accent: #f56607;
    --accent-2: #ffb020;
    --ok: #37c98a;
    --radius: 12px;
    --wave: #4a5568;
    --wave-progress: #f56607;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: radial-gradient(1200px 600px at 50% -10%, #1a2029 0%, var(--bg) 60%);
    color: var(--text);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 24px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 42px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.brand-sub strong { color: var(--accent); font-weight: 700; }

.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 28px 20px 60px; flex: 1; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
}

/* Hero / Home */
.hero h1 { font-size: 30px; line-height: 1.2; margin: 8px 0 12px; }
.lead { color: var(--muted); font-size: 17px; }

.upload-form h2 { margin-top: 0; }
label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
label small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], textarea, select {
    width: 100%; padding: 11px 13px; border-radius: 9px;
    border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
    font-size: 15px;
}
input[type=file] {
    width: 100%; padding: 11px; border-radius: 9px;
    border: 1px dashed var(--line); background: var(--bg-2); color: var(--muted);
}
textarea { resize: vertical; font-family: inherit; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line); background: var(--card-2); color: var(--text);
    padding: 11px 18px; border-radius: 9px; font-size: 15px; cursor: pointer;
    font-weight: 600; transition: .15s;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff734f; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 8px 13px; font-size: 14px; }
.btn-play { min-width: 92px; justify-content: center; }
.hint, .hint-inline { color: var(--muted); font-size: 13px; }
.hint { margin-top: 12px; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 8px; }
.features > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.features h3 { margin: 0 0 6px; font-size: 16px; }
.features p { margin: 0; color: var(--muted); font-size: 14px; }
@media (max-width: 700px) { .features { grid-template-columns: 1fr; } }

/* Projektkopf */
.project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.project-head h1 { margin: 0 0 6px; font-size: 26px; }
.meta { color: var(--muted); margin: 0; font-size: 14px; }
.role-badge {
    display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; padding: 2px 8px; border-radius: 20px; margin-right: 4px;
    background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.role-owner { background: rgba(255,92,56,.15); color: var(--accent); border-color: transparent; }
.role-commenter { background: rgba(55,201,138,.15); color: var(--ok); border-color: transparent; }
.role-viewer { background: rgba(139,149,165,.15); }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: rgba(55,201,138,.15); color: var(--ok); border: 1px solid rgba(55,201,138,.3); }
.flash.warn { background: rgba(255,176,32,.12); color: var(--accent-2); border: 1px solid rgba(255,176,32,.35); }
.banner-full { font-size: 15px; line-height: 1.6; padding: 16px 18px; }

/* Versions-Bar */
.version-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.vb-label { color: var(--muted); font-size: 14px; }
.version-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.vtab {
    background: var(--card); border: 1px solid var(--line); color: var(--text);
    padding: 7px 12px; border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.vtab:hover { border-color: var(--muted); }
.vtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.new-badge {
    background: var(--accent-2); color: #1a1200; font-size: 10px; font-weight: 800;
    padding: 1px 6px; border-radius: 10px; margin-left: 4px; vertical-align: middle;
}
.upload-inline { margin-bottom: 18px; }

/* Player */
.player-card { padding-top: 18px; position: relative; }

/* Marker-Popover */
.marker-popover {
    position: absolute; z-index: 30; width: 260px; max-width: 80vw;
    background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
    transform: translateX(-50%);
}
.marker-popover::after {
    content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
    border: 8px solid transparent; border-top-color: var(--card-2); border-bottom: 0;
}
.pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pop-head .avatar { width: 28px; height: 28px; font-size: 12px; }
.pop-author { font-weight: 700; font-size: 14px; }
.pop-ts { color: var(--accent); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pop-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.pop-actions { display: flex; gap: 6px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pop-actions button {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
    color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
}
.pop-actions button:hover { color: var(--text); border-color: var(--accent); }
.pop-close { position: absolute; top: 6px; right: 9px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.pop-close:hover { color: var(--text); }
.marker-popover.resolved .pop-body { text-decoration: line-through; opacity: .7; }
.version-info { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.waveform-wrap { position: relative; }
#waveform { background: var(--bg-2); border-radius: 9px; padding: 6px 4px; cursor: pointer; min-height: 96px; }
.ws-loading {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
    background: rgba(23,27,34,.78); border-radius: 9px; z-index: 20; color: var(--muted); font-size: 14px;
}
.spinner {
    width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent);
    border-radius: 50%; animation: tn-spin .8s linear infinite;
}
@keyframes tn-spin { to { transform: rotate(360deg); } }
/* Marker liegen jetzt IN der Wellenform (im wavesurfer-Wrapper) und zoomen/scrollen mit */
/* Dünne Linie in der Wellenform als Positions-Anker (die Raute liegt im Streifen darunter) */
.tn-marker {
    position: absolute; top: 0; height: 100%; width: 2px; z-index: 5;
    background: var(--accent-2); transform: translateX(-1px); cursor: pointer;
}
.tn-marker::after {
    content: attr(data-label); position: absolute; top: 2px; left: 4px;
    font-size: 10px; color: #fff; background: rgba(0,0,0,.7); padding: 0 4px;
    border-radius: 3px; white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .12s;
}
.tn-marker:hover::after { opacity: 1; }
.tn-marker:hover { box-shadow: 0 0 6px var(--accent-2); }
.tn-marker.resolved { background: var(--ok); opacity: .6; }
.tn-marker.carried { background: #6b8fd6; }
.tn-marker.carried::after { color: #cfe0ff; }
.tn-marker.preview {
    width: 3px; background: var(--accent); box-shadow: 0 0 10px var(--accent);
    animation: tn-pulse 1s ease-in-out infinite; z-index: 6;
}
.tn-marker.preview::after { background: var(--accent); color: #fff; font-weight: 700; opacity: 1; }

/* Rauten-Streifen UNTER der Wellenform (scrollt/zoomt via JS mit der Welle mit) */
.marker-strip { position: relative; height: 18px; margin-top: 6px; overflow: hidden; }
.marker-strip .mtrack { position: absolute; top: 0; left: 4px; height: 100%; }
.tn-pin {
    position: absolute; top: 2px; width: 16px; height: 16px;
    transform: translateX(-50%); cursor: pointer;
}
.tn-pin.movable { cursor: pointer; } /* fest: Tippen öffnet nur das Popover */
/* scharfgeschaltet über „✥ verschieben" im Popover: jetzt ziehbar */
.tn-pin.armed { cursor: grab; touch-action: none; z-index: 6; }
.tn-pin.armed.dragging, .tn-pin.dragging { cursor: grabbing; }
.tn-dia {
    position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
    background: var(--accent-2); transform: rotate(45deg);
    border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.4);
    transition: transform .12s;
}
.tn-pin:hover .tn-dia, .tn-pin.dragging .tn-dia { box-shadow: 0 0 7px rgba(255,255,255,.6); }
.tn-pin.armed .tn-dia {
    box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 10px #fff;
    transform: rotate(45deg) scale(1.35);
    animation: tn-pulse 1s ease-in-out infinite;
}
/* Farbe der Raute kommt pro Autor per Inline-Style; Zustände nur als Zusatz-Signal */
.tn-pin.resolved .tn-dia { opacity: .4; }                                   /* erledigt: gedimmt */
.tn-pin.carried .tn-dia { box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 0 3px rgba(255,255,255,.55); } /* übernommen: heller Ring */

/* Farb-Legende (wer hat welche Farbe) */
.marker-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); box-shadow: 0 0 0 1px rgba(0,0,0,.4); flex: none; }
.move-hint {
    position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%);
    background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,.35); z-index: 7; pointer-events: none;
}
@keyframes tn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.zoom-group { display: inline-flex; gap: 4px; }
.transport { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn-icon { min-width: 44px; justify-content: center; font-variant-numeric: tabular-nums; }
.transport .time { margin-left: 6px; }

/* Namens-Abfrage / -Änderung */
.name-prompt { border-color: var(--accent); }
.name-prompt h2 { margin-top: 0; }
.name-prompt-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.name-prompt-form input { flex: 1; min-width: 200px; }
.name-edit { margin-top: 6px; }
.name-edit summary { color: var(--accent-2); cursor: pointer; font-size: 13px; width: max-content; }
.name-edit summary:hover { text-decoration: underline; }
.name-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.name-form input { width: auto; min-width: 200px; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

/* Composer als Overlay/Bottom-Sheet */
.composer-overlay {
    position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55);
    display: flex; align-items: flex-end; justify-content: center;
}
.composer-overlay .comment-compose {
    width: 100%; max-width: 640px; margin: 0;
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.5);
    padding-bottom: max(22px, env(safe-area-inset-bottom));
}
/* Player während des Schreibens über den abgedunkelten Hintergrund heben,
   damit der Vorschau-Marker klar sichtbar bleibt (kein Überlappen: Sheet ist unten). */
.player-card.spotlight { position: relative; z-index: 61; }
.comment-compose .compose-head { margin-bottom: 8px; font-size: 15px; }
.comment-compose textarea { min-height: 90px; }
.compose-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* „Notiz an aktueller Stelle"-Button */
.add-note-btn { margin: 4px 0 14px; }

/* Kommentare */
.comments { margin-bottom: 28px; }
.comments h2 { font-size: 19px; }
.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
    display: grid; grid-template-columns: 40px 1fr; gap: 12px;
}
.comment.resolved { background: var(--bg-2); }
.comment.resolved .avatar { opacity: .5; }
.comment.resolved .c-author,
.comment.resolved .c-date { color: var(--muted); }
.comment.resolved .c-body { color: var(--muted); text-decoration: line-through; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 15px;
}
.c-main { min-width: 0; }
.c-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.c-author { font-weight: 700; }
.c-ts { color: var(--accent-2); font-variant-numeric: tabular-nums; cursor: pointer; font-size: 13px; font-weight: 600; }
.c-ts:hover { text-decoration: underline; }
.c-date { color: var(--muted); font-size: 12px; }
.c-body { white-space: pre-wrap; word-break: break-word; }
.c-actions { display: flex; gap: 12px; margin-top: 6px; }
.c-actions button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.c-actions button:hover { color: var(--text); text-decoration: underline; }
.empty { color: var(--muted); font-style: italic; }

/* Übernommene Notizen */
.carried-badge {
    display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .03em; padding: 2px 7px; border-radius: 20px; margin-right: 4px;
    background: rgba(107,143,214,.18); color: #8fb0ee; border: 1px dashed #6b8fd6;
}
.comment.carried { border-left: 3px solid #6b8fd6; }

/* Threads / Antworten */
.thread { display: flex; flex-direction: column; gap: 8px; }
.replies { margin-left: 40px; display: flex; flex-direction: column; gap: 8px; padding-left: 12px; border-left: 2px solid var(--line); }
.comment.reply { background: var(--bg-2); }
.reply-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.reply-form textarea { min-height: 60px; }
.reply-form button { align-self: flex-end; }

/* Bearbeiten-Formular (Popover und Kommentarliste) */
.edit-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.edit-form textarea { min-height: 60px; font-size: 13px; }
.edit-time { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.edit-time .ts-input {
    width: 90px; font-variant-numeric: tabular-nums; text-align: center;
}
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Checkbox-Zeile */
.checkbox-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.checkbox-row input { width: auto; margin-top: 3px; }
.checkbox-row span { margin: 0; color: var(--text); font-size: 14px; }

/* Popover-Antworten */
.pop-replies { margin: 4px 0 8px; border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.pop-reply { font-size: 13px; color: var(--text); }
.pop-replyform { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.pop-replyform textarea { min-height: 50px; font-size: 13px; }
.pop-replyform button { align-self: flex-end; }

/* Einladen */
.invite-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline > span { margin: 0; }
.inline select { width: auto; }
.invite-list { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.invite-item { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.invite-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn-remove-invite {
    background: none; border: 1px solid var(--line); color: var(--muted);
    padding: 4px 10px; border-radius: 7px; font-size: 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.btn-remove-invite:hover { color: #fff; border-color: var(--accent); background: var(--accent); }
.link-copy { width: 100%; font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.owner-note { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 14px; }
.owner-note .link-copy { margin-top: 6px; }

/* Legal / Error */
.legal h1 { margin-top: 0; }
.legal h2 { font-size: 18px; margin-top: 24px; }
.legal ul { color: var(--text); }
.muted { color: var(--muted); }
.error-box { text-align: center; }
.error-box h1 { font-size: 64px; margin: 0; color: var(--accent); }

.hidden { display: none; }

/* Auf anderem Gerät öffnen (QR + Link per Mail) */
.share-card summary { cursor: pointer; font-weight: 600; font-size: 16px; color: var(--accent-2); width: max-content; }
.share-card summary:hover { text-decoration: underline; }
.share-grid { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; margin-top: 16px; }
.qr-col { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.qrbox { background: #fff; padding: 8px; border-radius: 8px; width: 150px; height: 150px; }
.qrbox svg { width: 100%; height: 100%; display: block; }
.sendlink-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.sendlink-form input { flex: 1; min-width: 180px; }
@media (max-width: 560px) { .share-grid { grid-template-columns: 1fr; } }

/* Link vergessen? */
.recover-card { margin-top: 32px; }
.recover-card h2 { margin-top: 0; }
.recover-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.recover-form input { flex: 1; min-width: 200px; }

/* Eigene Projekte (localStorage) */
.mine-card h2 { margin-top: 0; }
.mine-list { display: flex; flex-direction: column; gap: 10px; }
.mine-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
}
.mine-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mine-title { font-weight: 700; font-size: 16px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mine-date { color: var(--muted); font-size: 13px; }
.mine-del { color: var(--muted); font-size: 13px; }
.mine-del.soon { color: var(--accent); font-weight: 600; }
.mine-open { flex-shrink: 0; text-decoration: none; }
.mine-open:hover { text-decoration: none; }
.mine-remove { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.mine-remove:hover { color: var(--accent); }
@media (max-width: 520px) {
    .mine-item { flex-wrap: wrap; }
    .mine-info { flex-basis: 100%; }
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--line); padding: 22px 24px; text-align: center;
    color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 8px;
}
.footer-links a, .footer-partners a { margin: 0 8px; }
.footer-partners span { color: var(--line); }

/* PWA-Installations-Banner */
.pwa-install {
    width: 100%; max-width: 860px; margin: 16px auto 0; padding: 12px 14px;
    display: flex; align-items: center; gap: 14px;
    background: linear-gradient(180deg, var(--card-2), var(--card));
    border: 1px solid var(--line); border-left: 4px solid var(--accent);
    border-radius: var(--radius);
}
.pwa-install[hidden] { display: none; }
.pwa-install-icon { width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto; }
.pwa-install-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.4; min-width: 0; }
.pwa-install-text strong { font-size: 15px; }
.pwa-install-text span { color: var(--muted); font-size: 13px; }
.pwa-install-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.pwa-install-close {
    background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1;
    cursor: pointer; padding: 2px 8px; border-radius: 8px;
}
.pwa-install-close:hover { color: var(--text); background: var(--bg-2); }
@media (max-width: 560px) {
    .pwa-install { align-items: flex-start; }
    .pwa-install-actions { flex-direction: column; }
}

/* FAQ */
.faq { display: flex; flex-direction: column; margin-top: 32px; }
.faq h2 { margin-top: 0; }
.faq details {
    border: 1px solid var(--line); border-radius: 10px; padding: 0 14px;
    margin-top: 10px; background: var(--bg-2);
}
.faq details[open] { border-color: var(--accent); }
.faq summary {
    cursor: pointer; padding: 13px 0; font-weight: 600; list-style: none;
    display: flex; align-items: center; gap: 8px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
    content: "＋"; color: var(--accent); font-weight: 700; width: 1em; flex: 0 0 auto;
}
.faq details[open] summary::before { content: "－"; }
.faq details p { margin: 0 0 14px; color: var(--muted); }
.faq details p a { color: var(--accent-2); }
