*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-system);
  background-color: var(--bg-app);
  color: var(--text-primary);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Background mesh */
.app-background-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(0, 122, 255, 0.15), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(175, 82, 222, 0.12), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(52, 199, 89, 0.08), transparent 50%),
    var(--bg-app);
  pointer-events: none;
}

/* Layout */
.app-container {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(142, 142, 147, 0.25);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(142, 142, 147, 0.45);
}

/* Typography & inputs */
input, textarea, button {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

.clickable {
  cursor: pointer;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  color: #ffffff;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.avatar-status-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background-color: var(--status-online);
  border: 2.5px solid var(--bg-sidebar);
  transition: background-color var(--duration-fast);
}

.avatar-status-badge.offline {
  background-color: var(--status-offline);
}

.badge {
  background-color: var(--badge-bg);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

/* Toasts */
#toast-container {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px), 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.ios-toast {
  background: rgba(30, 30, 32, 0.92);
  color: #ffffff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.35s var(--spring-bounce) forwards;
  pointer-events: auto;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ios-toast.hide {
  animation: toastOut 0.25s var(--spring-smooth) forwards;
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-15px) scale(0.95);
  }
}

/* Real-time Connection Status Bar */
.connection-status-bar {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 159, 10, 0.92);
  color: #ffffff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform var(--duration-normal) var(--spring-smooth), opacity var(--duration-fast);
  transform: translateY(0);
  opacity: 1;
}

.connection-status-bar.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.connection-status-bar.online {
  background: rgba(48, 209, 88, 0.92);
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ffffff;
  animation: pulseDot 1.3s infinite ease-in-out;
}

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