:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bubble-ai: rgba(139, 92, 246, 0.2);
    --bubble-user: rgba(56, 189, 248, 0.2);
    --accent: #38bdf8;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
    z-index: 10;
}

/* Setup Screen */
#setup-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.glass-panel h1 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(to right, var(--accent), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 12px;
}

.half {
    flex: 1;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

select option {
    background: #1e293b;
    color: #fff;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    margin-top: 12px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.1s ease;
}

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

.primary-btn:active {
    transform: scale(0.98);
}

/* Chat Screen */
.chat-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-info {
    flex: 1;
}

.header-info h2 {
    font-size: 18px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.status.visible {
    opacity: 1;
}

.question-counter {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    padding-bottom: 40px;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.4;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    word-wrap: break-word;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.9) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.bubble.ai {
    align-self: flex-start;
    background: var(--bubble-ai);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-bottom-left-radius: 4px;
}

.bubble.user {
    align-self: flex-end;
    background: var(--bubble-user);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-bottom-right-radius: 4px;
}

.bubble.system {
    align-self: center;
    background: rgba(255, 255, 255, 0.1);
    font-size: 13px;
    color: var(--text-muted);
    border-radius: 12px;
    padding: 8px 16px;
}

.chat-controls {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.quick-replies {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-bottom: 8px;
}

.qr-btn {
    flex: 1;
    padding: 14px;
    border-radius: 16px;
    border: none;
    font-size: 15px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.qr-btn:active {
    transform: scale(0.95);
}

.yes-btn { background: linear-gradient(135deg, #10b981, #059669); }
.no-btn { background: linear-gradient(135deg, #ef4444, #dc2626); }
.maybe-btn { background: linear-gradient(135deg, #64748b, #475569); }

.muted { opacity: 0.5; }

.mic-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(139, 92, 246, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 2;
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn.listening {
    animation: pulse 1.5s infinite;
}

.mic-btn.listening .mic-icon {
    color: #fff;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.text-input-fallback {
    display: flex;
    width: 100%;
    gap: 12px;
    align-items: center;
}

.text-input-fallback input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 12px 20px;
}

.text-input-fallback #send-btn {
    background: var(--primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 18px 20px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-main);
    border-radius: 50%;
    opacity: 0.6;
    animation: typing 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 32px 24px;
    text-align: center;
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.modal-content p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    width: 32px;
    height: 32px;
    font-size: 14px;
    font-weight: bold;
}

.auth-switch {
    margin-top: 16px;
    font-size: 13px;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
}

.premium-box {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    padding: 24px;
    margin-top: 16px;
}

.premium-box h3 {
    margin-bottom: 16px;
    color: #a78bfa;
}

.premium-box ul {
    list-style: none;
    text-align: left;
    margin-bottom: 24px;
}

.premium-box li {
    margin-bottom: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.premium-box li::before {
    content: "✓";
    color: #10b981;
    font-weight: bold;
}

/* Landing Page Elements */
.bg-orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: rgba(139, 92, 246, 0.4);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: rgba(56, 189, 248, 0.3);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: rgba(236, 72, 153, 0.3);
    top: 40%;
    left: 50%;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

.logo-container {
    text-align: center;
    margin-bottom: 24px;
    animation: slideDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-logo {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.4);
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.footer-text {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    animation: fadeIn 1s ease 1s both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
