:root {
    --blue-primary: #2563EB;
    --blue-light: #DBEAFE;
    --blue-mid: #3B82F6;
    --bg: #E8F3FC;
    --white: #FFFFFF;
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --shadow: 0 4px 24px rgba(37,99,235,0.10);
}

body { background: var(--bg); }
.page { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.5rem; }
.card { background: var(--white); margin-top: -10px; border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; min-height: calc(100vh - 120px); display: flex; flex-direction: column; }

.card-header {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-mid));
    padding: 1rem 2.5rem; color: white;
}
.card-header {
    display: flex;
    gap: 10px;
    align-items: end;
    margin-bottom: 0.3rem;
}

.card-header p  { color: rgba(255,255,255,0.82); font-size: 0.95rem; }

.card-body { padding: 1.25rem 1.5rem; margin-top: -10px; display: flex; flex-direction: column; flex: 1; }

/* ── Layout de dos columnas ── */
.layout-grid {
    display: grid;
    grid-template-columns: 4fr 2fr;
    gap: 1.25rem;
    align-items: stretch;
    flex: 1;
}

.col-camara {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.col-controles {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: flex-start;
    height: 100%;
}

.seña-info {
    text-align: center;
    padding: 0.5rem 0;
}


.card-header  svg{
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 10px;
    width: 60px;
    height: 60px;
}
.tet h1{
    font-size: 1.8rem; 
}

.camara-area {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 420px;
    max-width: 1280px;   /* no más ancho que una cámara Full HD típica */
    max-height: 720px;   /* altura máxima equivalente a 720p */
    background: #0F172A;
    border-radius: 16px;
    overflow: hidden;
    align-self: flex-start; /* evita que el flex-column lo estire */
}
.camara-area .emoji { font-size: 3rem; }
.camara-area p      { font-size: 0.9rem; font-weight: 500; }

#video {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 16px;
    transform: scaleX(-1);
}

#canvas { display: none; }

#placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    color: white;
}

#badge-seña {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(37,99,235,0.85); color: white;
    padding: 6px 20px; border-radius: 20px;
    font-size: 0.85rem; font-weight: 600;
    display: none;
}

.resultado {
    background: #F0F7FF; border: 1.5px solid #BFDBFE; border-radius: 12px;
    padding: 1rem 1.25rem;
    height: calc(1.6em * 3 + 2rem); /* exactamente 3 líneas + padding */
    overflow-y: auto;
    font-size: 1rem; color: var(--text-muted); font-style: italic;
    line-height: 1.6;
}
.resultado.activo { color: var(--text-dark); font-style: normal; font-weight: 500; }

#seña-actual {
    font-size: 2.5rem; font-weight: 800; color: var(--blue-primary);
    text-align: center; min-height: 50px; letter-spacing: 1px; margin-top: 0;
}
#confianza-texto { font-size: 0.85rem; color: var(--text-muted); text-align: center; }
#estado-texto    { font-size: 0.85rem; color: var(--text-muted); text-align: center; font-style: italic; }

#historial {
    font-size: 1rem; color: var(--text-dark);
    font-style: normal; font-weight: 500;
    word-wrap: break-word;
}

.btn {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-mid));
    color: white; border: none; border-radius: 12px; padding: 0.85rem 2rem;
    font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
    box-shadow: 0 4px 14px rgba(37,99,235,0.45);
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.45); }
.btn.rojo  { background: linear-gradient(135deg, #DC2626, #EF4444); box-shadow: 0 4px 14px rgba(220,38,38,0.35); }
.btn.btn-limpiar { background: linear-gradient(135deg,#64748B,#94A3B8); box-shadow: none; }

.botones {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.botones .pill-toggle {
    /* pill permanece en su tamaño natural, centrado */
    flex-shrink: 0;
}

.botones-fila {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    width: 100%;
}

.botones .btn {
    flex: 1 1 0;
    text-align: center;
}

/* ── Pill toggle ─────────────────────────────────────── */
.pill-toggle {
    position: relative;
    display: flex;
    align-items: center;
    width: 96px;
    height: 44px;
    background: #DBEAFE;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.15);
    flex-shrink: 0;
}

/* thumb deslizante */
.pill-thumb {
    position: absolute;
    left: 4px;
    width: 40px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-mid));
    border-radius: 999px;
    transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 2px 8px rgba(37,99,235,0.35);
    z-index: 1;
}

/* cuando está en modo voz, el thumb se desliza a la derecha */
.pill-toggle.voz .pill-thumb {
    transform: translateX(48px);
}

/* iconos fijos a cada lado */
.pill-icon {
    position: absolute;
    font-size: 1.15rem;
    z-index: 2;
    transition: opacity 0.2s;
    line-height: 1;
}

.pill-icon-left  { left: 12px; }
.pill-icon-right { right: 12px; }

/* el icono activo (cubierto por el thumb) se hace más brillante */
.pill-toggle:not(.voz) .pill-icon-left  { filter: brightness(10); }
.pill-toggle.voz        .pill-icon-right { filter: brightness(10); }


/* ================================================================
   RESPONSIVE — solo layout, espaciado y tamaños
   xs  : < 480px         Móviles pequeños
   sm  : 480px – 767px   Móviles grandes
   md  : 768px – 1023px  Tablets / laptops pequeñas
   lg  : 1024px – 1279px Laptops estándar 13"–14"
   xl  : 1280px – 1535px PC Windows / MacBook Pro 15–16"
   2xl : ≥ 1536px        iMac / pantallas grandes
================================================================ */

/* ── Móviles pequeños (< 480px) ────────────────────────── */
@media (max-width: 479px) {
    .page {
        padding: 0.75rem 0.75rem;
    }

    .card {
        border-radius: 16px;
        min-height: unset;
    }

    .card-header {
        padding: 0.85rem 1rem;
        align-items: center;
    }

    .card-header svg {
        width: 44px;
        height: 44px;
        padding: 8px;
        flex-shrink: 0;
    }

    .tet h1 {
        font-size: 1.1rem;
    }

    .card-header p {
        font-size: 0.78rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    .layout-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .camara-area {
        height: auto;
        aspect-ratio: 3 / 4;
        min-height: unset;
    }

    #seña-actual {
        font-size: 1.8rem;
    }

    .botones {
        gap: 0.65rem;
    }

    .botones-fila {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.65rem;
    }

    .botones .btn {
        flex: 1 1 calc(50% - 0.65rem);
        min-width: 120px;
        padding: 0.75rem 1rem;
        font-size: 0.88rem;
        width: auto;
    }

    .pill-toggle {
        order: -1;
        width: 88px;
        height: 40px;
    }

    .pill-thumb {
        width: 36px;
        height: 32px;
    }

    .pill-toggle.voz .pill-thumb {
        transform: translateX(44px);
    }
}

/* ── Móviles grandes (480px – 767px) ───────────────────── */
@media (min-width: 480px) and (max-width: 767px) {
    .page {
        padding: 1rem 1rem;
    }

    .card {
        border-radius: 20px;
        min-height: unset;
    }

    .card-header {
        padding: 1rem 1.25rem;
        align-items: center;
    }

    .card-header svg {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }

    .tet h1 {
        font-size: 1.35rem;
    }

    .card-body {
        padding: 1rem 1.25rem;
    }

    .layout-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .camara-area {
        height: auto;
        aspect-ratio: 3 / 4;
        min-height: unset;
    }

    .botones-fila {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .botones .btn {
        flex: 1 1 auto;
        padding: 0.8rem 1.25rem;
        font-size: 0.92rem;
        width: auto;
    }
}

/* ── Tablets y laptops pequeñas (768px – 1023px) ───────── */
@media (min-width: 768px) and (max-width: 1023px) {
    .page {
        padding: 1.25rem 1.25rem;
    }

    .card-header {
        padding: 1rem 1.75rem;
    }

    .card-body {
        padding: 1.25rem 1.75rem;
    }

    .tet h1 {
        font-size: 1.55rem;
    }

    .layout-grid {
        grid-template-columns: 3fr 2fr;
    }

    .camara-area {
        min-height: 320px;
    }
}

/* ── PC Windows / MacBook Pro 15–16" (1280px – 1535px) ─── */
@media (min-width: 1280px) and (max-width: 1535px) {
    .page {
        max-width: 1280px;
        padding: 1.5rem 2rem;
    }
}

/* ── iMac / pantallas grandes ≥ 1536px ─────────────────── */
@media (min-width: 1536px) {
    .page {
        max-width: 1400px;
        padding: 2rem 2.5rem;
    }

    .card-header {
        padding: 1.25rem 3rem;
    }

    .card-header svg {
        width: 68px;
        height: 68px;
    }

    .tet h1 {
        font-size: 2rem;
    }

    .card-body {
        padding: 1.75rem 2rem;
    }

    .btn {
        padding: 0.95rem 2.25rem;
        font-size: 1.05rem;
    }
}

/* ── Landscape móvil (altura < 500px) ──────────────────── */
@media (max-height: 500px) and (max-width: 900px) {
    .page {
        padding: 0.5rem 0.75rem;
    }

    .card {
        min-height: unset;
    }

    .card-header {
        padding: 0.65rem 1rem;
    }

    .card-header p {
        display: none;
    }

    .card-header svg {
        width: 36px;
        height: 36px;
        padding: 6px;
    }

    .tet h1 {
        font-size: 1rem;
    }

    .card-body {
        padding: 0.65rem 1rem;
        gap: 0.65rem;
    }

    #seña-actual {
        font-size: 1.6rem;
        min-height: 36px;
    }
}