/* ===== NAVBAR ===== */
#navbar {
  height: var(--nav-height);
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(28px) saturate(1.8);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  flex-shrink: 0;
  animation: navbarSlideDown 0.5s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes navbarSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.nav-left { display: flex; align-items: center; }

.nav-logo {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: background var(--transition); user-select: none;
}
.nav-logo:hover { background: var(--bg-hover); }
.nav-logo-text {
  font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
  color: rgba(255,255,255,0.9);
}
.nav-version {
  font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; padding: 1px 5px;
}

/* Center tabs */
.nav-center {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 2px;
}

.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.65);
  background: transparent; border: 1px solid transparent;
  transition: color var(--transition), background var(--transition);
  position: relative;
  white-space: nowrap;
}

/* Hover underline — animated in/out */
.nav-tab::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 16px; height: 1.5px;
  background: rgba(255,255,255,0.5);
  border-radius: 1px;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1),
              background 0.22s ease,
              opacity 0.22s ease;
  opacity: 0;
}

.nav-tab:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.07); }
.nav-tab:hover::after {
  transform: translateX(-50%) scaleX(1);
  background: rgba(255,255,255,0.5);
  opacity: 1;
}

.nav-tab.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.12);
}
.nav-tab.active::after {
  transform: translateX(-50%) scaleX(1);
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* Nav logo mark */
.nav-logo-mark {
  position: relative; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-logo-ring-outer, .nav-logo-ring-inner {
  position: absolute; border-radius: 50%; border: 1.5px solid white;
}
.nav-logo-ring-outer { width: 20px; height: 20px; opacity: 0.7; }
.nav-logo-ring-inner { width: 12px; height: 12px; opacity: 0.9; }
.nav-logo-dot { width: 4px; height: 4px; background: white; border-radius: 50%; }

/* Right */
.nav-right { display: flex; align-items: center; gap: 4px; }

.nav-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: rgba(255,255,255,0.6); transition: all var(--transition);
}
.nav-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
#panic-btn:hover { color: #ff6b6b; background: rgba(255,68,68,0.15); }
#pwa-install-btn {
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
#pwa-install-btn:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  transform: translateY(-1px);
}

/* ===== PROFILE BUTTON ===== */
.nav-profile-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; border-radius: 20px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer; transition: all var(--transition); position: relative;
}
.nav-profile-btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.13); }

.nav-profile-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.nav-profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.nav-profile-avatar-placeholder { font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.8); }
.nav-profile-name {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.85);
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Profile dropdown */
.profile-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 240px;
  background: var(--bg-card); border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 9000; overflow: hidden;
  opacity: 0; transform: translateY(-8px) scale(0.97); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.profile-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.profile-menu-header {
  padding: 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.profile-menu-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-active); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; position: relative; cursor: pointer;
}
.profile-menu-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-menu-avatar-placeholder { font-size: 18px; font-weight: 800; color: var(--text-secondary); }
.profile-menu-avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--transition); border-radius: 50%;
}
.profile-menu-avatar:hover .profile-menu-avatar-overlay { opacity: 1; }
.profile-menu-avatar-overlay svg { color: #fff; }
.profile-menu-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-menu-name { font-size: 14px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-menu-label { font-size: 11px; color: var(--text-muted); }
.profile-menu-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.profile-name-input {
  width: 100%; background: var(--bg-active); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px;
  color: var(--text-primary); font-family: var(--font); transition: border-color var(--transition);
}
.profile-name-input:focus { border-color: rgba(255,255,255,0.25); outline: none; }
.profile-save-btn {
  width: 100%; padding: 8px; background: var(--accent); color: var(--bg-primary);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; transition: all var(--transition);
}
.profile-save-btn:hover { opacity: 0.85; }
.profile-upload-label {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 7px; background: var(--bg-active); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.profile-upload-label:hover { color: var(--text-primary); border-color: var(--border-hover); background: var(--bg-hover); }

/* ===== PROXY TABS BAR ===== */
.proxy-tabs-bar {
  height: 36px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 8px; gap: 4px; overflow-x: auto;
  scrollbar-width: none; flex-shrink: 0;
}
.proxy-tabs-bar::-webkit-scrollbar { display: none; }

.proxy-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 10px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap; max-width: 160px; min-width: 80px;
  flex-shrink: 0; position: relative;
}
.proxy-tab:hover { color: var(--text-primary); border-color: var(--border-hover); }
.proxy-tab.active { color: var(--text-primary); background: var(--bg-active); border-color: var(--border-hover); }

.proxy-tab-favicon {
  width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0;
  object-fit: contain;
}
.proxy-tab-title {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proxy-tab-close {
  width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--text-muted); flex-shrink: 0;
  transition: all var(--transition); margin-left: 2px;
}
.proxy-tab-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.proxy-tab-new {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-muted); flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: all var(--transition); cursor: pointer;
}
.proxy-tab-new:hover { color: var(--text-primary); border-color: var(--border-hover); background: var(--bg-hover); }

/* Tab labels — always visible but styled */
.nav-tab-label {
  font-size: 13px;
  font-weight: 500;
}

/* Nav logo cloud icon */
.nav-logo-cloud {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); flex-shrink: 0;
}
.nav-logo-cloud svg { transition: filter var(--transition); }
.nav-logo:hover .nav-logo-cloud svg { filter: drop-shadow(0 0 6px rgba(255,255,255,0.5)); }
