/* ══════════════════════════════════════════════════════════════
   SÀI GÒN BAO DUNG · TRĂNG AI — PREMIUM ACCESSIBILITY LIGHT THEME
   Palette: Warm Cream Ivory & Glowing Sunset Amber (High-Contrast)
   Accessibility: WCAG AAA Contrast, Scaled Typography for Elderly
   Fonts: Outfit (Headings) + Inter (Body)
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@600;700;800&family=Outfit:wght@400;500;600;700;800;900&family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

/* ── Tokens (Warm Cream & High Contrast Amber) ──────────────── */
:root {
  --bg:          #FAF6EE;            /* Soft Cream Ivory — extremely gentle on older eyes */
  --space-dark:  #F4EFE6;            /* Warm linen shadow */
  --text:        #2C1A10;            /* Deep Charcoal Brown — ultra-high contrast (AAA), warm & legible */
  --text-muted:  #5D493D;            /* Secondary dark brown — highly readable sub-text */
  --orange:      #D96C33;            /* Rich Sunset Orange */
  --peach:       #F2A97E;            /* Warm Amber Peach */
  --green-from:  #1B5E20;            /* Forest green for active status (high contrast) */
  --green-to:    #2E7D32;
  --cyan:        #1565C0;            /* Rich contrast royal blue */
  --purple:      #4A148C;            /* Deep contrast purple */
  
  --white-glass: rgba(255, 255, 255, 0.82); /* Semi-solid frosted white glass */
  --dark-glass:  rgba(255, 255, 255, 0.95); /* Ultra-solid bright white card body */
  --glass-border: rgba(45, 27, 15, 0.15);   /* High-contrast border borders */
  --nav-h:       88px;
  
  --btn-shadow:  0 8px 24px rgba(217, 108, 51, 0.15);
  --btn-shadow-hover: 0 12px 32px rgba(217, 108, 51, 0.3);
  --btn-transition: cubic-bezier(0.16, 1, 0.3, 1) 0.35s;
}

/* ── Base ───────────────────────────────────────────────────── */
html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(217, 108, 51, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(94, 53, 177, 0.06) 0%, transparent 45%),
    radial-gradient(rgba(45, 27, 15, 0.04) 1.2px, transparent 1.2px);
  background-size: 100% 100%, 100% 100%, 32px 32px;
  background-attachment: fixed;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ══ NAVBAR ════════════════════════════════════════════════════ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: rgba(250, 246, 238, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 2px solid var(--glass-border);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Logo badge */
.brand-logo {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--orange);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(45, 27, 15, 0.1);
  flex-shrink: 0;
  transition: transform 0.5s var(--btn-transition);
}
.brand-logo:hover {
  transform: scale(1.05);
}
.brand-logo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  padding: 4px;
}

/* Brand text */
.brand-name {
  display: block;
  font-family: 'Be Vietnam Pro', 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  background: linear-gradient(to right, #2C1A10, #D96C33);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 9999px;
  background: rgba(27, 94, 32, 0.12);
  border: 2px solid rgba(27, 94, 32, 0.35);
  box-shadow: 0 4px 16px rgba(27, 94, 32, 0.05);
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #2E7D32;
  box-shadow: 0 0 10px rgba(46, 125, 50, 0.5);
  animation: dotBlink 2.2s ease-in-out infinite;
  flex-shrink: 0;
}
.status-dot.offline {
  background: #C62828;
  animation: none;
  box-shadow: none;
}
@keyframes dotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}
.status-text {
  font-size: 14px;
  font-weight: 700;
  color: #1B5E20;
}
/* Offline overrides */
.status-pill.offline-pill {
  background: rgba(198, 40, 40, 0.1);
  border-color: rgba(198, 40, 40, 0.35);
}
.status-pill.offline-pill .status-text {
  color: #C62828;
}

/* ── Change Shelter Button ── */
.change-shelter-btn {
  background: rgba(45, 27, 15, 0.05);
  border: 1.5px solid rgba(45, 27, 15, 0.15);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0;
  margin-left: 6px;
  flex-shrink: 0;
}
.change-shelter-btn:hover {
  background: rgba(217, 108, 51, 0.1);
  color: var(--orange);
  border-color: var(--orange);
}

/* ══ MAIN LAYOUT ═══════════════════════════════════════════════ */
.main {
  position: fixed;
  inset: 0;
  top: var(--nav-h);
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* ── Conversation Scroll Area ── */
.conversation {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
  position: relative;
  z-index: 1;
  
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(45, 27, 15, 0.2) transparent;
}
.conversation::-webkit-scrollbar {
  width: 8px;
}
.conversation::-webkit-scrollbar-track {
  background: transparent;
}
.conversation::-webkit-scrollbar-thumb {
  background-color: rgba(45, 27, 15, 0.2);
  border-radius: 999px;
}

/* ── Idle State (Guiding Moon) ── */
.idle-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h) - 240px);
  text-align: center;
  padding: 48px 24px;
  gap: 40px;
}

/* ══ CELESTIAL ORB (AMBER GLOWING SUN/MOON) ═════════════════════ */
.orb-wrap {
  position: relative;
  width: 300px; height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  user-select: none;
}

/* Breathing Aura Glows */
.orb-glow-warm {
  position: absolute;
  inset: -50px;
  background: radial-gradient(circle, rgba(217, 108, 51, 0.25) 0%, rgba(242, 169, 126, 0.08) 50%, transparent 75%);
  filter: blur(35px);
  z-index: 1;
}
.orb-glow-cyan {
  position: absolute;
  inset: -50px;
  background: radial-gradient(circle, rgba(255, 179, 71, 0.22) 0%, rgba(250, 246, 238, 0.05) 50%, transparent 75%);
  filter: blur(40px);
  z-index: 1;
}

/* Sphere Body */
.orb-body {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 
    0 16px 40px rgba(45, 27, 15, 0.15),
    0 0 80px rgba(217, 108, 51, 0.2);
  animation: orbFloat 6s ease-in-out infinite;
  overflow: hidden;
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-10px) scale(1.02); }
}

/* L1: Inner Core (Golden Harvest Moon) */
.orb-core {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 30%, #FFFFFF 0%, #FFEFC8 25%, #FFB347 65%, #D96C33 100%);
}

/* L2: Soft Lunar Crescent Shadow */
.orb-crescent {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 25% 75%, transparent 35%, rgba(45, 27, 15, 0.8) 100%);
  mix-blend-mode: multiply;
  opacity: 0.55;
  pointer-events: none;
}

/* L3: Specular Glass Shell */
.orb-glass {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 65% 15%,
    rgba(255, 255, 255, 0.45) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 75%
  );
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border: 2px solid rgba(255, 255, 255, 0.35);
}

/* L4: Specular Rim Light */
.orb-rim {
  position: absolute;
  top: 6%; left: 16%;
  width: 66%; height: 32%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center top,
    rgba(255, 255, 255, 0.8) 0%,
    transparent 85%
  );
  filter: blur(3px);
  pointer-events: none;
}

/* L5: Grain/Noise overlay */
.orb-grain {
  position: absolute; inset: 0;
  border-radius: 50%;
  opacity: 0.04;
  filter: url(#orb-grain-filter);
  background: white;
  pointer-events: none;
}

/* Shadow bloom beneath */
.orb-shadow-bloom {
  position: absolute;
  bottom: -20px;
  width: 150px; height: 36px;
  background: var(--orange);
  border-radius: 50%;
  filter: blur(24px);
  animation: bloomPulse 6s ease-in-out infinite;
  opacity: 0.12;
  pointer-events: none;
}
@keyframes bloomPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.08; }
  50%      { transform: scale(1.08); opacity: 0.16; }
}

/* ── Active Listening state for moon ── */
.orb-listening {
  animation: orbListeningPulse 1.8s ease-in-out infinite alternate;
}
@keyframes orbListeningPulse {
  0% { transform: scale(1); box-shadow: 0 0 40px rgba(217, 108, 51, 0.2); }
  100% { transform: scale(1.06); box-shadow: 0 0 70px rgba(217, 108, 51, 0.45); }
}

/* ── Idle copy ── */
.idle-copy { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
  max-width: 620px; 
}
.idle-heading {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(28px, 4.5vw, 42px); /* Larger for old eyes */
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #2C1A10, #D96C33);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.idle-hint {
  font-size: clamp(17px, 2.0vw, 20px); /* Larger hint size */
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Chat bubbles ───────────────────────────────────────────── */
.bubbles {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 100px;
}

.bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: bubbleSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes bubbleSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble-user { align-items: flex-end; }
.bubble-ai   { align-items: flex-start; }

.bubble-label {
  /* Be Vietnam Pro: dựng dấu chồng (Ế, Ố) chuẩn khi in hoa */
  font-family: 'Be Vietnam Pro', 'Outfit', sans-serif;
  font-size: 13px; /* Upgraded size */
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 8px;
}

.bubble-content {
  padding: 18px 24px;
  font-size: clamp(18px, 2.2vw, 22px); /* Highly readable scaled text sizes */
  line-height: 1.65;
  max-width: 85%;
  word-break: break-word;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(45, 27, 15, 0.05);
}

.bubble-user .bubble-content {
  background: linear-gradient(135deg, #D96C33 0%, #C0551E 100%);
  color: #FFFFFF;
  border-radius: 24px 24px 4px 24px;
  font-weight: 600;
  border: 1px solid rgba(217, 108, 51, 0.2);
  box-shadow: 0 6px 18px rgba(217, 108, 51, 0.15);
}

.bubble-ai .bubble-content {
  background: #FFFFFF;
  border: 1.8px solid var(--glass-border); /* Clear crisp frame border */
  color: var(--text);
  border-radius: 24px 24px 24px 4px;
  box-shadow: 0 8px 24px rgba(45, 27, 15, 0.04);
}

/* ══ TẢI FILE (PDF/Word/Excel) — chip nhỏ dưới câu trả lời ══
   Cố tình NHẠT và NHỎ: cụ già không dùng tới, không được cướp mắt khỏi
   câu trả lời. Nhân viên cần thì thấy ngay. Ẩn hẳn bằng ?tools=0 */
.tbt-export { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0 8px; }
.tbt-export-btn {
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .7);
  border: 1.5px solid var(--glass-border);
  color: var(--text-muted);
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.tbt-export-btn:hover:not(:disabled) {
  color: var(--orange); border-color: var(--orange); background: #fff;
}
.tbt-export-btn:disabled { opacity: .6; cursor: default; }

/* Báo trạng thái khi AI tự xuất file (người hỏi có câu "xuất file … giúp tôi") */
.tbt-export-note {
  font-size: 14px; font-weight: 700; color: var(--text-muted);
  margin: 8px 0 0 8px;
}

/* Thinking dots */
.thinking-dots { display: flex; align-items: center; gap: 8px; padding: 12px 0; }
.thinking-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--orange);
  animation: thinkPop 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .20s; }
.thinking-dots span:nth-child(3) { animation-delay: .40s; }
@keyframes thinkPop {
  0%, 60%, 100% { transform: scale(0.6); opacity: 0.3; }
  30%          { transform: scale(1.2); opacity: 1; }
}

/* ══ MIC ZONE (BIG TRIGGERS) ══════════════════════════════════ */
.mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 48px;
  padding-bottom: 40px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.state-label {
  font-family: 'Outfit', sans-serif;
  font-size: 14px; /* Larger */
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  height: 28px;
  display: flex;
  align-items: center;
  margin-bottom: 40px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 10;
}
.state-label.listening { color: #1B5E20; text-shadow: 0 0 10px rgba(27, 94, 32, 0.2); }
.state-label.thinking  { color: var(--orange); text-shadow: 0 0 10px rgba(217, 108, 51, 0.2); }

/* ── Dock ───────────────────────────────────────────────────── */
.dock {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  padding: 0 24px;
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 60px; /* Taller, easy-to-click buttons */
  padding: 0 24px;
  border-radius: 9999px;
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(45, 27, 15, 0.05);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.dock-btn:hover {
  background: #FFFFFF;
  border-color: var(--orange);
  color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(217, 108, 51, 0.12);
}
.dock-btn:active {
  transform: translateY(1px);
}
.dock-btn svg {
  width: 22px; height: 22px;
}

.speak-btn {
  position: absolute;
  left: 24px;
  animation: fadeSlideRight 0.4s var(--btn-transition) both;
}
.new-btn {
  position: absolute;
  right: 24px;
  animation: fadeSlideLeft 0.4s var(--btn-transition) both;
}
@keyframes fadeSlideRight {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeSlideLeft {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.dock-spacer {
  width: 110px;
  height: 60px;
  flex-shrink: 0;
  pointer-events: none;
}

/* ── Elevated Mic Button (Guiding Core) ── */
.mic-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 110px; height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* Dashed slow ring */
.mic-ring-dashed {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px dashed rgba(217, 108, 51, 0.3);
  pointer-events: none;
}
.mic-ring-cw {
  animation: spinCW 28s linear infinite;
}
@keyframes spinCW {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Counter rotating solid ring */
.mic-ring-solid {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(217, 108, 51, 0.15);
  pointer-events: none;
}
.mic-ring-ccw {
  animation: spinCCW 20s linear infinite;
}
@keyframes spinCCW {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0deg); }
}

/* Pulse glow under recording */
.mic-pulse-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--orange);
  filter: blur(20px);
  opacity: 0;
  transform: scale(0.85);
  transition: all 0.4s var(--btn-transition);
  pointer-events: none;
}
.mic-pulse-glow.active {
  animation: micPulse 1.8s cubic-bezier(0.16, 1, 0.3, 1) infinite alternate;
}
@keyframes micPulse {
  0%   { opacity: 0.15; transform: scale(0.9); }
  100% { opacity: 0.4; transform: scale(1.15); }
}

/* The core click button */
.mic-btn {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D96C33, #BF531B);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  box-shadow: 
    0 10px 24px rgba(217, 108, 51, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}
.mic-btn-shine {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}

/* Interactive States */
.mic-btn:hover {
  transform: scale(1.08);
  box-shadow: 
    0 12px 32px rgba(217, 108, 51, 0.45),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
}
.mic-btn:active {
  transform: scale(0.92);
}

/* State overrides: Recording */
.mic-btn.recording {
  background: linear-gradient(135deg, #C62828, #B71C1C);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 
    0 10px 24px rgba(198, 40, 40, 0.4),
    0 0 0 10px rgba(198, 40, 40, 0.15);
  animation: recordingHeartbeat 1.6s ease-in-out infinite alternate;
}
@keyframes recordingHeartbeat {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* State overrides: Thinking */
.mic-btn.thinking {
  background: linear-gradient(135deg, #1B5E20, #2E7D32);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 10px 24px rgba(46, 125, 50, 0.4);
  cursor: default;
  pointer-events: none;
}

/* Icons */
.mic-icon {
  width: 32px; height: 32px;
  transition: opacity 0.3s ease;
}
.spin-icon {
  width: 32px; height: 32px;
  animation: spinIcon 1.2s linear infinite;
}
@keyframes spinIcon {
  100% { transform: rotate(360deg); }
}

.hidden { display: none !important; }

/* ══ LISTENING OVERLAY (ACCESSIBILITY FIRST) ══════════════════ */
.listening-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Bỏ backdrop-filter blur (vẽ lại cả nền mỗi khung hình — giật trên tablet);
     tăng độ tối nền để chữ vẫn nổi rõ. */
  background: rgba(45, 27, 15, 0.5);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.listen-card {
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  border-radius: 32px;
  width: min(480px, 92vw);
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  box-shadow: 
    0 24px 64px rgba(45, 27, 15, 0.18),
    0 0 1px 1px rgba(45, 27, 15, 0.05);
  animation: cardZoom 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes cardZoom {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.listen-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.listening-orb-mini {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 30%, #FFEFC8, #FFB347);
  box-shadow: 0 4px 16px rgba(217, 108, 51, 0.3);
  animation: pulseMiniOrb 1.6s ease-in-out infinite alternate;
}
@keyframes pulseMiniOrb {
  0% { transform: scale(0.9); box-shadow: 0 4px 12px rgba(217, 108, 51, 0.2); }
  100% { transform: scale(1.1); box-shadow: 0 6px 24px rgba(217, 108, 51, 0.45); }
}
.listen-status {
  font-family: 'Outfit', sans-serif;
  font-size: 20px; /* Big for readability */
  font-weight: 800;
  color: var(--text);
}

/* Animated Waveform */
.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 50px;
}
.waveform .bar {
  width: 6px;
  /* Cao cố định, animate bằng scaleY (GPU) — KHÔNG animate height (ép layout mỗi khung) */
  height: 44px;
  transform-origin: 50% 50%;
  transform: scaleY(0.22);
  border-radius: 999px;
  background: var(--orange);
  animation: wavePulse 1.2s ease-in-out infinite;
  will-change: transform, opacity;
}
/* Stagger wave animations */
.waveform .bar:nth-child(1) { animation-delay: 0.1s; }
.waveform .bar:nth-child(2) { animation-delay: 0.2s; }
.waveform .bar:nth-child(3) { animation-delay: 0.3s; }
.waveform .bar:nth-child(4) { animation-delay: 0.4s; }
.waveform .bar:nth-child(5) { animation-delay: 0.5s; }
.waveform .bar:nth-child(6) { animation-delay: 0.4s; }
.waveform .bar:nth-child(7) { animation-delay: 0.3s; }
.waveform .bar:nth-child(8) { animation-delay: 0.2s; }
.waveform .bar:nth-child(9) { animation-delay: 0.1s; }

@keyframes wavePulse {
  0%, 100% { transform: scaleY(0.22); opacity: 0.5; }
  50%      { transform: scaleY(1);    opacity: 1; }
}
.waveform.paused .bar {
  animation-play-state: paused;
  transform: scaleY(0.18);
  opacity: 0.4;
}

/* Chat Compose area inside overlay */
.chat-compose {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--space-dark);
  border: 2px solid var(--glass-border);
  border-radius: 20px;
  padding: 10px 14px;
  transition: border-color 0.3s ease;
}
.chat-compose:focus-within {
  border-color: var(--orange);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 18px; /* Tông to dễ đọc */
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  max-height: 120px;
  padding: 4px 0;
  scrollbar-width: none;
}
.chat-textarea::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.chat-send-btn {
  width: 48px; height: 48px;
  border-radius: 16px;
  background: var(--orange);
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(217, 108, 51, 0.2);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--text);
  color: #FFFFFF;
  transform: scale(1.05);
}
.chat-send-btn:active {
  transform: scale(0.95);
}

/* Cancel Button */
.listen-cancel {
  width: 100%;
  height: 52px;
  border-radius: 18px;
  background: #FAF6EE;
  border: 2px solid var(--glass-border);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}
.listen-cancel:hover {
  background: #F4EFE6;
  color: var(--text);
  border-color: var(--text);
}

/* ── Shelter selection card customization ── */
.shelter-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1.5px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.25s ease;
}
.shelter-select-item:last-child {
  border-bottom: none;
}
.shelter-select-item:hover {
  background: rgba(217, 108, 51, 0.05);
}
.shelter-select-item.selected {
  background: rgba(217, 108, 51, 0.08);
}
.shelter-item-name {
  display: block;
  font-size: 18px; /* Tông chữ lớn hơn */
  font-weight: 700;
  color: var(--text);
}
.shelter-item-location {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}
.shelter-item-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
}
.shelter-select-item.selected .shelter-item-check {
  display: flex;
}

/* Selection Confirm Buttons */
.review-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  padding: 0 24px;
  border-radius: 18px;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}
.submit-btn {
  background: var(--orange);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(217, 108, 51, 0.2);
}
.submit-btn:hover {
  background: #C45B23;
}
.submit-btn:disabled {
  background: var(--space-dark);
  color: var(--text-muted);
  border: 1.5px solid var(--glass-border);
  cursor: not-allowed;
  box-shadow: none;
}
.cancel-btn {
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  color: var(--text-muted);
}
.cancel-btn:hover {
  background: #F4EFE6;
  color: var(--text);
}

/* ══ TOAST NOTIFICATION ════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translate(-50%, 20px);
  padding: 14px 28px;
  border-radius: 16px;
  background: var(--text);
  color: #FAF6EE;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(45, 27, 15, 0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ══ RESPONSIVE ADAPTATIONS (MOBILE) ══════════════════════════ */
@media (max-width: 600px) {
  .navbar {
    padding: 0 16px;
    height: 76px;
  }
  .main {
    top: 76px;
  }
  .brand-logo {
    width: 44px; height: 44px;
  }
  .brand-name {
    font-size: 19px;
  }
  .brand-sub {
    font-size: 9px;
  }
  .status-pill {
    padding: 6px 12px;
  }
  .status-text {
    font-size: 12px;
  }
  .idle-state {
    padding: 24px 16px;
    gap: 28px;
  }
  .orb-wrap {
    width: 220px; height: 220px;
  }
  .orb-glow-warm, .orb-glow-cyan {
    inset: -30px;
  }
  .orb-shadow-bloom {
    width: 100px;
    bottom: -12px;
  }
  .bubbles {
    padding: 16px 16px 80px;
    gap: 20px;
  }
  .bubble-content {
    font-size: 17px; /* Still very large and readable on mobile */
    padding: 14px 18px;
  }
  .dock {
    padding: 0 16px;
  }
  .dock-btn {
    height: 52px;
    font-size: 14px;
    padding: 0 16px;
  }
  .dock-btn svg {
    width: 18px; height: 18px;
  }
  .mic-center {
    width: 90px; height: 90px;
  }
  .mic-btn {
    width: 64px; height: 64px;
  }
  .mic-icon, .spin-icon {
    width: 26px; height: 26px;
  }
  .mic-ring-dashed {
    inset: -10px;
  }
  .mic-ring-solid {
    inset: -4px;
  }
  .dock-spacer {
    width: 90px;
    height: 52px;
  }
  .speak-btn {
    left: 16px;
  }
  .new-btn {
    right: 16px;
  }
}

/* ══ PERFORMANCE: TỐI ƯU CHO THIẾT BỊ CẢM ỨNG (ĐIỆN THOẠI/TABLET) ══
   Tắt các hiệu ứng tô-lại-mỗi-khung-hình tốn GPU. Laptop (chuột) giữ
   nguyên vẻ đẹp gốc vì không khớp media query này.
   ⚠ Sửa CSS thuần — cần deploy lại hosting mới có hiệu lực. */
@media (hover: none) and (pointer: coarse) {
  /* 1. Bỏ filter nhiễu SVG (feTurbulence) — gần như vô hình nhưng cực nặng */
  .orb-grain { display: none !important; }

  /* 2. Nền không còn fixed → hết giật khi cuộn; bỏ lớp lưới chấm lặp lại */
  html, body {
    background-attachment: scroll;
    background-image:
      radial-gradient(circle at 10% 20%, rgba(217, 108, 51, 0.08) 0%, transparent 45%),
      radial-gradient(circle at 90% 80%, rgba(94, 53, 177, 0.06) 0%, transparent 45%);
  }

  /* 3. Navbar: thay backdrop-filter bằng nền mờ đặc (rẻ hơn nhiều) */
  .navbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(250, 246, 238, 0.94);
  }

  /* 4. Quả cầu: bỏ backdrop-filter ở lớp kính + bỏ blend mode */
  .orb-glass {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .orb-crescent { mix-blend-mode: normal; }
}

/* ── Điện thoại nhỏ: giảm thêm glow & animation tô-lại nặng ── */
@media (max-width: 600px) {
  /* Giảm độ nặng 2 lớp glow blur lớn */
  .orb-glow-warm, .orb-glow-cyan { filter: blur(18px); opacity: 0.7; }

  /* Tắt animation đổi box-shadow / blur (giữ chuyển động bằng transform) */
  .orb-shadow-bloom { animation: none; }
  .mic-pulse-glow.active { animation: none; }
  .listening-orb-mini { animation: none; }
  .orb-listening { animation: orbListenLite 1.6s ease-in-out infinite alternate; }

  /* Listening overlay: bỏ blur nền cho nhẹ */
  .listening-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(45, 27, 15, 0.55);
  }
}
@keyframes orbListenLite {
  0%   { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* Loader spinner (dùng cho modal chọn cơ sở + đăng nhập) */
@keyframes spinLoader { to { transform: rotate(360deg); } }

/* ══ V2 — USER CHIP + ĐĂNG NHẬP CƯ DÂN ════════════════════════ */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* User / points chip trên navbar */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 9999px;
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: 'Outfit', sans-serif;
}
.user-chip:hover { border-color: var(--orange); }
.user-chip.guest { background: rgba(45, 27, 15, 0.04); }
.user-chip-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--peach), var(--orange));
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  flex-shrink: 0;
}
.user-chip.guest .user-chip-avatar { background: rgba(45, 27, 15, 0.2); }
.user-chip-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-chip-name { font-size: 14px; font-weight: 700; color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-points { font-size: 12px; font-weight: 700; color: var(--orange); }

/* Chuỗi lửa kiểu TikTok */
.user-chip-streak {
  display: inline-flex; align-items: center; gap: 3px;
  margin-left: 2px;
  padding: 4px 10px 4px 8px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #FF9D2E, #FF3D00);
  color: #FFFFFF; font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 10px rgba(255, 61, 0, 0.4);
  line-height: 1; flex-shrink: 0;
}
.user-chip-streak .flame {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 190, 60, 0.9));
  animation: flamePulse 1.5s ease-in-out infinite;
}
@keyframes flamePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* Login badge (header modal) */
.login-badge {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--peach), var(--orange));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(217, 108, 51, 0.22);
}

/* Lưới chọn tên cư dân */
.resident-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
}
.resident-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.resident-pick:hover { border-color: var(--orange); background: rgba(217, 108, 51, 0.05); transform: translateY(-1px); }
.resident-pick-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--peach), var(--orange));
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-size: 15px; font-weight: 800;
  flex-shrink: 0;
}
.resident-pick-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* PIN entry */
.pin-name { font-size: 18px; font-weight: 800; color: var(--text); font-family: 'Outfit', sans-serif; }
.pin-display { display: flex; gap: 16px; padding: 4px 0; }
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: transparent;
  transition: all 0.15s ease;
}
.pin-dot.filled { background: var(--orange); border-color: var(--orange); transform: scale(1.1); }
.pin-error { font-size: 14px; font-weight: 600; color: #C62828; }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.pin-key {
  height: 64px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 2px solid var(--glass-border);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}
.pin-key:hover { border-color: var(--orange); background: rgba(217, 108, 51, 0.05); }
.pin-key:active { transform: scale(0.95); }
.pin-key:disabled { opacity: 0.5; cursor: default; }
.pin-key-alt { color: var(--text-muted); font-size: 22px; }
.pin-key-ok  { background: var(--orange); color: #FFFFFF; border-color: var(--orange); }
.pin-key-ok:hover { background: #C45B23; }

@media (max-width: 600px) {
  .user-chip-name { max-width: 90px; font-size: 13px; }
  .user-chip-avatar { width: 30px; height: 30px; font-size: 13px; }
  .resident-grid { grid-template-columns: 1fr; }
  .pin-key { height: 58px; font-size: 22px; }
}