.ai-page { background: var(--soft-bg); }

.ai-hero { padding: 48px 0; }
.ai-hero-text { color: #e8ddd2; max-width: 50ch; margin-top: 10px; }

.ai-studio-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    align-items: start;
}

.upload-panel h2 { color: var(--maroon); margin-bottom: 8px; }
.upload-panel > p { margin-bottom: 20px; color: #5a4d4f; }

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 200px;
    border: 2px dashed var(--gold);
    border-radius: 20px;
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.upload-zone:hover {
    border-color: var(--maroon);
    background: #fffaf5;
}

.upload-icon { color: var(--maroon); }
.upload-label { font-weight: 600; color: var(--maroon); }
.upload-hint { font-size: 0.85rem; color: #7a6a6c; }

.ai-control-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.btn-outline-ai {
    border: 1px solid var(--maroon);
    color: var(--maroon);
    background: transparent;
}

.btn-outline-ai:hover { background: var(--maroon); color: #fff; }
.btn-outline-ai:disabled { opacity: 0.45; cursor: not-allowed; }

.analysis-state {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    color: var(--text);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    animation: pulse 1.4s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.loading-overlay {
    margin-top: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--white);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.loading-overlay.hidden { display: none; }

.scan-line {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent, rgba(201, 154, 60, 0.25), transparent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    from { transform: translateY(-100%); }
    to { transform: translateY(100%); }
}

.preview-stage {
    position: relative;
    min-height: 400px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--maroon-deep);
    border: 3px solid var(--gold);
    box-shadow: 0 20px 50px rgba(45, 7, 14, 0.2);
}

#video, #uploadedImage, #overlayCanvas, #tryOnCanvas, #tryOnDisplay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#overlayCanvas { z-index: 3; pointer-events: none; }
#tryOnCanvas { z-index: 2; }

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.6);
    z-index: 1;
}

.hidden { display: none !important; }

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.result-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 24px;
}

.result-badge {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 6px;
}

.face-result-inner h4 {
    font-family: "Cormorant Garamond", serif;
    font-size: 1.8rem;
    color: var(--maroon);
    margin: 8px 0;
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.metric-item {
    background: var(--soft-bg);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.82rem;
}

.recommendation-badges {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.rec-tag {
    background: var(--why-bg);
    border-left: 3px solid var(--gold);
    padding: 10px 12px;
    font-size: 0.88rem;
    border-radius: 0 8px 8px 0;
}

.tryon-section { background: var(--white); }
.tryon-desc { color: #5a4d4f; max-width: 52ch; margin-top: 8px; }

.tryon-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-top: 28px;
    align-items: start;
}

.tryon-preview-wrap {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: #1a0a0d;
    min-height: 420px;
    border: 2px solid var(--line);
}

#tryOnDisplay {
    width: 100%;
    height: auto;
    display: block;
    min-height: 420px;
    max-height: 560px;
    object-fit: contain;
    background: #1a0a0d;
}

.tryon-fit-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(45, 7, 14, 0.9));
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.frame-tryon-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 6px;
}

.frame-species-group {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
}

.frame-species-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--maroon);
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.frame-species-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.frame-color-tag {
    display: block;
    font-size: 0.68rem;
    text-transform: capitalize;
    color: #7a6a6c;
    margin-bottom: 4px;
}

.frame-tryon-item {
    border: 2px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: var(--soft-bg);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
}

.frame-tryon-item:hover,
.frame-tryon-item.active {
    border-color: var(--gold);
    box-shadow: 0 8px 24px rgba(61, 13, 20, 0.12);
}

.frame-tryon-item.match { border-color: #2d8a4e; }
.frame-tryon-item img {
    height: 56px;
    width: 100%;
    object-fit: contain;
    margin-bottom: 6px;
    background: #f5f2ee;
    border-radius: 8px;
    padding: 4px;
}

.frame-tryon-item h5 {
    font-size: 0.78rem;
    color: var(--ink);
    margin-bottom: 4px;
}

.fit-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-block;
}

.fit-badge.good { background: #d4edda; color: #155724; }
.fit-badge.ok { background: #fff3cd; color: #856404; }

.ai-benefits { background: var(--why-bg); }

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 32px;
}

.benefits-grid article {
    background: var(--white);
    border-radius: 16px;
    padding: 22px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--gold);
}

.benefits-grid h4 { color: var(--maroon); margin-bottom: 8px; }
.benefits-grid p { font-size: 0.9rem; color: #5a4d4f; }

@media (max-width: 900px) {
    .ai-studio-grid,
    .results-grid,
    .tryon-layout,
    .benefits-grid {
        grid-template-columns: 1fr;
    }
    .frame-tryon-list { max-height: none; }
}
