:root {
  --primary: #0066ff;
  --primary-light: #0052cc;
  --primary-soft: #eff6ff;
  --accent: #00c2ff;
  --accent-hover: #00a3d9;
  --coral: #ef4444;
  --coral-light: #fef2f2;
  --gold: #ffcc00;
  --gold-dark: #f59e0b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-light: #f1f5f9;
  --border-dark: #e2e8f0;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 102, 255, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 102, 255, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --header-height: 60px;
  --bottom-nav-height: 68px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #e8edf5 0%, #f1f5f9 100%);
  color: var(--text-primary);
  line-height: 1.4;
  overflow-x: hidden;
  user-select: none;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Device Wrapper for Desktop Preview */
.app-container {
  width: 100%;
  max-width: 440px;
  height: 92vh;
  max-height: 900px;
  background-color: var(--bg-main);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 65px rgba(0, 80, 200, 0.16);
  border-radius: 36px;
  border: 10px solid #cbd5e1;
  transition: max-width 0.3s ease, border-radius 0.3s ease, height 0.3s ease;
}

/* Fullscreen mode toggle on desktop */
.app-container.fullscreen {
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

@media (max-width: 500px) {
  body {
    background-color: var(--bg-main);
    align-items: stretch;
  }
  .app-container {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

/* Top Device Speaker / Notch Simulator */
.device-notch {
  height: 14px;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  z-index: 150;
  pointer-events: none;
}
.device-notch::after {
  content: '';
  width: 90px;
  height: 5px;
  background-color: #cbd5e1;
  border-radius: 4px;
}

/* Ensure device notch simulator never overlaps active chat window or modals */
.app-container:has(#active-chat-window:not([style*="display: none"])) .device-notch,
body:has(#active-chat-window:not([style*="display: none"])) .device-notch {
  display: none !important;
}

/* App Header (Clean White & Blue Design) */
.app-header {
  background: #ffffff;
  color: var(--text-primary);
  padding: 18px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 102, 255, 0.05);
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}
.brand-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.brand-logo:hover .logo-icon {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.18);
}
.brand-logo .logo-icon .logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 9px;
}

.brand-logo .logo-text {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.6px;
  display: flex;
  align-items: baseline;
  line-height: 1;
}
.brand-logo .logo-text .logo-r {
  color: #0066ff; /* Vivid Royal Blue */
}
.brand-logo .logo-text .logo-d {
  color: #ffcc00; /* Bright Golden Yellow */
  font-size: 24px;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.4);
}
.brand-logo .logo-text .logo-eal {
  color: #0066ff; /* Vivid Royal Blue */
}
.brand-logo .logo-badge {
  font-size: 8.5px;
  font-weight: 800;
  background: #eff6ff;
  color: #0066ff;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid #dbeafe;
  letter-spacing: 0.5px;
  margin-left: 6px;
  text-transform: uppercase;
}

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

.header-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #0066ff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.header-btn:hover {
  background: #e2e8f0;
  color: #0052cc;
}

.header-btn .badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--coral);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
}

/* Location Selector Bar (Soft Blue Pill) */
.location-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f0f7ff;
  border: 1px solid #dbeafe;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  color: #1e40af;
  transition: background 0.2s;
}
.location-bar:hover {
  background: #e0effe;
}
.location-info {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.location-info svg {
  color: #0066ff;
}
.location-radius-tag {
  background: #0066ff;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Search Header Input */
.search-container {
  position: relative;
  width: 100%;
}
.search-input {
  width: 100%;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 40px 10px 38px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  box-shadow: none;
  transition: all 0.2s;
}
.search-input:focus {
  border-color: #0066ff;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}
.search-icon-left {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #0066ff;
  pointer-events: none;
}
.search-filter-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #0066ff;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 4px;
}
.search-filter-btn:hover {
  background: #eff6ff;
}

/* App Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + 12px);
  scroll-behavior: smooth;
  position: relative;
}

/* Views Navigation Management */
.app-view {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}
.app-view.active {
  display: block;
}

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

/* Bottom Navigation Bar (Clean White with Royal Blue Accents) */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0, 102, 255, 0.05);
  padding-bottom: 4px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  position: relative;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--primary);
}
.nav-item.active svg {
  stroke-width: 2.5;
  color: var(--primary);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  transition: transform 0.15s;
}
.nav-item:active svg {
  transform: scale(0.9);
}

/* Floating Central Sell Button (Royal Blue with Golden Accent) */
.nav-sell-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.nav-sell-btn {
  position: absolute;
  top: -24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0052cc 0%, #0066ff 100%);
  border: 4px solid #ffffff;
  box-shadow: 0 6px 18px rgba(0, 102, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.nav-sell-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(0, 102, 255, 0.5);
}
.nav-sell-btn:active {
  transform: scale(0.95);
}
.nav-sell-btn svg {
  width: 24px;
  height: 24px;
  color: var(--gold);
}
.nav-sell-btn span {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff;
  margin-top: -2px;
}

/* Floating Quick Frame Switcher (for desktop testing) */
.desktop-controls {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  gap: 8px;
}
.control-btn {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-light);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 102, 255, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
}
.control-btn:hover {
  background: var(--primary-light);
}

