/* ==========================================
   หมอเมย์ AI - Medical Chatbot Styles
   ========================================== */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-chat: #0d1321;
    --surface: #1e293b;
    --surface-hover: #263348;
    --glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-glow: rgba(16, 185, 129, 0.3);
    --accent-secondary: #06b6d4;
    --accent-violet: #34d399;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --user-msg: #1e3a5f;
    --bot-msg: #1a2234;
    --sidebar-width: 300px;
    --header-height: 60px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 32px rgba(16, 185, 129, 0.15);
    --transition: 0.2s ease;
    --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
    --scan-color: #10b981;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: 'Noto Sans Thai', 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

/* ===== AMBIENT BACKGROUND ===== */
.ambient-bg {
    position: fixed; inset: 0; z-index: 0;
    overflow: hidden; pointer-events: none;
}
.orb {
    position: absolute; border-radius: 50%;
    filter: blur(80px); opacity: 0.5;
    animation: orbFloat 18s ease-in-out infinite;
}
.orb-1 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
    top: -10%; left: -5%;
    animation-delay: 0s;
}
.orb-2 {
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
    bottom: 5%; right: -5%;
    animation-delay: -6s;
}
.orb-3 {
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
    top: 50%; left: 40%;
    animation-delay: -12s;
}
@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 25px) scale(0.95); }
}
.mesh-gradient {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 70% 40% at 20% 30%, rgba(16, 185, 129, 0.06), transparent),
        linear-gradient(180deg, #0a0f1a 0%, #0d1321 50%, #0a0f1a 100%);
}
.noise-overlay {
    position: absolute; inset: 0; opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app-wrapper {
    display: flex; flex: 1; height: 100%; overflow: hidden;
    position: relative; z-index: 1;
    opacity: 1;
    transform: translateY(0);
}
body.app-ready .app-wrapper {
    animation: appFadeIn 0.45s ease;
}
@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    position: fixed; inset: 0; z-index: 500;
    background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.5s ease;
}
.login-screen.hidden { display: none; }

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

.login-glow {
    position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none; opacity: 0.5;
}

.login-container {
    position: relative; z-index: 1;
    max-width: 420px; width: 90%;
    text-align: center; padding: 40px 24px;
}

.login-logo { margin-bottom: 32px; }
.login-logo-icon {
    width: 80px; height: 80px; margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 20px; display: flex; align-items: center; justify-content: center;
    color: white; box-shadow: 0 8px 32px var(--accent-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-title { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.login-subtitle { font-size: 15px; color: var(--text-secondary); }

.login-features {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin: 28px 0; text-align: left;
}
.login-feature {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 13px; color: var(--text-secondary);
}
.login-feature span { font-size: 18px; }

.login-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.google-login-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 13px 20px; border-radius: var(--radius);
    background: white; border: none; color: #333;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: var(--transition); font-family: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.google-login-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }

.guest-login-btn {
    width: 100%; padding: 12px 20px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-secondary); font-size: 14px;
    cursor: pointer; transition: var(--transition); font-family: inherit;
}
.guest-login-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.login-disclaimer { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ===== MODEL PICKER (ChatGPT-style) ===== */
.model-picker { position: relative; }

.model-picker-trigger {
    display: flex; align-items: center; gap: 4px;
    background: none; border: none; color: var(--text-primary);
    font-size: 16px; font-weight: 600; cursor: pointer;
    padding: 6px 10px; border-radius: 8px;
    font-family: inherit; transition: var(--transition);
}
.model-picker-trigger:hover { background: var(--surface); }
.model-picker-trigger.open { background: var(--surface); }

.model-picker-chevron { opacity: 0.6; transition: transform 0.2s; }
.model-picker-trigger.open .model-picker-chevron { transform: rotate(180deg); }

.model-picker-menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 300px; max-width: calc(100vw - 24px);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0,0,0,0.5), var(--shadow-glow);
    padding: 6px; z-index: 50;
    animation: menuPop 0.25s var(--ease-spring);
}
@keyframes menuPop {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.model-picker-menu.hidden { display: none; }

.model-picker-item {
    width: 100%; display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border: none; border-radius: 10px;
    background: none; color: var(--text-primary);
    cursor: pointer; text-align: left; font-family: inherit;
    transition: var(--transition);
}
.model-picker-item:hover { background: var(--surface); }
.model-picker-item.active { background: var(--surface-hover); }

.model-picker-item .item-icon { font-size: 22px; flex-shrink: 0; }
.model-picker-item .item-body { flex: 1; min-width: 0; }
.model-picker-item .item-title { display: block; font-size: 14px; font-weight: 600; }
.model-picker-item .item-desc { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.model-picker-item .item-check {
    font-size: 16px; color: var(--accent); font-weight: 700;
    visibility: hidden; flex-shrink: 0;
}
.model-picker-item.active .item-check { visibility: visible; }

.model-picker-item .item-upgrade {
    flex-shrink: 0; padding: 5px 14px; border-radius: 20px;
    border: 1px solid var(--border-light);
    background: transparent; color: var(--text-primary);
    font-size: 12px; font-weight: 500; cursor: pointer;
    font-family: inherit;
}
.model-picker-item .item-upgrade:hover {
    background: var(--surface-hover);
}
.model-picker-item.is-locked .item-upgrade { opacity: 0.85; }

/* ===== USER PROFILE ===== */
.user-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    display: block; font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 11px; cursor: pointer; padding: 0; font-family: inherit;
}
.logout-btn:hover { color: var(--danger); }


/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    transition: transform 0.35s var(--ease-spring), opacity 0.3s ease;
    z-index: 100;
}

/* ===== SIDEBAR 3D BODY SCAN ===== */
.sidebar-model-panel {
    margin: 0 10px 8px;
    flex-shrink: 0;
}
.scan-viewport {
    position: relative;
    height: 220px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(180deg, #0a0f1a 0%, #0d1525 50%, #0a0f1a 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: inset 0 0 40px rgba(16, 185, 129, 0.08), 0 4px 20px rgba(0, 0, 0, 0.3);
}
.scan-viewport canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.scan-grid-overlay {
    position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(16, 185, 129, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.06) 1px, transparent 1px);
    background-size: 16px 16px;
    opacity: 0.7;
}
.scan-line {
    position: absolute; left: 0; right: 0; height: 2px; z-index: 3;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--scan-color), transparent);
    box-shadow: 0 0 16px var(--scan-color), 0 0 32px rgba(16, 185, 129, 0.5);
    animation: scanSweep 2.8s ease-in-out infinite;
}
.scan-ring {
    position: absolute; left: 50%; top: 50%;
    width: 120px; height: 120px;
    margin: -60px 0 0 -60px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 50%;
    pointer-events: none;
    animation: scanRingPulse 2s ease-in-out infinite;
}
.scan-label {
    position: absolute; top: 8px; left: 10px; z-index: 4;
    font-size: 9px; font-weight: 700; letter-spacing: 0.15em;
    color: var(--scan-color);
    opacity: 0.9;
    font-family: 'Inter', monospace;
}
.scan-status {
    position: absolute; bottom: 8px; left: 10px; z-index: 4;
    font-size: 10px; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}
.scan-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--scan-color);
    animation: scanBlink 1.2s ease-in-out infinite;
}
@keyframes scanSweep {
    0% { top: 8%; opacity: 0.4; }
    50% { top: 88%; opacity: 1; }
    100% { top: 8%; opacity: 0.4; }
}
@keyframes scanRingPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.6; }
}
@keyframes scanBlink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.sidebar.hidden { transform: translateX(-100%); opacity: 0; position: absolute; }

.sidebar-header {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
    animation: logoGlow 3s ease-in-out infinite;
}
@keyframes logoGlow {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
    50% { box-shadow: 0 4px 28px rgba(16, 185, 129, 0.45); }
}

.logo-text { font-size: 17px; font-weight: 700; color: var(--text-primary); }

.sidebar-close-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; border-radius: 6px;
    transition: var(--transition);
    display: none;
}
.sidebar-close-btn:hover { background: var(--surface); color: var(--text-primary); }

.new-chat-btn {
    margin: 12px 12px 4px;
    padding: 11px 16px;
    background: linear-gradient(135deg, var(--accent) 0%, #0d9488 50%, var(--accent-secondary) 100%);
    background-size: 200% 100%;
    border: none; border-radius: var(--radius);
    color: #042f2e; font-size: 14px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; gap: 8px;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 4px 20px var(--accent-glow);
    position: relative; overflow: hidden;
}
.new-chat-btn::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.25) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}
.new-chat-btn:hover {
    background-position: 100% 0;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 28px var(--accent-glow);
}
.new-chat-btn:hover::after { transform: translateX(100%); }

.sidebar-section { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar-section-title { padding: 8px 8px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }

.chat-history-list { display: flex; flex-direction: column; gap: 2px; }

.chat-history-item {
    padding: 10px 12px; border-radius: 10px;
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    transition: var(--transition); color: var(--text-secondary);
    font-size: 13px; position: relative;
    border: 1px solid transparent;
}
.chat-history-item:hover {
    background: var(--surface); color: var(--text-primary);
    border-color: var(--border); transform: translateX(4px);
}
.chat-history-item.active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--text-primary);
}

.chat-history-item .item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-history-item .delete-btn {
    opacity: 0; background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 2px; border-radius: 4px; transition: var(--transition);
}
.chat-history-item:hover .delete-btn { opacity: 1; }
.chat-history-item .delete-btn:hover { color: var(--danger); }

.sidebar-tools { padding: 8px; border-top: 1px solid var(--border); }
.sidebar-tools .sidebar-section-title { padding-top: 4px; }

.tool-btn {
    width: 100%; padding: 10px 12px; border: none; border-radius: 8px;
    background: none; color: var(--text-secondary); font-size: 13px;
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    transition: var(--transition); margin-bottom: 2px; font-family: inherit;
}
.tool-btn:hover { background: var(--surface); color: var(--text-primary); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.sidebar-footer-info { display: flex; justify-content: space-between; }
.powered-by { font-size: 11px; color: var(--text-muted); }
.version { font-size: 11px; color: var(--text-muted); }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    height: 100vh; overflow: hidden; position: relative;
}

/* ===== HEADER ===== */
.chat-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(6, 9, 18, 0.65);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; border-radius: 6px;
    transition: var(--transition); display: none;
}
.menu-toggle:hover { background: var(--surface); color: var(--text-primary); }

.history-empty {
    padding: 16px; text-align: center;
    color: var(--text-muted); font-size: 12px;
}

.header-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 8px; border-radius: 8px;
    transition: var(--transition);
}
.header-btn:hover { background: var(--surface); color: var(--text-primary); }

/* ===== CHAT CONTAINER ===== */
.chat-container {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    scroll-behavior: smooth;
}

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
    max-width: 760px; margin: 0 auto;
    padding: 48px 24px 40px;
    display: flex; flex-direction: column; align-items: center;
    text-align: center; position: relative;
    animation: fadeInUp 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.welcome-hero {
    display: flex; flex-direction: column; align-items: center;
    margin-bottom: 32px;
    animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s backwards;
}
.welcome-badges {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    margin-top: 16px;
}
.hero-badge {
    font-size: 12px; padding: 6px 14px; border-radius: 20px;
    background: var(--glass);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    backdrop-filter: blur(8px);
    animation: fadeInUp 0.6s ease backwards;
}
.hero-badge:nth-child(1) { animation-delay: 0.3s; }
.hero-badge:nth-child(2) { animation-delay: 0.4s; }
.hero-badge:nth-child(3) { animation-delay: 0.5s; }

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

.welcome-glow {
    position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
    width: 400px; height: 400px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none; opacity: 0.4;
}

.welcome-icon {
    position: relative; margin-bottom: 20px; color: white;
    width: 88px; height: 88px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 20px;
    box-shadow: 0 8px 32px var(--accent-glow);
}
.welcome-icon-ring {
    position: absolute; inset: -6px; border-radius: 28px;
    border: 2px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.3);
    animation: ringPulse 2s ease-in-out infinite;
}
@keyframes ringPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.03); }
}
.welcome-icon-pulse {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100px; height: 100px; border-radius: 50%;
    background: var(--accent-glow);
    animation: pulse 2.5s ease-in-out infinite;
    z-index: -1;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.1; }
}

.welcome-title {
    font-size: clamp(24px, 5vw, 32px); font-weight: 800;
    margin-bottom: 10px; line-height: 1.35; letter-spacing: -0.02em;
}
.gradient-text {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    background-size: 200% auto;
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s ease infinite;
}
@keyframes gradientShift {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 100% center; }
}
.welcome-subtitle { font-size: 15px; color: var(--text-secondary); max-width: 420px; line-height: 1.6; }

.feature-cards {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; width: 100%; margin-bottom: 28px;
}

.feature-card {
    --card-i: 0;
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px; cursor: pointer;
    display: flex; align-items: flex-start; gap: 14px;
    text-align: left;
    transition: transform 0.35s var(--ease-spring), box-shadow 0.35s ease, border-color 0.3s ease;
    animation: cardReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: calc(0.15s + var(--card-i) * 0.08s);
    position: relative; overflow: hidden;
}
.feature-card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(16,185,129,0.08), transparent 50%);
    opacity: 0; transition: opacity 0.3s ease;
}
.feature-card:hover {
    border-color: rgba(16, 185, 129, 0.35);
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow), var(--shadow-glow);
}
.feature-card:hover::before { opacity: 1; }
.feature-card:active { transform: translateY(-1px) scale(0.99); }
@keyframes cardReveal {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.feature-card-icon {
    font-size: 22px; flex-shrink: 0;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--border-light);
}
.card-icon-diagnose { background: rgba(16, 185, 129, 0.15); }
.card-icon-food { background: rgba(52, 211, 153, 0.12); }
.card-icon-bmi { background: rgba(56, 189, 248, 0.12); }
.card-icon-info { background: rgba(129, 140, 248, 0.12); }
.feature-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.feature-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.quick-prompts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.quick-prompt {
    padding: 8px 16px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 13px;
    cursor: pointer; transition: var(--transition); font-family: inherit;
}
.quick-prompt:hover {
    background: var(--surface-hover); color: var(--text-primary);
    border-color: rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.quick-prompt.hidden { display: none; }

.welcome-tabs {
    display: flex; flex-wrap: wrap; gap: 8px;
    justify-content: center; margin-bottom: 16px; width: 100%;
}
.welcome-tab {
    padding: 8px 16px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 13px;
    cursor: pointer; font-family: inherit; transition: var(--transition);
}
.welcome-tab:hover { color: var(--text-primary); }
.welcome-tab.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(56, 189, 248, 0.1));
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.med-warning {
    margin-top: 8px; padding: 8px 12px; border-radius: 8px;
    background: rgba(245,158,11,0.12); border-left: 3px solid var(--warning);
    font-size: 12px; color: var(--warning);
}

.citation-chips { margin-top: 8px; }
.citation-chips span {
    display: inline-block; font-size: 11px; color: var(--text-muted);
    padding: 4px 10px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border);
}

.symptom-urgency {
    padding: 10px 14px; border-radius: 8px; margin-bottom: 12px;
    font-size: 13px; font-weight: 600;
}
.symptom-urgency.low { background: rgba(16,185,129,0.15); color: var(--accent); }
.symptom-urgency.mid { background: rgba(245,158,11,0.15); color: var(--warning); }
.symptom-urgency.high { background: rgba(239,68,68,0.15); color: var(--danger); }

.quota-bar {
    text-align: center; font-size: 11px; color: var(--text-muted);
    margin-top: 6px;
}
.quota-bar.hidden { display: none; }

.modal-sm { max-width: 400px; }
.modal-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }
.plus-features-list {
    margin: 0 0 20px 20px; color: var(--text-secondary); font-size: 14px;
}
.plus-features-list li { margin: 6px 0; }

.disclaimer-check {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; font-size: 14px; cursor: pointer;
}
.disclaimer-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.confirm-overlay { align-items: flex-end; }
.confirm-sheet {
    width: 100%; max-width: 480px; margin: 0 auto 24px;
    background: var(--bg-secondary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow);
}
.confirm-message { font-size: 15px; margin-bottom: 16px; text-align: center; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-btn {
    flex: 1; padding: 12px; border-radius: 10px;
    border: 1px solid var(--border-light); font-family: inherit;
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.confirm-btn.cancel { background: var(--surface); color: var(--text-primary); }
.confirm-btn.danger { background: var(--danger); color: white; border-color: var(--danger); }

.tools-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.tool-card {
    padding: 20px 16px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; text-align: center; font-family: inherit;
    color: var(--text-primary); transition: var(--transition);
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.tool-card-title { font-size: 13px; font-weight: 600; }

.symptom-step.hidden { display: none; }
.symptom-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.symptom-chip {
    padding: 8px 14px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 13px; cursor: pointer;
}
.symptom-chip:has(input:checked) {
    border-color: var(--accent); background: rgba(16,185,129,0.1);
}
.symptom-chip input { display: none; }

.form-group textarea {
    padding: 10px 14px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-size: 14px;
    outline: none; resize: vertical; font-family: inherit; width: 100%;
}
.form-group textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}

.bmi-history { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.bmi-history.hidden { display: none; }
.bmi-history-list { list-style: none; font-size: 13px; color: var(--text-secondary); }
.bmi-history-list li {
    padding: 8px 0; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 8px;
}

.onboarding-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.onboarding-overlay.hidden { display: none; }
.onboarding-card {
    background: var(--bg-secondary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); max-width: 440px; width: 100%;
    padding: 28px 24px; box-shadow: var(--shadow);
}
.onboarding-card h2 { font-size: 20px; margin-bottom: 8px; }
.onboarding-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.onboarding-step.hidden { display: none; }
.onboarding-actions { display: flex; gap: 10px; margin-top: 20px; }
.onboarding-actions .bmi-submit-btn { flex: 1; }
.goal-options { display: flex; flex-direction: column; gap: 8px; }
.goal-option {
    padding: 12px 14px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; font-size: 14px;
}
.goal-option:has(input:checked) { border-color: var(--accent); }

.drawer-overlay {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0,0,0,0.4); opacity: 0; visibility: hidden;
    transition: 0.3s ease;
}
.drawer-overlay.active { opacity: 1; visibility: visible; }

.settings-drawer {
    position: fixed; top: 0; right: 0; z-index: 160;
    width: min(320px, 90vw); height: 100%;
    background: var(--bg-secondary); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform 0.3s ease;
    display: flex; flex-direction: column;
}
.settings-drawer.open { transform: translateX(0); }
.drawer-header {
    padding: 20px; display: flex; justify-content: space-between;
    align-items: center; border-bottom: 1px solid var(--border);
}
.drawer-header h2 { font-size: 18px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.settings-group { margin-bottom: 20px; }
.settings-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.settings-group select {
    width: 100%; padding: 10px 14px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-family: inherit;
}
.drawer-full-btn { margin-bottom: 8px; }

.memory-section {
    margin-top: 8px; padding-top: 16px;
    border-top: 1px solid var(--border);
}
.memory-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.memory-list { list-style: none; max-height: 160px; overflow-y: auto; margin-bottom: 10px; }
.memory-list li {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    padding: 8px 10px; margin-bottom: 6px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 13px; line-height: 1.4;
}
.memory-list .memory-text { flex: 1; }
.memory-list .memory-del {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1;
}
.memory-list .memory-del:hover { color: var(--danger); }
.memory-list .memory-empty {
    text-align: center; color: var(--text-muted); font-size: 12px; padding: 12px;
}
.memory-add-row { display: flex; gap: 8px; }
.memory-add-row input {
    flex: 1; padding: 8px 12px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-family: inherit; font-size: 13px;
}
.memory-add-row .guest-login-btn { width: auto; padding: 8px 14px; white-space: nowrap; }
.settings-memory-hint { padding: 0 4px 12px; margin: 0; }

/* Light theme */
body[data-theme="light"] {
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.85);
    --bg-tertiary: #f1f5f9;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-hover: #f8fafc;
    --border: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.12);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-glow: rgba(20, 184, 166, 0.2);
}
body[data-theme="light"] .ambient-bg .orb { opacity: 0.35; }
body[data-theme="light"] .mesh-gradient {
    background: linear-gradient(180deg, #f0f4f8 0%, #e8f0f8 50%, #f0f4f8 100%);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .orb { animation: none; }
}

body[data-font-size="large"] .message-text { font-size: 16px; }
body[data-font-size="large"] .message-input { font-size: 16px; }
body[data-font-size="xlarge"] .message-text { font-size: 18px; }
body[data-font-size="xlarge"] .message-input { font-size: 18px; }

/* ===== MESSAGES ===== */
.messages-area { max-width: 800px; margin: 0 auto; padding: 20px 24px 20px; width: 100%; }
.messages-area.hidden { display: none; }

.message {
    display: flex; gap: 14px; padding: 20px 0;
    animation: msgIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    border-bottom: 1px solid var(--border);
}
.message .message-content {
    background: var(--bot-msg);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 4px 0;
}
.message.user .message-content { background: transparent; }
.message:last-child { border-bottom: none; }

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

.message-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 14px; margin-top: 2px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; font-weight: 600;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: white;
}

.message-content { flex: 1; min-width: 0; }

.message-content .sender-name {
    font-size: 13px; font-weight: 600; margin-bottom: 6px;
    color: var(--text-secondary);
}

.message-content .message-text {
    font-size: 14px; line-height: 1.75; color: var(--text-primary);
    word-wrap: break-word;
}

/* Markdown Styles */
.message-text h1, .message-text h2, .message-text h3 { margin: 16px 0 8px; font-weight: 600; }
.message-text h1 { font-size: 20px; }
.message-text h2 { font-size: 17px; }
.message-text h3 { font-size: 15px; }
.message-text p { margin: 8px 0; }
.message-text ul, .message-text ol { margin: 8px 0; padding-left: 24px; }
.message-text li { margin: 4px 0; }
.message-text strong { color: var(--accent); font-weight: 600; }
.message-text em { color: var(--text-secondary); }

.message-text code {
    background: rgba(0,0,0,0.3); padding: 2px 6px;
    border-radius: 4px; font-size: 13px; color: #e879f9;
}

.message-text pre {
    background: #0d1117; border-radius: 8px;
    padding: 16px; margin: 12px 0;
    overflow-x: auto; border: 1px solid var(--border);
}
.message-text pre code { background: none; padding: 0; color: var(--text-primary); }

.message-text table {
    width: 100%; border-collapse: collapse; margin: 12px 0;
    font-size: 13px;
}
.message-text th, .message-text td {
    padding: 8px 12px; border: 1px solid var(--border);
    text-align: left;
}
.message-text th { background: var(--surface); font-weight: 600; }

.message-text blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px; margin: 12px 0;
    background: rgba(16,185,129,0.05); border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.message-text a { color: var(--accent-secondary); text-decoration: none; }
.message-text a:hover { text-decoration: underline; }

.message-text hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.message-actions {
    display: flex; gap: 4px; margin-top: 8px; opacity: 0;
    transition: var(--transition);
}
.message:hover .message-actions { opacity: 1; }

.msg-action-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px 8px; border-radius: 4px;
    font-size: 12px; display: flex; align-items: center; gap: 4px;
    transition: var(--transition); font-family: inherit;
}
.msg-action-btn:hover { background: var(--surface); color: var(--text-primary); }

/* Typing Indicator */
.typing-indicator {
    display: flex; gap: 4px; padding: 8px 0;
}
.typing-indicator span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); opacity: 0.4;
    animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.2); }
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 12px 24px 16px;
    background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
}

.input-container { max-width: 800px; margin: 0 auto; }

.input-wrapper {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex; flex-direction: column;
    transition: var(--transition);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}
.input-wrapper:focus-within {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 32px rgba(16, 185, 129, 0.1);
}

.message-input {
    width: 100%; background: none; border: none;
    color: var(--text-primary); font-size: 14px;
    resize: none; outline: none; font-family: inherit;
    max-height: 150px; line-height: 1.5;
}
.message-input::placeholder { color: var(--text-muted); }

.input-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.char-count { font-size: 11px; color: var(--text-muted); }

.send-btn {
    width: 38px; height: 38px; border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border: none; color: #042f2e; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.send-btn:not(:disabled):hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.45);
}
.send-btn:not(:disabled) { animation: sendPulse 2s ease-in-out infinite; }
@keyframes sendPulse {
    0%, 100% { box-shadow: 0 4px 16px var(--accent-glow); }
    50% { box-shadow: 0 4px 22px rgba(16, 185, 129, 0.5); }
}

.stop-btn-style {
    background: linear-gradient(135deg, var(--danger), #dc2626) !important;
}

.input-disclaimer {
    text-align: center; font-size: 11px; color: var(--text-muted);
    margin-top: 8px; padding: 0 8px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 90%; max-width: 500px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), var(--shadow-glow);
    transform: scale(0.92) translateY(16px);
    transition: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
    padding: 20px 24px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 18px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
}
.emergency-title { color: var(--danger); }

.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; border-radius: 6px;
    transition: var(--transition);
}
.modal-close:hover { background: var(--surface); color: var(--text-primary); }

.modal-body { padding: 24px; }

/* BMI Form */
.bmi-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.form-group input, .form-group select {
    padding: 10px 14px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-size: 14px;
    outline: none; transition: var(--transition); font-family: inherit;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}

.bmi-submit-btn {
    padding: 12px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border: none; color: white; font-size: 15px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: var(--transition); font-family: inherit;
}
.bmi-submit-btn:hover { filter: brightness(1.1); }

/* BMI Result */
.bmi-result { margin-top: 20px; animation: fadeInUp 0.4s ease; }
.bmi-result.hidden { display: none; }

.bmi-gauge-container { text-align: center; margin-bottom: 20px; }
.bmi-gauge { max-width: 220px; margin: 0 auto; }
.bmi-gauge-svg { width: 100%; }

.bmi-value { font-size: 36px; font-weight: 800; margin-top: -10px; }
.bmi-category { font-size: 16px; font-weight: 600; margin-top: 4px; }

.bmi-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.bmi-detail-card {
    background: var(--surface); border-radius: 10px; padding: 12px;
    text-align: center; border: 1px solid var(--border);
}
.bmi-detail-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.bmi-detail-value { font-size: 15px; font-weight: 600; }

.bmi-advice {
    background: rgba(16,185,129,0.08); border-radius: 10px;
    padding: 14px; font-size: 13px; line-height: 1.6;
    color: var(--text-secondary); border-left: 3px solid var(--accent);
    margin-bottom: 16px;
}

.bmi-chat-btn {
    width: 100%; padding: 10px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-size: 13px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: var(--transition); font-family: inherit;
}
.bmi-chat-btn:hover { background: var(--surface-hover); border-color: var(--accent); }

/* Emergency */
.emergency-list { display: flex; flex-direction: column; gap: 8px; }

.emergency-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    text-decoration: none; color: var(--text-primary);
    transition: var(--transition);
}
.emergency-item:hover { background: var(--surface-hover); transform: translateX(4px); }
.emergency-primary { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.emergency-primary:hover { background: rgba(239,68,68,0.12); }

.emergency-icon { font-size: 28px; }
.emergency-name { font-size: 13px; color: var(--text-secondary); margin-bottom: 2px; }
.emergency-number { font-size: 20px; font-weight: 700; }

/* Toast */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    padding: 12px 20px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border-light);
    color: var(--text-primary); font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    html, body {
        height: 100%;
        height: calc(var(--vh, 1vh) * 100);
        height: 100dvh;
    }

    .sidebar {
        position: fixed; left: 0; top: 0;
        width: min(300px, 92vw); height: 100%;
        transform: translateX(-100%); opacity: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    .sidebar.show { transform: translateX(0); opacity: 1; }
    .sidebar-close-btn { display: flex; }
    .menu-toggle { display: flex; }
    .scan-viewport { height: 180px; }

    .main-content {
        height: 100%;
        height: calc(var(--vh, 1vh) * 100);
        height: 100dvh;
    }

    .welcome-screen { padding: 30px 16px 20px; }
    .welcome-title { font-size: 22px; }
    .welcome-subtitle { font-size: 13px; margin-bottom: 24px; }
    .welcome-icon svg { width: 36px; height: 36px; }
    .welcome-glow { width: 250px; height: 250px; }

    .feature-cards { grid-template-columns: 1fr; gap: 8px; }
    .feature-card { padding: 14px; }
    .feature-card:active { background: var(--surface-hover); transform: scale(0.98); }

    .quick-prompts { gap: 6px; }
    .quick-prompt { font-size: 12px; padding: 7px 12px; }
    .quick-prompt:active { background: var(--surface-hover); border-color: var(--accent); }

    .messages-area { padding: 12px 14px; }
    .message { gap: 10px; padding: 14px 0; }
    .message-avatar { width: 28px; height: 28px; border-radius: 6px; }
    .message-avatar svg { width: 14px; height: 14px; }
    .message-content .message-text { font-size: 13.5px; }
    .message-content .sender-name { font-size: 12px; }
    /* Always show copy button on mobile since no hover */
    .message-actions { opacity: 1; }

    .chat-header { padding: 0 12px; height: 50px; }
    .model-picker-trigger { font-size: 14px; padding: 4px 8px; }
    .model-picker-menu { min-width: 260px; }

    .input-area {
        padding: 6px 10px 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .input-wrapper { padding: 10px 12px; border-radius: 12px; }
    .message-input { font-size: 16px; /* Prevent iOS auto-zoom */ }
    .input-disclaimer { font-size: 10px; margin-top: 6px; }

    .modal { width: 94%; max-height: 80vh; }
    .modal-body { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }

    .toast-container { bottom: 80px; right: 12px; left: 12px; }
    .toast { text-align: center; }

    /* Login screen mobile */
    .login-container { padding: 30px 20px; }
    .login-title { font-size: 26px; }
    .login-logo-icon { width: 64px; height: 64px; border-radius: 16px; }
    .login-logo-icon svg { width: 36px; height: 36px; }
    .login-features { grid-template-columns: 1fr; }
    .login-glow { width: 300px; height: 300px; }
}

/* Extra small phones */
@media (max-width: 380px) {
    .welcome-title { font-size: 19px; }
    .feature-card-title { font-size: 13px; }
    .feature-card-desc { font-size: 11px; }
    .quick-prompt { font-size: 11px; padding: 5px 10px; }
    .login-title { font-size: 22px; }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .feature-card { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    .quick-prompt { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    .send-btn { touch-action: manipulation; }
    .tool-btn { touch-action: manipulation; }
    .new-chat-btn { touch-action: manipulation; }
    .model-picker-trigger { touch-action: manipulation; }
    .model-picker-item { touch-action: manipulation; }
    .google-login-btn { touch-action: manipulation; }
    .guest-login-btn { touch-action: manipulation; }
    .chat-history-item .delete-btn { opacity: 0.6; }
    .feature-card:active { transition: none; background: var(--surface-hover); }
    .quick-prompt:active { transition: none; background: var(--surface-hover); }
}
