/* =========================================================================
   Lauschlappenparade – Stylesheet
   Warm, musikalisch, neutral und mobile first.
   ========================================================================= */

:root {
    --cream:      #f8f4eb;
    --cream-2:    #efe6d7;
    --rose:       #d8c39f;
    --rose-deep:  #b9894f;
    --red:        #b96c32;
    --red-deep:   #8e4f24;
    --ink:        #3f352d;
    --ink-soft:   #75685b;
    --white:      #fffdf8;
    --shadow:     0 18px 40px -18px rgba(104, 78, 48, 0.32);
    --radius:     22px;
    --font:       "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    color: var(--ink);
    min-height: 100vh;
    background:
        radial-gradient(90% 70% at 15% 0%, rgba(255, 218, 151, 0.24) 0%, transparent 58%),
        radial-gradient(85% 75% at 100% 100%, rgba(194, 140, 80, 0.16) 0%, transparent 62%),
        linear-gradient(160deg, #faf7f0 0%, #f2eadf 58%, #ece1d2 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

.hidden { display: none !important; }
.muted  { color: var(--ink-soft); }
.center { text-align: center; }

/* ---------- Dekoration --------------------------------------------------
   Alte Herzchen bleiben auch dann unsichtbar, wenn sie noch im HTML stehen.
   ------------------------------------------------------------------------- */
.hearts,
.hearts span,


/* Nach dem Login: gleicher ruhiger, warmer Hintergrund */
.page-player {
    background:
        radial-gradient(90% 70% at 15% 0%, rgba(255, 218, 151, 0.20) 0%, transparent 58%),
        radial-gradient(85% 75% at 100% 100%, rgba(194, 140, 80, 0.13) 0%, transparent 62%),
        linear-gradient(170deg, #faf7f0 0%, #f1e8dc 100%);
}

/* ---------- Karten ----------------------------------------------------- */
.card {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(185, 137, 79, 0.22);
    z-index: 1;
}

/* =========================================================================
   LOGIN
   ========================================================================= */
.login-wrap {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 30px 34px;
    text-align: center;
    overflow: hidden;
    animation: pop-in .6s cubic-bezier(.2,.8,.3,1.2) both;
}

/* Optionales Bild über dem Login (assets/start.jpg) – volle Kartenbreite */
.login-img {
    display: block;
    width: calc(100% + 60px);     /* gleicht das seitliche Padding der Karte aus */
    margin: -40px -30px 22px;     /* bündig an die oberen/seitlichen Kanten */
    height: auto;                 /* proportional skalieren */
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    opacity: 0;
    transition: opacity .5s ease;
}
.login-img.is-loaded { opacity: 1; }

.card-glow {
    position: absolute;
    inset: -40% -40% auto -40%;
    height: 220px;
    background: radial-gradient(closest-side, rgba(226,190,126,.34), transparent);
    filter: blur(10px);
}

@keyframes pop-in {
    0%   { opacity: 0; transform: translateY(18px) scale(.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.kicker {
    margin: 0 0 4px;
    font-size: 15px;
    letter-spacing: .3px;
    color: var(--red);
}
.title {
    margin: 0 0 6px;
    font-size: 34px;
    font-weight: 800;
    color: var(--red-deep);
    line-height: 1.1;
}
.subtitle {
    margin: 0 0 26px;
    color: var(--ink-soft);
    font-size: 15px;
}

.beat { display: inline-block; animation: beat 1.4s ease-in-out infinite; }
@keyframes beat {
    0%, 100% { transform: scale(1); }
    15%      { transform: scale(1.25); }
    30%      { transform: scale(1); }
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form input {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1.5px solid var(--rose);
    background: var(--cream);
    font-size: 16px;
    color: var(--ink);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.login-form input:focus {
    border-color: var(--rose-deep);
    box-shadow: 0 0 0 4px rgba(185,137,79,.20);
}
.login-form input.input-error {
    border-color: var(--red);
    animation: shake .4s;
}
@keyframes shake {
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.login-form button {
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .3px;
    box-shadow: 0 10px 22px -10px var(--red-deep);
    transition: transform .15s, box-shadow .15s;
}
.login-form button:hover { transform: translateY(-2px); }
.login-form button:active { transform: translateY(0); }

.error-msg {
    margin: 16px 0 0;
    color: var(--red-deep);
    font-size: 14px;
}

/* =========================================================================
   PLAYER
   ========================================================================= */
.player-wrap {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 14px 130px;   /* unten Platz für die Player-Leiste */
}

/* ---------- Hero / Header --------------------------------------------- */
.hero {
    position: relative;
    margin: 14px 0 18px;
    height: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.hero-placeholder {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 22% 20%, rgba(255, 223, 157, 0.42) 0%, transparent 36%),
        radial-gradient(circle at 82% 76%, rgba(106, 57, 33, 0.18) 0%, transparent 40%),
        linear-gradient(135deg, #d6933d 0%, #b86d32 48%, #874820 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-heart {
    font-size: 64px;
    color: rgba(255,255,255,.85);
    animation: beat 1.6s ease-in-out infinite;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,.15));
}
.hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .6s ease;
}
.hero-img.is-loaded { opacity: 1; }

.logout {
    position: absolute;
    top: 12px; right: 12px;
    background: rgba(255,255,255,.85);
    color: var(--red-deep);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

/* ---------- Controls / Filter ----------------------------------------- */
.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}
.filter-toggle {
    display: inline-flex;
    background: var(--white);
    padding: 5px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(185,137,79,.22);
}
.chip {
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 999px;
    transition: background .2s, color .2s;
}
.chip.is-active {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
    color: #fff;
}
.count {
    display: inline-block;
    min-width: 18px;
    font-size: 12px;
    background: rgba(255,255,255,.35);
    border-radius: 999px;
    padding: 0 5px;
    margin-left: 2px;
}

/* ---------- Playlist --------------------------------------------------- */
.playlist-card { padding: 8px; }
.empty-card    { padding: 30px 24px; text-align: center; margin-top: 10px; }
.empty-card code, .muted code {
    background: var(--cream-2);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: .9em;
}

.playlist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.song {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px;
    border-radius: 14px;
    transition: background .2s;
    cursor: pointer;
    user-select: none;
}
.song + .song { border-top: 1px solid rgba(185,137,79,.16); }
.song:hover { background: var(--cream); }

.song.is-playing {
    background: linear-gradient(135deg, rgba(226,190,126,.42), rgba(246,225,190,.45));
    border-top-color: transparent;
}
.song.is-playing .song-title { color: var(--red-deep); font-weight: 700; }

/* Drag-Zustände */
.song.dragging { opacity: .4; }
.song.drag-over { box-shadow: inset 0 2px 0 var(--red); }

.drag-handle {
    color: var(--rose-deep);
    font-size: 18px;
    cursor: grab;
    line-height: 1;
    touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.play-icon {
    flex: 0 0 38px;
    width: 38px; height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--cream-2);
    color: var(--red);
    font-size: 14px;
    transition: background .2s, color .2s, transform .15s;
}
.song:hover .play-icon { transform: scale(1.06); }
.song.is-playing .play-icon {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
    color: #fff;
}

.song-main { flex: 1 1 auto; min-width: 0; }
.song-title {
    display: block;
    font-size: 15px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.song-dur {
    display: block;
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 2px;
}

/* Favoriten-Checkbox */
.fav {
    flex: 0 0 auto;
    position: relative;
    width: 34px; height: 34px;
}
.fav input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fav .fav-heart {
    display: grid;
    place-items: center;
    width: 100%; height: 100%;
    font-size: 22px;
    color: var(--rose-deep);
    opacity: .55;
    transition: transform .15s, opacity .2s, color .2s;
}
.fav input:hover + .fav-heart { transform: scale(1.15); opacity: .8; }
.fav input:checked + .fav-heart {
    color: var(--red);
    opacity: 1;
    animation: beat .5s;
}

/* =========================================================================
   PLAYER-LEISTE (sticky unten)
   ========================================================================= */
.player-bar {
    position: fixed;
    z-index: 5;
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(255, 253, 248, 0.94);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(185,137,79,.30);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "info    buttons"
        "seek    seek";
    align-items: center;
    gap: 8px 12px;
    animation: pop-in .4s ease both;
}
.pb-info { grid-area: info; min-width: 0; }
.pb-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--red-deep);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pb-time { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.pb-buttons {
    grid-area: buttons;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pb-buttons button {
    background: transparent;
    color: var(--red);
    font-size: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: background .2s, transform .15s;
}
.pb-buttons button:hover { background: var(--cream-2); }
.pb-buttons button:active { transform: scale(.92); }
.pb-play {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%) !important;
    color: #fff !important;
    box-shadow: 0 8px 18px -8px var(--red-deep);
}

.pb-seek {
    grid-area: seek;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: var(--cream-2);
    outline: none;
    cursor: pointer;
}
.pb-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 2px 6px rgba(104,78,48,.38);
    cursor: pointer;
}
.pb-seek::-moz-range-thumb {
    width: 16px; height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--red);
    cursor: pointer;
}

/* ---------- Etwas mehr Luft auf grösseren Screens --------------------- */
@media (min-width: 560px) {
    .hero { height: 260px; }
    .hero-overlay h1 { font-size: 28px; }
    .song { padding: 14px; }
}

/* =========================================================================
   STATISTIK (Admin) – schlicht, mobil lesbar
   ========================================================================= */
.page-stats {
    background: linear-gradient(170deg, var(--cream) 0%, #ece4d8 100%);
}
.stats-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 14px 60px;
}
.stats-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.stats-head h1 {
    margin: 0;
    font-size: 24px;
    color: var(--red-deep);
}
.stats-logout {
    position: static;
    background: var(--white);
    box-shadow: var(--shadow);
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--white);
    border: 1px solid rgba(185,137,79,.22);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px 10px;
    text-align: center;
}
.stat-num {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--red-deep);
    line-height: 1.1;
}
.stat-label {
    display: block;
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 4px;
}

.stats-section { padding: 16px 16px 18px; margin-bottom: 16px; }
.stats-section h2 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--ink);
}
.stats-empty { padding: 26px; text-align: center; margin-top: 8px; }

.top-list {
    margin: 0;
    padding-left: 22px;
}
.top-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-top: 1px solid rgba(185,137,79,.16);
}
.top-list li:first-child { border-top: none; }
.top-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-count { flex: 0 0 auto; font-weight: 700; color: var(--red); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.stats-table th,
.stats-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(185,137,79,.16);
    vertical-align: top;
}
.stats-table th {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 700;
    white-space: nowrap;
}
.stats-table .nowrap { white-space: nowrap; }
.stats-table .muted-cell { color: var(--ink-soft); font-size: 12px; word-break: break-all; }

.mode-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.mode-all       { background: var(--cream-2); color: var(--ink-soft); }
.mode-favorites { background: var(--rose); color: var(--red-deep); }

/* --- Erweiterte Statistik (Hörverhalten) ------------------------------- */
.stats-cards-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) {
    .stats-cards-4 { grid-template-columns: repeat(2, 1fr); }
}
.stat-card.good   { border-color: rgba(120, 180, 120, .4); }
.stat-card.good   .stat-num { color: #3f9d5a; }
.stat-card.warn   .stat-num { color: #c98a2e; }
.stat-card.accent .stat-num { color: var(--red); }

.small { font-size: 11px; font-weight: 400; }

/* Top-5-Bereich */
.top5-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.top5-grid .stats-section { margin-bottom: 0; }
.top5-grid h2 { font-size: 14px; }
@media (max-width: 620px) {
    .top5-grid { grid-template-columns: 1fr; }
}

/* Zahlen-Spalten rechtsbündig */
.stats-table th.num,
.stats-table td.num { text-align: right; white-space: nowrap; }
.good-num { color: #3f9d5a; font-weight: 700; }
.warn-num { color: #c98a2e; font-weight: 700; }

/* Titel-Tabelle mit ausklappbaren Details */
.title-table .title-row { cursor: pointer; }
.title-table .title-row:hover { background: var(--cream); }
.title-table .title-row.open { background: var(--cream-2); }
.t-title { font-weight: 600; }
.caret {
    display: inline-block;
    color: var(--rose-deep);
    margin-right: 7px;
    transition: transform .15s;
}
.title-row.open .caret { transform: rotate(90deg); }

.detail-row > td { background: var(--cream); padding: 0 10px 12px; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 16px;
    padding: 12px 4px 4px;
}
@media (max-width: 520px) {
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
.detail-grid > div { display: flex; flex-direction: column; }
.d-label { font-size: 11px; color: var(--ink-soft); }
.d-val   { font-size: 15px; font-weight: 700; color: var(--ink); }

/* Status-Badges */
.status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.status-completed { background: #e3f4e6; color: #2f7d47; }
.status-aborted   { background: #fbeede; color: #b9791f; }

/* "Mehr anzeigen"-Button bei den letzten Wiedergaben */
.recent-more { text-align: center; margin-top: 12px; }
.more-btn {
    background: var(--cream-2);
    color: var(--red-deep);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 999px;
    transition: background .2s, transform .15s;
}
.more-btn:hover  { background: var(--rose); }
.more-btn:active { transform: scale(.96); }

/* Rueckmeldung nach dem Zuruecksetzen */
.stats-flash {
    margin: 0 0 16px;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow);
}
.stats-flash.ok  { background: #e3f4e6; color: #2f7d47; }
.stats-flash.err { background: #fbeede; color: #b9791f; }

/* Bereich zum Zuruecksetzen der Statistik */
.stats-danger { text-align: center; }
.stats-danger form { margin-top: 12px; }
.stats-danger code {
    font-size: 12px;
    background: var(--cream-2);
    padding: 1px 5px;
    border-radius: 6px;
}
.danger-btn {
    background: #f6ded0;
    color: #a3441f;
}
.danger-btn:hover { background: #efcbb6; }

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
