:root {
    --bg: #0f172a;
    --card: #ffffff;
    --muted: #6b7280;
    --text: #0b1220;
    --primary: #6a11cb;
    --primary2: #2575fc;
    --ok: #16a34a;
    --warn: #f59e0b;
    --bad: #ef4444;
    --shadow: 0 14px 35px rgba(0,0,0,0.12);
    --radius: 20px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}
/*
html { 
    overflow-y: scroll; 
}*/

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Helvetica Neue", sans-serif;
    background: radial-gradient(1200px 900px at 15% 10%, rgba(106,17,203,0.24), transparent 60%),
                  radial-gradient(1200px 900px at 85% 10%, rgba(37,117,252,0.22), transparent 60%),
                  #f6f8ff;
    min-height: 100vh;
    color: var(--text);
    padding: 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}
/*
body{
      margin:0;
      font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Helvetica Neue", sans-serif;
      background: radial-gradient(1200px 900px at 15% 10%, rgba(106,17,203,0.24), transparent 60%),
                  radial-gradient(1200px 900px at 85% 10%, rgba(37,117,252,0.22), transparent 60%),
                  #f6f8ff;
      color:var(--text);
    }
	*/
.container {
    max-width: 1100px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-top: -20px;
}

.main-content { 
    padding: 30px; 
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border-radius: 0 0 25px 25px;
    box-shadow: var(--shadow);
    width: 100%;
    /*max-width: 1100px;*/
    max-width: 100%;
}

.header h1 {
    margin: 0;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.header .tagline {
    margin: 10px 0 0;
    font-size: 1.2em;
    opacity: 0.9;
}

/* Animación typing + collapse */
@keyframes blinkCaret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.type-cursor {
    border-right: 2px solid rgba(255,255,255,0.95);
    padding-right: 2px;
    animation: blinkCaret 0.7s steps(1) infinite;
}

.header.hero-anim {
    overflow: hidden;
    max-height: 500px;
    will-change: transform, max-height, padding, margin, opacity;
    transition: transform 0.65s ease, opacity 0.65s ease, max-height 0.65s ease, padding 0.65s ease, margin 0.65s ease;
}

.header.hero-collapsing {
    transform: translateY(-120%);
    opacity: 0;
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* ============= CÁMARA CON LENTE CUADRADO ============= */
.camera-section {
    margin-bottom: 30px;
}

.camera-box {
    background: #111827;
    border-radius: 0px;
 /*   padding: 25px 20px;*/
    padding: 0px 0px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border: 0px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 100%;
	height: 100vh;
}

.camera-box:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(106, 17, 203, 0.4);
}

/* Lente cuadrado - OCUPA ANCHO COMPLETO */
.square-lens-container {
    position: relative;
    width: 100%;
    margin: 0 auto 25px;
    aspect-ratio: 1; /* Mantiene relación cuadrado */
    max-height: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.square-lens {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a202c, #111827);
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 0 40px rgba(0, 0, 0, 0.8),
        0 15px 35px rgba(0, 0, 0, 0.6);
    border: 8px solid #2d3748;
    border-radius: 12px; /* Esquinas ligeramente redondeadas */
}

/* Vista previa dentro del lente */
.lens-preview {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2d3748, #1a202c);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.lens-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
    /* REMOVER transform: scaleX(-1) si causa espejo */
}

.lens-preview.active video {
    opacity: 1;
}

/* Mensaje de vista previa */
.lens-preview-message {
    position: absolute;
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    text-align: center;
    padding: 20px;
    z-index: 3;
    transition: opacity 0.3s ease;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.lens-preview.active .lens-preview-message {
    opacity: 0;
}

.lens-preview-message i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    color: rgba(255, 255, 255, 0.9);
}

/* Botón de disparo */
.shutter-button {
    position: relative;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 10px 30px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 0 4px rgba(239, 68, 68, 0.2);
}

.shutter-button:hover {
    transform: scale(1.1);
    box-shadow: 
        0 15px 40px rgba(239, 68, 68, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 6px rgba(239, 68, 68, 0.3);
}

.shutter-button:active {
    transform: scale(0.95);
    box-shadow: 
        0 5px 20px rgba(239, 68, 68, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(239, 68, 68, 0.2);
}

.shutter-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.shutter-inner {
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Texto debajo del lente */
.camera-text {
    color: white;
    margin-bottom: 20px;
}

.camera-text h3 {
    font-size: 24px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.camera-text p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Botón de subida alternativo */
.camera-control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-weight: 600;
}

.camera-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.upload-fallback {
    text-align: center;
    margin-top: 20px;
}

/* Efecto de flash al tomar foto */
@keyframes cameraFlash {
    0% { 
        opacity: 0;
        transform: scale(0.8);
    }
    50% { 
        opacity: 1;
        transform: scale(1.2);
    }
    100% { 
        opacity: 0;
        transform: scale(1.5);
    }
}

.flash-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
}

.flash-effect.active {
    animation: cameraFlash 0.5s ease-out;
}

/* Vista previa de la foto capturada */
.camera-preview {
    margin-top: 20px;
    display: none;
    background: #f8f9ff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid rgba(0,0,0,0.08);
}

.preview-container {
    width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    max-height: 400px;
}

#cameraCapture {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.preview-info {
    text-align: center;
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    font-style: italic;
}

.capture-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.capture-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    justify-content: center;
    transition: all 0.2s;
}

.capture-btn.primary {
    background: var(--primary);
    color: #fff;
}

.capture-btn.secondary {
    background: #f1f5f9;
    color: var(--text);
}

.capture-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.auto-compress-toggle {
    margin-top: 15px;
    text-align: center;
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background-color: #ccc;
    border-radius: 34px;
    position: relative;
    transition: .4s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-weight: bold;
    color: var(--text);
}

/* ============= NIVELES DE COMPRESIÓN ============= */
.level-section {
    margin-top: 26px;
    margin-bottom: 18px;
}

.level-section h2 {
    margin-bottom: 14px;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.level-cards {
    display: flex;
    gap: 12px;
    width: 100%;
    flex-wrap: nowrap;
}

.level-card {
    flex: 1 1 0;
    min-width: 0;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.level-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(0,0,0,0.12);
    border-color: rgba(37,117,252,0.35);
}

.level-card.active {
    border: 0;
    background: linear-gradient(135deg, rgba(106,17,203,0.10), rgba(37,117,252,0.08));
    box-shadow: 0 16px 34px rgba(106,17,203,0.18);
    outline: 2px solid rgba(106,17,203,0.35);
}

.level-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    box-shadow: 0 10px 20px rgba(106,17,203,0.25);
    margin-bottom: 10px;
}

.level-name {
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 4px;
}

.level-desc {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.25;
}

.level-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 900;
}

.lossless .level-badge {
    background: rgba(22,163,74,0.12);
    color: var(--ok);
}

.super .level-badge {
    background: rgba(245,158,11,0.12);
    color: var(--warn);
}

.ultra .level-badge {
    background: rgba(239,68,68,0.12);
    color: var(--bad);
}

/* ============= SELECTOR DE FORMATO ============= */
.format-selector {
    margin-top: 18px;
    text-align: center;
}

.format-selector h3 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.format-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: nowrap;
}

.format-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    font-weight: 900;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.format-btn span {
    font-size: 13px;
}

.format-btn i {
    font-size: 16px;
}

.format-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.format-btn.avif {
    border-color: #0077ff;
}

.format-btn.avif.active {
    background: #0077ff;
    border-color: #0077ff;
}

/* ============= BOTÓN DE COMPRESIÓN ============= */
.action-section {
    text-align: center;
    margin-top: 22px;
}

.action-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    border: none;
    padding: 16px 32px;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    margin-bottom: 18px;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(106, 17, 203, 0.4);
}

.action-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.file-upload {
    margin-top: 15px;
}

.file-upload-btn {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid #cbd5e1;
    padding: 12px 18px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
}

#fileInput {
    display: none;
}

/* ============= RESULTADOS ============= */
.result-section {
    display: none;
    margin-top: 30px;
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.result-section h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* Grid para resultados: Primera fila 50% cada uno, segunda fila 100% */
.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas iguales */
    grid-template-rows: auto auto; /* Dos filas */
    gap: 15px;
    margin-bottom: 20px;
}

/* Primera fila: Original y Salida (50% cada uno) */
.stat.original,
.stat.output {
    grid-row: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat.original {
    grid-column: 1;
}

.stat.output {
    grid-column: 2;
}

/* Segunda fila: Ahorro (100% ancho) */
.stat.savings {
    grid-row: 2;
    grid-column: 1 / span 2; /* Ocupa ambas columnas */
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white !important;
    border: none;
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

/* Texto para todos los stats */
.stat .label {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat.savings .label {
    color: rgba(255, 255, 255, 0.9) !important;
}

.stat .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text);
}

.stat.savings .value {
    color: white !important;
    font-size: 28px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Animación para el ahorro */
@keyframes pulseSavings {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.stat.savings {
    animation: pulseSavings 2s ease-in-out;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============= TOAST ============= */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #111827;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 12px 26px rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    max-width: min(420px, calc(100vw - 40px));
}

.toast.visible {
    display: flex;
    animation: slideIn 0.3s ease;
}

.toast.ok {
    background: var(--ok);
}

.toast.error {
    background: var(--bad);
}

.toast.warn {
    background: var(--warn);
    color: #111827;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============= FOOTER ============= */
footer {
    margin-top: 30px;
    color: #fff;
    text-align: center;
    opacity: 0.85;
    font-size: 14px;
    width: 100%;
    max-width: 1100px;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    body {
        padding: 14px;
        padding: 0px;
    }
    
    .container {
        margin-top: -25px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 26px;
    }
    
    .header .tagline {
        font-size: 1em;
    }
    
    .square-lens-container {
        max-height: 400px;
        max-height: 800px;
    }
    
    .square-lens {
        border-width: 6px;
    }
    
    .lens-preview-message i {
        font-size: 36px;
    }
    
    .lens-preview-message {
        font-size: 14px;
        padding: 15px;
    }
    
    .shutter-button {
        width: 70px;
        height: 70px;
    }
    
    .camera-text h3 {
        font-size: 20px;
    }
    
    .level-cards {
        flex-direction: column;
    }
    
    .level-card {
        width: 100%;
    }
    
    .format-buttons {
        flex-direction: column;
    }
    
    .format-btn {
        width: 100%;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .stat.original {
        grid-row: 1;
        grid-column: 1;
    }
    
    .stat.output {
        grid-row: 2;
        grid-column: 1;
    }
    
    .stat.savings {
        grid-row: 3;
        grid-column: 1;
    }
    
    .capture-btn {
        width: 100%;
        min-width: 0;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
    
    .camera-control-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0px;
    max-width: 100%;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .square-lens-container {
        max-height: 350px;
        height: 650px;
        max-height: 650px;
    }
    
    .shutter-button {
        width: 60px;
        height: 60px;
    }
    
    .shutter-inner {
        width: 50%;
        height: 50%;
    }
    
    .camera-text h3 {
        font-size: 18px;
    }
    
    .camera-text p {
        font-size: 13px;
    }
    
    .stat .value {
        font-size: 20px;
    }
    
    .stat.savings .value {
        font-size: 22px;
    }

  /* ==== Mobile compact layout (<=480px): 3-up rows (no wrap) ==== */
  .camera-section { margin-bottom: 18px; }
  .camera-box{
    width: 100%;
    border: 0 !important;            /* sin borde claro */
    background: #0b1220;             /* caja sólida */
    color: #ffffff;
  /*  padding: 18px 16px;*/
    padding: 0px 0px;
    box-shadow: 0 14px 35px rgba(0,0,0,0.22);
	max-width: 100% !important;
  }
  .camera-box:hover{ background:#0f1b33; }
  .camera-box h3, .camera-box p{ color:#e5e7eb; }
  .camera-icon{ color:#ffffff; opacity:0.95; }

  /* Niveles: una sola fila */
  .level-cards{
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px;
  }
  .level-card{
    flex: 1 1 0;
    min-width: 0;
    padding: 14px 12px;
  }
  .level-icon{
    width: 38px; height: 38px;
    border-radius: 12px;
    margin-bottom: 10px;
  }
  .level-name{ font-size: 14px; margin-bottom: 6px; }
  .level-desc{ font-size: 11px; line-height: 1.2; }
  .level-badge{ top: 10px; right: 10px; font-size: 11px; padding: 3px 8px; }

  /* Formato: una sola fila */
  .format-buttons{
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px;
  }
  .format-btn{
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 8px;
    font-size: 12px;
    line-height: 1.1;
  }
  .format-btn i{ font-size: 14px; }

  /* Resultados: una sola fila */
  .result-stats{
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px;
  }
  .stat{
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 10px;
  }
  .stat .value{ font-size: 18px; }

}


/* Animaciones adicionales */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.camera-preview {
    animation: fadeIn 0.3s ease;
}

.result-section {
    animation: fadeIn 0.5s ease;
}


/***************************** ****************************/
/* ============= VISTA PREVIA DE FOTO CAPTURADA ============= */
/* ============= VISTA PREVIA DE FOTO CAPTURADA - EN UNA FILA ============= */
.camera-preview {
    margin-top: 20px;
    display: none;
    background: #f8f9ff;
    border-radius: 16px;
    padding: 15px;
    border: 1px solid rgba(0,0,0,0.08);
}

.preview-container {
    width: 100%;
    margin: 0 auto 12px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
    display: flex;
    justify-content: center;
    align-items: center;
}

#cameraCapture {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.preview-info {
    text-align: center;
    margin-bottom: 15px;
    color: var(--muted);
    font-size: 13px;
}

/* CONTROLES EN UNA SOLA FILA - SIN WRAP */
.camera-preview-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.capture-controls {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Permite que se encoja */
}

.capture-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.2s;
}

.capture-btn.primary {
    background: var(--primary);
    color: #fff;
}

.capture-btn.secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid #cbd5e1;
}

.auto-compress-toggle {
    flex-shrink: 0; /* No se encoge */
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    white-space: nowrap;
}

.toggle-slider {
    width: 40px;
    height: 20px;
    background-color: #ccc;
    border-radius: 34px;
    position: relative;
    transition: .4s;
    flex-shrink: 0;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-weight: 600;
    color: var(--text);
    display: none; /* Ocultar en móviles */
}

/* ============= NIVELES DE COMPRESIÓN - UNA FILA ============= */
.level-section {
    margin: 20px 0 15px;
}

.level-section h2 {
    margin-bottom: 12px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

/* CONTENEDOR PRINCIPAL - SCROLL HORIZONTAL */
.level-cards-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    margin-bottom: -10px;
}

.level-cards {
    display: inline-flex; /* ¡ESTO ES CLAVE! */
    gap: 8px;
    padding: 2px;
    min-width: min-content; /* Fuerza el scroll si es necesario */
}

.level-card {
    flex: 0 0 auto;
    width: 150px; /* Ancho FIJO */
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.level-card.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(106,17,203,0.05), rgba(37,117,252,0.03));
    box-shadow: 0 4px 12px rgba(106,17,203,0.1);
}

.level-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    margin-bottom: 8px;
    font-size: 14px;
}

.level-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.level-desc {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
    margin-bottom: 8px;
    height: 28px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.level-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 700;
    background: rgba(0,0,0,0.05);
}

.lossless .level-badge {
    background: rgba(22,163,74,0.1);
    color: var(--ok);
}

.super .level-badge {
    background: rgba(245,158,11,0.1);
    color: var(--warn);
}

.ultra .level-badge {
    background: rgba(239,68,68,0.1);
    color: var(--bad);
}

/* ============= SELECTOR DE FORMATO - UNA FILA ============= */
.format-selector {
    margin: 15px 0;
}

.format-selector h3 {
    margin-bottom: 10px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

/* CONTENEDOR CON SCROLL */
.format-buttons-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    margin-bottom: -8px;
}

.format-buttons {
    display: inline-flex; /* ¡ESTO ES CLAVE! */
    gap: 6px;
    padding: 2px;
    min-width: min-content;
}

.format-btn {
    flex: 0 0 auto;
    width: 120px; /* Ancho FIJO */
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
}

.format-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.format-btn.avif.active {
    background: #0077ff;
    border-color: #0077ff;
}

.format-btn i {
    font-size: 14px;
}

.format-btn span {
    font-size: 12px;
}

.preview-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* ============= RESULTADOS - UNA FILA ============= */
.result-section {
    display: none;
    margin-top: 20px;
    background: #fff;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.result-section h3 {
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
}

/* CONTENEDOR CON SCROLL */
.result-stats-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.result-stats {
    display: inline-flex; /* ¡ESTO ES CLAVE! */
    gap: 8px;
    padding: 2px;
    min-width: min-content;
}

.stat {
    flex: 0 0 auto;
    width: 140px; /* Ancho FIJO */
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat.savings {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white !important;
    border: none;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

.stat .label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.stat.savings .label {
    color: rgba(255, 255, 255, 0.95) !important;
}

.stat .value {
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat.savings .value {
    color: white !important;
    font-size: 20px;
}

.stat .size-detail {
    font-size: 11px;
    color: #6b7280;
    opacity: 0.8;
    white-space: nowrap;
}

.stat.savings .size-detail {
    color: rgba(255, 255, 255, 0.9) !important;
}

.result-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ============= MEDIA QUERIES ESPECÍFICAS ============= */

/* MÓVILES (≤480px) - YA ESTÁ CONFIGURADO PARA UNA FILA */
@media (max-width: 480px) {
    /* Mostrar label en toggle para móviles más grandes */
    .toggle-label {
        display: inline;
    }
    
    /* Ajustar ancho de botones para móviles pequeños */
    @media (max-width: 380px) {
        .level-card {
            width: 140px;
        }
        
        .format-btn {
            width: 110px;
        }
        
        .stat {
            width: 130px;
        }
    }
    
    @media (max-width: 340px) {
        .level-card {
            width: 130px;
            padding: 10px;
        }
        
        .format-btn {
            width: 100px;
            padding: 8px 6px;
            font-size: 12px;
        }
        
        .format-btn span {
            font-size: 11px;
        }
        
        .stat {
            width: 120px;
        }
        
        .capture-btn {
            padding: 8px 10px;
            font-size: 12px;
        }
    }
}

/* TABLETS (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .level-card {
        width: 160px;
    }
    
    .format-btn {
        width: 130px;
    }
    
    .stat {
        width: 150px;
    }
    
    .toggle-label {
        display: inline;
    }
}

/* DESKTOP (≥769px) */
@media (min-width: 769px) {
    /* Quitar scroll horizontal y centrar */
    .level-cards-container,
    .format-buttons-container,
    .result-stats-container {
        overflow-x: visible;
        padding-bottom: 0;
        margin-bottom: 0;
    }
    
    .level-cards,
    .format-buttons,
    .result-stats {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    
    .level-card {
        width: 180px;
    }
    
    .format-btn {
        width: 140px;
    }
    
    .stat {
        width: 160px;
    }
    
    .toggle-label {
        display: inline;
    }
}

/* SCROLLBAR ESTILIZADA */
.level-cards-container::-webkit-scrollbar,
.format-buttons-container::-webkit-scrollbar,
.result-stats-container::-webkit-scrollbar {
    height: 4px;
}

.level-cards-container::-webkit-scrollbar-track,
.format-buttons-container::-webkit-scrollbar-track,
.result-stats-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.level-cards-container::-webkit-scrollbar-thumb,
.format-buttons-container::-webkit-scrollbar-thumb,
.result-stats-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}


/*************************************************************************************************/
    *{box-sizing:border-box}
    body{
      margin:0;
      font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Helvetica Neue", sans-serif;
      background: radial-gradient(1200px 900px at 15% 10%, rgba(106,17,203,0.24), transparent 60%),
                  radial-gradient(1200px 900px at 85% 10%, rgba(37,117,252,0.22), transparent 60%),
                  #f6f8ff;
      color:var(--text);
    }
    .container{max-width:1100px; margin:0 auto; padding: 0 8px 40px;}
    .topbar{
      display:flex; align-items:center; justify-content:space-between;
      gap:12px; padding:14px 2px 10px;
    }
    .brand{
      display:flex; align-items:center; gap:10px;
      font-weight:900; letter-spacing:0.2px;
    }
    .brand .dot{width:10px;height:10px;border-radius:50%; background:linear-gradient(135deg,var(--primary),var(--primary2)); box-shadow:0 0 0 4px rgba(106,17,203,0.12);}
    .pill{
      font-size:12px; padding:7px 10px; border-radius:999px;
      background:#ffffffcc; border:1px solid rgba(0,0,0,0.06);
      box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    }
	
    /* Hero header EXACTO como pediste (con tu inline style) */
    header.header{ text-align:center; margin-bottom:30px; padding:30px;
      background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
      color:white; border-radius: 0 0 25px 25px;
      box-shadow: var(--shadow);
    }
    header.header h1{ margin:0; font-size: 32px; display:flex; align-items:center; justify-content:center; gap:10px;}
    header.header .tagline{ margin:10px 0 0; font-size:1.2em; opacity:0.9; }
