/* ===== 公共样式 — 导航栏、暗色模式、Toast、响应式 ===== */

/* === CSS 变量 === */
:root {
  --coral: #e94560;
  --coral-light: #ff6b81;
  --purple: #7c5ce7;
  --teal: #0abda0;
  --text: #2c2c3a;
  --text-light: #6b6b7a;
  --text-muted: #999aaa;
  --bg-glass: rgba(255,255,255,0.75);
  --border-glass: rgba(0,0,0,0.06);
  --shadow-nav: 0 1px 8px rgba(0,0,0,0.04);
  --radius-sm: 8px;
}

/* === 背景 === */
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: linear-gradient(135deg, #fef5f0 0%, #fdf2f8 25%, #f5f0fa 50%, #f0f4fa 75%, #fef9f5 100%);
  background-attachment: fixed;
  transition: background 0.3s, color 0.3s;
}
body.dark {
  color: #ccc;
  background: linear-gradient(180deg, rgba(26,26,46,0.95), rgba(26,26,46,0.98)), url("/diary-bg.jpg") center/cover fixed;
}

/* === 背景装饰 === */
.bg-blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.25; animation: blobFloat 12s ease-in-out infinite; }
.bg-blob:nth-child(1) { width: 500px; height: 500px; top: -150px; left: -100px; background: radial-gradient(circle, rgba(233,69,96,0.2), transparent); }
.bg-blob:nth-child(2) { width: 400px; height: 400px; top: 30%; right: -120px; background: radial-gradient(circle, rgba(124,92,231,0.15), transparent); animation-delay: -4s; }
.bg-blob:nth-child(3) { width: 450px; height: 450px; bottom: -100px; left: 30%; background: radial-gradient(circle, rgba(10,189,160,0.12), transparent); animation-delay: -8s; }
@keyframes blobFloat { 0%,100% { transform: translate(0,0) scale(1); } 25% { transform: translate(40px,-30px) scale(1.08); } 50% { transform: translate(-20px,20px) scale(0.94); } 75% { transform: translate(30px,10px) scale(1.04); } }

/* === 导航栏（毛玻璃统一风格）=== */
.navbar {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 210;
  border-bottom: 1px solid var(--border-glass);
  box-shadow: var(--shadow-nav);
}
body.dark .navbar {
  background: rgba(22,33,62,0.85);
  border-bottom-color: rgba(255,255,255,0.06);
}
.navbar .logo {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--coral), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.navbar ul {
  list-style: none;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.navbar a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}
.navbar a:hover { color: var(--coral); }
.navbar a.active { color: var(--coral); font-weight: 600; }

/* === 主题切换按钮 === */
#themeToggle, .theme-toggle {
  background: rgba(0,0,0,0.04);
  color: var(--text-light);
  border: 1px solid rgba(0,0,0,0.1);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.25s;
  white-space: nowrap;
}
body.dark #themeToggle, body.dark .theme-toggle {
  background: rgba(255,255,255,0.08);
  color: #ccc;
  border-color: rgba(255,255,255,0.15);
}
#themeToggle:hover, .theme-toggle:hover { border-color: var(--coral); color: var(--coral); }

/* === 用户显示 === */
#userDisplay { color: var(--coral); font-weight: 600; }
body.dark #userDisplay { color: #ff6b81; }

/* === 汉堡菜单 === */
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 26px; cursor: pointer; padding: 4px 8px; touch-action: manipulation; }
body.dark .hamburger { color: #ccc; }
.overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 199; pointer-events: none; }
.overlay.show { display: block; }
.menu-close { display: none; text-align: right; font-size: 22px; cursor: pointer; color: #888; margin-bottom: 8px; }
.menu-close:hover { color: var(--coral); }

/* === Toast === */
#toast {
  position: fixed; bottom: 30px; right: 30px; z-index: 1001;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  color: var(--text); padding: 0.85rem 1.4rem; border-radius: var(--radius-sm);
  opacity: 0; transform: translateY(20px);
  transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1.2);
  pointer-events: none;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  font-size: 0.9rem;
}
body.dark #toast { background: rgba(30,30,50,0.95); color: #ddd; border-color: rgba(255,255,255,0.08); }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { border-left: 3px solid #ff4757; }

/* === Loading === */
.loading-wrap { text-align: center; padding: 40px; }
.loading {
  display: inline-block; width: 24px; height: 24px;
  border: 2px solid #ddd; border-top-color: var(--coral);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === 响应式 === */
@media (max-width: 768px) {
  .hamburger { display: block; }
  .menu-close { display: block; }
  .overlay { display: none !important; }
  .navbar {
    padding: 0 1rem;
    background: rgba(255,255,255,0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 999;
    isolation: isolate;
  }
  body.dark .navbar { background: rgba(20,20,40,0.98); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .navbar ul {
    display: none;
    position: fixed; top: 0; right: 0;
    width: 200px; height: 100vh;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(16px);
    flex-direction: column;
    padding: 20px 16px; gap: 4px;
    z-index: 220;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
  }
  body.dark .navbar ul { background: rgba(20,20,40,0.98); }
  .navbar ul.open { display: flex; }
  #toast { bottom: 20px; right: 16px; left: 16px; padding: 0.7rem 1rem; font-size: 0.82rem; }
  .bg-blob:nth-child(1) { width: 300px; height: 300px; }
  .bg-blob:nth-child(2) { width: 250px; height: 250px; }
  .bg-blob:nth-child(3) { width: 280px; height: 280px; }
}

/* === 通用按钮 === */
button, a { touch-action: manipulation; }
