/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
  --bg-primary: #0a0a0f;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-search: rgba(255, 255, 255, 0.06);
  --bg-search-focus: rgba(255, 255, 255, 0.1);

  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;

  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-soft: rgba(99, 102, 241, 0.12);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --blur: 20px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ========================================
   Background
   ======================================== */
.bg-image {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 1s ease;
  opacity: 0;
}

.bg-image.loaded {
  opacity: 1;
}

/* Full-screen loading animation */
.bg-loading {
  position: fixed;
  inset: 0;
  z-index: -3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  overflow: hidden;
}

.bg-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.bg-loading-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.bg-loading-ring {
  width: 56px;
  height: 56px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loadRingSpin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  box-shadow: 0 0 20px var(--accent-glow);
}

.bg-loading-ring-2 {
  position: absolute;
  top: 0;
  width: 56px;
  height: 56px;
  border: 2px solid transparent;
  border-bottom-color: rgba(139, 92, 246, 0.6);
  border-radius: 50%;
  animation: loadRingSpin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
  box-shadow: none;
}

.bg-loading-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: loadPulse 1.5s ease-in-out infinite;
}

/* Shimmer sweep across the screen */
.bg-loading-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg,
      transparent 40%,
      rgba(99, 102, 241, 0.03) 45%,
      rgba(99, 102, 241, 0.06) 50%,
      rgba(99, 102, 241, 0.03) 55%,
      transparent 60%);
  background-size: 200% 100%;
  animation: loadShimmer 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes loadRingSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadPulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

@keyframes loadShimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg-primary);
  opacity: 0.5;
  pointer-events: none;
  transition: opacity var(--transition);
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99, 102, 241, 0.15), transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 50%, rgba(139, 92, 246, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(59, 130, 246, 0.06), transparent 60%);
  pointer-events: none;
}

/* ========================================
   Opacity Control
   ======================================== */
.opacity-control {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.opacity-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: rgba(24, 24, 32, 0.8);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
}

.opacity-toggle:hover {
  background: rgba(24, 24, 32, 0.95);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.opacity-slider-panel {
  background: rgba(24, 24, 32, 0.92);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.98);
  transition: var(--transition);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.opacity-slider-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.opacity-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.opacity-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: var(--transition);
}

.opacity-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--accent-glow);
}

.opacity-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.opacity-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.opacity-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
}

.opacity-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ========================================
   Container
   ======================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ========================================
   Hero / Clock
   ======================================== */
.hero {
  text-align: center;
  padding: 60px 0 40px;
  user-select: none;
}

.clock {
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #ffffff 0%, #d4d4d8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.greeting {
  font-size: 1.25rem;
  color: #e4e4e7;
  margin-top: 8px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.date {
  font-size: 0.875rem;
  color: #a1a1aa;
  margin-top: 4px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.weather {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 6px 14px;
  background: rgba(10, 10, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 0.8rem;
  color: #d4d4d8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.5s ease, background 0.3s ease, border-color 0.3s ease;
  cursor: pointer;
}

.weather:hover {
  background: rgba(40, 40, 50, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
}

.weather.loaded {
  opacity: 1;
}

.weather-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.weather-temp {
  font-weight: 600;
  color: #e4e4e7;
}

.weather-sep {
  color: rgba(255, 255, 255, 0.15);
  font-weight: 300;
}

.weather-location {
  color: #a1a1aa;
}

/* 天气位置设置弹层 */
.weather-wrap {
  position: relative;
  display: inline-block;
}

.weather-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  gap: 8px;
  width: 250px;
  padding: 12px;
  background: rgba(15, 15, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 300;
  text-align: left;
}

.weather-panel.show {
  display: flex;
}

.weather-city-input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s ease;
}

.weather-city-input:focus {
  border-color: var(--accent);
}

.weather-panel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.weather-panel-btn {
  flex: 1;
  padding: 7px 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.weather-panel-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.weather-panel-btn-primary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.weather-panel-btn-primary:hover {
  background: var(--accent);
  color: #fff;
}

/* ========================================
   Search
   ======================================== */
.search-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto 48px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(10, 10, 15, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: 4px 16px 4px 4px;
  transition: var(--transition);
  position: relative;
}

.search-box:focus-within {
  background: var(--bg-search-focus);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.engine-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  font-family: var(--font);
}

.engine-btn:hover {
  background: var(--accent);
  color: white;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 10px 12px;
  font-family: var(--font);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font);
  pointer-events: none;
  transition: var(--transition);
}

.search-box:focus-within .search-hint {
  opacity: 0;
}

/* Engine Dropdown */
.engine-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(24, 24, 32, 0.95);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.98);
  transition: var(--transition);
  z-index: 100;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.engine-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.engine-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: var(--transition);
  font-family: var(--font);
}

.engine-option:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.engine-option.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.engine-option-icon {
  font-weight: 700;
  width: 20px;
  text-align: center;
}

/* ========================================
   Bookmarks
   ======================================== */
.bookmarks {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.category {
  animation: fadeInUp 0.4s ease both;
}

.category:nth-child(2) {
  animation-delay: 50ms;
}

.category:nth-child(3) {
  animation-delay: 100ms;
}

.category:nth-child(4) {
  animation-delay: 150ms;
}

.category:nth-child(5) {
  animation-delay: 200ms;
}

.category:nth-child(6) {
  animation-delay: 250ms;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  user-select: none;
}

.category-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.category-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.category-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Collapse indicator */
.collapse-indicator {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.3s ease, opacity var(--transition);
  opacity: 0;
  transform: rotate(0deg);
}

.category-header:hover .collapse-indicator {
  opacity: 1;
}

.category.collapsed .collapse-indicator {
  transform: rotate(-90deg);
  opacity: 0.7;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin-bottom 0.3s ease;
  opacity: 1;
}

.category.collapsed .category-grid {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

.category.collapsed .category-header {
  margin-bottom: 0;
}

/* ========================================
   Link Card
   ======================================== */
.link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(10, 10, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  /* 自定义拖拽需要：禁掉文字选中和 Safari 的原生元素拖拽 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.link-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent 60%);
  opacity: 0;
  transition: var(--transition);
}

.link-card:hover {
  background: rgba(10, 10, 15, 0.75);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.link-card:hover::before {
  opacity: 1;
}

.link-card:active {
  transform: translateY(0);
}

.link-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.link-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fallback letter icon */
.link-icon-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  border-radius: var(--radius-sm);
}

.link-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

/* ========================================
   No Results
   ======================================== */
.no-results {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.no-results-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* 空分类占位（可作为拖拽目标） */
.category-empty {
  grid-column: 1 / -1;
  padding: 18px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .hero {
    padding: 40px 0 28px;
  }

  .clock {
    font-size: 3.5rem;
  }

  .greeting {
    font-size: 1.1rem;
  }

  .search-wrapper {
    margin-bottom: 36px;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
  }

  .link-card {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px 40px;
  }

  .clock {
    font-size: 2.8rem;
  }

  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   Selection
   ======================================== */
::selection {
  background: var(--accent);
  color: white;
}

/* ========================================
   Settings Button
   ======================================== */
.settings-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: rgba(24, 24, 32, 0.8);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
}

.settings-btn:hover {
  background: rgba(24, 24, 32, 0.95);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: rotate(30deg);
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 20px;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #16161e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-footer-left,
.modal-footer-right {
  display: flex;
  gap: 8px;
}

.modal-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.modal-btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.modal-btn-primary:hover {
  background: #5558e6;
}

.modal-btn-secondary {
  background: none;
  color: var(--text-muted);
  border-color: var(--border);
}

.modal-btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Settings Category Section */
.settings-cat {
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  position: relative;
}

.settings-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.settings-cat-header input {
  flex: 1;
}

/* Icon picker */
.settings-cat-icon-wrap {
  position: relative;
  flex-shrink: 0;
}

.settings-cat-icon-preview {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: var(--transition);
}

.settings-cat-icon-preview:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.settings-cat-icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 3px;
}

.settings-cat-icon-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  width: 280px;
  padding: 10px;
  margin-top: 4px;
  background: #1a1a24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
}

.settings-cat-icon-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.settings-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
  padding-right: 4px;
}

.settings-emoji-grid::-webkit-scrollbar {
  width: 4px;
}

.settings-emoji-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.settings-emoji-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.settings-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.15);
}

.settings-cat-icon-url-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.settings-cat-icon-url-input {
  width: 100%;
  font-size: 0.75rem;
}

/* Category icon image in bookmarks */
.category-icon-img {
  width: 1.1rem;
  height: 1.1rem;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 2px;
}

.settings-cat-name-input {
  font-weight: 600;
}

.settings-cat-del {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.settings-cat-del:hover {
  opacity: 1;
}

/* 分类上移/下移 */
.settings-cat-move {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.settings-cat-move:hover:not(:disabled) {
  opacity: 1;
  color: var(--accent);
}

.settings-cat-move:disabled {
  opacity: 0.15;
  cursor: default;
}

/* 非法网址提示 */
.settings-input-invalid {
  border-color: #ef4444 !important;
}

/* ========================================
   Settings: 外观与图标源
   ======================================== */
.settings-appearance-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-appearance-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px 14px;
}

.settings-appearance-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
}

.settings-textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.6;
  font-size: 0.75rem;
  white-space: pre;
  overflow-x: auto;
}

.settings-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.settings-appearance-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.settings-small-btn {
  padding: 6px 12px;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.settings-small-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-clear-msg {
  font-size: 0.7rem;
  color: var(--accent);
}

.settings-links {
  padding: 8px 14px;
}

.settings-link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-link-item:last-child {
  border-bottom: none;
}

.settings-link-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

.settings-favicon-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition);
}

.settings-favicon-wrap:hover {
  background: rgba(255, 255, 255, 0.08);
}

.settings-letter-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}

.settings-icon-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  width: 220px;
  padding: 10px;
  margin-top: 4px;
  background: #1a1a24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
}

.settings-icon-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.settings-icon-popup-btn {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-family: var(--font);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.settings-icon-popup-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.settings-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.settings-input:focus {
  border-color: var(--accent);
}

.settings-input-name {
  width: 100px;
}

.settings-input-url {
  flex: 1;
  min-width: 0;
}

.settings-link-del {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.settings-link-del:hover {
  opacity: 1;
}

.settings-add-link {
  display: block;
  width: 100%;
  padding: 7px;
  margin-top: 4px;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.settings-add-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Drag & Drop (Long-press to move)
   ======================================== */
body.is-dragging {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing !important;
}

body.is-dragging .link-card:hover {
  transform: none;
  box-shadow: none;
}

body.is-dragging .link-card:hover::before {
  opacity: 0;
}

/* Long-press visual feedback */
.link-card.long-pressing {
  transform: scale(0.96);
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* 拖拽期间原卡整个隐藏，只留占位符——不再和占位符一起占两个格子 */
.link-card.dragging {
  display: none;
}

/* Floating ghost that follows the pointer (transform 由 JS 实时设置) */
.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  will-change: transform;
  /* 必须干掉从 .link-card 继承的 transition: all 200ms——
     否则每次 transform 更新都被缓动「追赶」，表现为跟手延迟/瞬移 */
  transition: none;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--accent);
  border-radius: var(--radius-md);
}

/* Drop placeholder */
.drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  min-height: 52px;
  animation: placeholderPulse 1.5s ease-in-out infinite;
}

/* 占位符已经进入空分类时，藏掉「空分类」提示文字 */
.category-grid:has(.drag-placeholder) .category-empty {
  display: none;
}

@keyframes placeholderPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}
/* ========================================
   Hitokoto 一言
   ======================================== */
.hitokoto {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.6s ease;
  cursor: pointer;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.hitokoto.loaded {
  opacity: 0.9;
}

.hitokoto-from {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* ========================================
   搜索联想
   ======================================== */
.suggest-box {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 15, 20, 0.95);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 150;
}

.suggest-box.show {
  display: block;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.suggest-item.active {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.suggest-item-icon {
  font-size: 0.75rem;
  opacity: 0.5;
}

.suggest-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   快速添加卡片
   ======================================== */
.add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  background: none;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 1.3rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  opacity: 0.55;
}

.add-card:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ========================================
   卡片右键菜单
   ======================================== */
.card-menu {
  display: none;
  position: fixed;
  z-index: 1200;
  min-width: 170px;
  padding: 6px;
  background: rgba(20, 20, 26, 0.97);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.card-menu.show {
  display: block;
}

.card-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.card-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.card-menu-item-danger {
  color: #f87171;
}

.card-menu-item-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.card-menu-sep {
  height: 1px;
  margin: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
}

.card-menu-empty {
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   书签编辑/新增弹层
   ======================================== */
.link-editor {
  display: none;
  position: fixed;
  z-index: 1200;
  width: 300px;
  padding: 14px;
  background: rgba(18, 18, 24, 0.97);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  flex-direction: column;
  gap: 8px;
}

.link-editor.show {
  display: flex;
}

.link-editor-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.link-editor-icon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.link-editor-icon-preview {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  flex-shrink: 0;
}

.link-editor-icon-preview img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.link-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ========================================
   设置面板：新增控件
   ======================================== */
.settings-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-inline-row .settings-input {
  flex: 1;
  min-width: 0;
}

.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}

.settings-checkbox input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.settings-select {
  cursor: pointer;
}

.settings-select option {
  background: #1a1a22;
  color: var(--text-primary);
}

.settings-engines-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-engine-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-engine-name {
  width: 110px;
  flex-shrink: 0;
}

.settings-engine-url {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
}

.settings-link-move {
  flex-shrink: 0;
}

/* ========================================
   浅色主题
   ======================================== */
:root[data-theme="light"] {
  --bg-primary: #f4f4f5;
  --bg-card: rgba(0, 0, 0, 0.04);
  --bg-card-hover: rgba(0, 0, 0, 0.07);
  --bg-search: rgba(255, 255, 255, 0.8);
  --bg-search-focus: rgba(255, 255, 255, 0.98);
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.16);
  --accent-glow: rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .bg-gradient {
  background: linear-gradient(135deg, #e0e7ff 0%, #f4f4f5 45%, #fce7f3 100%);
}

[data-theme="light"] .bg-loading {
  background: #f4f4f5;
}

[data-theme="light"] .clock {
  background: linear-gradient(135deg, #18181b 0%, #52525b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: none;
}

[data-theme="light"] .greeting {
  color: #3f3f46;
  text-shadow: none;
}

[data-theme="light"] .date {
  color: #71717a;
  text-shadow: none;
}

[data-theme="light"] .hitokoto {
  text-shadow: none;
}

[data-theme="light"] .weather {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(0, 0, 0, 0.08);
  color: #3f3f46;
  text-shadow: none;
}

[data-theme="light"] .weather:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.14);
}

[data-theme="light"] .weather-temp {
  color: #18181b;
}

[data-theme="light"] .weather-sep {
  color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .weather-location {
  color: #71717a;
}

[data-theme="light"] .weather-panel,
[data-theme="light"] .engine-dropdown,
[data-theme="light"] .suggest-box,
[data-theme="light"] .opacity-slider-panel,
[data-theme="light"] .card-menu,
[data-theme="light"] .link-editor {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .weather-city-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .weather-panel-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .weather-panel-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #18181b;
}

[data-theme="light"] .search-box {
  background: var(--bg-search);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .search-box:focus-within {
  background: var(--bg-search-focus);
  border-color: var(--accent);
}

[data-theme="light"] .card-menu-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .card-menu-sep {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .link-card {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .link-card:hover {
  background: rgba(255, 255, 255, 0.98);
}

[data-theme="light"] .category-name {
  color: #27272a;
}

[data-theme="light"] .category-header:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .link-editor-icon-preview {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .modal {
  background: #fafafa;
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .settings-cat {
  background: rgba(0, 0, 0, 0.025);
}

[data-theme="light"] .settings-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .settings-select option {
  background: #ffffff;
  color: #18181b;
}

[data-theme="light"] .settings-icon-popup,
[data-theme="light"] .settings-cat-icon-popup {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .settings-icon-popup-btn,
[data-theme="light"] .settings-small-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .settings-btn {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.1);
  color: #52525b;
}

[data-theme="light"] .settings-btn:hover {
  background: #ffffff;
  color: #18181b;
}

[data-theme="light"] .opacity-toggle {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.1);
  color: #52525b;
}

[data-theme="light"] .drag-ghost {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--accent);
}

@media (max-width: 768px) {
  .link-editor {
    width: calc(100vw - 32px);
    left: 16px !important;
  }

  .settings-engine-name {
    width: 80px;
  }
}
