* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #eef2ff;
    color: #0f172a;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.app-shell {
    min-height: 100vh;
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1d4ed8;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.status-card {
    min-width: 110px;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    color: #ffffff;
    text-align: center;
    box-shadow: 0 14px 30px rgba(30, 58, 138, 0.24);
}

.status-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    opacity: 0.85;
}

.status-card strong {
    font-size: 30px;
}

.content {
    display: grid;
    gap: 16px;
}

.panel {
    padding: 16px;
    border: 1px solid #dbe4ff;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.panel-header p {
    margin: 0;
    color: #475569;
}

.provider-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #dbe4ff;
    border-radius: 14px;
    background: #f8fbff;
}

.provider-label {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.provider-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #1e3a8a;
    font-weight: 700;
}

.provider-option input {
    margin: 0;
}

.camera-frame,
.preview-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    overflow: hidden;
    border: 2px dashed #93c5fd;
    border-radius: 18px;
    background: #dbeafe;
}

#camera,
#previewImage {
    display: block;
    width: 100%;
    max-height: 440px;
    object-fit: contain;
    background: #0f172a;
}

.camera-placeholder,
.preview-placeholder {
    padding: 24px;
    text-align: center;
    color: #475569;
}

.button-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.button {
    border: none;
    border-radius: 14px;
    padding: 14px 16px;
    font-weight: 700;
    color: #ffffff;
    background: #1e40af;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.button-secondary {
    background: #475569;
}

.button-success {
    background: #15803d;
}

.message {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 600;
}

.message-neutral {
    background: #eff6ff;
    color: #1e3a8a;
}

.message-success {
    background: #dcfce7;
    color: #166534;
}

.message-error {
    background: #fee2e2;
    color: #991b1b;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.result-item {
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.result-item span {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.result-item strong {
    display: block;
    word-break: break-word;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: min(90vw, 280px);
    padding: 24px;
    border-radius: 18px;
    background: #ffffff;
    text-align: center;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #bfdbfe;
    border-top-color: #1d4ed8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 12px;
    }

    .topbar,
    .panel-header {
        flex-direction: column;
    }

    .status-card {
        width: 100%;
    }

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