/* ═══════════════════════════════════════════════════════════════════════
   v17.css — Estilos añadidos en la versión 1.7 (Fase 2: Social + Retención)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────
   Bloque "Mi Progreso" en perfil.php
   ───────────────────────────────────────────────────────────────────── */
.tv-progress-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 22px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.03);
}

.tv-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.tv-progress-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--dark);
}

.tv-progress-meta {
    font-size: .85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.tv-progress-grid {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 18px;
    align-items: stretch;
}

.tv-progress-level {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(6,214,160,.04), rgba(6,214,160,.0));
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(6,214,160,.12);
}

.tv-nivel-insignia {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    font-weight: 900;
}

.tv-nivel-num {
    font-size: 1.6rem;
    line-height: 1;
}

.tv-progress-bar-info {
    flex: 1;
    min-width: 0;
}

.tv-progress-bar-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.tv-progress-bar {
    height: 12px;
    border-radius: 6px;
    background: rgba(0,0,0,.06);
    overflow: hidden;
}

.tv-progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 1s cubic-bezier(.16,1,.3,1);
}

/* ─── Racha ─── */
.tv-racha-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, rgba(245,158,11,.08), rgba(239,68,68,.04));
    border: 1px solid rgba(245,158,11,.18);
    padding: 14px 16px;
    border-radius: 12px;
}

.tv-racha-emoji {
    font-size: 2.4rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(245,158,11,.4));
}

.tv-racha-info { min-width: 0; }

.tv-racha-actual {
    font-size: 2rem;
    font-weight: 900;
    color: #f59e0b;
    line-height: 1;
}

.tv-racha-lbl {
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

.tv-racha-max {
    margin-top: 6px;
    font-size: .8rem;
    color: var(--dark);
}

/* ─── Mini historial XP ─── */
.tv-xp-historial {
    margin-top: 16px;
    border-top: 1px dashed var(--border);
    padding-top: 14px;
}

.tv-xp-historial summary {
    cursor: pointer;
    font-size: .85rem;
    color: var(--muted);
    font-weight: 600;
    padding: 6px 0;
    user-select: none;
}

.tv-xp-historial summary:hover { color: var(--accent); }

.tv-xp-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tv-xp-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 6px 10px;
    font-size: .85rem;
    align-items: center;
    background: rgba(0,0,0,.02);
    border-radius: 6px;
}

.tv-xp-tipo { color: var(--dark); font-weight: 500; }
.tv-xp-fecha { color: var(--muted); font-size: .78rem; }

.tv-xp-delta {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    min-width: 70px;
    text-align: right;
}

.tv-xp-delta.pos { color: var(--accent); }
.tv-xp-delta.neg { color: var(--danger, #ef4444); }

/* Responsive */
@media (max-width: 768px) {
    .tv-progress-grid {
        grid-template-columns: 1fr;
    }
    .tv-nivel-insignia {
        width: 54px;
        height: 54px;
    }
    .tv-nivel-num { font-size: 1.4rem; }
}

/* ═════════════════════════════════════════════════════════════════════
   PASO 3: Sistema social — campana, amigos, notificaciones
   ═════════════════════════════════════════════════════════════════════ */

/* ─── Campana de notificaciones en el header ──────────────────────── */
.tv-notif {
    position: relative;
    display: inline-block;
}

.tv-notif-btn {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text, #111);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background .15s, border-color .15s;
}

.tv-notif-btn:hover {
    background: rgba(0,0,0,.05);
    border-color: var(--border);
}

.tv-notif-btn[aria-expanded="true"] {
    background: rgba(0,0,0,.05);
}

.tv-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface, #fff);
}

@keyframes tvNotifPulse {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.25); }
    60%  { transform: scale(.92); }
    100% { transform: scale(1); }
}
.tv-notif-pulse .tv-notif-badge { animation: tvNotifPulse .9s ease-out; }

.tv-notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,.18);
    z-index: 1000;
    overflow: hidden;
    animation: tvNotifPanelIn .16s ease-out;
}

@keyframes tvNotifPanelIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tv-notif-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.tv-notif-title {
    font-weight: 800; font-size: .95rem; color: var(--dark);
}

.tv-notif-clear {
    background: transparent; border: none; cursor: pointer;
    color: var(--muted); font-size: .75rem;
    text-decoration: underline; padding: 2px 4px;
}
.tv-notif-clear:hover { color: var(--accent); }

.tv-notif-list {
    max-height: 420px; overflow-y: auto;
}

.tv-notif-empty {
    padding: 28px 16px; text-align: center;
    color: var(--muted); font-size: .88rem;
}

.tv-notif-item {
    display: flex; gap: 10px; padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--dark); text-decoration: none;
    transition: background .12s;
    position: relative;
}
.tv-notif-item:last-child { border-bottom: none; }
.tv-notif-item:hover { background: rgba(0,0,0,.03); }

.tv-notif-item-unread {
    background: rgba(6,214,160,.04);
}
.tv-notif-item-unread:hover { background: rgba(6,214,160,.07); }

.tv-notif-item-ico {
    font-size: 1.3rem; flex-shrink: 0; line-height: 1;
}

.tv-notif-item-body { flex: 1; min-width: 0; }

.tv-notif-item-titulo {
    font-size: .88rem; font-weight: 700; color: var(--dark);
    margin-bottom: 2px;
}

.tv-notif-item-detalle {
    font-size: .82rem; color: var(--muted); line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tv-notif-item-fecha {
    font-size: .72rem; color: var(--muted); margin-top: 4px;
}

.tv-notif-item-dot {
    position: absolute; top: 14px; right: 10px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent, #06D6A0);
}

.tv-notif-foot {
    padding: 8px 14px;
    text-align: center;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,.02);
}

.tv-notif-all {
    color: var(--accent);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 600;
}
.tv-notif-all:hover { text-decoration: underline; }

/* ─── Página de amigos ────────────────────────────────────────────── */
.tv-amigos-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}

.tv-amigos-titulo {
    font-size: 1.5rem; font-weight: 800; margin: 0; color: var(--dark);
}

.tv-amigos-counts {
    display: flex; gap: 18px; font-size: .9rem; color: var(--muted);
}

.tv-amigos-count strong { color: var(--accent); font-weight: 800; }

/* Tabs */
.tv-amigos-tabs {
    display: flex; gap: 4px; margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tv-amigos-tab {
    background: transparent; border: none; cursor: pointer;
    padding: 10px 16px;
    font-size: .92rem; font-weight: 600; color: var(--muted);
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.tv-amigos-tab:hover { color: var(--dark); }
.tv-amigos-tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tv-amigos-tab-num {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 7px;
    background: rgba(0,0,0,.06);
    color: var(--dark);
    border-radius: 10px;
    font-size: .72rem; font-weight: 700;
}
.tv-amigos-tab-num-alert {
    background: #ef4444;
    color: #fff;
}

/* Panels */
.tv-amigos-panel { display: none; }
.tv-amigos-panel-active { display: block; }

.tv-amigos-section {
    font-size: 1rem; font-weight: 700;
    color: var(--dark); margin: 0 0 12px;
}

/* Buscador */
.tv-amigos-buscador { margin-bottom: 18px; }
.tv-amigos-buscador input {
    width: 100%; padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .95rem;
    background: #fff;
    transition: border-color .15s;
}
.tv-amigos-buscador input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6,214,160,.15);
}

/* Grid de tarjetas */
.tv-amigos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.tv-amigo-card {
    display: flex; align-items: center; gap: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    transition: box-shadow .15s, border-color .15s;
}

.tv-amigo-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    border-color: rgba(6,214,160,.3);
}

.tv-amigo-card-pending {
    background: linear-gradient(135deg, rgba(245,158,11,.04), transparent);
    border-color: rgba(245,158,11,.2);
}

.tv-amigo-card-blocked {
    opacity: .65;
    border-color: rgba(239,68,68,.25);
}

.tv-amigo-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(6,214,160,.15), rgba(6,214,160,.05));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}

.tv-amigo-info { flex: 1; min-width: 0; }

.tv-amigo-nombre {
    font-weight: 700; color: var(--dark);
    font-size: .95rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tv-amigo-stats {
    display: flex; gap: 8px; align-items: center;
    margin-top: 3px; font-size: .8rem; color: var(--muted);
    flex-wrap: wrap;
}

.tv-amigo-stat { font-weight: 600; }
.tv-amigo-stat-xp { font-variant-numeric: tabular-nums; }
.tv-amigo-stat-racha { color: #f59e0b; font-weight: 700; }
.tv-amigo-stat-meta { font-size: .76rem; font-style: italic; }

.tv-amigo-badge {
    display: inline-block;
    padding: 2px 9px;
    background: rgba(0,0,0,.06);
    color: var(--muted);
    border-radius: 8px;
    font-size: .72rem; font-weight: 700;
}
.tv-amigo-badge-ok {
    background: rgba(6,214,160,.15);
    color: var(--accent);
}
.tv-amigo-badge-blocked {
    background: rgba(239,68,68,.15);
    color: #ef4444;
}

.tv-amigo-actions {
    display: flex; gap: 6px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 5px 10px;
    font-size: .78rem;
}

/* Empty state mini */
.tv-empty-mini {
    padding: 18px 12px;
    text-align: center;
    color: var(--muted);
    font-size: .88rem;
    background: rgba(0,0,0,.02);
    border-radius: 10px;
}

/* Toast */
.tv-toast {
    position: fixed;
    bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 10px;
    color: #fff; font-weight: 600; font-size: .9rem;
    z-index: 9999;
    box-shadow: 0 6px 20px rgba(0,0,0,.2);
    animation: tvToastIn .25s ease-out;
}
.tv-toast-ok    { background: var(--accent, #06D6A0); }
.tv-toast-error { background: #ef4444; }
@keyframes tvToastIn {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── Página bandeja completa de notificaciones ────────────────────── */
.tv-notif-page-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.tv-notif-page-titulo {
    font-size: 1.5rem; font-weight: 800; margin: 0; color: var(--dark);
}
.tv-notif-page-actions {
    display: flex; gap: 8px;
}

.tv-notif-page-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 18px;
}

.tv-notif-page-item {
    display: flex; gap: 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--dark);
    text-decoration: none;
    transition: background .15s, border-color .15s;
    position: relative;
}

.tv-notif-page-item:hover {
    background: rgba(0,0,0,.02);
    border-color: rgba(6,214,160,.3);
}

.tv-notif-page-item-unread {
    background: rgba(6,214,160,.04);
    border-left: 3px solid var(--accent);
}

.tv-notif-page-ico { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }

.tv-notif-page-body { flex: 1; min-width: 0; }

.tv-notif-page-titulo-row {
    font-weight: 700;
    font-size: .95rem;
    color: var(--dark);
    margin-bottom: 3px;
}

.tv-notif-page-detalle {
    color: var(--muted); font-size: .85rem;
    line-height: 1.4;
}

.tv-notif-page-fecha {
    color: var(--muted); font-size: .75rem;
    margin-top: 6px;
}

.tv-notif-page-dot {
    position: absolute; top: 14px; right: 12px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
}

.tv-pag {
    display: flex; justify-content: center; align-items: center; gap: 14px;
    margin: 24px 0;
}
.tv-pag-info {
    font-size: .85rem; color: var(--muted);
}

/* Responsive */
@media (max-width: 600px) {
    .tv-notif-panel { width: 320px; }
    .tv-amigos-grid { grid-template-columns: 1fr; }
    .tv-amigo-actions { flex-direction: column; gap: 4px; }
    /* Historial XP: la fecha pasa a una 2ª línea bajo el tipo, evitando
       que las 3 columnas (tipo / fecha / delta) se compriman. */
    .tv-xp-row { grid-template-columns: 1fr auto; }
    .tv-xp-fecha { grid-column: 1 / -1; order: 3; margin-top: 2px; }
    .tv-xp-delta { min-width: 0; }
}

/* ═════════════════════════════════════════════════════════════════════
   PASO 4: Viralidad — compartir tarjeta + retos + invitaciones
   ═════════════════════════════════════════════════════════════════════ */

/* ─── Fila de compartir + retar en resultado.php ───────────────────── */
.res-share-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.res-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: .9rem;
    background: linear-gradient(135deg, var(--accent, #06D6A0), #04b585);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    min-width: 160px;
}
.res-share-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(6,214,160,.35);
}

.res-share-btn-alt {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.res-share-btn-alt:hover {
    box-shadow: 0 6px 18px rgba(139,92,246,.35);
}

/* ─── Modal de tarjeta ─────────────────────────────────────────────── */
.res-tarjeta-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: tvModalFadeIn .2s ease-out;
}

/* [hidden] debe ganar a display:flex (ver nota en .tv-modal-overlay) */
.res-tarjeta-modal[hidden] {
    display: none;
}

@keyframes tvModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.res-tarjeta-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.res-tarjeta-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border: none;
    background: transparent;
    color: var(--muted, #64748b);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
}
.res-tarjeta-close:hover {
    background: rgba(0,0,0,.06);
    color: var(--dark);
}

.res-tarjeta-preview {
    margin: 14px 0;
    text-align: center;
    background: rgba(0,0,0,.03);
    border-radius: 10px;
    padding: 8px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.res-tarjeta-preview img {
    max-width: 100%;
    max-height: 460px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
}

.res-tarjeta-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.res-tarjeta-hint {
    margin-top: 14px;
    font-size: .82rem;
    color: var(--muted);
    text-align: center;
    font-style: italic;
}

/* ─── Tarjeta de detalle de reto (r.php / j.php) ───────────────────── */
.tv-reto-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 4px 14px rgba(0,0,0,.04);
}

.tv-reto-card-head {
    text-align: center;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px dashed var(--border);
}

.tv-reto-card-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

.tv-reto-card-titulo {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--dark);
}

.tv-reto-card-subtitulo {
    font-size: .95rem;
    color: var(--muted);
}

.tv-reto-card-codigo {
    margin-top: 8px;
    font-size: .8rem;
    color: var(--muted);
}
.tv-reto-card-codigo code {
    background: rgba(0,0,0,.06);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    font-weight: 700;
    color: var(--dark);
    letter-spacing: 1px;
}

.tv-reto-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}

.tv-reto-stat {
    text-align: center;
    background: linear-gradient(135deg, rgba(6,214,160,.05), transparent);
    border: 1px solid rgba(6,214,160,.15);
    border-radius: 10px;
    padding: 14px 8px;
}

.tv-reto-stat-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent, #06D6A0);
    line-height: 1;
}

.tv-reto-stat-lbl {
    margin-top: 6px;
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.tv-reto-card-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 18px 0 12px;
}

.tv-reto-card-actions .btn-primary,
.tv-reto-card-actions .btn-secondary,
.tv-reto-card-actions .btn-ghost {
    min-width: 160px;
}

.tv-reto-card-meta {
    margin-top: 14px;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    font-style: italic;
}

/* ─── Listado de retos (retos.php) ─────────────────────────────────── */
.tv-reto-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tv-reto-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--dark);
    transition: border-color .15s, background .15s;
}
.tv-reto-row:hover {
    border-color: rgba(6,214,160,.4);
    background: rgba(6,214,160,.02);
}

.tv-reto-row-ico {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.tv-reto-row-body { flex: 1; min-width: 0; }

.tv-reto-row-titulo {
    font-weight: 700;
    font-size: .95rem;
    margin-bottom: 3px;
}

.tv-reto-row-meta {
    display: flex;
    gap: 6px;
    font-size: .8rem;
    color: var(--muted);
    flex-wrap: wrap;
    align-items: center;
}

.tv-reto-row-fecha {
    font-size: .75rem;
    color: var(--muted);
    flex-shrink: 0;
    text-align: right;
    min-width: 50px;
}

.tv-reto-marcador {
    background: rgba(0,0,0,.06);
    padding: 2px 10px;
    border-radius: 8px;
    font-weight: 800;
    font-family: var(--font-mono, monospace);
    color: var(--dark);
    margin-left: 4px;
}

/* ─── Modal genérico (v1.9.1 — sistema ÚNICO y canónico) ───────────────── */
/* Sistema ÚNICO de visibilidad de modales por atributo [hidden]:
   - Sin [hidden]  → visible (display:flex).
   - Con [hidden]  → oculto (display:none).
   Toda apertura/cierre pasa por el helper tvModal (assets/js/ui.js), que solo
   añade/quita el atributo [hidden]. El antiguo sistema ".open" (que coexistía
   en trivialista.css con opacity:0 + pointer-events:none) se ELIMINÓ en v1.9.1,
   junto con su contra-parche :not([hidden]). Esta es ahora la única definición
   de visibilidad de .tv-modal-overlay en todo el proyecto. */
.tv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: tvModalFadeIn .2s ease-out;
}

.tv-modal-overlay[hidden] {
    display: none;
}

.tv-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.tv-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.tv-modal-head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.tv-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 6px;
}
.tv-modal-close:hover {
    background: rgba(0,0,0,.06);
    color: var(--dark);
}

.tv-modal-body  { padding: 22px; }

.tv-modal-body label {
    display: block;
}

.tv-modal-body select,
.tv-modal-body input[type="text"],
.tv-modal-body input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    background: #fff;
    color: var(--dark);
}
.tv-modal-body select:focus,
.tv-modal-body input:focus {
    outline: none;
    border-color: var(--accent);
}

.tv-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,.02);
    border-radius: 0 0 14px 14px;
}

/* Responsive para los componentes del Paso 4 */
@media (max-width: 768px) {
    .tv-reto-card-grid { grid-template-columns: 1fr; gap: 8px; }
    .tv-reto-stat { padding: 10px 8px; }
    .tv-reto-stat-val { font-size: 1.2rem; }
    .res-share-btn { min-width: 100%; }
    .tv-reto-card-actions > * { width: 100%; }
}

/* ─── A11y: Respetar prefers-reduced-motion ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .tv-notif-pulse .tv-notif-badge { animation: none !important; }
}

/* ─── A11y: focus-visible coherente ──────────────────────────────────── */
.tv-notif-btn:focus-visible,
.tv-notif-item:focus-visible,
.tv-modal-close:focus-visible,
.res-tarjeta-close:focus-visible,
.tv-reto-row:focus-visible,
.res-share-btn:focus-visible,
.tv-amigos-tab:focus-visible {
    outline: 2px solid var(--accent, #06D6A0);
    outline-offset: 2px;
}
