/* CSS Variables for design system tokens */
:root {
  --font-family: 'Outfit', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Dark Theme Palette (Default) */
  --bg-desktop: #0b0f19;
  --bg-device: #121824;
  --bg-surface: #1e2640;
  --bg-surface-hover: #293456;
  --bg-input: #171d33;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Primary Accent & Brand Colors */
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-alpha: rgba(59, 130, 246, 0.15);
  --color-accent: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  
  /* Card Custom Colors (Replicating Screenshot) */
  --card-quizzes-bg: linear-gradient(135deg, #1d61e6, #0d4bc3);
  --card-quizzes-sub: rgba(255, 255, 255, 0.8);
  
  --card-games-bg: linear-gradient(135deg, #0ea960, #06723e);
  --card-games-sub: rgba(255, 255, 255, 0.8);
  
  --card-learning-bg: linear-gradient(135deg, #1a62d8, #0eab67);
  --card-learning-sub: rgba(255, 255, 255, 0.85);

  --chat-user-bubble: linear-gradient(135deg, #3b82f6, #1d4ed8);
  --chat-bot-bubble: #1e293b;
  
  /* Layout constraints */
  --phone-width: 380px;
  --phone-height: 800px;
  --border-radius-phone: 40px;
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme overrides */
[data-theme="light"] {
  --bg-desktop: #f0f2f5;
  --bg-device: #ffffff;
  --bg-surface: #f3f4f6;
  --bg-surface-hover: #e5e7eb;
  --bg-input: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --glass-border: rgba(0, 0, 0, 0.08);
  --chat-bot-bubble: #f3f4f6;
  --chat-user-bubble: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* Base resets & layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-desktop);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: var(--transition-smooth);
  touch-action: pan-x pan-y; /* Disable double-tap and pinch zoom on touch screens */
}

/* Layout for presentation: Left Panel & Smartphone Frame */
.web-layout {
  display: flex;
  gap: 60px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  padding: 20px;
}

/* Left panel for desktop users */
.desktop-panel {
  flex: 1;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

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

.panel-header h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  background: var(--color-primary-alpha);
  color: #60a5fa;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.panel-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.stats-card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 5px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.stat-row span {
  color: var(--text-secondary);
}

.stat-row strong {
  color: var(--color-accent);
}

.control-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.control-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.control-btn.secondary {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.control-btn.secondary:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
}

.bot-status-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.bot-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.bot-indicator.online .dot {
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
}

/* Smartphone Device Mockup Wrapper */
.device-wrapper {
  perspective: 1000px;
  transition: var(--transition-smooth);
}

.phone-frame {
  width: var(--phone-width);
  height: var(--phone-height);
  background-color: var(--bg-device);
  border: 11px solid #1f2937;
  border-radius: var(--border-radius-phone);
  box-shadow: var(--shadow-premium), 0 0 0 2px rgba(255, 255, 255, 0.05);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition-smooth);
}

/* Smartphone Fullscreen override */
.device-wrapper.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-desktop);
}

.device-wrapper.fullscreen .phone-frame {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  max-width: 480px;
}

/* Status Bar */
.status-bar {
  height: 44px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  z-index: 100;
  background: transparent;
}

.status-bar .notch {
  width: 120px;
  height: 25px;
  background-color: #000;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  border-radius: 0 0 16px 16px;
}

.status-bar .notch::after {
  content: '';
  width: 8px;
  height: 8px;
  background: #111;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  box-shadow: inset 0 0 2px #fff;
}

.status-bar .signals {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signal-text {
  font-size: 10px;
  opacity: 0.8;
}

.battery-icon {
  width: 20px;
  height: 10px;
  border: 1px solid var(--text-primary);
  border-radius: 3px;
  padding: 1px;
  position: relative;
  display: flex;
  align-items: center;
}

.battery-icon::after {
  content: '';
  width: 1.5px;
  height: 4px;
  background: var(--text-primary);
  position: absolute;
  right: -3px;
  border-radius: 0 1px 1px 0;
}

.battery-level {
  height: 100%;
  background: var(--text-primary);
  border-radius: 1px;
}

/* App Header */
.app-header {
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  z-index: 99;
  background: var(--bg-device);
}

.app-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: transform 0.2s ease;
}

.header-icon-btn:active {
  transform: scale(0.9);
}

.notification-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bg-device);
}

.avatar-pq {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* Search Drawer */
.search-drawer {
  position: absolute;
  top: 104px;
  left: 0;
  width: 100%;
  height: 50px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(-110%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 98;
}

.search-drawer.active {
  transform: translateY(0);
}

.search-drawer input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.search-drawer button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

/* Main Content Area */
.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg-device);
}

/* Hide scrollbar for clean app design */
.screen-content::-webkit-scrollbar {
  display: none;
}

/* View transition container */
.tab-view {
  display: none;
  padding: 20px;
  animation: fadeIn 0.4s ease-out forwards;
}

.tab-view.active {
  display: block;
}

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

.view-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 25px;
  color: var(--text-primary);
}

/* Cards Grid Layout (Forge Tab) */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 768px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
}

.forge-card {
  border-radius: 24px;
  padding: 22px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 20px -5px rgba(0,0,0,0.25);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}

.forge-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 15px 25px -5px rgba(0,0,0,0.35);
}

.forge-card:active {
  transform: translateY(0) scale(0.99);
}

.card-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 25px;
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 400;
}

/* Specific Card Styling */
.card-quizzes {
  background: var(--card-quizzes-bg);
}

.card-quizzes .card-subtitle {
  color: var(--card-quizzes-sub);
}

.card-games {
  background: var(--card-games-bg);
}

.card-games .card-subtitle {
  color: var(--card-games-sub);
}

.card-learning {
  background: var(--card-learning-bg);
}

.card-learning .card-subtitle {
  color: var(--card-learning-sub);
}

/* Home View styles */
.home-hero {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 25px;
}

.home-hero h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.home-hero p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 15px;
}

.hero-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.feed-section h4 {
  font-size: 15px;
  margin-bottom: 15px;
  color: var(--text-secondary);
}

.feed-item {
  display: flex;
  gap: 15px;
  padding: 15px 0;
  border-bottom: 1px solid var(--glass-border);
}

.feed-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #4f46e5;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.feed-avatar.green {
  background: #10b981;
}

.feed-content {
  flex: 1;
}

.feed-content strong {
  font-size: 14px;
}

.feed-content p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.feed-time {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-top: 6px;
}

/* Reels View styles */
.reels-container {
  height: calc(100vh - 200px);
  max-height: 580px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reel-video-wrapper {
  flex: 1;
  background: #000;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.reel-placeholder-media {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #334155 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.reel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  color: white;
}

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

.reel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.reel-user strong {
  font-size: 13px;
}

.reel-user p {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 4px;
}

.reel-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.reel-action-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reel-action-btn span {
  font-size: 11px;
  font-weight: 500;
}

.reel-action-btn svg.active {
  fill: var(--color-danger);
  stroke: var(--color-danger);
  animation: heartPop 0.3s ease;
}

@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.reel-play-btn {
  position: absolute;
  color: white;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.reel-placeholder-media.paused .reel-play-btn {
  opacity: 0.6;
}

.next-reel-btn {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

/* Network View styles */
.network-search input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  outline: none;
  margin-bottom: 20px;
}

.network-tabs {
  display: flex;
  gap: 15px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.net-tab {
  padding-bottom: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.net-tab.active {
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  font-weight: 600;
}

.network-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.network-user-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
}

.net-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f59e0b;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.net-avatar.blue { background: #3b82f6; }
.net-avatar.gold { background: #8b5cf6; }

.net-info {
  flex: 1;
}

.net-info strong {
  font-size: 14px;
}

.net-info p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.net-connect-btn {
  background: var(--color-primary-alpha);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.net-connect-btn.connected {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--glass-border);
}

/* Menu View styles */
.menu-profile {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--bg-surface);
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  margin-bottom: 25px;
}

.menu-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.menu-meta h3 {
  font-size: 16px;
}

.menu-meta p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  background: var(--bg-surface);
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.2s ease;
}

.menu-item:hover {
  background: var(--bg-surface-hover);
}

.menu-item-icon {
  font-size: 18px;
}

.menu-item-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.menu-item-value {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
  padding: 4px 8px;
  border-radius: 6px;
}

/* System Chat Screen Layout */
#view-chat {
  padding: 0;
  height: calc(100% - 60px); /* Fill main minus header */
}

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Chat Sidebar (list of channels) */
.chat-sidebar {
  width: 100%;
  height: 100%;
  background: var(--bg-device);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-sidebar.hidden {
  transform: translateX(-100%);
}

.sidebar-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.chat-channels-list {
  flex: 1;
  overflow-y: auto;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.2s ease;
  position: relative;
}

.channel-item:hover {
  background: var(--bg-surface-hover);
}

.channel-item.active {
  background: var(--color-primary-alpha);
}

.channel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.channel-avatar.sys { background: #3b82f6; }
.channel-avatar.quiz { background: #8b5cf6; }
.channel-avatar.game { background: #10b981; }
.channel-avatar.study { background: #ec4899; }

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.channel-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

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

.channel-last-msg {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.channel-badge {
  background: var(--color-primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Chat Main Window */
.chat-window {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-device);
}

.chat-header {
  height: 55px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  gap: 12px;
}

.back-to-channels {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #3b82f6;
}

.chat-header-info {
  flex: 1;
}

.chat-header-info h4 {
  font-size: 13px;
  font-weight: 600;
}

.chat-header-info p {
  font-size: 10px;
}

.status-online {
  color: var(--color-accent);
}

.status-typing {
  color: #3b82f6;
  font-style: italic;
}

/* Chat Message Container */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages-container::-webkit-scrollbar {
  width: 4px;
}
.chat-messages-container::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

.msg-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
  animation: messageSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.msg-wrapper.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-wrapper.received {
  align-self: flex-start;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.msg-wrapper.sent .msg-bubble {
  background: var(--chat-user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-wrapper.received .msg-bubble {
  background: var(--chat-bot-bubble);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-time-stamp {
  font-size: 9px;
  color: var(--text-muted);
  align-self: flex-end;
  margin-bottom: 2px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* Suggestion Chips */
.chat-suggestions {
  display: flex;
  gap: 8px;
  padding: 8px 15px;
  overflow-x: auto;
  flex-shrink: 0;
}

.chat-suggestions::-webkit-scrollbar {
  display: none;
}

.suggestion-chip {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.suggestion-chip:hover {
  background: #3b82f6;
  color: white;
}

/* Input Area */
.chat-input-area {
  padding: 10px 15px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-attachment-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

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

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

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

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

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

/* Bottom Navigation Bar */
.app-bottom-nav {
  height: 64px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-device);
  z-index: 99;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  height: 100%;
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-item svg {
  transition: transform 0.2s ease;
}

.nav-item span {
  font-size: 10px;
  font-weight: 500;
}

.nav-item.active {
  color: var(--text-primary);
}

.nav-item.active svg {
  color: var(--color-primary);
  transform: translateY(-1px);
}

/* Modals System styling */
.app-modal {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-end; /* Mobile drawer style */
}

.app-modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  background: var(--bg-device);
  border-top: 1px solid var(--glass-border);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  max-height: 85%;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
}

.modal-action-btn {
  display: block;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
  margin-top: 15px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-action-btn:hover {
  background: var(--bg-surface-hover);
}

.modal-action-btn.primary {
  background: var(--color-primary);
  border: none;
  color: white;
}

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

.modal-body hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 20px 0;
}

/* Interactive elements inside Quiz Modal */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}

.quiz-opt {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px 15px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-smooth);
}

.quiz-opt:hover {
  background: var(--bg-surface-hover);
}

.quiz-opt.correct {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--color-accent);
  color: #34d399;
}

.quiz-opt.wrong {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--color-danger);
  color: #fca5a5;
}

/* Interactive elements inside Games Modal */
.game-clicker-container {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  margin-top: 15px;
}

.clicker-item {
  font-size: 64px;
  margin: 20px auto;
  cursor: pointer;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-device);
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  user-select: none;
  transition: transform 0.05s ease;
}

.clicker-item:active {
  transform: scale(0.9);
}

.mined-count {
  font-size: 16px;
  margin-bottom: 15px;
}

/* Learning Modal elements */
.study-card textarea {
  width: 100%;
  height: 100px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px;
  outline: none;
  resize: none;
  font-size: 13px;
  margin-top: 12px;
}

.study-output-box {
  background: var(--bg-surface);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 15px;
  margin-top: 15px;
}

.study-output-box h5 {
  font-size: 13px;
  color: var(--color-accent);
  margin-bottom: 8px;
}

.study-output-box p {
  font-size: 12px;
  line-height: 1.5;
}

.podcast-player {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 15px;
  margin-top: 12px;
}

.podcast-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.podcast-info strong {
  font-size: 13px;
}

.podcast-info span {
  font-size: 11px;
  color: var(--text-secondary);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.play-btn-circle {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.playback-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.playback-progress {
  width: 0%;
  height: 100%;
  background: var(--color-primary);
  transition: width 0.1s linear;
}

/* Responsive adjustments for desktop, tablet, and mobile screens.
   We strip the mockup phone frame and status bar on all screen sizes,
   creating a native full-screen web app experience on both desktop and mobile. */
html, body {
  height: 100% !important;
  width: 100% !important;
  overflow: hidden !important;
  background-color: var(--bg-device) !important;
}
body {
  align-items: stretch !important;
}
.web-layout {
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  display: flex !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  gap: 0 !important;
}
.desktop-panel {
  display: none !important; /* Hide old presentation info panel */
}
.device-wrapper {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  flex: 1 !important;
  display: flex !important;
  align-items: stretch !important;
}
.phone-frame {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
}
.status-bar,
.phone-frame .volume-up,
.phone-frame .volume-down,
.phone-frame .power-btn {
  display: none !important; /* Hide simulated physical hardware elements */
}
.screen-content {
  height: calc(100% - 124px) !important; /* 60px header + 64px bottom nav */
  max-width: 1200px !important;
  width: 100% !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
  padding: 24px !important;
  overflow-y: auto !important;
}
#view-chat {
  height: calc(100% - 60px) !important;
  max-width: 1200px !important;
  margin: 0 auto !important;
}

/* ==========================================
   AUTH SCREEN STYLES
   ========================================== */
.auth-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-desktop);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
  backdrop-filter: blur(20px);
}

.auth-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.05);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: authFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.auth-logo-area {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

.auth-logo-img {
  width: 70px;
  height: 70px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.5));
}

.auth-logo-area h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-logo-area p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-card-wrapper {
  width: 100%;
  position: relative;
  min-height: 420px;
  perspective: 1000px;
}

.auth-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 30px;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  position: absolute;
  top: 0;
  left: 0;
}

/* Card flip animation triggers */
.auth-card-wrapper.flip #card-signin {
  transform: rotateY(180deg);
  opacity: 0;
  pointer-events: none;
}

.auth-card-wrapper.flip #card-signup {
  transform: rotateY(0deg);
  opacity: 1;
  pointer-events: auto;
}

#card-signup {
  transform: rotateY(-180deg);
  opacity: 0;
  pointer-events: none;
}

.auth-card h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 25px;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.auth-form-group input {
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 16px; /* Enlarge to 16px to prevent iOS Safari auto-zoom on focus */
  outline: none;
  transition: var(--transition-smooth);
}

.auth-form-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
  background: var(--bg-surface);
}

.auth-error-msg {
  color: var(--color-danger);
  font-size: 12px;
  margin-bottom: 15px;
  min-height: 18px;
  font-weight: 500;
  text-align: center;
}

.auth-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition-smooth);
}

.auth-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-switch-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 20px;
}

.auth-switch-text a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch-text a:hover {
  text-decoration: underline;
}

/* Spinner for buttons */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btnSpin 0.8s linear infinite;
  display: inline-block;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* Shake animation for input errors */
.shake {
  animation: authShake 0.4s ease;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ==========================================
   WELCOME LOADING SCREEN STYLES
   ========================================== */
.welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-desktop);
  z-index: 11000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-screen.fade-out {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  width: 90%;
  max-width: 320px;
}

/* Glowing Double Ring Logo Loader */
.logo-loader-container {
  width: 110px;
  height: 110px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.logo-loader-svg {
  width: 100%;
  height: 100%;
}

.logo-loader-svg circle {
  fill: none;
  stroke-width: 4;
  transform-origin: center;
}

.logo-loader-svg .ring-outer {
  stroke: #3b82f6;
  stroke-dasharray: 200;
  stroke-dashoffset: 40;
  animation: rotateOuter 2s linear infinite;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
}

.logo-loader-svg .ring-inner {
  stroke: #10b981;
  stroke-dasharray: 120;
  stroke-dashoffset: 20;
  animation: rotateInner 1.5s linear infinite reverse;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.6));
}

.loader-logo-center {
  position: absolute;
  font-size: 32px;
  animation: bounceLogo 2s ease-in-out infinite;
  user-select: none;
}

@keyframes rotateOuter {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes rotateInner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

.welcome-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGliss 3s ease infinite;
}

/* Loading Bar */
.loader-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-top: 10px;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 10px;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.welcome-status {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  min-height: 18px;
  transition: opacity 0.2s ease;
}

/* ==========================================
   DESKTOP SIDEBAR NAVIGATION
   ========================================== */
.desktop-sidebar {
  display: none;
  flex-direction: column;
  width: 260px;
  height: 100vh;
  background-color: var(--bg-device);
  border-right: 1px solid var(--glass-border);
  padding: 24px;
  box-sizing: border-box;
  z-index: 100;
}

@media (min-width: 768px) {
  .desktop-sidebar {
    display: flex;
  }
  .app-bottom-nav {
    display: none !important;
  }
  .app-header .app-logo {
    display: none !important; /* Hide app logo in header since sidebar logo exists */
  }
  .app-header {
    justify-content: flex-end !important; /* Align actions to right */
    gap: 15px;
  }
}

.sidebar-logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.sidebar-logo-img {
  width: 32px;
  height: 32px;
}

.sidebar-logo-area h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin: 0;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-sizing: border-box;
  text-align: left;
}

.sidebar-nav-item svg {
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.sidebar-nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-nav-item:hover svg {
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-left: 3px solid var(--color-primary);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.sidebar-nav-item.active svg {
  color: var(--color-primary);
}

.sidebar-footer {
  padding-top: 15px;
  border-top: 1px solid var(--glass-border);
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-profile .avatar-pq {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.profile-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px 0;
}

.profile-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ==========================================
   DESKTOP SPLIT-SCREEN CHAT LAYOUT
   ========================================== */
@media (min-width: 768px) {
  .chat-layout {
    display: flex !important;
    flex-direction: row !important;
  }
  
  .chat-sidebar {
    position: static !important;
    width: 320px !important;
    height: 100% !important;
    border-right: 1px solid var(--glass-border) !important;
    transform: none !important; /* Never translate off-screen */
    z-index: 1 !important;
  }

  .chat-window {
    flex: 1 !important;
    display: flex !important;
    height: 100% !important;
  }

  /* Hide mobile back-to-channels button since both list and window are side-by-side */
  #back-to-channels-btn {
    display: none !important;
  }
}


