/* ═══════════════════════════════════════════════════════════════
   A1W9 Zivlos Lern-Abenteuer – Mobile-First Stylesheet
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --orange:    #FF6B35;
    --orange-lt: #FF8C5A;
    --blue:      #3B82F6;
    --blue-lt:   #60A5FA;
    --green:     #22C55E;
    --green-lt:  #4ADE80;
    --yellow:    #FBBF24;
    --purple:    #A855F7;
    --pink:      #EC4899;
    --bg:        #FFF8F0;
    --bg2:       #FFFFFF;
    --text:      #1E293B;
    --text-muted:#64748B;
    --border:    #E2E8F0;
    --shadow:    0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius:    16px;
    --radius-sm: 10px;

    /* Touch-friendly minimum sizes */
    --touch-min: 48px;
}

/* ── Body – Mobile First ──────────────────────────────────────── */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255,107,53,0.08) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(59,130,246,0.08) 0%, transparent 50%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Mobile: tight side padding */
    padding: 0 12px 60px;
}

/* ── Header – Mobile First ────────────────────────────────────── */
header {
    width: 100%;
    max-width: 700px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0 14px;
    margin-bottom: 8px;
}

.header-logo {
    /* Mobile: smaller logo so it doesn't dominate */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--orange);
    box-shadow: 0 3px 12px rgba(255,107,53,0.30);
    flex-shrink: 0;
}

.header-text h1 {
    font-family: 'Fredoka', sans-serif;
    /* Mobile: smaller title */
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--orange);
    line-height: 1.15;
    letter-spacing: 0.3px;
}

.header-text p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 3px;
    font-weight: 600;
}

/* ── Coin Bar – Mobile First ──────────────────────────────────── */
.coin-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg2);
    border: 2px solid var(--yellow);
    border-radius: 50px;
    /* Mobile: compact padding */
    padding: 8px 16px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(251,191,36,0.2);
    /* Allow wrapping on very small screens */
    flex-wrap: wrap;
    justify-content: center;
}

.coin-bar .coin-icon { font-size: 1.3rem; }
.coin-bar .coin-label { color: var(--text-muted); }
.coin-bar .coin-count { color: var(--yellow); font-size: 1.1rem; }
.coin-bar .coin-stats {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 4px;
    font-weight: 600;
}

/* ── Flash Messages ───────────────────────────────────────────── */
.flash {
    width: 100%;
    max-width: 700px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}
.flash.success {
    background: #DCFCE7;
    border: 2px solid var(--green);
    color: #166534;
}
.flash.error {
    background: #FEE2E2;
    border: 2px solid #EF4444;
    color: #991B1B;
}

/* ── Cards – Mobile First ─────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    /* Mobile: tighter padding */
    padding: 18px 16px;
    width: 100%;
    max-width: 700px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Mascot / Greeting – Mobile First ────────────────────────── */
.mascot-section {
    width: 100%;
    max-width: 700px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #EFF6FF 0%, #FFF7ED 100%);
    border: 2px solid #BFDBFE;
    border-radius: var(--radius);
    /* Mobile: compact */
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.mascot-img {
    /* Mobile: small mascot */
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--blue-lt);
    flex-shrink: 0;
}

.mascot-bubble {
    background: white;
    border: 2px solid var(--blue-lt);
    border-radius: 14px 14px 14px 4px;
    padding: 10px 14px;
    position: relative;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}

/* Speech bubble tail – hidden on mobile (too small) */
.mascot-bubble::before,
.mascot-bubble::after { display: none; }

.mascot-bubble .highlight { color: var(--orange); }

/* ── Upload Area – Mobile First ───────────────────────────────── */
.upload-card {
    background: linear-gradient(135deg, #FFF7ED 0%, #FFFBEB 100%);
    border: 2px dashed var(--orange);
}

.upload-area {
    border: 3px dashed var(--orange-lt);
    border-radius: var(--radius-sm);
    /* Mobile: comfortable padding */
    padding: 24px 16px;
    text-align: center;
    transition: all 0.25s;
    background: rgba(255,107,53,0.04);
    cursor: pointer;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--orange);
    background: rgba(255,107,53,0.08);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    display: block;
}

.upload-hint {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--orange);
    margin-bottom: 4px;
}

.upload-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.upload-area input[type="file"] {
    display: block;
    margin: 0 auto 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    /* Full width on mobile */
    width: 100%;
    max-width: 320px;
}

/* ── Buttons – Mobile First (min 48px touch target) ──────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--orange) 0%, #FF8C5A 100%);
    color: white;
    border: none;
    /* Mobile: full-width friendly, min 48px height */
    min-height: var(--touch-min);
    padding: 12px 28px;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(255,107,53,0.35);
    letter-spacing: 0.4px;
    text-align: center;
    /* Prevent text shrink */
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,107,53,0.45);
}
.btn:active { transform: translateY(0); }

.btn:disabled {
    background: linear-gradient(135deg, #CBD5E1, #94A3B8);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-blue {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-lt) 100%);
    box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}
.btn-blue:hover { box-shadow: 0 6px 20px rgba(59,130,246,0.45); }

.btn-green {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-lt) 100%);
    box-shadow: 0 4px 14px rgba(34,197,94,0.35);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    background: white;
    color: var(--blue);
    border: 2px solid var(--blue);
    padding: 10px 24px;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background: var(--blue);
    color: white;
}

/* ── File List – Mobile First ─────────────────────────────────── */
.file-list { list-style: none; }

.file-list li {
    /* Mobile: min 48px touch target */
    min-height: var(--touch-min);
    padding: 12px 14px;
    background: #F8FAFC;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.file-list li:hover {
    border-color: var(--blue-lt);
    background: #EFF6FF;
}

.file-list li .file-icon { font-size: 1.3rem; flex-shrink: 0; }

.file-btn {
    background: none;
    border: none;
    color: var(--blue);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    transition: color 0.2s;
    text-align: left;
    flex: 1;
    /* Ensure full touch area */
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    /* Allow long filenames to wrap */
    word-break: break-word;
    overflow-wrap: anywhere;
}
.file-btn:hover { color: var(--orange); }

.file-badge {
    background: linear-gradient(135deg, var(--blue), var(--blue-lt));
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 50px;
    white-space: nowrap;
    flex-shrink: 0;
}

.empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 16px;
    font-weight: 600;
}

/* ── Loading Overlay ──────────────────────────────────────────── */
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,248,240,0.96);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}
#loading-overlay.active { display: flex; }

.spinner-wrap {
    position: relative;
    width: 90px;
    height: 90px;
}

.spinner {
    width: 90px;
    height: 90px;
    border: 7px solid #E2E8F0;
    border-top-color: var(--orange);
    border-right-color: var(--blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-emoji {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%       { transform: translate(-50%, -50%) scale(1.2); }
}

.loading-text {
    font-family: 'Fredoka', sans-serif;
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 600;
    text-align: center;
}

.loading-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    font-weight: 600;
    max-width: 280px;
}

.loading-filename {
    background: white;
    border: 2px solid var(--orange-lt);
    border-radius: 50px;
    padding: 7px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--orange);
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Quiz Page ────────────────────────────────────────────────── */
.quiz-header {
    width: 100%;
    max-width: 700px;
    text-align: center;
    padding: 16px 0 12px;
    margin-bottom: 8px;
}

.quiz-header h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--blue);
}

.quiz-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    font-weight: 600;
    word-break: break-word;
}

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-wrap {
    width: 100%;
    max-width: 700px;
    margin-bottom: 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 700;
}

.progress-bar-bg {
    background: #E2E8F0;
    border-radius: 50px;
    height: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--blue));
    border-radius: 50px;
    transition: width 0.4s ease;
}

/* ── Quiz Question Cards – Mobile First ───────────────────────── */
.quiz-card {
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    /* Mobile: comfortable padding */
    padding: 18px 16px;
    width: 100%;
    max-width: 700px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.q-number {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    font-weight: 700;
}

.q-text {
    font-family: 'Fredoka', sans-serif;
    /* Mobile: readable size */
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ── Options – Mobile First (min 48px touch) ──────────────────── */
.options { display: flex; flex-direction: column; gap: 10px; }

.option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F8FAFC;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    /* Mobile: min 48px touch target */
    min-height: var(--touch-min);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 600;
    /* Prevent text overflow */
    word-break: break-word;
}

.option-label:hover {
    border-color: var(--blue-lt);
    background: #EFF6FF;
}

.option-label input[type="radio"] {
    accent-color: var(--blue);
    /* Larger touch target for radio */
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.option-label.selected {
    border-color: var(--blue);
    background: #EFF6FF;
    color: var(--blue);
}

.option-label.correct {
    border-color: var(--green);
    background: #DCFCE7;
    color: #166534;
}

.option-label.wrong {
    border-color: #EF4444;
    background: #FEE2E2;
    color: #991B1B;
}

.option-label.reveal-correct {
    border-color: var(--green);
    background: #DCFCE7;
    color: #166534;
}

/* ── Submit Button Wrap ───────────────────────────────────────── */
.btn-wrap {
    width: 100%;
    max-width: 700px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

/* Full-width submit button on mobile */
.btn-wrap .btn {
    width: 100%;
    min-height: 56px;
    font-size: 1.15rem;
}

/* ── Result Banner ────────────────────────────────────────────── */
#result-banner {
    display: none;
    width: 100%;
    max-width: 700px;
    border-radius: var(--radius);
    padding: 24px 20px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
}

#result-banner.show { display: block; }

#result-banner h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    margin-bottom: 10px;
    line-height: 1.3;
}

#result-banner .score {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    font-weight: 700;
}

#result-banner .coins-earned {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--yellow);
    margin-bottom: 4px;
}

#result-banner .coins-label {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-weight: 700;
}

#result-banner.great {
    background: linear-gradient(135deg, #DCFCE7, #D1FAE5);
    border: 3px solid var(--green);
}

#result-banner.ok {
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border: 3px solid var(--blue);
}

#result-banner.poor {
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border: 3px solid var(--orange);
}

/* ═══════════════════════════════════════════════════════════════
   MEDIA QUERIES – Progressive Enhancement
   ═══════════════════════════════════════════════════════════════ */

/* ── Small phones (≥ 375px) ───────────────────────────────────── */
@media (min-width: 375px) {
    body { padding: 0 14px 60px; }

    .header-logo { width: 62px; height: 62px; }
    .header-text h1 { font-size: 1.35rem; }

    .mascot-img { width: 70px; height: 70px; }
    .mascot-bubble { font-size: 0.92rem; }
}

/* ── Tablets portrait (≥ 480px) ───────────────────────────────── */
@media (min-width: 480px) {
    body { padding: 0 16px 60px; }

    .header-logo { width: 68px; height: 68px; }
    .header-text h1 { font-size: 1.5rem; }
    .header-text p { font-size: 0.85rem; }

    .card { padding: 22px 20px; }
    .quiz-card { padding: 22px 20px; }

    .mascot-img { width: 76px; height: 76px; }
    .mascot-bubble { font-size: 0.95rem; }

    .q-text { font-size: 1.15rem; }

    .upload-hint { font-size: 1.1rem; }
    .upload-icon { font-size: 2.8rem; }
}

/* ── Tablets landscape / small desktop (≥ 640px) ─────────────── */
@media (min-width: 640px) {
    body { padding: 0 20px 60px; }

    header { gap: 16px; padding: 20px 0 16px; }
    .header-logo {
        width: 76px;
        height: 76px;
        border-width: 4px;
    }
    .header-text h1 { font-size: 1.75rem; }
    .header-text p { font-size: 0.9rem; }

    .card { padding: 26px 28px; margin-bottom: 20px; }
    .card h2 { font-size: 1.3rem; }

    .quiz-card { padding: 26px 28px; }
    .q-text { font-size: 1.2rem; }

    .mascot-section { padding: 18px 24px; gap: 18px; }
    .mascot-img { width: 84px; height: 84px; }
    .mascot-bubble {
        font-size: 1rem;
        padding: 12px 16px;
        /* Show speech bubble tail on larger screens */
        border-radius: 18px 18px 18px 4px;
    }
    .mascot-bubble::before {
        display: block;
        content: '';
        position: absolute;
        left: -12px;
        bottom: 14px;
        border: 6px solid transparent;
        border-right-color: var(--blue-lt);
    }
    .mascot-bubble::after {
        display: block;
        content: '';
        position: absolute;
        left: -9px;
        bottom: 15px;
        border: 5px solid transparent;
        border-right-color: white;
    }

    .coin-bar { padding: 10px 22px; font-size: 0.95rem; }
    .coin-bar .coin-count { font-size: 1.15rem; }

    .upload-area { padding: 30px 24px; }
    .upload-icon { font-size: 3rem; }
    .upload-hint { font-size: 1.15rem; }

    .file-list li { padding: 13px 16px; }
    .file-btn { font-size: 1rem; }

    .btn { font-size: 1.1rem; padding: 13px 32px; }
    .btn-wrap .btn { max-width: 380px; }

    .quiz-header h1 { font-size: 2rem; }
    .quiz-header p { font-size: 0.9rem; }

    #result-banner { padding: 28px 28px; }
    #result-banner h2 { font-size: 1.8rem; }
    #result-banner .coins-earned { font-size: 2.4rem; }
}

/* ── Desktop (≥ 768px) ────────────────────────────────────────── */
@media (min-width: 768px) {
    .header-logo { width: 80px; height: 80px; }
    .header-text h1 { font-size: 1.9rem; }

    .card { padding: 28px 32px; }
    .quiz-card { padding: 28px 32px; }

    .mascot-img { width: 90px; height: 90px; }

    .coin-bar { padding: 10px 24px; font-size: 1rem; }

    .btn { font-size: 1.15rem; padding: 14px 36px; }
    .btn-wrap .btn { max-width: 400px; min-height: 56px; font-size: 1.2rem; }

    .quiz-header h1 { font-size: 2.2rem; }

    #result-banner h2 { font-size: 2rem; }
    #result-banner .coins-earned { font-size: 2.5rem; }

    /* Hover effects only on non-touch devices */
    .file-list li:hover { transform: translateX(4px); }
    .option-label:hover { transform: translateX(4px); }
    .card:hover { box-shadow: var(--shadow-lg); }
}

/* ── Large desktop (≥ 1024px) ────────────────────────────────── */
@media (min-width: 1024px) {
    body { padding: 0 24px 60px; }
}

/* ── Portrait orientation hint ────────────────────────────────── */
@media (orientation: portrait) and (max-width: 480px) {
    /* Extra breathing room in portrait on small phones */
    .quiz-card { margin-bottom: 14px; }
    .options { gap: 8px; }
    .option-label { padding: 11px 12px; font-size: 0.9rem; }
}

/* ═══════════════════════════════════════════════════════════════
   SPEECH FEATURES – TTS & STT
   ═══════════════════════════════════════════════════════════════ */

/* ── Question header row (number + TTS button) ────────────────── */
.q-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

/* ── TTS (Text-to-Speech) Speaker Button ─────────────────────── */
.tts-btn {
    /* Minimum 44×44px touch target */
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--blue-lt);
    background: #EFF6FF;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.tts-btn:hover {
    background: var(--blue);
    border-color: var(--blue);
    transform: scale(1.1);
}

.tts-btn.tts-active {
    background: var(--blue);
    border-color: var(--blue);
    animation: tts-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes tts-pulse {
    from { transform: scale(1);    box-shadow: 0 0 0   0   rgba(59,130,246,0.4); }
    to   { transform: scale(1.12); box-shadow: 0 0 0 8px rgba(59,130,246,0);    }
}

/* ── Microphone Row ───────────────────────────────────────────── */
.mic-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

/* ── STT (Speech-to-Text) Mic Button ─────────────────────────── */
.mic-btn {
    /* Minimum 44×44px touch target */
    min-width: 48px;
    min-height: 48px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #E2E8F0;
    background: #F8FAFC;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.mic-btn:hover {
    background: #FEE2E2;
    border-color: #EF4444;
    transform: scale(1.08);
}

.mic-btn.mic-listening {
    background: #EF4444;
    border-color: #DC2626;
    animation: mic-ring 1s ease-in-out infinite;
}

@keyframes mic-ring {
    0%   { box-shadow: 0 0 0 0   rgba(239,68,68,0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(239,68,68,0);  }
    100% { box-shadow: 0 0 0 0   rgba(239,68,68,0);   }
}

.mic-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Mic Status Banner ────────────────────────────────────────── */
.mic-banner {
    display: none;
    width: 100%;
    max-width: 700px;
    align-items: center;
    gap: 12px;
    background: #FEF2F2;
    border: 2px solid #EF4444;
    border-radius: 50px;
    padding: 10px 20px;
    margin-bottom: 14px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #991B1B;
}

.mic-banner.active {
    display: flex;
}

/* Pulsing red dot */
.mic-pulse {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #EF4444;
    flex-shrink: 0;
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1);   opacity: 1;   }
    50%       { transform: scale(1.4); opacity: 0.6; }
}

/* ── Responsive adjustments for speech buttons ────────────────── */
@media (min-width: 640px) {
    .tts-btn {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }
    .mic-btn {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
    }
    .mic-hint { font-size: 0.85rem; }
}

/* ═══════════════════════════════════════════════════════════════
   USER PROFILE SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* ── Profile Switcher (top-right in header) ───────────────────── */
.profile-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 2px solid var(--purple);
    border-radius: 50px;
    padding: 6px 12px 6px 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 0.8rem;
    transition: all 0.2s;
    margin-left: auto;
    flex-shrink: 0;
    min-height: 44px;
    box-shadow: 0 2px 8px rgba(168,85,247,0.15);
}

.profile-switcher:hover {
    background: var(--purple);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(168,85,247,0.35);
}

.profile-switcher-avatar {
    font-size: 1.3rem;
    line-height: 1;
}

.profile-switcher-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-switcher-icon {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* ── Login Page Title ─────────────────────────────────────────── */
.login-title {
    width: 100%;
    max-width: 700px;
    text-align: center;
    margin-bottom: 20px;
    padding: 0 4px;
}

.login-title h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 6px;
}

.login-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
}

/* ── Profile Grid ─────────────────────────────────────────────── */
.profile-grid {
    width: 100%;
    max-width: 700px;
    display: grid;
    /* Mobile: 2 columns */
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.profile-form { display: contents; }

/* ── Profile Card ─────────────────────────────────────────────── */
.profile-card {
    background: white;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    text-align: center;
    /* Touch target */
    min-height: 130px;
    font-family: inherit;
    color: var(--text);
}

.profile-card:hover {
    border-color: var(--blue);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(59,130,246,0.2);
}

.profile-card:active {
    transform: translateY(-1px);
}

.profile-avatar {
    font-size: 2.8rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.profile-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

.profile-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.profile-coins {
    background: #FEF9C3;
    border: 1px solid var(--yellow);
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #92400E;
}

.profile-correct {
    background: #DCFCE7;
    border: 1px solid var(--green);
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #166534;
}

/* ── Add Profile Card ─────────────────────────────────────────── */
.profile-card-add {
    border-style: dashed;
    border-color: var(--orange-lt);
    background: #FFF7ED;
    color: var(--orange);
}

.profile-card-add:hover {
    border-color: var(--orange);
    background: #FFEDD5;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(255,107,53,0.2);
}

.profile-card-add .profile-avatar {
    font-size: 2.2rem;
}

.profile-card-add .profile-name {
    color: var(--orange);
}

/* ── No Profiles State ────────────────────────────────────────── */
.no-profiles {
    width: 100%;
    max-width: 700px;
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.8;
    margin-bottom: 20px;
}

/* ── Create Profile Form ──────────────────────────────────────── */
.create-form-wrap {
    display: none;
    width: 100%;
    max-width: 700px;
    margin-bottom: 24px;
}

.create-form-wrap.active {
    display: block;
}

.create-card {
    border-color: var(--green);
    background: linear-gradient(135deg, #F0FDF4, #FFFFFF);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    background: white;
    transition: border-color 0.2s;
    min-height: var(--touch-min);
}

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ── Avatar Grid ──────────────────────────────────────────────── */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.avatar-option {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.avatar-option input[type="radio"] {
    display: none;
}

.avatar-emoji {
    font-size: 2rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid transparent;
    background: #F8FAFC;
    transition: all 0.15s;
    cursor: pointer;
}

.avatar-option:hover .avatar-emoji {
    background: #EFF6FF;
    border-color: var(--blue-lt);
    transform: scale(1.1);
}

.avatar-option.selected .avatar-emoji {
    background: #EFF6FF;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
    transform: scale(1.15);
}

/* ── Form Actions ─────────────────────────────────────────────── */
.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Delete Section ───────────────────────────────────────────── */
.delete-section {
    width: 100%;
    max-width: 700px;
    margin-bottom: 24px;
}

.delete-summary {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    user-select: none;
}

.delete-summary::-webkit-details-marker { display: none; }
.delete-summary::marker { display: none; }

.delete-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delete-form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    gap: 12px;
}

.delete-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.delete-btn {
    background: #EF4444;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
    transition: background 0.2s;
    font-family: inherit;
}

.delete-btn:hover { background: #DC2626; }

/* ── Profile Responsive ───────────────────────────────────────── */
@media (min-width: 480px) {
    .profile-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .profile-avatar { font-size: 3rem; }
    .profile-name { font-size: 1.15rem; }
    .avatar-grid { grid-template-columns: repeat(5, 1fr); gap: 12px; }
}

@media (min-width: 640px) {
    .profile-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
    .profile-card { padding: 24px 16px 20px; min-height: 150px; }
    .profile-avatar { font-size: 3.2rem; }
    .login-title h2 { font-size: 2rem; }
    .profile-switcher-name { max-width: 100px; }
    .avatar-grid { grid-template-columns: repeat(5, 1fr); }
    .avatar-emoji { font-size: 2.2rem; width: 56px; height: 56px; }
}

@media (min-width: 768px) {
    .profile-grid { grid-template-columns: repeat(4, 1fr); }
    .profile-switcher { font-size: 0.9rem; padding: 8px 16px 8px 10px; }
    .profile-switcher-avatar { font-size: 1.5rem; }
    .profile-switcher-name { max-width: 120px; }
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGES – Login / Register / Verify
   ═══════════════════════════════════════════════════════════════ */

/* ── Auth wrapper (centers the card) ─────────────────────────── */
.auth-wrap {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-top: 8px;
}

/* ── Auth Card ────────────────────────────────────────────────── */
.auth-card {
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--shadow-lg);
}

.auth-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-icon {
    font-size: 2rem;
    line-height: 1;
}

.auth-card-header h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--blue);
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.5;
    margin-top: -12px;
}

/* ── Auth Flash (Zivlo speech bubble style) ───────────────────── */
.auth-flash {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.5;
}

.auth-flash.success {
    background: #DCFCE7;
    border: 2px solid var(--green);
    color: #166534;
}

.auth-flash.error {
    background: #FEF2F2;
    border: 2px solid #EF4444;
    color: #991B1B;
}

.auth-flash-avatar {
    font-size: 1.6rem;
    flex-shrink: 0;
    line-height: 1;
}

.auth-flash-bubble {
    background: white;
    border-radius: 10px 10px 10px 2px;
    padding: 8px 12px;
    flex: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── Form hint (small text next to label) ─────────────────────── */
.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Checkbox row ─────────────────────────────────────────────── */
.form-check {
    margin-bottom: 12px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.check-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
    flex-shrink: 0;
}

/* ── Auth links (register / login switch) ─────────────────────── */
.auth-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-wrap: wrap;
}

.auth-link {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-link:hover { color: var(--orange); }

/* ── Auth responsive ──────────────────────────────────────────── */
@media (min-width: 480px) {
    .auth-card { padding: 28px 28px; }
    .auth-card-header h2 { font-size: 1.8rem; }
}

@media (min-width: 640px) {
    .auth-card { padding: 32px 36px; }
}

/* ═══════════════════════════════════════════════════════════════
   ADMIN DASHBOARD
   ═══════════════════════════════════════════════════════════════ */

/* ── Admin body override: wider max-width ─────────────────────── */
body:has(.admin-stats-row) {
    max-width: 960px;
    margin: 0 auto;
}

/* ── Stats Row ────────────────────────────────────────────────── */
.admin-stats-row {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.admin-stat-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.admin-stat-card:hover { transform: translateY(-2px); }

.admin-stat-icon { font-size: 1.8rem; margin-bottom: 6px; }

.admin-stat-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
    margin-bottom: 4px;
}

.admin-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Admin Mascot Banner ──────────────────────────────────────── */
.admin-mascot {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border: 2px solid var(--green);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-weight: 700;
    color: #166534;
    font-size: 0.95rem;
}

.admin-mascot-emoji { font-size: 2rem; flex-shrink: 0; }
.admin-mascot-text { line-height: 1.5; }

/* ── Admin Card ───────────────────────────────────────────────── */
.admin-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    width: 100%;
    max-width: 900px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.admin-section-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Admin Table ──────────────────────────────────────────────── */
.admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 600px;
}

.admin-table thead {
    background: #F8FAFC;
    border-bottom: 2px solid var(--border);
}

.admin-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tbody tr:last-child td { border-bottom: none; }

.admin-table tbody tr:hover { background: #F8FAFC; }

.admin-row-self { background: #FFFBEB !important; }

.admin-td-muted { color: var(--text-muted); font-size: 0.8rem; }
.admin-td-center { text-align: center; }

/* ── Admin Badges ─────────────────────────────────────────────── */
.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.admin-badge-green  { background: #DCFCE7; color: #166534; border: 1px solid var(--green); }
.admin-badge-red    { background: #FEE2E2; color: #991B1B; border: 1px solid #EF4444; }
.admin-badge-blue   { background: #DBEAFE; color: #1E40AF; border: 1px solid var(--blue); }
.admin-badge-purple { background: #F3E8FF; color: #6B21A8; border: 1px solid var(--purple); }
.admin-badge-orange { background: #FFEDD5; color: #9A3412; border: 1px solid var(--orange); }
.admin-badge-gray   { background: #F1F5F9; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Admin Action Buttons ─────────────────────────────────────── */
.admin-action-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 50px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.admin-btn-green  { background: #DCFCE7; color: #166534; }
.admin-btn-green:hover  { background: var(--green); color: white; }

.admin-btn-blue   { background: #DBEAFE; color: #1E40AF; }
.admin-btn-blue:hover   { background: var(--blue); color: white; }

.admin-btn-purple { background: #F3E8FF; color: #6B21A8; }
.admin-btn-purple:hover { background: var(--purple); color: white; }

.admin-btn-orange { background: #FFEDD5; color: #9A3412; }
.admin-btn-orange:hover { background: var(--orange); color: white; }

.admin-btn-red    { background: #FEE2E2; color: #991B1B; }
.admin-btn-red:hover    { background: #EF4444; color: white; }

/* ── Admin Nav Buttons (header) ───────────────────────────────── */
.admin-nav-btn {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 50px;
    background: white;
    border: 2px solid var(--border);
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.admin-nav-btn:hover { border-color: var(--blue); color: var(--blue); }
.admin-nav-btn-red:hover { border-color: #EF4444; color: #EF4444; }

/* ── Admin Responsive ─────────────────────────────────────────── */
@media (min-width: 480px) {
    .admin-stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 640px) {
    .admin-stats-row { grid-template-columns: repeat(5, 1fr); gap: 14px; }
    .admin-stat-value { font-size: 2rem; }
    .admin-card { padding: 24px 24px; }
    .admin-table { font-size: 0.9rem; }
    .admin-btn { font-size: 0.8rem; padding: 5px 12px; min-height: 34px; }
}

@media (min-width: 768px) {
    .admin-stats-row { gap: 16px; }
    .admin-stat-card { padding: 20px 16px; }
    .admin-stat-icon { font-size: 2rem; }
}

/* ═══════════════════════════════════════════════════════════════
   ROLE SYSTEM – Teal badge + Role Legend
   ═══════════════════════════════════════════════════════════════ */

/* Teal badge for Moderator role */
.admin-badge-teal {
    background: #CCFBF1;
    color: #0F766E;
    border: 1px solid #2DD4BF;
}

.admin-btn-teal { background: #CCFBF1; color: #0F766E; }
.admin-btn-teal:hover { background: #0D9488; color: white; }

/* Role legend row */
.admin-role-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.admin-role-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   MODERATOR DASHBOARD
   ═══════════════════════════════════════════════════════════════ */

/* Moderator mascot banner – purple/teal theme */
.mod-mascot {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #F0FDFA, #CCFBF1);
    border: 2px solid #2DD4BF;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-weight: 700;
    color: #0F766E;
    font-size: 0.95rem;
    line-height: 1.5;
}

.mod-mascot-emoji {
    font-size: 2.2rem;
    flex-shrink: 0;
    /* Clipboard + whistle visual */
    position: relative;
}

.mod-mascot-text { line-height: 1.6; }

.mod-role-badge {
    display: inline-block;
    background: #0D9488;
    color: white;
    border-radius: 50px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    margin: 0 2px;
}

/* Quick action buttons */
.mod-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.mod-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: all 0.2s;
    border: 2px solid transparent;
    min-height: 100px;
}

.mod-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.mod-action-icon { font-size: 2rem; line-height: 1; }

.mod-action-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.mod-action-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.mod-action-blue  { background: #EFF6FF; border-color: #BFDBFE; }
.mod-action-blue:hover  { background: #DBEAFE; border-color: var(--blue); }

.mod-action-green { background: #F0FDF4; border-color: #BBF7D0; }
.mod-action-green:hover { background: #DCFCE7; border-color: var(--green); }

.mod-action-purple { background: #FAF5FF; border-color: #E9D5FF; }
.mod-action-purple:hover { background: #F3E8FF; border-color: var(--purple); }

/* Event list in moderator dashboard */
.mod-event-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mod-event-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: background 0.15s;
}

.mod-event-item:hover { background: #F1F5F9; }

.mod-event-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
    flex-shrink: 0;
}

.mod-event-day {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.mod-event-month {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mod-event-info { flex: 1; }

.mod-event-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 2px;
}

.mod-event-time {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.mod-event-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   CALENDAR PAGE
   ═══════════════════════════════════════════════════════════════ */

/* Calendar body override: wider */
body:has(.cal-wrap) {
    max-width: 1000px;
    margin: 0 auto;
}

/* Month navigation */
.cal-nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0 4px;
}

.cal-nav-btn {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 18px;
    border-radius: 50px;
    background: white;
    border: 2px solid var(--border);
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.cal-nav-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: #EFF6FF;
}

.cal-month-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blue);
    text-align: center;
    flex: 1;
}

/* Calendar wrapper */
.cal-wrap {
    width: 100%;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* 7-column grid */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

/* Day header row */
.cal-day-header {
    background: #F8FAFC;
    border-bottom: 2px solid var(--border);
    padding: 8px 4px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Calendar cells */
.cal-cell {
    min-height: 80px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px 5px 5px;
    vertical-align: top;
    position: relative;
    transition: background 0.15s;
}

.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell:hover { background: #F8FAFC; }

.cal-cell-empty {
    background: #FAFAFA;
    min-height: 80px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.cal-cell-today {
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE) !important;
}

.cal-cell-today .cal-day-num {
    background: var(--blue);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-day-num {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Event chips inside cells */
.cal-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cal-event-chip {
    display: flex;
    align-items: center;
    gap: 3px;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.3;
    cursor: default;
    overflow: hidden;
}

.cal-event-chip-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event-del {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: inherit;
    opacity: 0.6;
    padding: 0 1px;
    line-height: 1;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.cal-event-del:hover { opacity: 1; }

/* Add event form */
.cal-add-form { }

.cal-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 4px;
}

.cal-form-row .form-group { margin-bottom: 12px; }

/* Color picker row */
.cal-color-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.cal-color-opt {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.cal-color-opt input[type="radio"] { display: none; }

.cal-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: all 0.15s;
    display: block;
}

.cal-color-opt:hover .cal-color-dot {
    transform: scale(1.2);
    border-color: rgba(0,0,0,0.2);
}

.cal-color-opt input[type="radio"]:checked + .cal-color-dot {
    border-color: var(--text);
    transform: scale(1.25);
    box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor;
}

/* Read-only hint for kids */
.cal-readonly-hint {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F0FDF4;
    border: 2px solid var(--green);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #166534;
}

.cal-readonly-icon { font-size: 1.5rem; }

/* Legend */
.cal-legend {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 4px;
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.cal-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-legend-today {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--blue);
    flex-shrink: 0;
}

/* Calendar responsive */
@media (min-width: 480px) {
    .cal-cell { min-height: 90px; }
    .cal-event-chip { font-size: 0.72rem; }
    .cal-day-num { font-size: 0.95rem; }
}

@media (min-width: 640px) {
    .cal-cell { min-height: 100px; padding: 8px 6px 6px; }
    .cal-day-header { padding: 10px 6px; font-size: 0.78rem; }
    .cal-event-chip { font-size: 0.75rem; padding: 3px 6px; }
    .cal-month-title { font-size: 1.8rem; }
}

@media (min-width: 768px) {
    .cal-cell { min-height: 110px; }
    .cal-day-num { font-size: 1rem; width: 26px; height: 26px; }
    .cal-cell-today .cal-day-num { width: 26px; height: 26px; }
}

/* ═══════════════════════════════════════════════════════════════
   Admin View-Switch – Preview Banner & Yellow Nav Button
   ═══════════════════════════════════════════════════════════════ */

/* ── Preview Banner ───────────────────────────────────────────── */
.preview-banner {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    /* full-bleed: break out of the body's padding */
    margin-left: calc(-50vw + 50%);
    width: 100vw;
    background: linear-gradient(135deg, #FBBF24, #F59E0B);
    color: #78350F;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 3px 12px rgba(251,191,36,0.45);
    flex-wrap: wrap;
}

.preview-banner-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.preview-banner-text {
    flex: 1;
    min-width: 160px;
}

.preview-banner-text strong {
    color: #92400E;
}

.preview-banner-btn {
    background: #92400E;
    color: #FEF3C7;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
}

.preview-banner-btn:hover {
    background: #78350F;
    transform: scale(1.04);
}

.preview-banner-btn:active {
    transform: scale(0.97);
}

/* ── Yellow Nav Button (View Switch in header) ────────────────── */
.admin-nav-btn-yellow {
    background: linear-gradient(135deg, #FBBF24, #F59E0B) !important;
    color: #78350F !important;
    border: 2px solid #F59E0B !important;
    font-weight: 800 !important;
}

.admin-nav-btn-yellow:hover {
    background: linear-gradient(135deg, #F59E0B, #D97706) !important;
    color: #451A03 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(251,191,36,0.5) !important;
}

/* ── Subject choice (child view) ─────────────────────────────── */
.subject-choice {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
