:root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: rgba(24, 24, 27, 0.78);
    --card-strong: rgba(39, 39, 42, 0.88);
    --muted: #a1a1aa;
    --border: rgba(255, 255, 255, 0.12);
    --input: rgba(39, 39, 42, 0.92);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.42);
    --danger: #fb7185;
    --success: #22c55e;
    --radius: 18px;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--foreground);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34rem),
        linear-gradient(135deg, #050507 0%, #0b1020 54%, #09090b 100%);
}

button,
input {
    font: inherit;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 0 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(9, 9, 11, 0.74);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(18px);
}

.eyebrow,
.result-label {
    display: block;
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 6px 0 0;
    font-size: clamp(2rem, 5vw, 4.4rem);
    line-height: 0.96;
    letter-spacing: 0;
    font-weight: 900;
}

.status-pill {
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.86rem;
    font-weight: 700;
}

.status-pill.is-active {
    color: #bbf7d0;
    border-color: rgba(34, 197, 94, 0.36);
    background: rgba(34, 197, 94, 0.12);
}

.status-pill.is-warning {
    color: #fef3c7;
    border-color: rgba(250, 204, 21, 0.42);
    background: rgba(250, 204, 21, 0.12);
}

.status-pill.is-good {
    color: #bbf7d0;
    border-color: rgba(34, 197, 94, 0.42);
    background: rgba(34, 197, 94, 0.14);
}

.status-pill.is-bad {
    color: #fecdd3;
    border-color: rgba(251, 113, 133, 0.42);
    background: rgba(251, 113, 133, 0.12);
}

.hero-copy {
    max-width: 680px;
}

.hero-copy p {
    margin: 0;
    color: #d4d4d8;
    font-size: clamp(1rem, 2.4vw, 1.22rem);
    line-height: 1.65;
}

.emotion-card {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 8px);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.preview-panel {
    position: relative;
    min-height: 440px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(39, 39, 42, 0.72), rgba(10, 10, 12, 0.9));
}

.camera-preview,
.image-preview {
    width: 100%;
    height: 100%;
    min-height: 440px;
    display: none;
    object-fit: cover;
}

.camera-preview {
    transform: scaleX(-1);
}

.image-preview {
    max-width: none;
}

.face-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    pointer-events: none;
    z-index: 2;
}

.face-guide {
    position: absolute;
    left: 50%;
    bottom: 16px;
    z-index: 3;
    display: none;
    min-width: min(280px, calc(100% - 28px));
    transform: translateX(-50%);
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--foreground);
    background: rgba(9, 9, 11, 0.72);
    text-align: center;
    font-size: 0.92rem;
    font-weight: 850;
    backdrop-filter: blur(12px);
}

.face-guide.is-good {
    color: #bbf7d0;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(20, 83, 45, 0.64);
}

.face-guide.is-warn {
    color: #fef3c7;
    border-color: rgba(250, 204, 21, 0.5);
    background: rgba(113, 63, 18, 0.62);
}

.face-guide.is-bad {
    color: #fecdd3;
    border-color: rgba(251, 113, 133, 0.5);
    background: rgba(136, 19, 55, 0.62);
}

.countdown-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: none;
    place-content: center;
    gap: 12px;
    padding: 28px;
    color: var(--foreground);
    text-align: center;
    background: rgba(9, 9, 11, 0.48);
    backdrop-filter: blur(2px);
}

.countdown-overlay.is-active {
    display: grid;
}

.countdown-number {
    display: block;
    font-size: clamp(5rem, 18vw, 9rem);
    line-height: 0.9;
    font-weight: 950;
    text-shadow: 0 10px 36px rgba(0, 0, 0, 0.58);
}

.countdown-overlay p {
    margin: 0;
    font-size: clamp(1.35rem, 4vw, 2.2rem);
    font-weight: 900;
    text-shadow: 0 8px 28px rgba(0, 0, 0, 0.62);
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 8px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.preview-placeholder span {
    color: var(--foreground);
    font-size: 1.15rem;
    font-weight: 900;
}

.preview-placeholder p {
    max-width: 340px;
    margin: 0;
    line-height: 1.55;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 850;
    color: var(--foreground);
    text-align: center;
    transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.btn:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary {
    background: var(--primary);
    border-color: rgba(147, 197, 253, 0.24);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--card-strong);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: rgba(147, 197, 253, 0.36);
    background: rgba(49, 49, 54, 0.96);
}

.file-input {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.file-trigger {
    margin: 0;
}

.resultado {
    min-height: 190px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(9, 9, 11, 0.52);
}

.resultado h2 {
    margin: 8px 0 14px;
    font-size: 1.35rem;
    font-weight: 900;
}

.resultado p {
    margin: 9px 0;
    color: #e4e4e7;
    line-height: 1.5;
}

.resultado strong {
    color: var(--foreground);
}

.metric-grid {
    display: grid;
    gap: 10px;
}

.metric {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 1.05rem;
}

.muted-text {
    color: var(--muted);
}

.message-error {
    color: #fecdd3;
}

.message-warning {
    color: #fef3c7;
}

.message-loading {
    color: #bfdbfe;
}

@media (max-width: 840px) {
    .app-shell {
        justify-content: flex-start;
        padding-top: 18px;
    }

    .topbar,
    .emotion-card {
        border-radius: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .emotion-card {
        grid-template-columns: 1fr;
    }

    .preview-panel,
    .camera-preview,
    .image-preview {
        min-height: 340px;
    }
}

@media (max-width: 520px) {
    .app-shell {
        width: min(100% - 20px, 1120px);
        gap: 14px;
    }

    .topbar,
    .emotion-card,
    .resultado {
        padding: 14px;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }

    .preview-panel,
    .camera-preview,
    .image-preview {
        min-height: 300px;
    }
}
