/* RESET & BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #ff8fe5;
    --secondary: #c7b7ff;
    --font-tech: 'Rajdhani', sans-serif;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top, #1b1026, #09060f 70%);
    min-height: 100vh;
    /* Fix dla iOS Safari, żeby tło się nie ucinało */
    min-height: -webkit-fill-available; 
    color: #f5e9ff;
    overflow-x: hidden;
    transition: background 1.5s ease;
}

/* Fix dla paska adresu w iOS */
html { height: -webkit-fill-available; }

#chat-container {
    margin-top: 20px;
    width: 92%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    /* Fix dla Safari - efekt szkła */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Zmieniono z 'all' na konkretne właściwości, aby uniknąć migotania */
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.chat-hidden { 
    opacity: 0; 
    transform: translateY(20px); 
    pointer-events: none; 
    /* Ukrywamy z layoutu, żeby nie robił pustego miejsca na Safari */
    display: none !important; 
}

#chat-messages {
    height: 200px;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.9rem;
    -webkit-overflow-scrolling: touch; /* Płynne przewijanie na iOS */
}

.msg { padding: 8px 12px; border-radius: 12px; max-width: 85%; }
.msg.user { align-self: flex-end; background: rgba(147, 51, 234, 0.3); color: white; }
.msg.ai { align-self: flex-start; background: rgba(255, 255, 255, 0.1); color: #e0e0e0; }

.chat-input-area { display: flex; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 5px 10px;
    outline: none;
    font-size: 16px; /* Zapobiega zoomowaniu na iPhone przy kliknięciu */
}
#send-chat { background: none; border: none; cursor: pointer; fill: #a855f7; width: 30px; }

/* MOTYWY */
body.theme-Wiosna { --primary: #a8ffb5; background: radial-gradient(circle at top, #102615, #060f09 70%); }
body.theme-Lato { --primary: #ffeb3b; background: radial-gradient(circle at top, #262410, #0f0e06 70%); }
body.theme-Jesień { --primary: #ff9800; background: radial-gradient(circle at top, #261810, #0f0a06 70%); }
body.theme-Zima { --primary: #80deea; background: radial-gradient(circle at top, #102126, #060d0f 70%); }

.bg-orb { position: fixed; border-radius: 50%; filter: blur(120px); opacity: 0.35; z-index: 0; }
.orb-1 { width: 420px; height: 420px; background: #ff7ad9; top: -120px; left: -100px; }
.orb-2 { width: 480px; height: 480px; background: #8f7bff; bottom: -180px; right: -120px; }

/* MAIN CARD */
.main-card {
    position: relative; z-index: 2;
    max-width: 420px; margin: 40px auto;
    padding: 28px 22px;
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: blur(24px); /* Fix Safari */
    backdrop-filter: blur(24px);
    border-radius: 26px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 30px 80px rgba(0,0,0,0.6);
}

.logo-section { text-align: center; margin-bottom: 18px; }
.logo-section h1 { font-family: var(--font-tech); font-size: 38px; letter-spacing: 4px; }
.neon-text { color: var(--primary); text-shadow: 0 0 10px var(--primary); }
.status-top { font-size: 12px; color: var(--secondary); margin-top: 5px; min-height: 1.2em; }

/* SCANNER */
.scanner-circle {
    width: 260px; height: 260px; border-radius: 50%;
    position: relative; overflow: hidden; margin: 0 auto 18px;
    background: #0a0612; box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
    /* Fix dla Safari, żeby obrazek nie wychodził poza kółko podczas animacji */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}
.scanner-circle img { width: 100%; height: 100%; object-fit: cover; }

.scan-laser {
    position: absolute; top: -10%; left: 0; width: 100%; height: 3px;
    background: var(--primary); box-shadow: 0 0 15px var(--primary);
    display: none; z-index: 3;
    opacity: 0.7; /* Zmniejszona jasność, żeby nie raziło */
}
.scanning .scan-laser { display: block; animation: scanMove 3s infinite linear; } /* Zwolniona animacja */
@keyframes scanMove { 0% { top: -10%; } 100% { top: 110%; } }

/* BUTTONS */
.upload-btn {
    display: block; padding: 14px; text-align: center;
    background: linear-gradient(135deg, #ffb6ec, #c7b7ff);
    color: #2b0a2f; border-radius: 30px; cursor: pointer;
    font-family: var(--font-tech); font-weight: 700;
    user-select: none; /* Zapobiega zaznaczaniu tekstu przy klikaniu */
}
.mode-select { display: flex; gap: 5px; margin-top: 15px; }
.mode-btn {
    flex: 1; padding: 8px; font-size: 10px; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1); color: #fff; border-radius: 8px; cursor: pointer;
    transition: background 0.3s;
}
.mode-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(255,143,229,0.1); }

/* RESULTS - STABILIZACJA */
#result-overlay {
    margin-top: 20px; padding: 15px; border-radius: 15px;
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);
    display: none;
    min-height: 150px;
    animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#result-overlay.active { display: block !important; }

.aura-description { font-size: 14px; line-height: 1.5; min-height: 4.5em; margin-bottom: 10px; }
.aura-punchline { font-family: var(--font-tech); font-weight: 700; color: var(--primary); font-size: 16px; min-height: 1.2em; }

.result-details {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-top: 15px; border-top: 1px dotted rgba(255,255,255,0.2); padding-top: 15px;
}
.detail span { font-size: 10px; color: var(--secondary); display: block; }
.detail strong { font-size: 14px; color: #fff; }

#download-btn {
    display: block; margin: 20px auto; background: none; border: 1px solid var(--primary);
    color: var(--primary); padding: 10px 20px; border-radius: 20px; cursor: pointer;
    text-align: center;
}
.hidden, .download-hidden { display: none !important; }
.scan-lock { opacity: 0.3; pointer-events: none; }