/* ============ 主题变量 ============ */
:root {
  --bg: #1a1a2e;
  --bg-2: #16213e;
  --bg-3: #0f0f1e;
  --text: #e8e4d9;
  --text-2: #a8a296;
  --gold: #d4af37;
  --gold-2: #b8941f;
  --cinnabar: #c0392b;
  --border: rgba(212, 175, 55, 0.18);
  --card: rgba(30, 30, 55, 0.72);
  --card-hover: rgba(40, 40, 72, 0.88);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 8px;
  --font-title: "Songti SC", "STSong", "SimSun", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --transition: 0.25s ease;
}

body[data-theme="light"] {
  --bg: #f5f0e8;
  --bg-2: #ede6d8;
  --bg-3: #e8e0ce;
  --text: #3d2914;
  --text-2: #6b5a3e;
  --gold: #b8941f;
  --gold-2: #8a6d14;
  --cinnabar: #a83224;
  --border: rgba(61, 41, 20, 0.15);
  --card: rgba(255, 252, 245, 0.85);
  --card-hover: rgba(255, 255, 255, 0.98);
  --shadow: 0 4px 20px rgba(61, 41, 20, 0.1);
}

/* ============ 基础重置 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; display: block; }

/* ============ 星空背景 ============ */
.star-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(212, 175, 55, 0.06), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(192, 57, 43, 0.05), transparent 50%),
    radial-gradient(ellipse at 50% 50%, var(--bg-2), var(--bg-3));
}

.star-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 35% 85%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 90% 50%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 10% 60%, rgba(255,255,255,0.35), transparent);
  background-size: 100% 100%;
  opacity: 0.7;
}

body[data-theme="light"] .star-bg::after { opacity: 0.15; }

/* ============ 导航 ============ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 26, 46, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

body[data-theme="light"] .nav { background: rgba(245, 240, 232, 0.9); }

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.logo-icon { font-size: 1.4rem; }

.nav-links {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--text-2);
  transition: color var(--transition);
  position: relative;
}

.nav-links a:hover,
.nav-links a.active { color: var(--gold); }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--gold);
  transform: rotate(20deg);
}

.lang-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.lang-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
}

/* ============ 容器 ============ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ============ Hero ============ */
.hero {
  text-align: center;
  padding: 2.5rem 0 2rem;
}

.hero-title {
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
  margin-bottom: 0.5rem;
}

.hero-sub {
  color: var(--text-2);
  font-size: 0.95rem;
  letter-spacing: 0.2em;
}

/* ============ 功能卡片 ============ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.feature-card:hover {
  background: var(--card-hover);
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.feature-card:hover::before { opacity: 1; }

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.3));
}

.feature-name {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
  letter-spacing: 0.08em;
}

.feature-desc {
  font-size: 0.85rem;
  color: var(--text-2);
}

/* ============ 面板 ============ */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.panel-head {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(212, 175, 55, 0.04);
}

.panel-head h3 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.panel-body { padding: 1.25rem; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #1a1a2e;
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ============ 输入框 ============ */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}

body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] textarea {
  background: rgba(255, 255, 255, 0.6);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

/* ============ 快捷起卦 ============ */
.hint { color: var(--text-2); font-size: 0.88rem; margin-bottom: 0.75rem; }

.quick-input {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.quick-input input { flex: 1; min-width: 100px; }
.quick-input .btn { flex-shrink: 0; }

.quick-result {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.9;
}

.quick-result .gua-name {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

/* ============ 今日干支 ============ */
.ganzhi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.ganzhi-item {
  text-align: center;
  padding: 0.6rem 0.5rem;
  background: rgba(212, 175, 55, 0.05);
  border-radius: var(--radius-sm);
}

.gz-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-2);
  margin-bottom: 0.2rem;
  letter-spacing: 0.05em;
}

.gz-value {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--gold);
}

/* ============ 每日一签 ============ */
.daily-lot { text-align: center; }

.daily-lot .lot-text {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--gold);
  line-height: 2;
  margin: 1rem 0;
  padding: 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.daily-lot .lot-level {
  display: inline-block;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--gold);
  color: var(--gold);
  margin-bottom: 0.5rem;
}

/* ============ 广告位 ============ */
.ad-slot {
  margin: 1.25rem 0;
  min-height: 60px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}

.ad-slot:empty::after { content: "广告位"; }

.ad-slot-top { min-height: 70px; }
.ad-slot-bottom { min-height: 90px; }

/* ============ 底部 ============ */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  margin-top: 2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-2);
}

.footer-links a:hover { color: var(--gold); }
.footer-links .sep { margin: 0 0.5rem; opacity: 0.5; }

.footer-friends {
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-2);
  opacity: 0.85;
}

.footer-friends .friends-label {
  color: var(--gold);
  margin-right: 0.35rem;
}

.footer-friends a {
  color: var(--text-2);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-friends a:hover { color: var(--gold); }
.footer-friends .sep { margin: 0 0.4rem; opacity: 0.5; }

.footer-disclaimer {
  font-size: 0.8rem;
  color: var(--text-2);
  max-width: 640px;
  margin: 0 auto 0.75rem;
  line-height: 1.7;
}

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-2);
  opacity: 0.7;
}

/* ============ 返回顶部 ============ */
.back-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  z-index: 90;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}

.back-top:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* ============ 加载动画 ============ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-2);
  font-size: 0.9rem;
}

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .nav-links { gap: 0.85rem; font-size: 0.88rem; }
  .logo-text { display: none; }
  .container { padding: 1rem 1rem 2.5rem; }
  .hero { padding: 1.75rem 0 1.25rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .quick-input { flex-direction: column; }
  .quick-input .btn { width: 100%; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}
