/* ==========================================================================
   寻序 · 经典个人聚合导航样式表
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.15);
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-surface: #f1f5f9;
  
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-card: rgba(226, 232, 240, 0.8);
  --border-card-hover: #cbd5e1;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 12px 30px rgba(79, 70, 229, 0.12);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  background-color: var(--bg-page);
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-body);
  background-color: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, select {
  font: inherit;
  border: none;
  outline: none;
}

/* Ambient Glow Background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
  opacity: 0.6;
}

.ambient-top {
  top: -160px;
  left: 20%;
  width: 500px;
  height: 380px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.16) 0%, rgba(224, 231, 255, 0.05) 70%, transparent 100%);
}

.ambient-bottom {
  bottom: -180px;
  right: 15%;
  width: 550px;
  height: 420px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.12) 0%, rgba(224, 242, 254, 0.05) 70%, transparent 100%);
}

/* Common Layout Container */
.nav-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* Common Helper Classes */
.is-hidden {
  display: none !important;
}

.text-danger {
  color: #ef4444 !important;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  vertical-align: middle;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
  padding: 8px 16px;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-body);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--bg-surface);
  border-color: var(--border-card-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background-color: var(--primary-light);
  color: var(--primary);
}

/* ==========================================================================
   Top Navbar
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.navbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  height: 32px;
  width: auto;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.navbar-center {
  display: flex;
  align-items: center;
}

.time-badge {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid rgba(226, 232, 240, 0.6);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.user-trigger:hover {
  background: var(--bg-surface);
  border-color: var(--border-card-hover);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  padding: 8px 0;
  z-index: 100;
  animation: dropdownIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.user-dropdown-header {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-dropdown-header strong {
  font-size: 14px;
  color: var(--text-main);
}

.user-role-badge {
  font-size: 11px;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-body);
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.item-icon {
  font-size: 14px;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-content {
  flex: 1;
  padding-top: 36px;
  padding-bottom: 60px;
}

/* ==========================================================================
   Search Hero Section (Redesigned with Bing & Google Dual-Engine)
   ========================================================================== */
.search-hero {
  max-width: 680px;
  margin: 8px auto 38px auto;
  text-align: center;
  position: relative;
}

/* Engine Switcher */
.engine-switcher-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.engine-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(241, 245, 249, 0.9);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.engine-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.engine-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

.engine-tab.is-active {
  color: var(--text-main);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

.engine-tab[data-engine="bing"].is-active {
  color: #0078d4;
}

.engine-tab[data-engine="google"].is-active {
  color: #1a73e8;
}

.engine-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
}

/* Search Box Dock */
.search-box {
  position: relative;
  width: 100%;
}

.search-box-inner {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 2px solid rgba(226, 232, 240, 0.85);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  padding: 5px 6px 5px 12px;
  transition: var(--transition);
}

.search-box-inner:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 28px -4px rgba(15, 23, 42, 0.08);
}

.search-box-inner:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 12px 32px -4px rgba(79, 70, 229, 0.18), 0 0 0 4px rgba(79, 70, 229, 0.1);
  transform: translateY(-2px);
}

.search-engine-indicator {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.search-box-inner:focus-within .search-engine-indicator {
  transform: scale(1.05);
}

.indicator-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-width: 0;
}

#search-input {
  width: 100%;
  height: 44px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  letter-spacing: -0.01em;
}

#search-input::placeholder {
  color: var(--text-dim);
  font-weight: 400;
}

.search-clear-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.search-clear-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

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

.search-btn {
  height: 42px;
  padding: 0 20px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  flex-shrink: 0;
}

.search-btn:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #4f46e5 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

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

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

/* Search Suggestions & Realtime Dropdown */
.search-suggestions {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 8px 6px;
  text-align: left;
  z-index: 60;
  max-height: 360px;
  overflow-y: auto;
  animation: dropdownIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.suggestions-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 6px 12px 4px 12px;
  text-transform: uppercase;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
  margin: 1px 0;
}

.suggestion-item:hover, .suggestion-item.is-selected {
  background: var(--bg-surface);
}

.suggestion-item-link .suggestion-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.suggestion-engine-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.suggestion-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggestion-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.suggestion-url {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-query {
  color: var(--primary);
  font-weight: 600;
}

.suggestion-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(241, 245, 249, 0.8);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.suggestion-badge-primary {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

/* ==========================================================================
   Category Filter Bar
   ========================================================================== */
/* ==========================================================================
   Category Filter Bar
   ========================================================================== */
.category-bar-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  flex-wrap: wrap;
}

.category-tabs-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.category-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  user-select: none;
}

.category-tab[data-category-draggable="true"] {
  cursor: grab;
  touch-action: none;
}

.category-tab[data-category-draggable="true"]:active,
.category-tab.is-dragging {
  cursor: grabbing;
  opacity: 0.55;
}

.category-tab.is-drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-sm);
  transform: translateY(-2px);
}

.category-tab:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-card-hover);
}

.category-tab.is-active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.category-tab-count {
  font-size: 11px;
  opacity: 0.8;
}

.add-category-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px dashed rgba(79, 70, 229, 0.35);
  transition: var(--transition);
}

.add-category-btn:hover {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15);
  transform: translateY(-1px);
}

.category-filter-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   Navigation Matrix & Cards (Optimized & Clean)
   ========================================================================== */
.navigation-matrix {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.category-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

.category-header-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  padding: 4px 8px;
  margin-left: -8px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.category-header-left:hover {
  background: rgba(0, 0, 0, 0.04);
}

.category-header-left:active {
  transform: scale(0.98);
}

.category-collapse-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), color 0.15s ease, background 0.15s ease;
}

.category-header-left:hover .category-collapse-icon {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
}

.category-section.is-collapsed .category-collapse-icon {
  transform: rotate(-90deg);
}

.category-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

.category-count-badge {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(241, 245, 249, 0.8);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.category-body {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.category-section.is-collapsed .category-body {
  display: none;
}

/* Subtle, discreet category add button revealed smoothly on section hover */
.category-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  opacity: 0;
  transform: translateX(4px);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.category-section:hover .category-add-btn {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.category-add-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
  color: var(--primary);
}

@media (hover: none) {
  .category-add-btn {
    opacity: 0.8;
    transform: none;
    pointer-events: auto;
  }
}

.navigation-matrix {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.category-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 84px);
  justify-content: start;
  gap: 18px 22px;
}

/* Link Card (Modern OS / iTab App-Grid Tile) */
.link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 84px;
  padding: 6px 2px;
  background: transparent;
  border: none;
  border-radius: 14px;
  box-shadow: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
  user-select: none;
  box-sizing: border-box;
  text-decoration: none;
}

.link-card:hover {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.link-card:hover .link-card-icon {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
}

.link-card:active .link-card-icon {
  transform: translateY(0) scale(0.98);
}

.link-card-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.link-card-icon.link-card-icon-img {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.link-card-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
}

.link-card-icon-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

/* Color tones (applied only when no logo is present or on fallback) */
.link-card-icon.tone-purple { background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%); border-color: transparent; }
.link-card-icon.tone-blue   { background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); border-color: transparent; }
.link-card-icon.tone-green  { background: linear-gradient(135deg, #34d399 0%, #10b981 100%); border-color: transparent; }
.link-card-icon.tone-orange { background: linear-gradient(135deg, #fb923c 0%, #f97316 100%); border-color: transparent; }
.link-card-icon.tone-pink   { background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%); border-color: transparent; }
.link-card-icon.tone-red    { background: linear-gradient(135deg, #f87171 0%, #ef4444 100%); border-color: transparent; }
.link-card-icon.tone-cyan   { background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%); border-color: transparent; }

.link-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .link-grid {
    grid-template-columns: repeat(auto-fill, 72px);
    gap: 14px 16px;
  }
  .link-card {
    width: 72px;
  }
  .link-card-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
  }
  .link-card-icon img {
    width: 26px;
    height: 26px;
  }
  .link-card-name {
    max-width: 68px;
    font-size: 11px;
  }
}

/* Category Empty Card (shown only when a group has 0 links) */
.category-empty-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 14px;
  background: rgba(248, 250, 252, 0.6);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.category-empty-card:hover {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.empty-card-icon {
  font-size: 16px;
  font-weight: 600;
}

/* Favicon Preview in Modal */
.favicon-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.favicon-preview-box {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.favicon-preview-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.favicon-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.favicon-preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.favicon-preview-info strong {
  font-size: 13px;
  color: var(--text-main);
}

.favicon-preview-info span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Context Menu (Dark Frosted Glass Style, inspired by macOS / iTab)
   ========================================================================== */
.context-menu {
  position: fixed;
  z-index: 500;
  min-width: 190px;
  background: rgba(26, 31, 46, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  animation: menuFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 6px 10px;
}

.ctx-header-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
}

.ctx-header-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ctx-header-icon-cat {
  font-size: 15px;
}

.ctx-header-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 0;
}

.context-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
}

.context-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.context-item.text-danger {
  color: #f87171 !important;
}

.context-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #fca5a5 !important;
}

.ctx-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
  width: 16px;
  text-align: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

.empty-icon {
  font-size: 40px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto 20px auto;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  padding: 20px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-quote {
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--text-main);
}

.footer-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  padding: 28px;
  animation: zoomIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-lg {
  max-width: 720px;
}

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

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-mode-switch {
  display: flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.mode-tab.is-active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
}

.form-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  transition: var(--transition);
}

.form-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-error {
  color: #ef4444;
  font-size: 12px;
  min-height: 16px;
}

.modal-footer-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
}

/* Admin Modal Stats & Table */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.admin-stat-card {
  background: var(--bg-surface);
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-value-status {
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-table-wrap {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.admin-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  opacity: 0;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 300;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 768px) {
  .navbar-inner {
    height: 56px;
  }
  
  .navbar-center {
    display: none;
  }
  
  .engine-tabs {
    flex-wrap: wrap;
    border-radius: var(--radius-lg);
  }
  
  .search-hero {
    margin-bottom: 24px;
  }
  
  .search-btn {
    padding: 0 16px;
    font-size: 14px;
  }
  
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}
