/* ===================================================================
   Mystic Tao / 玄机 — Dark Taoist Theme
   Ancient oracle meets Swiss design
   =================================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700;900&family=Noto+Sans+SC:wght@300;400;500;700&family=ZCOOL+XiaoWei&display=swap');

/* ===================================================================
   CSS Custom Properties
   =================================================================== */
:root {
  /* Background layers */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a28;
  --bg-hover: #222235;
  --bg-input: #151520;

  /* Text */
  --text-primary: #e8e0d0;
  --text-secondary: #a09880;
  --text-muted: #6a6050;
  --text-heading: #f0e8d8;

  /* Accent */
  --accent-gold: #c9a96e;
  --accent-red: #b33a3a;
  --accent-gold-dim: #8a7548;
  --accent-gold-glow: rgba(201, 169, 110, 0.25);
  --accent-red-dim: #7a2828;

  /* Borders & shadows */
  --border: #2a2a3a;
  --border-gold: rgba(201, 169, 110, 0.3);
  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-gold: rgba(201, 169, 110, 0.1);

  /* Five Elements 五行 */
  --wu-mu: #4ade80;
  --wu-huo: #ef4444;
  --wu-tu: #eab308;
  --wu-jin: #f59e0b;
  --wu-shui: #3b82f6;

  --wu-mu-bg: rgba(74, 222, 128, 0.08);
  --wu-huo-bg: rgba(239, 68, 68, 0.08);
  --wu-tu-bg: rgba(234, 179, 8, 0.08);
  --wu-jin-bg: rgba(245, 158, 11, 0.08);
  --wu-shui-bg: rgba(59, 130, 246, 0.08);

  /* Typography */
  --font-heading: 'ZCOOL XiaoWei', 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', serif;
  --font-mono: 'Noto Serif SC', 'STKaiti', serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --transition-reveal: 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* --- Noise / grain texture overlay --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- Radial glow centered on content --- */
body::after {
  content: '';
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 700px;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(201, 169, 110, 0.04) 0%,
    rgba(201, 169, 110, 0.015) 35%,
    transparent 70%
  );
}

/* Ensure all content sits above overlays */
body > * {
  position: relative;
  z-index: 1;
}

/* ===================================================================
   Typography
   =================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  line-height: 1.3;
  font-weight: 600;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
h4 { font-size: clamp(1rem, 2vw, 1.2rem); }

p {
  color: var(--text-secondary);
  line-height: 1.7;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--text-heading);
}

/* ===================================================================
   Layout
   =================================================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-3xl) 0;
}

/* Gold thin divider */
.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-gold) 20%,
    var(--accent-gold-dim) 50%,
    var(--border-gold) 80%,
    transparent 100%
  );
  margin: var(--space-xl) 0;
  border: none;
}

/* ===================================================================
   Header
   =================================================================== */
.site-header {
  text-align: center;
  padding: var(--space-3xl) 0 var(--space-xl);
  position: relative;
}

.site-title {
  font-family: var(--font-heading);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 0.15em;
  text-shadow:
    0 0 40px rgba(201, 169, 110, 0.2),
    0 0 80px rgba(201, 169, 110, 0.08);
  margin-bottom: var(--space-sm);
  user-select: none;
}

.site-subtitle {
  font-family: var(--font-serif);
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  color: var(--text-muted);
  letter-spacing: 0.4em;
  font-weight: 400;
}

/* --- Tab navigation --- */
.nav-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}

.nav-tab {
  font-family: var(--font-serif);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  padding: 0.6em 1.6em;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  letter-spacing: 0.1em;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.nav-tab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(201, 169, 110, 0.06) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity var(--transition-base);
}

.nav-tab:hover {
  border-color: var(--accent-gold-dim);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-tab:hover::before {
  opacity: 1;
}

.nav-tab.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: var(--bg-hover);
  box-shadow:
    0 0 12px rgba(201, 169, 110, 0.1),
    inset 0 1px 0 rgba(201, 169, 110, 0.15);
}

.nav-tab.active::before {
  opacity: 1;
}

.nav-tab.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-tab.disabled:hover {
  border-color: var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
}

/* ===================================================================
   Input Form
   =================================================================== */
.input-section {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-xl) 0;
}

.input-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  position: relative;
}

.input-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--border-gold),
    transparent
  );
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md) var(--space-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  padding-left: 2px;
}

/* Label row with inline toggle (e.g. 出生日期 [公历|农历]) */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

/* Shared input styles */
.form-select,
.form-input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65em 0.9em;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236a6050' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 12px;
  padding-right: 2.2em;
  cursor: pointer;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--accent-gold-dim);
  box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.1);
}

.form-select:hover,
.form-input:hover {
  border-color: rgba(201, 169, 110, 0.25);
}

/* Date row — three selects side by side */
.date-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr;
  gap: var(--space-sm);
}

/* Gender toggle */
.gender-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.gender-btn {
  flex: 1;
  padding: 0.65em 0;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  text-align: center;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.1em;
}

.gender-btn:first-child {
  border-right: 1px solid var(--border);
}

.gender-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.gender-btn.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-weight: 500;
}

/* Submit button */
.btn-paipan {
  grid-column: 1 / -1;
  margin-top: var(--space-sm);
  padding: 0.85em 2em;
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--bg-primary);
  background: linear-gradient(135deg, var(--accent-gold), #d4b87a);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-paipan::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-gold), #d4b87a);
  opacity: 0;
  filter: blur(12px);
  transition: opacity var(--transition-base);
  z-index: -1;
}

.btn-paipan:hover {
  transform: translateY(-1px);
  box-shadow:
    0 4px 20px rgba(201, 169, 110, 0.3),
    0 0 40px rgba(201, 169, 110, 0.15);
}

.btn-paipan:hover::before {
  opacity: 1;
}

.btn-paipan:active {
  transform: translateY(0);
}

.btn-paipan:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===================================================================
   Results Section
   =================================================================== */
#resultSection {
  display: none;
  opacity: 0;
  animation: fadeSlideIn var(--transition-reveal) forwards;
}

#resultSection.visible {
  display: block;
}

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

/* Input summary line below heading */
.input-summary {
  display: none;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: calc(-1 * var(--space-md));
  margin-bottom: var(--space-lg);
}

/* Section headings inside results */
.result-heading {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  color: var(--accent-gold);
  text-align: center;
  margin-bottom: var(--space-lg);
  letter-spacing: 0.12em;
  position: relative;
}

.result-heading::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: var(--accent-gold-dim);
  margin: var(--space-sm) auto 0;
}

/* ===================================================================
   Four Pillars (四柱)
   =================================================================== */
#pillarsContainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  max-width: 720px;
  margin: 0 auto var(--space-2xl);
}

.pillar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  transition: all var(--transition-base);

  /* Stagger animation */
  opacity: 0;
  transform: translateY(20px);
  animation: pillarReveal 500ms ease forwards;
}

.pillar-card:nth-child(1) { animation-delay: 100ms; }
.pillar-card:nth-child(2) { animation-delay: 200ms; }
.pillar-card:nth-child(3) { animation-delay: 300ms; }
.pillar-card:nth-child(4) { animation-delay: 400ms; }

@keyframes pillarReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pillar-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
}

.pillar-card:hover {
  border-color: var(--border-gold);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    0 0 24px var(--shadow-gold),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.pillar-label {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-bottom: var(--space-md);
}

.pillar-shishen {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  min-height: 1.2em;
}

/* Tiangan (Heavenly Stem) */
/* Use Noto Serif SC instead of ZCOOL XiaoWei for large characters —
   ZCOOL XiaoWei renders 己(jǐ) identically to 巳(sì), causing confusion */
.pillar-gan {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
  padding: var(--space-sm) 0;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

/* Dizhi (Earthly Branch) */
.pillar-zhi {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  padding: var(--space-sm) 0;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

/* Hidden stems (藏干) */
.pillar-canggan {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  min-height: 1.5em;
}

.pillar-canggan span {
  margin: 0 2px;
}

/* Dishi (地势/长生) */
.pillar-dishi {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

/* Nayin (纳音) */
.pillar-nayin {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Five Element color coding classes */
.wu-mu  { color: var(--wu-mu);  }
.wu-huo { color: var(--wu-huo); }
.wu-tu  { color: var(--wu-tu);  }
.wu-jin { color: var(--wu-jin); }
.wu-shui { color: var(--wu-shui); }

.wu-mu-bg  { background-color: var(--wu-mu-bg);  }
.wu-huo-bg { background-color: var(--wu-huo-bg); }
.wu-tu-bg  { background-color: var(--wu-tu-bg);  }
.wu-jin-bg { background-color: var(--wu-jin-bg); }
.wu-shui-bg { background-color: var(--wu-shui-bg); }

/* ===================================================================
   Five Elements Distribution (五行分布)
   =================================================================== */
#wuxingChart {
  max-width: 560px;
  margin: 0 auto var(--space-2xl);
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.wuxing-bar-group {
  margin-bottom: var(--space-md);
}

.wuxing-bar-group:last-child {
  margin-bottom: 0;
}

.wuxing-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.wuxing-bar-name {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.wuxing-bar-name .element-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.wuxing-bar-count {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wuxing-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-primary);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.wuxing-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 800ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 0;
  position: relative;
}

.wuxing-bar-fill.animate {
  /* width set via inline style by JS */
}

.wuxing-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15));
  border-radius: 0 5px 5px 0;
}

/* Day master strength indicator */
.daymaster-strength {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.daymaster-strength .label {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.daymaster-strength .value {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--accent-gold);
  margin-left: var(--space-sm);
}

/* ===================================================================
   Special Palaces (命宫 · 身宫 · 胎元 · 空亡)
   =================================================================== */
#specialPalaces {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  max-width: 720px;
  margin: 0 auto var(--space-2xl);
}

.palace-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  transition: all var(--transition-base);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.palace-card:hover {
  border-color: var(--border-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.palace-label {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

.palace-value {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  color: var(--text-heading);
}

/* ===================================================================
   Da Yun Timeline (大运)
   =================================================================== */
#daYunTimeline {
  margin: 0 auto var(--space-2xl);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-md) 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold-dim) var(--bg-secondary);
}

#daYunTimeline::-webkit-scrollbar {
  height: 4px;
}

#daYunTimeline::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 2px;
}

#daYunTimeline::-webkit-scrollbar-thumb {
  background: var(--accent-gold-dim);
  border-radius: 2px;
}

.dayun-track {
  display: flex;
  gap: var(--space-sm);
  min-width: max-content;
  padding: 0 var(--space-sm);
}

.dayun-item {
  flex-shrink: 0;
  width: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-sm);
  text-align: center;
  transition: all var(--transition-base);
  cursor: default;
}

.dayun-item.clickable {
  cursor: pointer;
}

.dayun-item:hover {
  border-color: var(--border-gold);
  background: var(--bg-hover);
}

.dayun-item.current {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(201, 169, 110, 0.15);
  background: var(--bg-hover);
}

.dayun-item.expanded {
  border-color: var(--accent-gold);
  background: var(--bg-hover);
  box-shadow: 0 0 16px rgba(201, 169, 110, 0.15);
}

.dayun-shishen {
  font-family: var(--font-serif);
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  letter-spacing: 0.05em;
}

.dayun-age {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.dayun-ganzhi {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: 1.3rem;
  line-height: 1.3;
  margin-bottom: var(--space-xs);
}

.dayun-ganzhi .gan {
  display: block;
}

.dayun-ganzhi .zhi {
  display: block;
}

.dayun-years {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ===================================================================
   AI Interpretation Section
   =================================================================== */
#aiSection {
  max-width: 720px;
  margin: 0 auto var(--space-2xl);
  text-align: center;
}

.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.8em 2.4em;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent-gold);
  background: transparent;
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-ai::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-gold), transparent, var(--accent-gold));
  opacity: 0;
  filter: blur(16px);
  transition: opacity var(--transition-slow);
  z-index: -1;
}

.btn-ai:hover {
  background: rgba(201, 169, 110, 0.08);
  box-shadow: 0 0 30px rgba(201, 169, 110, 0.12);
  transform: translateY(-1px);
}

.btn-ai:hover::before {
  opacity: 1;
}

.btn-ai .ai-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

.btn-ai.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-ai.loading .btn-ai-text::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  animation: aiDots 1.4s infinite;
}

@keyframes aiDots {
  0%, 80%, 100% { opacity: 0; transform: scale(0.6); }
  40% { opacity: 1; transform: scale(1); }
}

/* AI response area */
.ai-response {
  display: none;
  margin-top: var(--space-xl);
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  max-height: 500px;
  overflow-y: auto;
  line-height: 1.8;
  font-size: 0.95rem;
  color: var(--text-primary);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.ai-response.visible {
  display: block;
  animation: fadeSlideIn 400ms ease forwards;
}

/* ===================================================================
   Footer
   =================================================================== */
.site-footer {
  text-align: center;
  padding: var(--space-2xl) 0 var(--space-xl);
  border-top: 1px solid var(--border);
}

.footer-brand {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--accent-gold-dim);
  letter-spacing: 0.15em;
  margin-bottom: var(--space-sm);
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}

.footer-credits {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ===================================================================
   Loading / Spinner
   =================================================================== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

/* ===================================================================
   Tab Panels
   =================================================================== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeSlideIn 400ms ease forwards;
}

/* Placeholder for inactive tabs */
.coming-soon {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.coming-soon h3 {
  color: var(--text-muted);
  font-size: 1.3rem;
  margin-bottom: var(--space-sm);
}

.coming-soon p {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.9rem;
}

/* ===================================================================
   Responsive — Tablet
   =================================================================== */
@media (max-width: 960px) {
  #pillarsContainer {
    gap: var(--space-sm);
  }

  #specialPalaces {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===================================================================
   Responsive — Mobile
   =================================================================== */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-md);
  }

  .site-header {
    padding: var(--space-2xl) 0 var(--space-lg);
  }

  .site-title {
    letter-spacing: 0.1em;
  }

  .site-subtitle {
    letter-spacing: 0.2em;
    font-size: 0.8rem;
  }

  .nav-tabs {
    gap: var(--space-xs);
  }

  .nav-tab {
    padding: 0.5em 1em;
    font-size: 0.82rem;
  }

  .input-card {
    padding: var(--space-lg) var(--space-md);
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  #pillarsContainer {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    max-width: 400px;
  }

  .pillar-gan,
  .pillar-zhi {
    font-size: 2rem;
  }

  #specialPalaces {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .dayun-item {
    width: 76px;
    padding: var(--space-sm) var(--space-xs);
  }

  .dayun-ganzhi {
    font-size: 1.1rem;
  }

  .ai-response {
    padding: var(--space-lg);
  }

  .btn-paipan {
    font-size: 1rem;
    letter-spacing: 0.15em;
  }
}

/* ===================================================================
   Responsive — Small phones
   =================================================================== */
@media (max-width: 420px) {
  .site-title {
    font-size: 2.5rem;
  }

  /* Stack label and calendar toggle vertically on small phones */
  .form-label-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .calendar-toggle {
    align-self: flex-start;
  }

  .cal-btn {
    font-size: 0.78rem;
    padding: var(--space-xs) var(--space-sm);
  }

  .date-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
  }

  .date-row > *:first-child {
    grid-column: 1 / -1;
  }

  #pillarsContainer {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
  }

  .pillar-card {
    padding: var(--space-md) var(--space-sm);
  }
}

/* ===================================================================
   Utility / Helper Classes
   =================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-gold { color: var(--accent-gold); }
.text-red  { color: var(--accent-red); }
.text-muted { color: var(--text-muted); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ===================================================================
   Analysis Cards (格局/用神/合冲/神煞/解读)
   =================================================================== */
.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  animation: fadeSlideIn var(--transition-reveal) both;
}

.analysis-loading {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}

/* Pattern (格局) */
.pattern-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
}

.pattern-desc {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.92rem;
}

.dm-strength {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dm-strength .strong { color: var(--wu-huo); }
.dm-strength .weak { color: var(--wu-shui); }

/* Yong Shen / Ji Shen (用神/忌神) */
.yongshen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.yongshen-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-gold);
}

.yongshen-item.ji {
  border-left-color: var(--accent-red);
}

.yongshen-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-xs);
}

.yongshen-element {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: var(--space-xs);
}

.yongshen-reason {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* He Chong (合冲刑害) */
.hechong-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.hechong-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  font-size: 0.9rem;
}

.hechong-type {
  font-weight: 600;
  color: var(--accent-gold);
  min-width: 3em;
}

.hechong-type.chong { color: var(--accent-red); }
.hechong-type.xing { color: #e97451; }
.hechong-type.hai { color: #c084fc; }

.hechong-display {
  color: var(--text-primary);
}

.hechong-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}

/* Shen Sha (神煞) */
.shensha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-sm);
}

.shensha-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  font-size: 0.88rem;
}

.shensha-name {
  font-weight: 600;
  color: var(--text-primary);
}

.shensha-type {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.shensha-type.ji { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.shensha-type.xiong { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.shensha-type.zhong { background: rgba(234, 179, 8, 0.15); color: #eab308; }

.shensha-pillar {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: auto;
}

/* Interpretation (解读) */
.interpret-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.interpret-block {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.interpret-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border);
}

.interpret-content {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.9;
  white-space: pre-wrap;
}

/* Responsive: analysis cards */
@media (max-width: 768px) {
  .yongshen-grid {
    grid-template-columns: 1fr;
  }
  .shensha-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================================================================
   Calendar Toggle (公历/农历) — styled consistent with gender toggle
   =================================================================== */
.calendar-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cal-btn {
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: none;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.1em;
}

.cal-btn:first-child {
  border-right: 1px solid var(--border);
}

.cal-btn.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-weight: 500;
}

.cal-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===================================================================
   History Section
   =================================================================== */
.history-section {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.history-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--accent-gold);
  margin-bottom: var(--space-md);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

.history-item:hover {
  background: var(--bg-hover);
  border-left-color: var(--accent-gold);
}

.history-main {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
}

.history-cal-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(201, 169, 110, 0.15);
  color: var(--accent-gold);
  white-space: nowrap;
}

.history-date {
  color: var(--text-primary);
  font-weight: 500;
}

.history-gender {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-xs);
  font-size: 0.78rem;
}

.history-pillars {
  color: var(--text-secondary);
  font-family: var(--font-serif);
  letter-spacing: 0.1em;
}

.history-time {
  color: var(--text-muted);
}

.history-clear {
  display: block;
  margin-top: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
}

.history-clear:hover {
  color: var(--accent-red);
  border-color: var(--accent-red-dim);
}

/* ===================================================================
   User Bar (header auth status)
   =================================================================== */
.user-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-md);
}

.user-bar-state {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-bar-welcome {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.user-bar-login,
.user-bar-logout {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  padding: 0.3em 1em;
  background: transparent;
  color: var(--accent-gold);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.08em;
}

.user-bar-login:hover,
.user-bar-logout:hover {
  background: rgba(201, 169, 110, 0.1);
  border-color: var(--accent-gold);
}

.user-bar-logout {
  color: var(--text-muted);
  border-color: var(--border);
}

.user-bar-logout:hover {
  color: var(--accent-red);
  border-color: var(--accent-red-dim);
  background: rgba(179, 58, 58, 0.08);
}

/* ===================================================================
   Auth Modal
   =================================================================== */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.auth-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(201, 169, 110, 0.05);
  animation: fadeSlideIn 300ms ease forwards;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.auth-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-md);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

.auth-close:hover {
  color: var(--text-primary);
}

.auth-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.auth-tab {
  flex: 1;
  padding: 0.6em 0;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  text-align: center;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.1em;
}

.auth-tab:first-child {
  border-right: 1px solid var(--border);
}

.auth-tab.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-weight: 500;
}

.auth-tab:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-field {
  display: flex;
  flex-direction: column;
}

.auth-input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.7em 0.9em;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.auth-input:focus {
  border-color: var(--accent-gold-dim);
  box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.1);
}

.auth-input:hover {
  border-color: rgba(201, 169, 110, 0.25);
}

.auth-input::placeholder {
  color: var(--text-muted);
}

.auth-btn {
  padding: 0.75em 0;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--bg-primary);
  background: linear-gradient(135deg, var(--accent-gold), #d4b87a);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: var(--space-xs);
}

.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 4px 16px rgba(201, 169, 110, 0.3),
    0 0 30px rgba(201, 169, 110, 0.1);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-error {
  font-size: 0.82rem;
  color: var(--accent-red);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(179, 58, 58, 0.1);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-red);
}

/* ===================================================================
   History Delete Button
   =================================================================== */
.history-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
  opacity: 0.5;
  flex-shrink: 0;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--accent-red);
}

/* ===================================================================
   Responsive — Auth modal on mobile
   =================================================================== */
@media (max-width: 420px) {
  .auth-card {
    padding: var(--space-lg) var(--space-md) var(--space-md);
  }

  .auth-input {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
}

/* ===================================================================
   Liu Nian Detail (流年详情)
   =================================================================== */
.liunian-detail {
  max-width: 720px;
  margin: var(--space-md) auto var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  animation: fadeSlideIn 300ms ease forwards;
}

.liunian-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.liunian-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--accent-gold);
  letter-spacing: 0.08em;
}

.liunian-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

.liunian-close:hover {
  color: var(--text-primary);
}

/* Da Yun Summary Card (大运分析卡) */
.dayun-summary {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.dayun-summary-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}

.dayun-summary-row:last-child {
  margin-bottom: 0;
}

.dayun-summary-label {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 2.5em;
  letter-spacing: 0.08em;
}

.dayun-summary-char {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.dayun-summary-ss {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 1px 6px;
  background: var(--bg-hover);
  border-radius: 3px;
}

.dayun-summary-hidden {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: var(--space-sm);
}

.dayun-summary-hidden-ss {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.dayun-summary-interactions {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.dayun-interaction-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.dayun-interaction-tag {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(201, 169, 110, 0.1);
  color: var(--accent-gold);
  white-space: nowrap;
}

.dayun-interaction-tag.chong {
  background: rgba(179, 58, 58, 0.1);
  color: var(--accent-red);
}

.dayun-interaction-tag.hai {
  background: rgba(192, 132, 252, 0.1);
  color: #c084fc;
}

.dayun-interaction-tag .tag-pillar {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.liunian-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

.liunian-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-xs);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.liunian-item:hover {
  border-color: var(--border-gold);
  background: var(--bg-hover);
}

.liunian-item.current {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(201, 169, 110, 0.12);
}

.liunian-item.expanded {
  border-color: var(--accent-gold);
  background: var(--bg-hover);
}

.liunian-year {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.liunian-gz {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: 1.2rem;
  line-height: 1.3;
  margin-bottom: 2px;
}

.liunian-shishen {
  font-family: var(--font-serif);
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.liunian-age {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ===================================================================
   Liu Yue Detail (流月详情)
   =================================================================== */
.liuyue-detail {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.liuyue-header {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.06em;
}

.liuyue-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-xs);
}

.liuyue-item {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  text-align: center;
}

.liuyue-item:hover {
  border-color: var(--border-gold);
}

.liuyue-month {
  font-family: var(--font-serif);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.liuyue-gz {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  font-size: 0.95rem;
  line-height: 1.3;
}

.liuyue-shishen {
  font-family: var(--font-serif);
  font-size: 0.6rem;
  color: var(--text-secondary);
}

.liuyue-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-sm);
}

/* Responsive: liu nian/yue grids */
@media (max-width: 768px) {
  .liuyue-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 420px) {
  .liunian-grid {
    gap: var(--space-xs);
  }

  .liunian-gz {
    font-size: 1rem;
  }

  .liuyue-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .liunian-detail {
    padding: var(--space-md);
  }
}

/* ===================================================================
   Basic Info (基础信息)
   =================================================================== */
.basic-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.basic-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.basic-info-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.basic-info-value {
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 500;
}

@media (max-width: 768px) {
  .basic-info-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .basic-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===================================================================
   Jiaoyun Info (交运信息)
   =================================================================== */
.jiaoyun-card {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.jiaoyun-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  min-width: 120px;
}

.jiaoyun-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.jiaoyun-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.jiaoyun-value.highlight {
  color: var(--accent-gold);
  font-weight: 600;
}

/* ===================================================================
   Dayun Jiaoyun Date (大运交运日期)
   =================================================================== */
.dayun-jiaoyun {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}

/* ===================================================================
   Shensha Expanded (神煞展开详情)
   =================================================================== */
.shensha-item.expandable {
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  transition: background 0.2s ease;
}

.shensha-item.expandable:hover {
  background: var(--bg-hover);
}

.shensha-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.shensha-desc {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.shensha-desc-text {
  font-size: 0.82rem;
  color: var(--accent-gold-dim);
  margin-bottom: var(--space-xs);
}

.shensha-interp {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.shensha-item.open {
  background: var(--bg-hover);
  border-left: 2px solid var(--accent-gold);
}

/* Print styles — hide interactive elements */
@media print {
  body::before,
  body::after,
  .nav-tabs,
  .input-section,
  .btn-ai,
  #aiSection,
  .site-footer,
  .user-bar,
  .auth-modal {
    display: none !important;
  }

  body {
    background: white;
    color: #333;
  }

  .pillar-card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}

/* ===================================================================
   Ziwei Dou Shu (紫微斗数) Grid Styles
   =================================================================== */

.ziwei-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.ziwei-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ziwei-meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ziwei-meta-value {
  font-family: 'Noto Serif SC', serif;
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 600;
}

/* --- 4x4 Grid --- */
.ziwei-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, auto);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  overflow: hidden;
}

.ziwei-cell {
  background: var(--bg-card);
  padding: 0.5rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

.ziwei-cell.ziwei-body-palace {
  background: rgba(201, 169, 110, 0.06);
}

/* Center area */
.ziwei-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: auto;
  background: var(--bg-secondary);
}

.ziwei-center-title {
  font-family: 'ZCOOL XiaoWei', serif;
  font-size: 1.25rem;
  color: var(--accent-gold);
  margin-bottom: 0.75rem;
}

.ziwei-center-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.ziwei-center-info div {
  white-space: nowrap;
}

/* Palace header */
.ziwei-palace-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.ziwei-palace-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.ziwei-body-tag {
  display: inline-block;
  font-size: 0.6rem;
  color: var(--accent-red);
  border: 1px solid var(--accent-red-dim);
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 3px;
  vertical-align: super;
}

.ziwei-palace-branch {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Stars */
.ziwei-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
}

.ziwei-star {
  font-size: 0.8rem;
  white-space: nowrap;
}

.ziwei-star-major {
  color: var(--text-primary);
  font-weight: 600;
  font-family: 'Noto Serif SC', serif;
}

.ziwei-star-minor {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.ziwei-star sub {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 1px;
}

/* Four Transformations (四化) */
.ziwei-mutagen {
  display: inline-block;
  font-size: 0.6rem;
  padding: 0 3px;
  border-radius: 3px;
  margin-left: 2px;
  font-weight: 700;
  vertical-align: super;
}

.ziwei-mutagen-lu {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
}

.ziwei-mutagen-quan {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

.ziwei-mutagen-ke {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
}

.ziwei-mutagen-ji {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Changsheng12 */
.ziwei-changsheng {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* Decadal age range */
.ziwei-decadal {
  font-size: 0.6rem;
  color: var(--accent-gold-dim);
  position: absolute;
  bottom: 4px;
  right: 6px;
}

/* --- Responsive: stack on mobile --- */
@media (max-width: 640px) {
  .ziwei-cell {
    min-height: 90px;
    padding: 0.35rem;
  }
  .ziwei-palace-name { font-size: 0.75rem; }
  .ziwei-star { font-size: 0.7rem; }
  .ziwei-star-minor { font-size: 0.65rem; }
  .ziwei-center-title { font-size: 1rem; }
  .ziwei-center-info { font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .ziwei-grid {
    grid-template-columns: repeat(4, 1fr);
    font-size: 0.7rem;
  }
  .ziwei-cell { min-height: 70px; padding: 0.25rem; }
  .ziwei-star sub, .ziwei-mutagen { font-size: 0.5rem; }
}

/* ===================================================================
   AI Interpretation Styles
   =================================================================== */

.ai-interpret-section {
  margin-top: 2rem;
}

.ai-interpret-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-gold-dim), var(--accent-gold));
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-interpret-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--accent-gold-glow);
}

.ai-interpret-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ai-interpret-btn .spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: var(--bg-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.ai-interpret-btn.loading .spinner { display: inline-block; }
.ai-interpret-btn.loading .btn-text { display: none; }

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

.ai-interpret-output {
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  display: none;
}

.ai-interpret-output.visible {
  display: block;
}

.ai-interpret-output .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-gold);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink { 50% { opacity: 0; } }

.ai-login-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── Follow-up deep dive ── */
.ai-followup-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.followup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.followup-tag {
  padding: 0.35rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.followup-tag:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.08);
}

.followup-tag.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.15);
}

.followup-input-row {
  display: flex;
  gap: 0.5rem;
}

.followup-input {
  flex: 1;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: 'Noto Sans SC', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.followup-input:focus {
  border-color: var(--accent-gold);
}

.followup-input::placeholder {
  color: var(--text-muted);
}

.followup-btn {
  padding: 0.6rem 1.2rem;
  background: linear-gradient(135deg, var(--accent-gold-dim), var(--accent-gold));
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.followup-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--accent-gold-glow);
}

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

#aiFollowupOutput {
  margin-top: 1rem;
}
