/* ===== AI ASSISTANT: Panel, Lounge ===== */

/* ===== AI ASSISTANT ===== */
#ai-assistant.active { display:flex; flex-direction:column; height:calc(100dvh - 3rem); max-height:calc(100dvh - 3rem); overflow:hidden; position:relative; }
#ai-assistant .panel-select-screen { overflow-y:auto; -webkit-overflow-scrolling:touch; max-height:100%; padding-bottom:2rem; }
#ai-assistant .section-header { display:flex; justify-content:space-between; align-items:center; padding:0.8rem 1rem; border-bottom:1px solid var(--border,#E8E0D8); flex-shrink:0; color:var(--text,#3D2B1F); }
.ai-chat-messages { flex:1; overflow-y:auto; padding:1rem; display:flex; flex-direction:column; gap:0.8rem; min-height:0; }
.ai-input-bar { display:flex; gap:0.5rem; padding:0.8rem 1rem; border-top:1px solid var(--border,#E8E0D8); flex-shrink:0; background:var(--bg-card,#3D2B1F); z-index:10; padding-bottom:max(0.8rem, env(safe-area-inset-bottom)); }
.ai-input-bar input { flex:1; border:1px solid var(--border,#E8E0D8); border-radius:20px; padding:0.6rem 1rem; font-size:0.9rem; outline:none; background:var(--bg,#FFF8F0); color:var(--text,#3D2B1F); }
.ai-input-bar input:focus { border-color:#8B6914; }
.ai-input-bar input::placeholder { color:var(--text-muted,‌#6B5744); }
.ai-input-bar button { flex-shrink:0; }
.ai-send-btn { width:40px; height:40px; border-radius:50%; border:none; background:#8B6914; color:#FFF8F08F0; font-size:1.2rem; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.ai-send-btn:hover { background:#6B5744; }

.ai-msg { display:flex; gap:0.5rem; align-items:flex-end; }
.ai-msg-user { flex-direction:row-reverse; }
.ai-avatar { width:32px; height:32px; border-radius:50%; background:linear-gradient(135deg,#8B6914,#F0C060); display:flex; align-items:center; justify-content:center; font-size:1rem; flex-shrink:0; }
.panel-avatar-img { width:40px; height:40px; border-radius:50%; object-fit:cover; }
.ai-bubble { max-width:80%; padding:0.7rem 1rem; border-radius:16px; font-size:0.9rem; line-height:1.5; word-break:break-word; }
.ai-bubble-user { background:#8B6914; color:#FFF8F08F0; border-bottom-right-radius:4px; }
.ai-bubble-bot { background:var(--bg-card-alt,#F7F3ED); color:var(--text,#3D2B1F); border-bottom-left-radius:4px; }
.ai-bubble-bot ul { margin:0.3rem 0; padding-left:1.2rem; }
.ai-bubble-bot code { background:rgba(255,255,255,0.1); padding:0.1rem 0.3rem; border-radius:3px; font-size:0.85em; }

.ai-typing span { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--text-muted,‌#6B5744); margin:0 2px; animation:ai-dot 1.4s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay:0.2s; }
.ai-typing span:nth-child(3) { animation-delay:0.4s; }
@keyframes ai-dot { 0%,80%,100%{transform:scale(0.4);opacity:0.3} 40%{transform:scale(1);opacity:1} }

.ai-welcome { text-align:center; padding:2rem 1rem; margin:auto; }
.ai-welcome-icon { font-size:3rem; margin-bottom:0.5rem; }
.ai-welcome h3 { font-size:1.1rem; margin-bottom:0.3rem; color:var(--text,#3D2B1F); }
.ai-welcome p { color:var(--text,#3D2B1F); font-size:0.9rem; margin-bottom:1.5rem; }
.ai-quick-cards { display:flex; flex-wrap:wrap; gap:0.5rem; justify-content:center; }
.ai-quick-card { background:var(--bg-card-alt,#F7F3ED); border:1px solid var(--border,#E8E0D8); border-radius:12px; padding:0.6rem 1rem; font-size:0.85rem; cursor:pointer; transition:all 0.2s; color:var(--text,#3D2B1F); }
.ai-quick-card:hover { background:var(--bg-card,#3D2B1F); border-color:var(--gold,#8B6914); transform:translateY(-1px); }

/* ── Crowny Panel: Character Select ── */
.panel-select-screen { text-align:center; padding:1.5rem 1rem; margin:auto; width:100%; max-width:420px; overflow-y:auto; }
.panel-select-title { margin-bottom:1.5rem; }
.panel-select-icon { font-size:3rem; margin-bottom:0.3rem; }
.panel-select-title h3 { font-size:1.15rem; color:var(--text,#3D2B1F); margin-bottom:0.2rem; }
.panel-select-title p { color:var(--text,#3D2B1F); font-size:0.85rem; }
.panel-char-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:0.7rem; }
.panel-char-grid > :nth-child(4),
.panel-char-grid > :nth-child(5) { grid-column:span 1; }
@media(max-width:360px){ .panel-char-grid { grid-template-columns:repeat(2,1fr); } }

.panel-char-card { background:var(--bg-card-alt,#F7F3ED); border:2px solid var(--border,#333); border-radius:14px; padding:1rem 0.5rem; cursor:pointer; transition:all 0.2s; text-align:center; color:var(--text,#3D2B1F); }
.panel-char-card:hover { border-color:var(--char-color); transform:translateY(-2px); box-shadow:0 4px 16px rgba(0,0,0,0.3); }
.panel-char-avatar { width:48px; height:48px; border-radius:50%; margin:0 auto 0.4rem; display:flex; align-items:center; justify-content:center; font-size:1.5rem; color:#FFF8F08F0; }
.panel-char-name { font-weight:700; font-size:0.9rem; color:var(--text,#3D2B1F); }
.panel-char-role { font-size:0.75rem; color:var(--text-muted,‌#6B5744); margin-top:0.15rem; line-height:1.3; }

/* ── Crowny Panel: Chat Header ── */
.panel-chat-header-left { display:flex; align-items:center; gap:0.5rem; }
.panel-back-btn { background:none; border:none; font-size:1.3rem; cursor:pointer; padding:0.2rem 0.4rem; color:var(--text-muted,‌#6B5744); }
.panel-back-btn:hover { color:var(--text,#3D2B1F); }
.panel-chat-avatar { width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1rem; flex-shrink:0; }
.panel-chat-name { font-weight:700; font-size:0.9rem; line-height:1.2; color:var(--text,#3D2B1F); }
.panel-chat-role { font-size:0.75rem; color:var(--text-muted,‌#6B5744); line-height:1.2; }

/* ── Lounge Styles ── */
.lounge-enter-btn { display:flex; align-items:center; gap:0.7rem; width:100%; padding:0.8rem 1rem; margin-bottom:1.2rem; background:linear-gradient(135deg,#3D2B1F,#6B5744); border:2px solid #8B691444; border-radius:14px; cursor:pointer; transition:all 0.2s; text-align:left; color:#FFF8F08F0; }
.lounge-enter-btn:hover { border-color:#8B6914; transform:translateY(-2px); box-shadow:0 4px 20px rgba(212,175,55,0.2); }
.lounge-enter-icon { font-size:1.8rem; }
.lounge-enter-text { flex:1; }
.lounge-enter-text strong { display:block; font-size:0.95rem; color:#8B6914; }
.lounge-enter-text span { font-size:0.75rem; color:#3D2B1F; }
.lounge-enter-avatars { display:flex; gap:-4px; }
.lounge-mini-avatar { width:24px; height:24px; border-radius:50%; object-fit:cover; margin-left:-6px; border:2px solid #3D2B1F; }
.lounge-mini-avatar:first-child { margin-left:0; }
.lounge-mini-avatar-emoji { width:24px; height:24px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:0.75rem; margin-left:-6px; border:2px solid #3D2B1F; color:#FFF8F08F0; }
.lounge-mini-avatar-emoji:first-child { margin-left:0; }

.lounge-header-avatars { display:flex; margin-right:0.2rem; }
.lounge-header-avatar-img { width:26px; height:26px; border-radius:50%; object-fit:cover; margin-left:-8px; border:2px solid #3D2B1F; }
.lounge-header-avatar-img:first-child { margin-left:0; }
.lounge-header-avatar-emoji { width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:0.75rem; margin-left:-8px; border:2px solid #3D2B1F; color:#FFF8F08F0; }
.lounge-header-avatar-emoji:first-child { margin-left:0; }

.lounge-welcome-avatars { display:flex; justify-content:center; gap:0.3rem; margin-bottom:0.8rem; }
.lounge-welcome-avatar { width:42px; height:42px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1.2rem; color:#FFF8F08F0; }
.lounge-welcome-avatar img { width:42px; height:42px; border-radius:50%; object-fit:cover; }

.lounge-msg { align-items:flex-start !important; }
.lounge-avatar { width:30px; height:30px; font-size:0.85rem; }
.lounge-avatar img { width:30px; height:30px; }
.lounge-msg-content { display:flex; flex-direction:column; gap:0.15rem; max-width:80%; }
.lounge-char-label { font-size:0.75rem; font-weight:700; padding-left:0.2rem; }
.lounge-bubble { border-radius:12px !important; }
.lounge-typing-bubble { display:flex; flex-direction:column; gap:0.15rem; }

.lounge-msg-enter { opacity:0; transform:translateY(8px); transition:all 0.3s ease; }
.lounge-msg-visible { opacity:1; transform:translateY(0); }



/* ============================================================
   AI TUTOR SETUP
   ============================================================ */
.tutor-setup { padding:1.5rem; text-align:center; max-width:500px; margin:0 auto; }
.tutor-setup-icon { font-size:3rem; margin-bottom:0.5rem; }
.tutor-setup h3 { font-size:1.3rem; margin-bottom:0.3rem; color:var(--text,#3D2B1F); }
.tutor-section { text-align:left; margin-bottom:1.5rem; }
.tutor-section h4 { margin-bottom:0.6rem; font-size:0.95rem; color:var(--text,#3D2B1F); }
.tutor-goal-grid { display:flex; flex-wrap:wrap; gap:0.4rem; }
.tutor-goal-btn { padding:0.5rem 0.8rem; border:1px solid var(--border,#333); border-radius:20px; background:var(--card-bg,#3D2B1F); color:var(--text,#3D2B1F); font-size:0.85rem; cursor:pointer; transition:all 0.2s; }
.tutor-goal-btn:hover { border-color:#8B6914; }
.tutor-goal-btn.tutor-goal-selected { background:#8B6914; color:#FFF8F0; border-color:#8B6914; }
.tutor-opt-row { display:flex; gap:0.4rem; flex-wrap:wrap; }
.tutor-opt-btn { padding:0.5rem 1rem; border:1px solid var(--border,#333); border-radius:20px; background:var(--card-bg,#3D2B1F); color:var(--text,#3D2B1F); font-size:0.85rem; cursor:pointer; transition:all 0.2s; }
.tutor-opt-btn:hover { border-color:#8B6914; }
.tutor-opt-btn.tutor-opt-selected { background:#8B6914; color:#FFF8F0; border-color:#8B6914; }
.tutor-custom-input { width:100%; margin-top:0.5rem; padding:0.6rem 0.8rem; border:1px solid var(--border,#333); border-radius:10px; background:var(--card-bg,#3D2B1F); color:var(--text,#3D2B1F); font-size:0.85rem; outline:none; box-sizing:border-box; }
.tutor-custom-input:focus { border-color:#8B6914; }
.tutor-save-btn { width:100%; padding:0.9rem; border:none; border-radius:12px; background:linear-gradient(135deg,#8B6914,#6B5744); color:#FFF8F0; font-size:1rem; font-weight:700; cursor:pointer; margin-top:1rem; transition:opacity 0.2s; }
.tutor-save-btn:hover { opacity:0.9; }
