:root {
  --imessage-blue: #007AFF;
  --imessage-blue-solid: #007AFF;
  --imessage-gray: #E9E9EB;
  --imessage-bg: #FFFFFF;
  --imessage-header-bg: rgba(255, 255, 255, 0.8);
  --imessage-input-bg: #F6F6F6;
  --imessage-sidebar-bg: #F6F6F6;
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --text-tertiary: #C7C7CC;
  --separator: rgba(60, 60, 67, 0.12);
  --sidebar-width: 320px;
  --vh: 1vh;
  --app-height: 100vh;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* Professional typography scale */
h1, h2, h3, .sidebar-title {
  font-weight: 700;
  letter-spacing: -0.025em;
}

button, input, textarea {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-feature-settings: "kern" 1, "liga" 1;
}

/* Smooth scroll globally */
html {
  scroll-behavior: smooth;
}

/* Selection styling */
::selection {
  background: rgba(0, 122, 255, 0.3);
  color: inherit;
}

html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

body {
  background: #0a0a0f;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  height: 100vh;
}

/* Smooth theme transitions - all elements transition together */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning .sidebar,
body.theme-transitioning .imessage-header,
body.theme-transitioning .chat-area,
body.theme-transitioning .input-area,
body.theme-transitioning .bubble,
body.theme-transitioning .app-container {
  transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Interactive Gradient Background */
.gradient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0;
  will-change: transform, opacity, filter;
}

/* Coordinated animation timing - all orbs move together */
.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 122, 255, 0.7) 0%, transparent 70%);
  top: -150px;
  left: -100px;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(88, 86, 214, 0.6) 0%, transparent 70%);
  bottom: -200px;
  right: -150px;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
              filter 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.05s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(175, 82, 222, 0.6) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
              filter 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

/* Focus state - subtle awakening */
.gradient-bg.focused .orb-1 {
  opacity: 0.25;
  filter: blur(100px);
  transform: scale(1.05);
}

.gradient-bg.focused .orb-2 {
  opacity: 0.2;
  filter: blur(100px);
  transform: scale(1.05);
}

.gradient-bg.focused .orb-3 {
  opacity: 0.15;
  filter: blur(100px);
  transform: translate(-50%, -50%) scale(1.05);
}

/* Typing state - orbs glow and breathe */
.gradient-bg.typing .orb-1 {
  opacity: 0.5;
  filter: blur(80px);
  transform: scale(1.15);
}

.gradient-bg.typing .orb-2 {
  opacity: 0.45;
  filter: blur(80px);
  transform: scale(1.15);
}

.gradient-bg.typing .orb-3 {
  opacity: 0.4;
  filter: blur(80px);
  transform: translate(-50%, -50%) scale(1.2);
}

/* Sending state - orbs flash bright and expand */
.gradient-bg.sending .orb-1 {
  opacity: 0.85;
  filter: blur(50px);
  transform: scale(1.4);
}

.gradient-bg.sending .orb-2 {
  opacity: 0.75;
  filter: blur(50px);
  transform: scale(1.35);
}

.gradient-bg.sending .orb-3 {
  opacity: 0.7;
  filter: blur(50px);
  transform: translate(-50%, -50%) scale(1.5);
}

/* Receiving state - gentle pulsing glow */
.gradient-bg.receiving .orb-1 {
  opacity: 0.4;
  filter: blur(90px);
  transform: scale(1.1);
}

.gradient-bg.receiving .orb-2 {
  opacity: 0.35;
  filter: blur(90px);
  transform: scale(1.1);
}

.gradient-bg.receiving .orb-3 {
  opacity: 0.3;
  filter: blur(90px);
  transform: translate(-50%, -50%) scale(1.15);
}

/* Loading Splash Screen */
.loading-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
}

.loading-splash.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: loadingBreathe 2s ease-in-out infinite;
}

.loading-logo {
  font-size: 64px;
  animation: loadingScale 2s ease-in-out infinite;
}

@keyframes loadingScale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes loadingBreathe {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.loading-text {
  font-size: 20px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: -0.5px;
  text-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg,
    rgba(0, 122, 255, 0.3),
    rgba(0, 122, 255, 0.8),
    rgba(88, 86, 214, 0.8),
    rgba(88, 86, 214, 0.3));
  background-size: 200% 100%;
  animation: loadingProgress 2s ease-in-out infinite;
  border-radius: 2px;
}

@keyframes loadingProgress {
  0% { width: 0%; background-position: 0% 0%; }
  50% { width: 100%; background-position: 100% 0%; }
  100% { width: 0%; background-position: 100% 0%; }
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.login-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-container {
  text-align: center;
  padding: 40px;
  max-width: 400px;
  width: 90%;
  animation: fadeInUp 0.6s ease backwards;
}

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

.login-logo {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

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

.login-title {
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 32px;
}

.login-error {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: #FF3B30;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  text-align: center;
  animation: slideDown 0.3s ease;
}

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

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  position: relative;
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.login-btn .btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.login-btn .btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.login-btn.google-btn {
  background: #fff;
  color: #333;
}

.login-btn.google-btn:hover:not(:disabled) {
  background: #f5f5f5;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.login-btn.google-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.login-btn.totp-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-btn.totp-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.login-divider span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.login-footer {
  margin-top: 40px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   MODALS (Generic)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--imessage-bg);
  border-radius: 20px;
  max-width: 420px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-backdrop.visible .modal-content {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--imessage-gray);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--separator);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-body label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--imessage-input-bg);
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.modal-input:focus {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.modal-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--imessage-input-bg);
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: all 0.2s ease;
}

.modal-textarea:focus {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.modal-btn {
  width: 100%;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modal-btn.primary {
  background: var(--imessage-blue);
  color: #fff;
}

.modal-btn.primary:hover {
  background: #0066d6;
  transform: translateY(-1px);
}

.modal-btn.primary:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}

.modal-btn.secondary {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

.modal-btn.secondary:hover {
  background: var(--separator);
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--separator);
}

.modal-divider span {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================================
   TOTP MODAL
   ============================================================ */

.totp-code-input {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

.totp-digit {
  width: 48px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid var(--separator);
  background: var(--imessage-input-bg);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.totp-digit:focus {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* TOTP Signup Steps */
.step-indicator {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px !important;
  text-align: center;
  font-weight: 600;
}

.qr-code-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  padding: 20px;
  background: #fff;
  border-radius: 16px;
}

.qr-code {
  width: 200px;
  height: 200px;
  border-radius: 12px;
}

.backup-secret {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 20px 0 8px !important;
}

.secret-code {
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  padding: 12px 16px;
  background: var(--imessage-input-bg);
  border-radius: 12px;
  margin-bottom: 20px;
  word-break: break-all;
  user-select: all;
  color: var(--text-primary);
}

/* ============================================================
   ADD BOT MODAL
   ============================================================ */

.add-bot-section {
  text-align: center;
}

.share-code-input {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 20px;
}

.code-digit {
  width: 56px;
  height: 64px;
  border-radius: 12px;
  border: 2px solid var(--separator);
  background: var(--imessage-input-bg);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  outline: none;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.code-digit:focus {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.add-bot-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.create-bot-btn {
  margin-top: 8px;
}

/* ============================================================
   BOT CREATION WIZARD
   ============================================================ */

.create-bot-modal {
  max-width: 480px;
}

.wizard-step {
  animation: fadeIn 0.3s ease;
}

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

.wizard-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--imessage-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.wizard-back:hover {
  background: var(--imessage-gray);
}

.roblox-search {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.roblox-search .modal-input {
  flex: 1;
}

.search-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--imessage-blue);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.search-btn:hover {
  background: #0066d6;
}

.roblox-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--imessage-input-bg);
  border-radius: 16px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

.roblox-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}

.roblox-info {
  flex: 1;
}

.roblox-username {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.roblox-id {
  font-size: 14px;
  color: var(--text-secondary);
}

.roblox-found {
  color: #34C759;
  font-weight: 600;
  font-size: 14px;
}

.roblox-error {
  padding: 12px 16px;
  background: rgba(255, 59, 48, 0.1);
  border-radius: 12px;
  color: #FF3B30;
  font-size: 14px;
  margin-bottom: 20px;
}

.description-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 20px;
}

.wizard-complete {
  text-align: center;
}

.bot-preview {
  margin-bottom: 24px;
}

.bot-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.share-info {
  background: var(--imessage-input-bg);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 24px;
}

.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.share-row:not(:last-child) {
  border-bottom: 1px solid var(--separator);
}

.share-row label {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.share-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-value span {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.share-link {
  font-size: 14px !important;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--imessage-gray);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: var(--imessage-blue);
  color: #fff;
}

.copy-btn.copied {
  background: #34C759;
  color: #fff;
}

.start-chat-btn {
  margin-top: 8px;
}

/* ============================================================
   MY BOTS MODAL
   ============================================================ */

.my-bots-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.my-bot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.my-bot-item:hover {
  background: var(--imessage-input-bg);
}

.my-bot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.my-bot-info {
  flex: 1;
}

.my-bot-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.my-bot-code {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.my-bot-actions {
  display: flex;
  gap: 8px;
}

.my-bot-action {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.my-bot-action:hover {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

.my-bot-action.delete:hover {
  background: rgba(255, 59, 48, 0.1);
  color: #FF3B30;
}

.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.modal-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.my-bot-item.selected {
  outline: 2px solid rgba(0, 122, 255, 0.5);
  background: rgba(0, 122, 255, 0.08);
}

.bot-settings-modal {
  max-width: 640px;
}

.bot-settings-status {
  font-size: 13px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  display: inline-block;
  background: var(--imessage-input-bg);
  color: var(--text-secondary);
}

.bot-settings-status.approved {
  background: rgba(52, 199, 89, 0.12);
  color: #34C759;
}

.bot-settings-status.pending {
  background: rgba(255, 204, 0, 0.12);
  color: #FFCC00;
}

.bot-settings-status.rejected {
  background: rgba(255, 59, 48, 0.12);
  color: #FF3B30;
}

.my-bots-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* ============================================================
   USER MENU (Sidebar)
   ============================================================ */

.user-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
  background: var(--imessage-sidebar-bg);
}

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

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

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

.user-actions {
  display: flex;
  gap: 4px;
}

.user-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.user-action-btn:hover {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

/* Support bot indicator */
.chat-item.support {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.08) 0%, rgba(88, 86, 214, 0.08) 100%);
}

.chat-item.support .chat-avatar {
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}

/* App Container - holds sidebar and chat */
.app-container {
  width: 100%;
  max-width: 1100px;
  height: 80vh;
  max-height: 750px;
  display: flex;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 25px 60px -12px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 80px -30px rgba(0, 122, 255, 0.12);
  background: var(--imessage-bg);
  position: relative;
  z-index: 1;
  animation: containerAppear 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  flex-shrink: 0;
}

@keyframes containerAppear {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--imessage-sidebar-bg);
  border-right: 0.5px solid var(--separator);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 18px 20px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--separator);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.sidebar-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.new-chat-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
  padding: 0;
  line-height: 1;
}

.new-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.45);
}

.new-chat-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 4px rgba(0, 122, 255, 0.3);
}

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

.chat-list::-webkit-scrollbar {
  width: 8px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.3s ease, transform 0.3s ease;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.04);
  position: relative;
}

.chat-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.chat-item.deleting {
  opacity: 0;
  transform: translateX(-100%);
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item.active {
  background: #FFFFFF;
  box-shadow: inset 3px 0 0 var(--imessage-blue-solid);
}

.chat-item-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.chat-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  letter-spacing: -0.08px;
}

.chat-item-preview {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.08px;
}

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.chat-item-time {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.chat-item-unread {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--imessage-blue-solid);
}

.chat-item-delete {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: #FF3B30;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.15s ease;
  pointer-events: auto;
  z-index: 10;
}

.chat-item-delete:hover {
  background: #FF2D1A;
}

/* Main Chat Container */
.imessage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--imessage-bg);
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* Hide phone elements */
.dynamic-island,
.status-bar {
  display: none;
}

/* iMessage Header */
.imessage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
  min-height: 58px;
  height: 58px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--imessage-blue-solid);
  font-size: 17px;
  cursor: pointer;
  min-width: 44px;
}

.header-left svg {
  width: 24px;
  height: 24px;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--imessage-blue-solid);
  cursor: pointer;
  padding: 8px;
}

.menu-btn svg {
  width: 24px;
  height: 24px;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  font-weight: 600;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(88, 86, 214, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contact-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(88, 86, 214, 0.35);
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.06px;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 44px;
  justify-content: flex-end;
}

.header-right svg {
  width: 22px;
  height: 22px;
  color: var(--imessage-blue-solid);
  cursor: pointer;
}

/* Chat Area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--imessage-bg);
  scroll-behavior: smooth;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

.chat-area::-webkit-scrollbar {
  width: 8px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

.time-separator {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 14px 0 10px;
  font-weight: 400;
  width: 100%;
  letter-spacing: -0.08px;
}

/* System messages (theme changes, etc) */
.message-wrapper.system {
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}

.message-wrapper.system .bubble-container {
  max-width: 100%;
  align-items: center;
}

.message-wrapper.system .bubble {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 16px;
  box-shadow: none;
  text-align: center;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
  width: 100%;
  position: relative;
  padding: 0 8px;
}

.message-wrapper.sent {
  align-items: flex-end;
}

.message-wrapper.received {
  align-items: flex-start;
}

.message-wrapper.sent + .message-wrapper.received,
.message-wrapper.received + .message-wrapper.sent {
  margin-top: 8px;
}

/* Only animate new messages */
.message-wrapper.new-message {
  animation: messageAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.message-wrapper.new-message.sent {
  animation: sentMessageAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Smooth iMessage-style message appear animation with spring effect */
@keyframes messageAppear {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Sent message specific animation with slight slide-in from right */
@keyframes sentMessageAppear {
  0% {
    opacity: 0;
    transform: translateY(12px) translateX(8px) scale(0.96);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) translateX(-1px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
}

/* Swipe to reply */
.message-wrapper.swiping {
  transition: none;
}

.message-wrapper::before {
  content: '↩';
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  font-size: 16px;
  color: var(--imessage-blue-solid);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.message-wrapper.swipe-active::before {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Bubble container */
.bubble-container {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  max-width: 75%;
}

.message-wrapper.sent .bubble-container {
  align-items: flex-end;
}

.message-wrapper.received .bubble-container {
  align-items: flex-start;
}

.bubble {
  max-width: 100%;
  min-width: 40px;
  padding: 8px 13px;
  font-size: 17px;
  line-height: 1.3;
  word-wrap: break-word;
  word-break: break-word;
  position: relative;
  letter-spacing: -0.41px;
}

.bubble.sent {
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 1px 4px rgba(0, 122, 255, 0.2);
  transition: box-shadow 0.2s ease;
}

.bubble.sent:hover {
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.bubble.received {
  background: var(--imessage-gray);
  color: #000000;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease;
}

.bubble.received:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Consecutive message styling */
.bubble.sent.first { border-radius: 18px 18px 4px 18px; }
.bubble.sent.middle { border-radius: 18px 4px 4px 18px; }
.bubble.sent.last { border-radius: 18px 4px 18px 18px; }

.bubble.received.first { border-radius: 18px 18px 18px 4px; }
.bubble.received.middle { border-radius: 4px 18px 18px 4px; }
.bubble.received.last { border-radius: 4px 18px 18px 18px; }

/* Image messages */
.bubble.image {
  padding: 0;
  background: transparent;
  max-width: 280px;
  min-width: 180px;
}

.bubble.image img {
  width: 100%;
  max-width: 280px;
  max-height: 300px;
  border-radius: 18px;
  display: block;
  object-fit: cover;
}

/* Reactions */
.reaction {
  position: absolute;
  bottom: -6px;
  background: rgba(255, 255, 255, 0.95);
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 2px 5px;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  cursor: pointer;
  z-index: 10;
  animation: reactionBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.reaction.sent { right: 6px; }
.reaction.received { left: 6px; }

.reaction-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 5px 8px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.14), 0 0 0 0.5px rgba(0,0,0,0.06);
  display: flex;
  gap: 2px;
  z-index: 100;
  animation: pickerPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.reaction-picker.sent { right: 0; }
.reaction-picker.received { left: 0; }

.reaction-picker span {
  font-size: 26px;
  cursor: pointer;
  padding: 3px;
  border-radius: 6px;
  transition: transform 0.12s, background 0.12s;
}

.reaction-picker span:hover {
  transform: scale(1.15);
  background: rgba(0,0,0,0.04);
}

/* Read Receipt */
.read-receipt {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  text-align: right;
  padding-right: 8px;
  opacity: 0;
  animation: receiptFade 0.3s ease 0.2s forwards;
  letter-spacing: -0.06px;
}

@keyframes receiptFade {
  to { opacity: 1; }
}

/* Typing Indicator - FIXED ALIGNMENT */
.typing-wrapper {
  display: flex;
  align-items: flex-start;
  margin-bottom: 2px;
  padding: 0 8px;
  width: 100%;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--imessage-gray);
  border-radius: 18px 18px 18px 4px;
  animation: typingAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), typingBreathe 2.5s ease-in-out infinite 0.4s;
  box-shadow: 0 0 0 rgba(142, 142, 147, 0);
}

@keyframes typingAppear {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typingBreathe {
  0%, 100% {
    box-shadow: 0 0 0 rgba(142, 142, 147, 0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 2px 12px rgba(142, 142, 147, 0.15);
    transform: scale(1.01);
  }
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8E8E93;
  animation: typingDot 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 rgba(142, 142, 147, 0);
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.4;
    box-shadow: 0 0 0 rgba(142, 142, 147, 0);
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
    box-shadow: 0 2px 6px rgba(142, 142, 147, 0.3);
  }
}

/* Input Area */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
  background: var(--imessage-bg);
  border-top: 0.5px solid var(--separator);
  flex-shrink: 0;
  min-height: 50px;
}

.input-accessories {
  display: flex;
  align-items: center;
  gap: 4px;
}

.camera-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}

.camera-btn:hover {
  background: rgba(0,0,0,0.05);
}

.camera-btn svg {
  width: 27px;
  height: 27px;
  color: var(--text-secondary);
}

.input-field-container {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--imessage-input-bg);
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.06);
  padding: 6px 6px 6px 14px;
  gap: 6px;
  min-height: 36px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.input-field {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 17px;
  line-height: 1.29;
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 100px;
  padding: 0;
  letter-spacing: -0.41px;
}

.input-field::placeholder {
  color: #C7C7CC;
}

.send-button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.25);
}

.send-button:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(0, 122, 255, 0.35);
}

.send-button:active:not(:disabled) {
  transform: scale(0.94);
}

.send-button:disabled {
  opacity: 0.35;
  cursor: default;
  background: var(--text-tertiary);
  box-shadow: none;
}

.send-button svg {
  width: 15px;
  height: 15px;
  margin-top: -1px;
}

/* Link Previews */
.link-preview {
  background: #F2F2F7;
  border-radius: 14px;
  overflow: hidden;
  margin-top: 6px;
  max-width: 260px;
  width: 100%;
  border: 0.5px solid rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s;
}

.link-preview:hover {
  transform: scale(1.02);
}

.link-preview-image {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  display: block;
}

.link-preview-row {
  display: flex;
  padding: 8px 12px;
  margin: 0 12px 8px;
  border-radius: 8px;
  position: relative;
  animation: slideUp 0.2s ease;
}

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

.reply-preview {
  background: rgba(0, 122, 255, 0.08);
  border-left: 3px solid var(--imessage-blue-solid);
  border-radius: 10px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.reply-preview.active {
  max-height: 60px;
  opacity: 1;
  padding: 8px 12px;
}

.reply-preview-label {
  font-size: 12px;
  color: var(--imessage-blue-solid);
  font-weight: 600;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reply-preview-label::before {
  content: '↩';
  font-size: 14px;
}

.reply-preview-text {
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
  padding-right: 8px;
}

.reply-preview-close {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.1);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50%;
  transition: background 0.15s;
}

.reply-preview-close:hover {
  background: rgba(0,0,0,0.15);
}

.reply-quote {
  background: rgba(0,0,0,0.1);
  border-left: 3px solid rgba(255,255,255,0.6);
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0.9;
  max-width: 90%;
}

.bubble.received .reply-quote {
  background: rgba(0,0,0,0.08);
  border-left-color: rgba(0,0,0,0.3);
}

/* Search */
.search-bar {
  display: flex;
  background: var(--imessage-input-bg);
  border-bottom: 0.5px solid var(--separator);
  gap: 8px;
  align-items: center;
  max-height: 0;
  overflow: hidden;
  padding: 0 12px;
  opacity: 0;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.search-bar.active {
  max-height: 50px;
  padding: 8px 12px;
  opacity: 1;
}

.search-input {
  flex: 1;
  background: rgba(0,0,0,0.05);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  outline: none;
  color: var(--text-primary);
}

.search-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-counter {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 60px;
  text-align: center;
}

.search-nav-btn {
  background: none;
  border: none;
  color: var(--imessage-blue-solid);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
}

.search-nav-btn:hover {
  background: rgba(0,122,255,0.1);
}

.search-nav-btn svg {
  width: 18px;
  height: 18px;
}

.search-close {
  background: none;
  border: none;
  color: var(--imessage-blue-solid);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
}

.bubble.search-highlight {
  background: rgba(255, 214, 10, 0.3) !important;
  transition: background 0.2s ease;
}

.bubble.search-highlight-current {
  background: #FFD60A !important;
  color: #000 !important;
  box-shadow: 0 0 0 2px var(--imessage-blue-solid);
}

/* Search icon button */
.search-icon-btn {
  background: none;
  border: none;
  color: var(--imessage-blue-solid);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}

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

.search-icon-btn svg {
  width: 22px;
  height: 22px;
}

/* Image Preview */
.image-preview {
  position: absolute;
  bottom: 70px;
  left: 12px;
  max-width: 100px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: previewPop 0.2s ease;
}

@keyframes previewPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.image-preview img {
  width: 100%;
  display: block;
}

.image-preview-close {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Copy Notification */
.copy-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  z-index: 1000;
  animation: notifyPop 2s forwards;
}

@keyframes notifyPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

/* Scroll Button */
.scroll-to-bottom {
  position: absolute;
  bottom: 85px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid var(--separator);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
}

.scroll-to-bottom svg {
  width: 18px;
  height: 18px;
}

.scroll-to-bottom:hover {
  transform: translateY(0) scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  color: var(--imessage-blue-solid);
}

.scroll-to-bottom:active {
  transform: translateY(0) scale(0.95);
}

.scroll-to-bottom.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Timestamp Divider */
.timestamp-divider {
  text-align: center;
  padding: 16px 0 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--separator);
  border-top-color: var(--imessage-blue-solid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Message Effects */
.effect-slam { animation: slam 0.5s ease-out; }
.effect-loud .bubble { animation: loud 0.6s ease-in-out 3; font-size: 22px !important; }
.effect-gentle .bubble { animation: gentle 1.5s ease-out; opacity: 0.85; }

@keyframes slam {
  0% { transform: scale(3); opacity: 0; }
  50% { transform: scale(0.9); }
  75% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes loud {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.15) rotate(-2deg); }
  50% { transform: scale(1.2); }
  75% { transform: scale(1.15) rotate(2deg); }
}

@keyframes gentle {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.effect-invisible .bubble {
  background: var(--imessage-gray) !important;
  color: transparent !important;
  text-shadow: 0 0 8px rgba(0,0,0,0.5);
  cursor: pointer;
}

.effect-invisible .bubble.revealed {
  color: var(--text-primary) !important;
  text-shadow: none;
  transition: all 0.3s;
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 10px;
  padding: 40px;
}

.empty-state-icon {
  font-size: 56px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 15px;
  text-align: center;
  font-weight: 400;
  letter-spacing: -0.24px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .app-container {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 85%;
    max-width: 320px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: flex;
  }

  .imessage-container {
    width: 100%;
  }

  /* Better header for mobile */
  .imessage-header {
    padding: max(env(safe-area-inset-top), 11px) 12px 11px 12px;
  }

  .chat-area {
    padding: 14px 10px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .message-wrapper {
    padding: 0 6px;
  }

  .typing-wrapper {
    padding: 0 6px;
  }

  /* Match desktop bubble sizing */
  .bubble-container {
    max-width: 75%;
  }

  .bubble {
    font-size: 17px;
    padding: 8px 13px;
    line-height: 1.3;
  }

  .input-field {
    font-size: 17px;
  }

  /* Match desktop input area */
  .input-area {
    gap: 8px;
    padding: 10px 12px max(14px, env(safe-area-inset-bottom)) 12px;
  }

  /* Touch targets - match desktop sizing */
  .send-button {
    min-width: 32px;
    min-height: 32px;
    width: 32px;
    height: 32px;
  }

  .menu-btn,
  .search-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Match desktop reaction picker */
  .reaction-picker {
    padding: 5px 8px;
  }

  .reaction-picker span {
    font-size: 26px;
    padding: 3px;
  }

  /* Match desktop link previews */
  .link-preview {
    max-width: 260px;
  }

  /* Match desktop chat item sizing */
  .chat-item {
    padding: 11px 16px;
    gap: 12px;
  }

  .chat-item-avatar {
    width: 50px;
    height: 50px;
  }

  .chat-item-name {
    font-size: 15px;
  }

  /* Scroll to bottom on mobile */
  .scroll-to-bottom {
    width: 40px;
    height: 40px;
    bottom: 100px;
  }

  /* Match desktop input field container */
  .input-field-container {
    min-height: 36px;
  }
}

/* Hide elements utility */
.hidden {
  display: none !important;
}

/* Prevent zoom on input focus (iOS) */
@supports (-webkit-touch-callout: none) {
  .input-field {
    font-size: 16px;
  }
}

/* ============================================================
   QoL Animation Improvements
   ============================================================ */

/* 1. Smooth scrollbar appearance */
.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  transition: background 0.2s ease;
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* 2. Message wrapper smooth entry */
.message-wrapper {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.message-wrapper.removing {
  opacity: 0;
  transform: scale(0.9);
}

/* 4. Chat area smooth content transitions */
.chat-area {
  scroll-behavior: smooth;
}

/* 5. Search bar smooth slide */
.search-bar {
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

/* 6. Reply preview smooth appearance */
.reply-preview {
  transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.2s ease;
  max-height: 0;
  opacity: 0;
  transform: translateY(10px);
  padding: 0 40px 0 14px;
  margin: 0 12px;
  overflow: hidden;
}

.reply-preview.active {
  max-height: 80px;
  opacity: 1;
  transform: translateY(0);
  padding: 10px 40px 10px 14px;
  margin: 0 12px 8px;
}

/* 7. Sidebar backdrop smooth */
.sidebar-backdrop {
  transition: opacity 0.35s ease;
}

/* 8. Header buttons subtle hover */
.search-icon-btn,
.menu-btn {
  transition: background 0.2s ease, transform 0.15s ease;
}

.search-icon-btn:active,
.menu-btn:active {
  transform: scale(0.9);
}

/* 9. Chat item delete button smooth appear */
.chat-item-delete {
  transition: opacity 0.2s ease, transform 0.15s ease, background 0.15s ease;
  transform: translateX(10px);
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
  transform: translateX(0);
}

/* 10. Input field container subtle glow on focus */
.input-field-container:focus-within {
  border-color: rgba(0, 122, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1), 0 2px 8px rgba(0, 122, 255, 0.1);
}

/* 11. Empty state fade in */
.empty-state {
  animation: fadeIn 0.4s ease;
}

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

/* 12. Time separator subtle appearance */
.time-separator {
  animation: fadeIn 0.3s ease;
}

/* 13. Reaction picker smoother animation */
.reaction-picker {
  animation: pickerPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 14. Copy notification smoother */
.copy-notification {
  animation: notifySlide 2s ease forwards;
}

@keyframes notifySlide {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(20px); }
  10% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  90% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-10px); }
}

/* ============================================================
   Animation Chokepoint Fixes
   ============================================================ */

/* 1. Chat area content fade transitions */
.chat-area {
  transition: opacity 0.15s ease;
}

.chat-area.switching {
  opacity: 0;
}

/* 2. Chat list item smooth entry after delete */
.chat-item.appearing {
  animation: chatItemSlideIn 0.3s ease-out forwards;
}

@keyframes chatItemSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 3. Typing indicator with reserved space */
.typing-wrapper {
  min-height: 44px;
  transition: opacity 0.2s ease, min-height 0.2s ease;
}

.typing-wrapper.hiding {
  opacity: 0;
  min-height: 0;
}

/* 4. Time separator smooth entry */
.time-separator {
  animation: fadeInDown 0.3s ease-out;
}

@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 5. Chat item active state transition */
.chat-item {
  transition: background 0.2s ease, opacity 0.3s ease, transform 0.3s ease, box-shadow 0.2s ease;
}

.chat-item.active {
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

/* 6. Empty state smooth transitions */
.chat-area .empty-state {
  animation: fadeInUp 0.4s ease-out;
}

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

/* ============================================================
   Contact Card Modal
   ============================================================ */

.contact-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.contact-modal-backdrop.ready {
  display: flex;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.contact-modal-backdrop.ready.active {
  opacity: 1;
  visibility: visible;
}

.contact-modal {
  background: white;
  border-radius: 20px;
  width: 90%;
  max-width: 340px;
  padding: 30px 24px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  position: relative;
}

.contact-modal-header {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
}

.contact-modal-close-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color 0.2s ease, transform 0.2s ease;
  border-radius: 50%;
}

.contact-modal-close-icon:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.05);
  transform: rotate(90deg);
}

.contact-modal-close-icon svg {
  width: 20px;
  height: 20px;
}

.contact-modal-backdrop.active .contact-modal {
  transform: scale(1) translateY(0);
}

.contact-modal-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: white;
  font-weight: 600;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(88, 86, 214, 0.4);
}

.contact-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-modal-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.contact-modal-status {
  font-size: 14px;
  color: #34C759;
  margin-bottom: 20px;
}

.contact-modal-info {
  text-align: left;
  border-top: 1px solid var(--separator);
  padding-top: 16px;
}

.contact-info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--separator);
}

.contact-info-row:last-child {
  border-bottom: none;
}

.contact-info-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.contact-info-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.contact-modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.contact-modal-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.contact-modal-btn:active {
  transform: scale(0.96);
}

.contact-modal-btn.primary {
  background: var(--imessage-blue);
  color: white;
}

.contact-modal-btn.secondary {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

/* Button with icon support */
.contact-modal-btn svg {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.contact-modal-btn:hover svg {
  opacity: 1;
}

/* ============================================================
   Character Counter
   ============================================================ */

.char-counter {
  position: absolute;
  right: 50px;
  bottom: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  transition: color 0.2s ease;
  pointer-events: none;
}

.char-counter.warning {
  color: #FF9500;
}

.char-counter.danger {
  color: #FF3B30;
}

.input-field-container {
  position: relative;
}

/* ============================================================
   THEMES
   ============================================================ */

/* Theme transition */
body, .app-container, .sidebar, .imessage-container, .imessage-header,
.chat-area, .input-area, .bubble, .chat-item {
  transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* ==================== DARK THEME ==================== */
body.theme-dark {
  --imessage-bg: #1c1c1e;
  --imessage-header-bg: rgba(28, 28, 30, 0.9);
  --imessage-input-bg: #2c2c2e;
  --imessage-sidebar-bg: #1c1c1e;
  --imessage-gray: #3a3a3c;
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;
  --separator: rgba(255, 255, 255, 0.1);
}

body.theme-dark .gradient-bg {
  background: linear-gradient(135deg, #000000 0%, #1a1a2e 50%, #0d0d15 100%);
}

body.theme-dark .app-container {
  background: var(--imessage-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body.theme-dark .sidebar {
  background: var(--imessage-sidebar-bg);
  border-right-color: var(--separator);
}

body.theme-dark .sidebar-header {
  background: rgba(28, 28, 30, 0.8);
}

body.theme-dark .sidebar-title {
  color: var(--text-primary);
}

body.theme-dark .chat-item.active {
  background: #2c2c2e;
}

body.theme-dark .imessage-container {
  background: var(--imessage-bg);
}

body.theme-dark .imessage-header {
  background: linear-gradient(180deg, rgba(28, 28, 30, 0.95) 0%, rgba(28, 28, 30, 0.85) 100%);
  border-bottom-color: var(--separator);
}

body.theme-dark .chat-area {
  background: var(--imessage-bg);
}

body.theme-dark .bubble.received {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

body.theme-dark .input-area {
  background: var(--imessage-bg);
  border-top-color: var(--separator);
}

body.theme-dark .input-field-container {
  background: var(--imessage-input-bg);
  border-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark .input-field {
  color: var(--text-primary);
}

body.theme-dark .input-field::placeholder {
  color: var(--text-tertiary);
}

body.theme-dark .contact-modal {
  background: #2c2c2e;
}

body.theme-dark .contact-modal-name,
body.theme-dark .contact-info-value {
  color: var(--text-primary);
}

body.theme-dark .contact-modal-btn.secondary {
  background: #3a3a3c;
  color: var(--text-primary);
}

/* Dark theme modals */
body.theme-dark .modal-content {
  background: #1c1c1e;
}

body.theme-dark .modal-header {
  border-color: #3a3a3c;
}

body.theme-dark .modal-close {
  background: #3a3a3c;
}

body.theme-dark .modal-input,
body.theme-dark .modal-textarea {
  background: #2c2c2e;
  border-color: #3a3a3c;
}

body.theme-dark .modal-btn.secondary {
  background: #3a3a3c;
}

body.theme-dark .code-digit,
body.theme-dark .totp-digit {
  background: #2c2c2e;
  border-color: #3a3a3c;
}

body.theme-dark .roblox-preview,
body.theme-dark .share-info {
  background: #2c2c2e;
}

body.theme-dark .my-bot-item:hover {
  background: #2c2c2e;
}

/* ==================== LIQUID GLASS THEME (Apple-style) ==================== */
body.theme-glass {
  --imessage-bg: rgba(255, 255, 255, 0.05);
  --imessage-header-bg: rgba(255, 255, 255, 0.08);
  --imessage-input-bg: rgba(255, 255, 255, 0.08);
  --imessage-sidebar-bg: rgba(255, 255, 255, 0.04);
  --imessage-gray: rgba(255, 255, 255, 0.12);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-tertiary: rgba(255, 255, 255, 0.45);
  --separator: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.15);
  --glass-shadow: rgba(0, 0, 0, 0.3);
}

body.theme-glass .gradient-bg {
  background: linear-gradient(135deg, #0c1929 0%, #1a2940 25%, #0f2847 50%, #1c3a5e 75%, #0d1f35 100%);
  animation: liquidShift 20s ease-in-out infinite;
}

@keyframes liquidShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

body.theme-glass .gradient-bg {
  background-size: 200% 200%;
}

body.theme-glass .gradient-orb {
  opacity: 0.4;
  animation: orbFloat 8s ease-in-out infinite;
}

body.theme-glass .orb-1 {
  background: radial-gradient(circle, rgba(100, 180, 255, 0.4) 0%, rgba(60, 120, 200, 0.2) 40%, transparent 70%);
  animation-delay: 0s;
}

body.theme-glass .orb-2 {
  background: radial-gradient(circle, rgba(140, 100, 255, 0.35) 0%, rgba(100, 60, 200, 0.15) 40%, transparent 70%);
  animation-delay: -3s;
}

body.theme-glass .orb-3 {
  background: radial-gradient(circle, rgba(80, 200, 220, 0.3) 0%, rgba(40, 150, 180, 0.1) 40%, transparent 70%);
  animation-delay: -6s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(20px, -30px) scale(1.05); }
  50% { transform: translate(-10px, 20px) scale(0.98); }
  75% { transform: translate(15px, 10px) scale(1.02); }
}

body.theme-glass .orb-3 {
  animation-name: orbFloat3;
}

@keyframes orbFloat3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  25% { transform: translate(calc(-50% + 30px), calc(-50% - 20px)) scale(1.08); }
  50% { transform: translate(calc(-50% - 20px), calc(-50% + 30px)) scale(0.95); }
  75% { transform: translate(calc(-50% + 10px), calc(-50% + 10px)) scale(1.03); }
}

/* Main app container - liquid glass effect */
body.theme-glass .app-container {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(80px) saturate(130%);
  -webkit-backdrop-filter: blur(80px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(255, 255, 255, 0.02);
  position: relative;
  overflow: hidden;
}

/* Subtle inner glow effect */
body.theme-glass .app-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 35%,
    transparent 65%,
    rgba(255, 255, 255, 0.01) 100%
  );
  pointer-events: none;
  border-radius: inherit;
}

/* Sidebar glass */
body.theme-glass .sidebar {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(50px) saturate(120%);
  -webkit-backdrop-filter: blur(50px) saturate(120%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

body.theme-glass .sidebar-header {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

body.theme-glass .sidebar-title {
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.theme-glass .chat-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-glass .chat-item.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
  border-left: 3px solid rgba(100, 180, 255, 0.8);
  box-shadow: inset 0 0 20px rgba(100, 180, 255, 0.1);
}

body.theme-glass .chat-item:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-glass .chat-item-name {
  color: var(--text-primary);
}

body.theme-glass .chat-item-preview {
  color: var(--text-secondary);
}

body.theme-glass .chat-item-time {
  color: var(--text-tertiary);
}

/* Main chat container */
body.theme-glass .imessage-container {
  background: transparent;
}

/* Header glass */
body.theme-glass .imessage-header {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(50px) saturate(120%);
  -webkit-backdrop-filter: blur(50px) saturate(120%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

body.theme-glass .contact-name {
  color: var(--text-primary);
}

body.theme-glass .header-left svg,
body.theme-glass .header-right svg {
  color: #ffffff;
  opacity: 0.8;
}

body.theme-glass .chat-area {
  background: transparent;
}

/* Glass bubbles with liquid effect */
body.theme-glass .bubble.sent {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(30px) saturate(130%);
  -webkit-backdrop-filter: blur(30px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
}

body.theme-glass .bubble.sent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  border-radius: inherit;
  pointer-events: none;
}

body.theme-glass .bubble.received {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(30px) saturate(130%);
  -webkit-backdrop-filter: blur(30px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  position: relative;
}

body.theme-glass .bubble.received::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
  border-radius: inherit;
  pointer-events: none;
}

/* Input area glass */
body.theme-glass .input-area {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(50px) saturate(120%);
  -webkit-backdrop-filter: blur(50px) saturate(120%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

body.theme-glass .input-field-container {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.theme-glass .input-field-container:focus-within {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 12px rgba(0, 0, 0, 0.12);
}

body.theme-glass .input-field {
  color: var(--text-primary);
}

body.theme-glass .input-field::placeholder {
  color: var(--text-tertiary);
}

body.theme-glass .send-button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.theme-glass .send-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Typing indicator glass */
body.theme-glass .typing-indicator {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(30px) saturate(130%);
  -webkit-backdrop-filter: blur(30px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.theme-glass .typing-indicator .dot {
  background: rgba(255, 255, 255, 0.6);
}

/* Contact modal glass */
body.theme-glass .contact-modal {
  background: rgba(20, 25, 40, 0.85);
  backdrop-filter: blur(80px) saturate(130%);
  -webkit-backdrop-filter: blur(80px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.theme-glass .contact-modal-name,
body.theme-glass .contact-info-value {
  color: var(--text-primary);
}

body.theme-glass .contact-info-label {
  color: var(--text-secondary);
}

body.theme-glass .contact-modal-btn.primary {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
}

body.theme-glass .contact-modal-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* New chat button glass */
body.theme-glass .new-chat-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Reactions glass */
body.theme-glass .reaction {
  background: rgba(20, 25, 40, 0.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body.theme-glass .reaction-picker {
  background: rgba(20, 25, 40, 0.9);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Search bar glass */
body.theme-glass .search-bar {
  background: rgba(255, 255, 255, 0.03);
}

body.theme-glass .search-input {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.theme-glass .search-close,
body.theme-glass .search-nav-btn {
  color: rgba(255, 255, 255, 0.7);
}

/* Reply preview glass */
body.theme-glass .reply-preview {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: rgba(255, 255, 255, 0.3);
}

body.theme-glass .reply-preview-label {
  color: rgba(255, 255, 255, 0.8);
}

/* Scrollbar glass */
body.theme-glass .chat-area::-webkit-scrollbar-thumb,
body.theme-glass .chat-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

body.theme-glass .chat-area::-webkit-scrollbar-thumb:hover,
body.theme-glass .chat-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Contact avatar glow */
body.theme-glass .contact-avatar {
  box-shadow: 0 4px 20px rgba(100, 130, 255, 0.4);
}

body.theme-glass .contact-modal-avatar {
  box-shadow: 0 8px 32px rgba(100, 130, 255, 0.5);
}

/* ==================== GRADIENT THEME ==================== */
body.theme-gradient {
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --separator: rgba(255, 255, 255, 0.15);
}

body.theme-gradient .gradient-bg {
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
}

body.theme-gradient .gradient-orb {
  opacity: 0.6 !important;
  filter: blur(100px);
}

body.theme-gradient .app-container {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

body.theme-gradient .sidebar {
  background: rgba(0, 0, 0, 0.4);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-gradient .sidebar-header {
  background: rgba(0, 0, 0, 0.3);
}

body.theme-gradient .sidebar-title {
  color: var(--text-primary);
}

body.theme-gradient .chat-item.active {
  background: rgba(255, 255, 255, 0.1);
}

body.theme-gradient .imessage-container {
  background: transparent;
}

body.theme-gradient .imessage-header {
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-gradient .contact-name {
  color: var(--text-primary);
}

body.theme-gradient .chat-area {
  background: transparent;
}

body.theme-gradient .bubble.received {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

body.theme-gradient .input-area {
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-gradient .input-field-container {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

body.theme-gradient .input-field {
  color: var(--text-primary);
}

body.theme-gradient .typing-indicator {
  background: rgba(255, 255, 255, 0.15);
}

body.theme-gradient .typing-indicator .dot {
  background: rgba(255, 255, 255, 0.6);
}

body.theme-gradient .contact-modal {
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.theme-gradient .contact-modal-name,
body.theme-gradient .contact-info-value {
  color: var(--text-primary);
}

/* ==================== MIDNIGHT THEME ==================== */
body.theme-midnight {
  --imessage-bg: #0d1117;
  --imessage-header-bg: rgba(13, 17, 23, 0.9);
  --imessage-input-bg: #161b22;
  --imessage-sidebar-bg: #0d1117;
  --imessage-gray: #21262d;
  --imessage-blue: #58a6ff;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-tertiary: #484f58;
  --separator: rgba(48, 54, 61, 0.8);
}

body.theme-midnight .gradient-bg {
  background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
}

body.theme-midnight .gradient-orb {
  opacity: 0.15;
}

body.theme-midnight .orb-1 {
  background: radial-gradient(circle, rgba(88, 166, 255, 0.5) 0%, transparent 70%);
}

body.theme-midnight .orb-2 {
  background: radial-gradient(circle, rgba(139, 148, 158, 0.3) 0%, transparent 70%);
}

body.theme-midnight .app-container {
  background: var(--imessage-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(48, 54, 61, 0.5);
}

body.theme-midnight .sidebar {
  background: var(--imessage-sidebar-bg);
  border-right-color: var(--separator);
}

body.theme-midnight .sidebar-header {
  background: rgba(13, 17, 23, 0.8);
}

body.theme-midnight .sidebar-title {
  color: var(--text-primary);
}

body.theme-midnight .chat-item.active {
  background: #161b22;
  box-shadow: inset 3px 0 0 var(--imessage-blue);
}

body.theme-midnight .imessage-container {
  background: var(--imessage-bg);
}

body.theme-midnight .imessage-header {
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.95) 0%, rgba(13, 17, 23, 0.85) 100%);
  border-bottom-color: var(--separator);
}

body.theme-midnight .contact-name {
  color: var(--text-primary);
}

body.theme-midnight .chat-area {
  background: var(--imessage-bg);
}

body.theme-midnight .bubble.sent {
  background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
}

body.theme-midnight .bubble.received {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

body.theme-midnight .input-area {
  background: var(--imessage-bg);
  border-top-color: var(--separator);
}

body.theme-midnight .input-field-container {
  background: var(--imessage-input-bg);
  border-color: var(--separator);
}

body.theme-midnight .input-field {
  color: var(--text-primary);
}

body.theme-midnight .typing-indicator {
  background: var(--imessage-gray);
}

body.theme-midnight .typing-indicator .dot {
  background: var(--text-secondary);
}

body.theme-midnight .contact-modal {
  background: #161b22;
}

body.theme-midnight .contact-modal-name,
body.theme-midnight .contact-info-value {
  color: var(--text-primary);
}

body.theme-midnight .contact-modal-btn.secondary {
  background: #21262d;
  color: var(--text-primary);
}

/* ==================== SUNSET THEME ==================== */
body.theme-sunset {
  --imessage-bg: #1a1216;
  --imessage-header-bg: rgba(26, 18, 22, 0.9);
  --imessage-input-bg: #2a1f24;
  --imessage-sidebar-bg: #1a1216;
  --imessage-gray: #3a2a30;
  --imessage-blue: #ff6b6b;
  --text-primary: #ffeedd;
  --text-secondary: #c9a89a;
  --text-tertiary: #7a5a50;
  --separator: rgba(255, 107, 107, 0.15);
}

body.theme-sunset .gradient-bg {
  background: linear-gradient(135deg, #1a1216 0%, #2d1f28 50%, #1a1216 100%);
}

body.theme-sunset .gradient-orb {
  opacity: 0.25;
}

body.theme-sunset .orb-1 {
  background: radial-gradient(circle, rgba(255, 107, 107, 0.6) 0%, transparent 70%);
}

body.theme-sunset .orb-2 {
  background: radial-gradient(circle, rgba(255, 159, 67, 0.5) 0%, transparent 70%);
}

body.theme-sunset .orb-3 {
  background: radial-gradient(circle, rgba(238, 90, 151, 0.5) 0%, transparent 70%);
}

body.theme-sunset .app-container {
  background: var(--imessage-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 107, 107, 0.1);
}

body.theme-sunset .sidebar {
  background: var(--imessage-sidebar-bg);
  border-right-color: var(--separator);
}

body.theme-sunset .sidebar-header {
  background: rgba(26, 18, 22, 0.8);
}

body.theme-sunset .sidebar-title {
  color: var(--text-primary);
}

body.theme-sunset .new-chat-btn {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a97 100%);
}

body.theme-sunset .chat-item.active {
  background: #2a1f24;
  box-shadow: inset 3px 0 0 #ff6b6b;
}

body.theme-sunset .imessage-container {
  background: var(--imessage-bg);
}

body.theme-sunset .imessage-header {
  background: linear-gradient(180deg, rgba(26, 18, 22, 0.95) 0%, rgba(26, 18, 22, 0.85) 100%);
  border-bottom-color: var(--separator);
}

body.theme-sunset .contact-name {
  color: var(--text-primary);
}

body.theme-sunset .header-left svg,
body.theme-sunset .header-right svg {
  color: #ff6b6b;
}

body.theme-sunset .chat-area {
  background: var(--imessage-bg);
}

body.theme-sunset .bubble.sent {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a97 100%);
}

body.theme-sunset .bubble.received {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

body.theme-sunset .input-area {
  background: var(--imessage-bg);
  border-top-color: var(--separator);
}

body.theme-sunset .input-field-container {
  background: var(--imessage-input-bg);
  border-color: var(--separator);
}

body.theme-sunset .input-field {
  color: var(--text-primary);
}

body.theme-sunset .send-button {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a97 100%);
}

body.theme-sunset .typing-indicator {
  background: var(--imessage-gray);
}

body.theme-sunset .typing-indicator .dot {
  background: #c9a89a;
}

body.theme-sunset .contact-modal {
  background: #2a1f24;
}

body.theme-sunset .contact-modal-name,
body.theme-sunset .contact-info-value {
  color: var(--text-primary);
}

body.theme-sunset .contact-modal-btn.primary {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a97 100%);
}

body.theme-sunset .contact-modal-btn.secondary {
  background: #3a2a30;
  color: var(--text-primary);
}

/* ==================== THEME PICKER IN MODAL ==================== */
.theme-picker {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.theme-btn:hover {
  transform: scale(1.1);
}

.theme-btn.active {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

.theme-btn[data-theme="light"] {
  background: linear-gradient(135deg, #ffffff 0%, #f6f6f6 100%);
  border-color: #e0e0e0;
}

.theme-btn[data-theme="dark"] {
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
}

.theme-btn[data-theme="glass"] {
  background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
}

.theme-btn[data-theme="gradient"] {
  background: linear-gradient(135deg, #007AFF 0%, #AF52DE 100%);
}

.theme-btn[data-theme="midnight"] {
  background: linear-gradient(135deg, #0d1117 0%, #238636 100%);
}

.theme-btn[data-theme="sunset"] {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a97 100%);
}

/* ==================== MOBILE RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
  body {
    padding: 0;
    width: 100vw;
    overflow-x: hidden;
    height: 100vh;
    min-height: 100vh;
  }

  html, body {
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .app-container {
    height: 100dvh;
    height: -webkit-fill-available;
    max-height: 100dvh;
    max-height: -webkit-fill-available;
    border-radius: 0;
    width: 100vw;
    margin: 0;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100dvh;
    height: -webkit-fill-available;
    z-index: 1000;
    transition: left 0.3s ease;
    border-radius: 0 12px 12px 0;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: flex !important;
  }

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

  .imessage-container {
    flex: 1;
    width: 100%;
    min-height: 0;
  }

  .bubble-container {
    max-width: 85%;
  }

  .bubble {
    padding: 10px 14px;
    font-size: 15px;
  }

  .input-field {
    font-size: 16px;
  }

  .contact-modal {
    width: 90%;
    max-width: 400px;
  }

  .loading-content {
    gap: 16px;
  }

  .loading-logo {
    font-size: 48px;
  }

  .loading-text {
    font-size: 18px;
  }

  .loading-bar {
    width: 160px;
  }

  /* Theme buttons smaller on mobile */
  .theme-btn {
    width: 32px;
    height: 32px;
  }

  /* Chat area padding */
  .chat-area {
    padding: 8px 12px;
    gap: 0px;
  }

  .message-wrapper {
    padding: 0 4px;
  }

  /* Reduce bubble container max-width for more readability */
  .message-wrapper.sent .bubble-container {
    margin-right: 0;
  }

  .message-wrapper.received .bubble-container {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
    height: var(--app-height, 100vh);
    height: 100dvh;
    min-height: var(--app-height, 100vh);
    min-height: 100dvh;
  }

  .app-container {
    border-radius: 0;
    height: var(--app-height, 100vh);
    height: 100dvh;
    max-height: var(--app-height, 100vh);
    max-height: 100dvh;
    width: 100vw;
    display: flex;
  }

  .imessage-container {
    min-height: 0;
    height: 100%;
    max-height: var(--app-height, 100vh);
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    width: 260px;
  }

  .bubble-container {
    max-width: 90%;
  }

  .bubble {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
  }

  .time-separator {
    font-size: 11px;
    padding: 10px 0 6px;
  }

  .read-receipt {
    font-size: 10px;
  }

  .input-area {
    padding: 8px 8px 10px;
    gap: 6px;
  }

  .input-field-container {
    gap: 4px;
  }

  .send-button {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .send-button svg {
    width: 16px;
    height: 16px;
  }

  .contact-modal {
    width: 95%;
    padding: 16px;
  }

  .contact-modal-avatar img {
    width: 80px;
    height: 80px;
  }

  .contact-info-row {
    padding: 8px 0;
  }

  .contact-modal-btn {
    font-size: 14px;
    padding: 8px 16px;
  }

  .header-center {
    flex: 1;
  }

  .contact-name {
    font-size: 15px;
  }

  .chat-item {
    padding: 8px 12px;
  }

  .chat-item-name {
    font-size: 14px;
  }

  .chat-item-preview {
    font-size: 12px;
  }

  .search-bar {
    padding: 8px 12px;
    gap: 6px;
  }

  .search-input {
    font-size: 14px;
    padding: 6px 8px;
  }

  .reply-preview {
    padding: 8px 12px;
  }

  .theme-btn {
    width: 28px;
    height: 28px;
  }

  .loading-logo {
    font-size: 40px;
  }

  .loading-text {
    font-size: 16px;
  }

  .loading-bar {
    width: 140px;
    height: 2px;
  }
}

@media (max-width: 360px) {
  .bubble {
    padding: 6px 10px;
    font-size: 13px;
  }

  .bubble-container {
    max-width: 95%;
  }

  .send-button svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
  }

  .contact-modal-name {
    font-size: 18px;
  }

  .loading-text {
    font-size: 14px;
  }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .app-container {
    height: 95vh;
  }

  .chat-area {
    padding: 6px 12px;
  }

  .bubble {
    padding: 6px 12px;
    font-size: 14px;
  }

  .input-area {
    padding: 6px 8px 8px;
  }

  .imessage-header {
    padding: 6px 16px;
  }
}

/* Glass theme mobile improvements */
body.theme-glass .bubble-container {
  max-width: 85%;
}

@media (max-width: 768px) {
  /* Mobile glass theme adjustments */
  body.theme-glass .app-container {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
  }

  body.theme-glass .sidebar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(40px) saturate(110%);
    -webkit-backdrop-filter: blur(40px) saturate(110%);
  }

  body.theme-glass .bubble.sent {
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
  }

  body.theme-glass .bubble.received {
    background: rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
  }

  body.theme-glass .input-field-container {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }

  body.theme-glass .gradient-orb {
    opacity: 0.25 !important;
    filter: blur(60px) !important;
  }

  /* Fallback for mobile browsers with poor backdrop-filter support */
  @supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
    body.theme-glass .app-container,
    body.theme-glass .sidebar,
    body.theme-glass .bubble.sent,
    body.theme-glass .bubble.received,
    body.theme-glass .input-field-container {
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      background: rgba(20, 20, 24, 0.92) !important;
    }
  }
}

@media (max-width: 480px) {
  body.theme-glass .bubble-container {
    max-width: 90%;
  }

  body.theme-glass .app-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px) saturate(110%);
    -webkit-backdrop-filter: blur(30px) saturate(110%);
  }

  body.theme-glass .gradient-orb {
    opacity: 0.2 !important;
    filter: blur(50px) !important;
  }
}

/* All themes need proper padding on mobile to avoid overflow */
@media (max-width: 768px) {
  .imessage-container {
    padding: 0;
  }

  .bubble {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .input-field-container {
    flex: 1;
    min-width: 0;
  }

  .send-button {
    flex-shrink: 0;
  }

  /* Ensure header icons are visible and touch-friendly */
  .menu-btn,
  .search-icon-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }

  /* Contact modal adjustments */
  .contact-modal {
    margin: 0 auto;
    max-height: 80vh;
    overflow-y: auto;
  }

  .contact-modal-avatar {
    width: 80px;
    height: 80px;
  }

  .contact-modal-name {
    font-size: 20px;
  }

  .contact-modal-info {
    max-height: 200px;
    overflow-y: auto;
  }
}

/* Prevent overflow and ensure 100% width usage */
@media (max-width: 768px) {
  body {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app-container {
    width: 100vw;
    margin: 0;
    box-shadow: none;
  }

  .sidebar {
    max-height: 100%;
    overflow-y: auto;
  }

  .chat-area {
    min-height: 0;
    flex: 1;
  }

  .imessage-header {
    flex-shrink: 0;
  }

  .input-area {
    flex-shrink: 0;
  }

  .reply-preview {
    flex-shrink: 0;
  }

  .search-bar {
    flex-shrink: 0;
  }
}


/* ============================================================
   SAFARI GLASS THEME FIX
   ============================================================ */

/* Safari-specific backdrop-filter fallbacks */
@supports not (backdrop-filter: blur(1px)) {
  body.theme-glass .app-container {
    background: rgba(15, 25, 45, 0.95);
  }
  
  body.theme-glass .sidebar {
    background: rgba(15, 25, 45, 0.98);
  }
  
  body.theme-glass .sidebar-header {
    background: rgba(20, 30, 50, 0.95);
  }
  
  body.theme-glass .imessage-header {
    background: rgba(20, 30, 50, 0.95);
  }
  
  body.theme-glass .input-area {
    background: rgba(20, 30, 50, 0.95);
  }
  
  body.theme-glass .bubble.sent,
  body.theme-glass .bubble.received {
    background: rgba(255, 255, 255, 0.15);
  }
}

/* Safari explicit fix - uses webkit prefix check */
@media not all and (min-resolution:.001dpcm) { 
  @supports (-webkit-appearance:none) {
    body.theme-glass .sidebar {
      background: rgba(12, 25, 41, 0.97) !important;
      -webkit-backdrop-filter: saturate(180%) blur(40px);
    }
    
    body.theme-glass .sidebar-header {
      background: rgba(15, 30, 50, 0.95) !important;
    }
    
    body.theme-glass .app-container {
      background: rgba(12, 25, 41, 0.9) !important;
    }
  }
}

/* ============================================================
   SYSTEM MESSAGE STYLING (No Bubble)
   ============================================================ */

.message-wrapper.system {
  align-items: center !important;
  justify-content: center !important;
  margin: 12px 0 !important;
  padding: 0 !important;
}

.message-wrapper.system .bubble-container {
  max-width: 100% !important;
  align-items: center !important;
}

.message-wrapper.system .bubble {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  padding: 4px 0 !important;
  text-align: center !important;
  opacity: 0.7;
}

.message-wrapper.system .bubble::before {
  display: none !important;
}

/* Dark themes system message */
body.theme-dark .message-wrapper.system .bubble,
body.theme-glass .message-wrapper.system .bubble,
body.theme-gradient .message-wrapper.system .bubble,
body.theme-midnight .message-wrapper.system .bubble,
body.theme-sunset .message-wrapper.system .bubble {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* ============================================================
   THEME MAKER MODAL
   ============================================================ */

.theme-maker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.theme-maker-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.theme-maker-modal {
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 24px;
  width: 95%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.theme-maker-backdrop.active .theme-maker-modal {
  transform: scale(1) translateY(0);
}

.theme-maker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.theme-maker-header h2 {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.theme-maker-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-maker-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: rotate(90deg);
}

.theme-maker-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.theme-maker-content::-webkit-scrollbar {
  width: 6px;
}

.theme-maker-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.theme-section {
  margin-bottom: 24px;
}

.theme-section-label {
  display: block;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Style Selection Grid */
.theme-style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

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

.style-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.15);
  color: #fff;
}

.style-preview {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.solid-preview {
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-preview {
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.gradient-preview {
  background: linear-gradient(135deg, #007AFF 0%, #AF52DE 100%);
}

.neon-preview {
  background: #0a0a0f;
  border: 2px solid #00ff88;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.5), inset 0 0 10px rgba(0, 255, 136, 0.2);
}

/* Color Scheme Grid */
.color-scheme-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--btn-color);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-btn:hover {
  transform: scale(1.15);
}

.color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.color-btn.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.custom-color-row input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.custom-color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-row input[type="color"]::-webkit-color-swatch {
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Background Mode Grid */
.bg-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.bg-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

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

.bg-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.15);
  color: #fff;
}

.bg-preview {
  width: 40px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.light-bg {
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
}

.dark-bg {
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
}

.amoled-bg {
  background: #000000;
}

/* Sliders */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.theme-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #007AFF;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.4);
  transition: transform 0.15s ease;
}

.theme-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.slider-value {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  min-width: 40px;
  text-align: right;
}

/* Bubble Style Grid */
.bubble-style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.bubble-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.bubble-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.15);
}

.bubble-preview {
  width: 50px;
  height: 24px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
}

.rounded-bubble {
  border-radius: 12px 12px 4px 12px;
}

.pill-bubble {
  border-radius: 12px;
}

.square-bubble {
  border-radius: 4px;
}

.cloud-bubble {
  border-radius: 18px 18px 4px 18px;
  position: relative;
}

/* Gradient Direction Grid */
.gradient-dir-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.dir-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
}

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

.dir-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.15);
  color: #fff;
}

/* Toggle Grid */
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toggle-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #007AFF;
  cursor: pointer;
}

.toggle-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

/* Preset Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  text-align: center;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

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

/* Theme Preview Box */
.theme-preview-box {
  background: var(--preview-bg, #1c1c1e);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.preview-header {
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--preview-text, #fff);
  background: var(--preview-header-bg, rgba(0, 0, 0, 0.3));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-chat {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  background: var(--preview-chat-bg, transparent);
}

.preview-bubble {
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 13px;
  max-width: 70%;
  transition: all 0.3s ease;
}

.preview-bubble.sent {
  align-self: flex-end;
  background: var(--preview-sent-bg, linear-gradient(135deg, #007AFF 0%, #5856D6 100%));
  color: var(--preview-sent-text, #fff);
  border-radius: 16px 16px 4px 16px;
}

.preview-bubble.received {
  align-self: flex-start;
  background: var(--preview-received-bg, rgba(255, 255, 255, 0.1));
  color: var(--preview-received-text, rgba(255, 255, 255, 0.9));
  border-radius: 16px 16px 16px 4px;
}

.preview-input {
  padding: 12px 16px;
  background: var(--preview-input-bg, rgba(255, 255, 255, 0.05));
  color: var(--preview-input-text, rgba(255, 255, 255, 0.4));
  font-size: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Theme Maker Footer */
.theme-maker-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-maker-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-maker-btn.primary {
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.theme-maker-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.theme-maker-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.theme-maker-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Custom Theme Button in Theme Picker */
.theme-btn-custom {
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%) !important;
  border: 2px dashed rgba(255, 255, 255, 0.3) !important;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn-custom:hover {
  border-color: rgba(255, 255, 255, 0.5) !important;
  color: #fff;
}

/* Light theme custom button */
body:not(.theme-dark):not(.theme-glass):not(.theme-gradient):not(.theme-midnight):not(.theme-sunset) .theme-btn-custom {
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%) !important;
  border-color: #ccc !important;
  color: #666;
}

/* Mobile Theme Maker */
@media (max-width: 480px) {
  .theme-maker-modal {
    width: 100%;
    max-width: none;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    margin-top: auto;
  }
  
  .theme-style-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .color-scheme-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .toggle-grid {
    grid-template-columns: 1fr;
  }
  
  .gradient-dir-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================================
   CUSTOM THEME DYNAMIC STYLES
   ============================================================ */

body.theme-custom {
  --custom-accent: #007AFF;
  --custom-accent-rgb: 0, 122, 255;
}

body.theme-custom .bubble.sent {
  background: linear-gradient(135deg, var(--custom-accent) 0%, color-mix(in srgb, var(--custom-accent), #5856D6 50%) 100%);
}

body.theme-custom .send-button {
  background: linear-gradient(135deg, var(--custom-accent) 0%, color-mix(in srgb, var(--custom-accent), #5856D6 50%) 100%);
}

body.theme-custom .new-chat-btn {
  background: linear-gradient(135deg, var(--custom-accent) 0%, color-mix(in srgb, var(--custom-accent), #5856D6 50%) 100%);
}

body.theme-custom .chat-item.active {
  box-shadow: inset 3px 0 0 var(--custom-accent);
}

/* Neon style */
body.theme-custom.style-neon .bubble.sent {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid var(--custom-accent);
  box-shadow: 0 0 15px rgba(var(--custom-accent-rgb), 0.5), inset 0 0 15px rgba(var(--custom-accent-rgb), 0.1);
}

body.theme-custom.style-neon .bubble.received {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(var(--custom-accent-rgb), 0.3);
}

body.theme-custom.style-neon .app-container {
  box-shadow: 0 0 40px rgba(var(--custom-accent-rgb), 0.2), 0 0 80px rgba(var(--custom-accent-rgb), 0.1);
}

/* Glass style with custom color */
body.theme-custom.style-glass .bubble.sent {
  background: rgba(var(--custom-accent-rgb), 0.2);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(var(--custom-accent-rgb), 0.3);
}

/* Bubble shape variants */
body.theme-custom.bubble-pill .bubble.sent { border-radius: 20px !important; }
body.theme-custom.bubble-pill .bubble.received { border-radius: 20px !important; }

body.theme-custom.bubble-square .bubble.sent { border-radius: 6px !important; }
body.theme-custom.bubble-square .bubble.received { border-radius: 6px !important; }

body.theme-custom.bubble-cloud .bubble.sent { border-radius: 22px 22px 6px 22px !important; }
body.theme-custom.bubble-cloud .bubble.received { border-radius: 22px 22px 22px 6px !important; }

/* Animation variants */
body.theme-custom.anim-glow .bubble.sent {
  animation: bubbleGlow 2s ease-in-out infinite;
}

@keyframes bubbleGlow {
  0%, 100% { box-shadow: 0 2px 8px rgba(var(--custom-accent-rgb), 0.3); }
  50% { box-shadow: 0 4px 20px rgba(var(--custom-accent-rgb), 0.5); }
}

body.theme-custom.anim-gradient .gradient-bg {
  animation: gradientMove 15s ease infinite;
  background-size: 400% 400%;
}

@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}


/* ============================================================
   THEME MAKER UI IMPROVEMENTS
   ============================================================ */

/* Better contrast and readability */
.theme-maker-modal {
  background: linear-gradient(145deg, #1e1e2e 0%, #12121c 100%);
}

.theme-maker-header {
  background: rgba(0, 0, 0, 0.4);
}

.theme-maker-header h2 {
  font-size: 18px;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.theme-section-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Style buttons improved */
.style-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 600;
}

.style-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.style-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.2);
  box-shadow: 0 0 20px rgba(0, 122, 255, 0.3);
}

.style-preview {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

/* Color buttons larger and clearer */
.color-scheme-grid {
  gap: 10px;
}

.color-btn {
  width: 36px;
  height: 36px;
  border: 3px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Background buttons improved */
.bg-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 600;
  padding: 14px 10px;
}

.bg-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.bg-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.2);
}

.bg-preview {
  width: 44px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Bubble buttons improved */
.bubble-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  padding: 14px;
}

.bubble-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.bubble-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.2);
}

.bubble-preview {
  width: 55px;
  height: 28px;
}

/* Preset buttons improved */
.preset-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Toggle items improved */
.toggle-item {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 14px;
}

.toggle-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 500;
}

/* Slider improved */
.theme-slider {
  background: rgba(255, 255, 255, 0.15);
  height: 8px;
}

.theme-slider::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  box-shadow: 0 2px 10px rgba(0, 122, 255, 0.5);
}

.slider-value {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  font-size: 13px;
  min-width: 50px;
}

/* Preview box improved */
.theme-preview-box {
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  overflow: hidden;
}

.preview-header {
  font-size: 15px;
  font-weight: 700;
  padding: 14px 18px;
}

.preview-chat {
  min-height: 130px;
  padding: 18px;
}

.preview-bubble {
  font-size: 14px;
  padding: 10px 16px;
  font-weight: 500;
}

.preview-input {
  font-size: 14px;
  padding: 14px 18px;
}

/* Custom color row */
.custom-color-row {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
  border-radius: 10px;
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.custom-color-row input[type="color"] {
  width: 40px;
  height: 40px;
}

/* Footer buttons improved */
.theme-maker-footer {
  padding: 18px 24px;
  background: rgba(0, 0, 0, 0.4);
}

.theme-maker-btn {
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 14px;
}

.theme-maker-btn.primary {
  box-shadow: 0 4px 20px rgba(0, 122, 255, 0.4);
}

.theme-maker-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

/* Direction buttons */
.dir-btn {
  font-size: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.dir-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.dir-btn.active {
  border-color: #007AFF;
  background: rgba(0, 122, 255, 0.2);
}

/* Scrollbar in theme maker */
.theme-maker-content::-webkit-scrollbar {
  width: 8px;
}

.theme-maker-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.theme-maker-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

.theme-maker-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   CODE SANDBOX STYLES
   ============================================================ */

.code-sandbox-container {
  background: #1e1e2e;
  border-radius: 12px;
  overflow: hidden;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-sandbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-sandbox-lang {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
  text-transform: uppercase;
}

.code-sandbox-run {
  background: #34C759;
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-sandbox-run:hover {
  background: #2db84d;
  transform: scale(1.05);
}

.code-sandbox-code {
  padding: 12px 14px;
  font-family: 'SF Mono', 'Fira Code', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #e0e0e0;
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-sandbox-output {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-family: 'SF Mono', 'Fira Code', 'Monaco', monospace;
  font-size: 12px;
  color: #a0a0a0;
  min-height: 30px;
}

.code-sandbox-output.success {
  color: #34C759;
}

.code-sandbox-output.error {
  color: #FF3B30;
}

/* Syntax highlighting */
.code-keyword { color: #FF79C6; }
.code-string { color: #F1FA8C; }
.code-number { color: #BD93F9; }
.code-comment { color: #6272A4; }
.code-function { color: #50FA7B; }

/* ============================================================
   MOBILE GLASS THEME FIXES
   ============================================================ */

/* Tablet and smaller screens */
@media (max-width: 768px) {
  body.theme-glass .app-container {
    backdrop-filter: blur(40px) saturate(130%);
    -webkit-backdrop-filter: blur(40px) saturate(130%);
  }

  body.theme-glass .sidebar {
    backdrop-filter: blur(30px) saturate(120%);
    -webkit-backdrop-filter: blur(30px) saturate(120%);
  }

  body.theme-glass .sidebar-header {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  body.theme-glass .imessage-header {
    backdrop-filter: blur(30px) saturate(120%);
    -webkit-backdrop-filter: blur(30px) saturate(120%);
  }

  body.theme-glass .bubble.sent,
  body.theme-glass .bubble.received {
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
  }

  body.theme-glass .input-area {
    backdrop-filter: blur(30px) saturate(120%);
    -webkit-backdrop-filter: blur(30px) saturate(120%);
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  /* Reduce blur for better mobile performance */
  body.theme-glass .app-container {
    backdrop-filter: blur(25px) saturate(130%);
    -webkit-backdrop-filter: blur(25px) saturate(130%);
  }

  body.theme-glass .sidebar {
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
  }

  body.theme-glass .sidebar-header {
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }

  body.theme-glass .imessage-header {
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
  }

  body.theme-glass .bubble.sent,
  body.theme-glass .bubble.received {
    backdrop-filter: blur(15px) saturate(130%);
    -webkit-backdrop-filter: blur(15px) saturate(130%);
  }

  body.theme-glass .input-area {
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
  }

  /* Reduce orb opacity on mobile for less distraction */
  body.theme-glass .gradient-orb {
    opacity: 0.25;
  }

  /* Scale down orb animations */
  @keyframes orbFloatMobile {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(10px, -15px) scale(1.02); }
    50% { transform: translate(-5px, 10px) scale(0.99); }
    75% { transform: translate(8px, 5px) scale(1.01); }
  }

  body.theme-glass .orb-1,
  body.theme-glass .orb-2 {
    animation: orbFloatMobile 8s ease-in-out infinite;
  }

  /* Slightly increase background opacity for better readability on mobile */
  body.theme-glass {
    --imessage-sidebar-bg: rgba(255, 255, 255, 0.06);
    --glass-highlight: rgba(255, 255, 255, 0.12);
  }

  body.theme-glass .sidebar {
    background: rgba(255, 255, 255, 0.05);
  }

  body.theme-glass .app-container {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Very small screens - disable some effects */
@media (max-width: 360px) {
  body.theme-glass .gradient-orb {
    opacity: 0.15;
  }

  body.theme-glass .app-container::before {
    opacity: 0.5;
  }

  /* Further reduce blur for very small devices */
  body.theme-glass .bubble.sent,
  body.theme-glass .bubble.received {
    backdrop-filter: blur(10px) saturate(130%);
    -webkit-backdrop-filter: blur(10px) saturate(130%);
  }
}
/* ============================================================
   SPUNNIE REBRAND & NEW FEATURES
   ============================================================ */

/* Discord Login Button */
.discord-btn {
  background: #5865F2 !important;
  color: #fff !important;
}

.discord-btn:hover:not(:disabled) {
  background: #4752C4 !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(88, 101, 242, 0.3);
}

.discord-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(88, 101, 242, 0.2);
}

.discord-btn .spinner {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

/* Sidebar Tabs Navigation */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--imessage-sidebar-bg);
  border-bottom: 1px solid var(--separator);
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-tab svg {
  transition: transform 0.2s ease;
}

.sidebar-tab:hover {
  background: var(--imessage-gray);
  color: var(--text-primary);
}

.sidebar-tab.active {
  background: var(--imessage-blue);
  color: #fff;
}

.sidebar-tab.active svg {
  transform: scale(1.1);
}

/* Sidebar Content Container */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
}

/* ============================================================
   MARKETPLACE VIEW
   ============================================================ */

.marketplace-view {
  padding: 16px;
  height: 100%;
  overflow-y: auto;
}

.marketplace-header {
  margin-bottom: 20px;
}

.marketplace-header h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.marketplace-search {
  position: relative;
}

.marketplace-search-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--imessage-input-bg);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.marketplace-search-input:focus {
  border-color: var(--imessage-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.marketplace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.marketplace-card {
  background: var(--imessage-bg);
  border: 1px solid var(--separator);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.marketplace-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--imessage-blue);
}

.marketplace-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.marketplace-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--separator);
}

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

.marketplace-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.marketplace-card-username {
  font-size: 13px;
  color: var(--text-secondary);
}

.marketplace-card-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.marketplace-card-creator {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  font-style: italic;
}

.marketplace-card-creator strong {
  color: var(--text-secondary);
  font-weight: 600;
  font-style: normal;
}

.marketplace-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
}

.marketplace-card-stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.marketplace-card-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.marketplace-card-stat svg {
  width: 14px;
  height: 14px;
}

.marketplace-card-btn {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  background: var(--imessage-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.marketplace-card-btn:hover {
  background: #0066d6;
  transform: scale(1.05);
}

.marketplace-card-btn.pending {
  background: #FF9500;
  pointer-events: none;
}

.marketplace-card-btn.pending::after {
  content: ' (Pending)';
}

.marketplace-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.marketplace-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.marketplace-empty-text {
  font-size: 16px;
  margin-bottom: 8px;
}

.marketplace-empty-subtext {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ============================================================
   PROFILE VIEW
   ============================================================ */

.profile-view {
  padding: 24px 16px;
  height: 100%;
  overflow-y: auto;
}

.profile-header {
  text-align: center;
  margin-bottom: 32px;
}

.profile-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--imessage-blue) 0%, #5856D6 100%);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 122, 255, 0.3);
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.profile-edit-btn {
  padding: 10px 24px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-edit-btn:hover {
  background: var(--imessage-gray);
  border-color: var(--text-secondary);
}

.profile-section {
  margin-bottom: 32px;
}

.profile-section h4 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.profile-bots-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-bot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--imessage-input-bg);
  border-radius: 12px;
  border: 1px solid var(--separator);
  transition: all 0.2s ease;
  cursor: pointer;
}

.profile-bot-item:hover {
  background: var(--imessage-gray);
  transform: translateX(4px);
}

.profile-bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

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

.profile-bot-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-bot-code {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'SF Mono', monospace;
}

.profile-bot-status {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-bot-status.approved {
  background: rgba(52, 199, 89, 0.15);
  color: #34C759;
}

.profile-bot-status.pending {
  background: rgba(255, 149, 0, 0.15);
  color: #FF9500;
}

.profile-bot-status.rejected {
  background: rgba(255, 59, 48, 0.15);
  color: #FF3B30;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-item {
  text-align: center;
  padding: 20px;
  background: var(--imessage-input-bg);
  border-radius: 16px;
  border: 1px solid var(--separator);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--imessage-blue);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.profile-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* ============================================================
   MODERATION BADGE
   ============================================================ */

.moderation-required-badge {
  display: inline-block;
  padding: 4px 8px;
  background: rgba(255, 149, 0, 0.15);
  color: #FF9500;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .sidebar-tabs {
    padding: 8px 8px;
  }

  .sidebar-tab span {
    display: none;
  }

  .sidebar-tab {
    padding: 10px;
  }

  .marketplace-grid {
    grid-template-columns: 1fr;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   DARK THEME SUPPORT
   ============================================================ */

body.theme-dark .marketplace-card,
body.theme-dark .profile-bot-item,
body.theme-dark .stat-item {
  background: #2c2c2e;
  border-color: #3a3a3c;
}

body.theme-dark .marketplace-card:hover,
body.theme-dark .profile-bot-item:hover {
  background: #3a3a3c;
}

body.theme-dark .marketplace-search-input,
body.theme-dark .profile-edit-btn {
  background: #2c2c2e;
  border-color: #3a3a3c;
}

/* ============================================================
   MODERATION VIEW
   ============================================================ */

.moderation-view {
  padding: 16px;
  height: 100%;
  overflow-y: auto;
}

.moderation-header {
  margin-bottom: 20px;
}

.moderation-header h3 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.moderation-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.mod-stat {
  font-size: 14px;
  color: var(--text-secondary);
}

.mod-stat strong {
  color: var(--text-primary);
  font-weight: 600;
}

.moderation-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mod-bot-card {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.mod-bot-card:hover {
  background: #f0f0f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mod-bot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mod-bot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ddd;
  overflow: hidden;
  flex-shrink: 0;
}

.mod-bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.mod-bot-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px 0;
}

.mod-bot-username {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.mod-bot-creator {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}

.mod-bot-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.mod-bot-actions {
  display: flex;
  gap: 8px;
}

.mod-action-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mod-approve-btn {
  background: #34C759;
  color: white;
}

.mod-approve-btn:hover {
  background: #2fb350;
  transform: translateY(-1px);
}

.mod-reject-btn {
  background: #FF3B30;
  color: white;
}

.mod-reject-btn:hover {
  background: #e6352a;
  transform: translateY(-1px);
}

.mod-view-btn {
  background: #007AFF;
  color: white;
}

.mod-view-btn:hover {
  background: #0066dd;
  transform: translateY(-1px);
}

.mod-ai-btn {
  background: #5856D6;
  color: white;
}

.mod-ai-btn:hover {
  background: #4745b8;
  transform: translateY(-1px);
}

.mod-ai-review {
  margin: 12px 0;
}

.mod-ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(88, 86, 214, 0.1);
  border: 1px solid rgba(88, 86, 214, 0.2);
  border-radius: 8px;
  font-size: 14px;
  color: #5856D6;
}

.mod-ai-result {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.mod-ai-result.recommend-approve {
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid rgba(52, 199, 89, 0.3);
  color: #34C759;
}

.mod-ai-result.recommend-reject {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: #FF3B30;
}

.mod-ai-result.mod-ai-error {
  background: rgba(255, 204, 0, 0.1);
  border: 1px solid rgba(255, 204, 0, 0.3);
  color: #FFCC00;
}

.mod-ai-header {
  font-size: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mod-ai-confidence {
  font-size: 12px;
  opacity: 0.8;
}

.mod-ai-reasoning {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.mod-ai-concerns {
  font-size: 13px;
  color: var(--text-secondary);
}

.mod-ai-concerns ul {
  margin: 4px 0 0 0;
  padding-left: 20px;
}

.mod-ai-concerns li {
  margin: 2px 0;
}

.mod-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.mod-empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.mod-empty-state h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: var(--text-primary);
}

.mod-empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Dark theme for moderation */
body.theme-dark .mod-bot-card {
  background: #2c2c2e;
  border-color: #3a3a3c;
}

body.theme-dark .mod-bot-card:hover {
  background: #3a3a3c;
}

/* ============================================================
   EDIT PROFILE MODAL
   ============================================================ */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.modal-content {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--separator);
  border-radius: 8px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--imessage-bg);
  transition: all 0.2s;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #007AFF;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--separator);
}

.modal-btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-btn.primary {
  background: #007AFF;
  color: white;
}

.modal-btn.primary:hover {
  background: #0066dd;
  transform: translateY(-1px);
}

.modal-btn.secondary {
  background: #f0f0f0;
  color: var(--text-primary);
}

.modal-btn.secondary:hover {
  background: #e0e0e0;
  transform: translateY(-1px);
}

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

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

/* Dark theme for edit profile modal */
body.theme-dark .modal-dialog {
  background: #2c2c2e;
}

body.theme-dark .form-input {
  background: #1c1c1e;
  border-color: #3a3a3c;
  color: #fff;
}

body.theme-dark .modal-btn.secondary {
  background: #3a3a3c;
  color: #fff;
}

body.theme-dark .modal-btn.secondary:hover {
  background: #4a4a4c;
}
