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

:root,
:root[data-theme="light"] {
  /* Light theme (default) */
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.82);
  --dropdown-bg: rgba(255, 255, 255, 0.96);
  --border-color: rgba(0, 0, 0, 0.08);
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --accent-cyan: #00d4ff;
  --accent-purple: #7b2fff;
  --accent-pink: #e040fb;
  --accent-green: #00e676;
  --accent-orange: #ff9100;
  --glow-cyan: rgba(0, 212, 255, 0.25);
  --glow-purple: rgba(123, 47, 255, 0.25);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-thumb: rgba(0, 0, 0, 0.12);
  --footer-muted: rgba(107, 114, 128, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #06060e;
    --bg-secondary: #0d0d1a;
    --bg-card: rgba(20, 20, 40, 0.6);
    --dropdown-bg: rgba(18, 18, 36, 0.96);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #e8e8f0;
    --text-secondary: #8b8fa3;
    --glow-cyan: rgba(0, 212, 255, 0.3);
    --glow-purple: rgba(123, 47, 255, 0.3);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb: rgba(255, 255, 255, 0.1);
    --footer-muted: rgba(139, 143, 163, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg-primary: #06060e;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(20, 20, 40, 0.6);
  --dropdown-bg: rgba(18, 18, 36, 0.96);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #8b8fa3;
  --glow-cyan: rgba(0, 212, 255, 0.3);
  --glow-purple: rgba(123, 47, 255, 0.3);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --footer-muted: rgba(139, 143, 163, 0.5);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* ========== Particle Canvas ========== */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ========== Main Container ========== */
.main-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ========== Header ========== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  flex-shrink: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-link {
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
}

.header-link:hover {
  color: var(--accent-cyan);
}

.btn-login {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #fff;
  border: none;
  padding: 7px 22px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
}

/* ========== Search Section ========== */
.search-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 12vh;
}

/* ========== Logo ========== */
.logo-area {
  text-align: center;
  margin-bottom: 36px;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.logo-icon {
  filter: drop-shadow(0 0 12px var(--glow-cyan));
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.logo-text {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px var(--glow-cyan));
  animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  0% { filter: drop-shadow(0 0 16px var(--glow-cyan)); }
  100% { filter: drop-shadow(0 0 32px rgba(0, 212, 255, 0.6)); }
}

.logo-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  letter-spacing: 4px;
  opacity: 0.8;
}

/* ========== Search Box ========== */
.search-box-wrapper {
  width: 100%;
  max-width: 640px;
  position: relative;
  z-index: 100;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1.5px solid var(--border-color);
  border-radius: 28px;
  padding: 6px 8px 6px 8px;
  transition: background-color 0.3s ease, border-color 0.3s, box-shadow 0.3s;
}

.search-box:focus-within {
  border-color: var(--accent-cyan);
  box-shadow:
    0 0 30px var(--glow-cyan),
    0 0 60px rgba(0, 212, 255, 0.1),
    inset 0 0 30px rgba(0, 212, 255, 0.03);
}

.search-box.focused .engine-collapse {
  max-width: 0;
  opacity: 0;
  margin-right: 0;
  pointer-events: none;
}

.search-box.focused .search-divider {
  width: 0;
  margin-left: 0;
  margin-right: 0;
  opacity: 0;
}

.search-box.focused .search-input {
  padding-left: 14px;
}

/* ========== Engine Selector ========== */
.engine-selector {
  position: relative;
  flex-shrink: 0;
  user-select: none;
}

.engine-collapse {
  max-width: 140px;
  overflow: hidden;
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              margin-right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.engine-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.engine-current:hover {
  background: var(--hover-bg);
}

.engine-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.engine-arrow {
  transition: transform 0.25s;
}

.engine-selector.open .engine-arrow {
  transform: rotate(180deg);
}

.engine-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: -4px;
  min-width: 140px;
  background: var(--dropdown-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s,
              background-color 0.4s ease, border-color 0.4s ease;
  z-index: 200;
}

.engine-selector.open .engine-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.engine-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.engine-option:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.engine-option.active {
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.08);
}

.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.engine-dot.bing { background: #00a4ef; box-shadow: 0 0 6px rgba(0, 164, 239, 0.5); }
.engine-dot.baidu { background: #4e6ef2; box-shadow: 0 0 6px rgba(78, 110, 242, 0.5); }
.engine-dot.google { background: #ea4335; box-shadow: 0 0 6px rgba(234, 67, 53, 0.5); }
.engine-dot.sogou { background: #ff7f00; box-shadow: 0 0 6px rgba(255, 127, 0, 0.5); }
.engine-dot.so360 { background: #2db400; box-shadow: 0 0 6px rgba(45, 180, 0, 0.5); }

.search-divider {
  width: 1px;
  height: 26px;
  background: var(--border-color);
  margin: 0 8px;
  flex-shrink: 0;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  padding: 10px 0;
  padding-left: 4px;
  min-width: 0;
  transition: padding-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

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

.btn-voice {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-voice:hover {
  background: var(--hover-bg);
}

.btn-voice.listening {
  background: rgba(0, 212, 255, 0.15);
}

.btn-voice.listening svg path {
  fill: var(--accent-cyan);
}

.btn-search {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-search:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.5);
}

/* ========== Search Suggestions ========== */
.search-suggestions {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s, visibility 0.25s, transform 0.25s,
              background-color 0.4s ease, border-color 0.4s ease;
  z-index: 10;
}

.search-suggestions.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.suggestion-item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

/* ========== AI Chips ========== */
.ai-chips {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.ai-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s;
}

.ai-chip:hover, .ai-chip.active {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  box-shadow: 0 0 16px var(--glow-cyan);
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.chip-dot.purple { background: var(--accent-purple); box-shadow: 0 0 6px var(--accent-purple); }
.chip-dot.green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.chip-dot.orange { background: var(--accent-orange); box-shadow: 0 0 6px var(--accent-orange); }
.chip-dot.pink { background: var(--accent-pink); box-shadow: 0 0 6px var(--accent-pink); }

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 20px 28px 24px;
  flex-shrink: 0;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

.footer-copy {
  font-size: 12px;
  color: var(--footer-muted);
}

.footer-copy a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-copy a:hover {
  color: var(--accent-cyan);
}

.footer-icp {
  font-size: 11px;
  color: var(--footer-muted);
  margin-top: 4px;
}

.footer-icp a {
  color: inherit;
  text-decoration: none;
}

.footer-icp a:hover {
  color: var(--text-secondary);
}

/* ========== Theme Toggle Button ========== */
.theme-toggle-btn {
  position: fixed;
  bottom: 104px;
  right: 36px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: var(--text-secondary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.4s ease,
              border-color 0.4s ease,
              box-shadow 0.3s ease,
              color 0.4s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 28px var(--glow-cyan), 0 0 40px rgba(0, 212, 255, 0.25);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.theme-toggle-btn:active {
  transform: scale(0.9);
}

/* Pulse ring */
.theme-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  animation: themePulse 3s ease-out infinite;
  opacity: 0;
}

.theme-toggle-btn:hover .theme-pulse {
  border-color: var(--accent-cyan);
  animation: themePulseHover 2s ease-out infinite;
}

@keyframes themePulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes themePulseHover {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.theme-icon {
  position: absolute;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease;
}

/* Default (light mode): sun visible, moon hidden */
.theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

/* Auto dark mode: moon visible, sun hidden */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
  }
  :root:not([data-theme="light"]) .theme-icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* Manual dark mode override */
:root[data-theme="dark"] .theme-icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
:root[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

@keyframes themeTogglePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.theme-toggle-btn.popping {
  animation: themeTogglePop 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== AI Assistant Floating Button ========== */
.ai-assistant-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
}

.ai-assistant-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(0, 212, 255, 0.6);
}

.ai-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(0, 212, 255, 0.5);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ========== AI Panel ========== */
.ai-panel {
  position: fixed;
  bottom: 104px;
  right: 32px;
  width: 400px;
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  z-index: 99;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px var(--glow-cyan);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s, opacity 0.3s, visibility 0.3s,
              background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
  transform-origin: bottom right;
}

.ai-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

.ai-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.ai-panel-header h3 {
  font-size: 16px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-close-panel {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: background 0.2s;
}

.btn-close-panel:hover {
  background: var(--hover-bg);
}

.ai-panel-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-message {
  display: flex;
  gap: 10px;
  animation: msgIn 0.3s ease-out;
}

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

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.ai-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 80%;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.ai-message-user {
  flex-direction: row-reverse;
}

.ai-message-user .ai-bubble {
  background: linear-gradient(135deg, var(--glow-cyan), var(--glow-purple));
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

.ai-panel-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.ai-panel-input input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: background-color 0.4s ease, border-color 0.2s;
}

.ai-panel-input input:focus {
  border-color: var(--accent-cyan);
}

#btnAiSend {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

#btnAiSend:hover {
  transform: scale(1.1);
}

/* ========== Scrollbar ========== */
.ai-panel-chat::-webkit-scrollbar {
  width: 4px;
}

.ai-panel-chat::-webkit-scrollbar-track {
  background: transparent;
}

.ai-panel-chat::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .logo-text { font-size: 40px; letter-spacing: 4px; }
  .logo-icon { width: 60px; height: 60px; }
  .search-box-wrapper { max-width: 90vw; }
  .header { padding: 12px 16px; }
  .header-left, .header-right { gap: 14px; }
  .ai-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 90px;
    height: 420px;
  }
  .theme-toggle-btn { bottom: 82px; right: 26px; width: 44px; height: 44px; }
  .theme-toggle-btn .theme-icon { width: 20px; height: 20px; }
  .ai-assistant-btn { bottom: 20px; right: 20px; }
  .footer-links { gap: 18px; }
  .ai-chips { gap: 6px; }
  .ai-chip { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .logo-text { font-size: 32px; }
  .logo-icon { width: 48px; height: 48px; }
  .logo-subtitle { font-size: 13px; letter-spacing: 2px; }
  .search-box { padding: 4px 6px; }
  .btn-search { padding: 8px 18px; font-size: 13px; }
}
