:root {
  --primary: #4DB6E8;
  --primary-light: #87CEFA;
  --primary-dark: #0288D1;
  --primary-glow: rgba(77, 182, 232, 0.35);
  --accent: #7C9EFF;
  --bg: #F0F8FF;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --text: #2C3E50;
  --text-light: #7B8FA0;
  --border: #E3F2FD;
  --shadow: 0 2px 12px rgba(77, 182, 232, 0.12);
  --radius: 14px;
  --card-padding: 16px;
  --card-gap: 16px;
  --sidebar-width: 220px;
  --sidebar-collapsed: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========== Sidebar ========== */
/* 侧边栏已废弃，改为顶部导航 */
.sidebar {
  display: none !important;
}

/* ========== Global Top Bar ========== */
.global-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.global-topbar .topbar-inner {
  width: 100%;
  max-width: 1920px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.global-topbar .topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.global-topbar .context:empty {
  display: none;
}

.global-topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 8px;
}


.global-topbar .nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.global-topbar .nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.global-topbar .nav a:hover,
.global-topbar .nav a.active {
  background: var(--bg);
  color: var(--primary-dark);
}

.global-topbar .context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.global-topbar .user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: 8px;
}

.global-topbar .user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  transition: background 0.2s;
  white-space: nowrap;
  cursor: pointer;
  overflow: visible;
}

.global-topbar .user-mini:hover {
  background: var(--bg);
}

.global-topbar .user-mini img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transform-origin: right top;
}

/* ========== User Menu Dropdown ========== */
.user-menu-wrap {
  position: relative;
  overflow: visible;
}

.user-menu-wrap .user-mini {
  overflow: visible;
}

.user-menu-wrap .user-mini svg {
  margin-left: 4px;
  opacity: 0.5;
  transition: transform 0.2s;
}

.user-menu-wrap.open .user-mini svg {
  transform: rotate(180deg);
}

.user-menu-wrap.open .user-mini img {
  transform: scale(2);
  transform-origin: right top;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border: 3px solid #fff;
  position: relative;
  z-index: 3000;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  left: -40px;
  right: 0;
  min-width: calc(100% + 40px);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border: 1px solid var(--border);
  z-index: 2000;
  padding: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.user-menu-wrap.open .user-dropdown {
  max-height: 300px;
  opacity: 1;
  padding: 42px 6px 6px;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}

.user-dropdown-item span {
  flex: 1;
}

.user-dropdown-arrow {
  opacity: 0.3;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.user-dropdown-item:hover .user-dropdown-arrow {
  opacity: 0.6;
  transform: translateX(2px);
}

.user-dropdown-item:hover {
  background: var(--bg);
}

.user-dropdown-danger {
  color: #e74c3c;
}

.user-dropdown-danger:hover {
  background: rgba(231, 76, 60, 0.08);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ========== Favorites Dropdown ========== */
.fav-topbar-wrap {
  position: relative;
}

.fav-topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  color: var(--text);
}

.fav-topbar-btn:hover {
  background: var(--bg);
}

.fav-topbar-btn:hover svg {
  animation: favBounce 0.4s ease;
}

@keyframes favBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.fav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  border: 1px solid var(--border);
  z-index: 2000;
  padding: 0;
  transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
}

.fav-topbar-wrap.open .fav-dropdown {
  max-height: 320px;
  overflow-y: auto;
  opacity: 1;
  padding: 6px;
  animation: favDropIn 0.2s ease;
}

@keyframes favDropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.fav-dropdown-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-light);
  font-size: 14px;
}

.fav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  transition: background 0.15s;
}

.fav-dropdown-item:hover {
  background: var(--bg);
}

.fav-dropdown-item img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
/* ========== Main Content ========== */
.main {
  margin-left: 0 !important;
  padding-top: 60px;
  min-height: 100vh;
}

/* 页面内二级 topbar 已废弃 */

/* ========== Content Area ========== */
.content {
  max-width: 1920px;
  margin: 0 auto;
  padding: 24px;
}

/* ========== Cards ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: var(--card-padding);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

/* ========== Filter Bar ========== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-label {
  font-size: 16px;
  color: var(--text-light);
  font-weight: 600;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(77, 182, 232, 0.3);
}

/* ========== AI Character Grid ========== */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--card-gap);
  margin-top: 20px;
}

.ai-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  position: relative;
}

.ai-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(77, 182, 232, 0.2);
}

.ai-card .avatar-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.ai-card .avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.ai-card:hover .avatar-wrap img {
  transform: scale(1.05);
}

.ai-card .avatar-wrap .placeholder-emoji {
  font-size: 80px;
}

.ai-card .info {
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-height: 0;
}

.ai-card .name {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.ai-card .desc {
  font-size: 16px;
  color: var(--text-light);
  line-height: 1.6;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-card .card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 16px;
  color: var(--text-light);
}
.ai-card .card-stats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ai-card .fav-btn {
  transition: transform 0.2s;
}
.ai-card .fav-btn:hover {
  transform: scale(1.15);
}

.ai-card.placeholder-card {
  border-style: dashed;
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(227,242,253,0.5), rgba(187,222,251,0.3));
}
.ai-card.placeholder-card:hover {
  transform: none;
  box-shadow: var(--shadow);
}

/* ========== Site Footer ========== */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding: 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  padding: 32px 24px;
  flex-wrap: wrap;
}

.footer-brand .footer-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.footer-brand p {
  font-size: 16px;
  color: var(--text-light);
  margin-top: 6px;
  line-height: 1.6;
}

.footer-links {
  display: flex;
  gap: 48px;
}

.footer-col h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  font-size: 16px;
  color: var(--text-light);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.2s;
}

.footer-col a:hover {
  color: var(--primary);
}

.footer-bottom {
  text-align: center;
  padding: 16px 24px;
  color: var(--text-light);
  font-size: 16px;
  border-top: 1px solid var(--border);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(77, 182, 232, 0.45);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--border);
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========== Chat Page ========== */
.chat-layout {
  display: flex;
  height: calc(100vh - 60px - 48px);
  gap: 16px;
}

.chat-left {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-right {
  width: 260px;
}

.chat-messages {
  flex: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-top-right-radius: 4px;
}

.msg-bubble.ai {
  align-self: flex-start;
  background: #f5f5f5;
  color: var(--text);
  border-top-left-radius: 4px;
}

.msg-meta {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: 4px;
  opacity: 0.7;
}

.msg-bubble.user .msg-meta {
  color: rgba(255, 255, 255, 0.85);
}

.chat-input-area {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.chat-input-area textarea {
  flex: 1;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  resize: none;
  height: 56px;
}

.chat-input-area textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.model-viewer {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.model-viewer .placeholder-img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .chat-left, .chat-right {
    display: none;
  }
  .ai-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar .title,
  .sidebar .label,
  .sidebar .user-mini .info {
    display: none;
  }
  .main {
    margin-left: var(--sidebar-collapsed);
  }
  .toggle-btn {
    display: none;
  }
}

/* ========== Utility ========== */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* Toast */
.toast-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 28px;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  pointer-events: auto;
  text-align: center;
  min-width: 180px;
}

.toast.success { background: #66BB6A; }
.toast.error { background: #EF5350; }
.toast.info { background: var(--primary); }

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-20px); opacity: 0; }
}

.toast.fade-out {
  animation: slideOut 0.3s ease forwards;
}

/* ========== 二次元 Decorative ========== */
.ai-card:hover .avatar-wrap {
  box-shadow: 0 0 20px var(--primary-glow), 0 0 40px rgba(77, 182, 232, 0.15);
}

/* Glow border for character avatars */
.glow-avatar {
  border: 2px solid rgba(77, 182, 232, 0.4);
  box-shadow: 0 0 12px rgba(77, 182, 232, 0.3), 0 0 24px rgba(77, 182, 232, 0.15);
  transition: box-shadow 0.3s ease;
}

.glow-avatar:hover {
  box-shadow: 0 0 18px rgba(77, 182, 232, 0.5), 0 0 36px rgba(77, 182, 232, 0.25);
}

/* Star/Note nav hover decoration */
.global-topbar .nav a {
  position: relative;
}

.global-topbar .nav a:hover::before {
  content: '\2726';
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: 16px;
  color: var(--primary);
  animation: starPop 0.3s ease-out;
}

@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Falling particles background */
@keyframes fallParticle {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

.particle-field {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle-field .particle {
  position: absolute;
  font-size: 16px;
  opacity: 0;
  will-change: transform, opacity;
  animation: fallParticle linear infinite;
}

/* Character tag styles */
.char-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.char-tag.tycoon { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.char-tag.gentle { background: rgba(77, 182, 232, 0.15); color: #4DB6E8; }
.char-tag.genki { background: rgba(255, 193, 7, 0.15); color: #f0a030; }
.char-tag.cool { background: rgba(124, 158, 255, 0.15); color: #7C9EFF; }
.char-tag.cunning { background: rgba(156, 39, 176, 0.15); color: #9C27B0; }
.char-tag.airhead { background: rgba(255, 183, 77, 0.15); color: #FFB74D; }
.char-tag.yandere { background: rgba(211, 47, 47, 0.15); color: #D32F2F; }
.char-tag.kuudere { background: rgba(96, 125, 139, 0.15); color: #607D8B; }
.char-tag.healing { background: rgba(129, 199, 132, 0.15); color: #81C784; }

/* ========== Mobile Responsive ========== */
@media (max-width: 640px) {
  .global-topbar .topbar-inner {
    padding: 0 16px;
  }

  .global-topbar .topbar-left {
    min-width: 0;
    overflow: hidden;
  }

  .global-topbar .nav {
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 1;
    min-width: 0;
  }

  .global-topbar .nav::-webkit-scrollbar {
    display: none;
  }

  .global-topbar .nav a {
    padding: 6px 10px;
    font-size: 16px;
  }

  .global-topbar .user-mini span {
    display: none;
  }

  .fav-dropdown {
    left: auto;
    right: 0;
  }

  .user-dropdown {
    left: auto;
    right: -20px;
    min-width: 200px;
  }

  .content {
    padding: 16px;
  }

  .ai-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  .ai-grid > * {
    min-width: 0;
  }

  .ai-card .card-tags {
    font-size: 12px;
  }

  .ai-card .card-tag {
    padding: 2px 6px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .ai-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== SVG Icon System ========== */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon.icon-filled svg {
  fill: currentColor;
  stroke: none;
}

.icon-sm { font-size: 16px; }
.icon-md { font-size: 18px; }
.icon-lg { font-size: 24px; }

/* Particle SVG styles */
.particle-field .particle svg {
  width: 100%;
  height: 100%;
}
