/* ──────────────────────────────────────────────────────────
   BaziMap — main stylesheet
   Design tokens lifted from the polished landing-page reference
   (File 17), with the editorial Cormorant accent retained for
   hero headings.
   ────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --green:        #1f4d2c;
  --green-mid:    #4a7d3a;
  --green-light:  #7ba668;
  --green-soft:   #a8c49e;
  --gold:         #c9a84a;
  --gold-light:   #e6d28a;
  --terracotta:   #c97b4f;

  /* Surfaces */
  --bg:           #f4f3ee;
  --bg-soft:      #ebebde;
  --bg-card:      #ffffff;
  --bg-overlay:   rgba(255, 255, 255, 0.65);

  /* Text */
  --text:         #1a2e1f;
  --text-soft:    #5a6d5b;
  --text-muted:   #8a9a8b;
  --text-on-dark: #ffffff;

  /* UI */
  --border:       rgba(31, 77, 44, 0.12);
  --border-strong: rgba(31, 77, 44, 0.25);
  --shadow-sm:    0 2px 12px rgba(31, 77, 44, 0.06);
  --shadow-md:    0 8px 30px rgba(31, 77, 44, 0.10);
  --shadow-lg:    0 20px 60px rgba(31, 77, 44, 0.14);
  --radius-sm:    10px;
  --radius:       16px;
  --radius-lg:    24px;
  --radius-pill:  100px;

  /* Type */
  --ff-sans:      'Inter', -apple-system, system-ui, sans-serif;
  --ff-display:   'Cormorant Garamond', 'Inter', serif;
  --ff-cn:        'Noto Serif SC', serif;

  /* Layout */
  --maxw:         1200px;
  --gutter:       1.5rem;

  color-scheme: light;
}

/* ──────────────────────────────────────────────────────────
   Dark theme — toggled via <html data-theme="dark">
   Components that use vars adapt automatically. Some pages
   still rely on inline rgba(31,77,44,…)/#fff backgrounds and
   will need a follow-up pass to convert to vars.
   ────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --green:        #5fa074;
  --green-mid:    #6fb085;
  --green-light:  #88c89d;
  --green-soft:   #3a5b44;
  --gold:         #d4b85f;
  --gold-light:   #ecd99a;

  --bg:           #0f1612;
  --bg-soft:      #161e19;
  --bg-card:      #1c2520;
  --bg-overlay:   rgba(28, 37, 32, 0.75);

  --text:         #e8eae3;
  --text-soft:    #a3b0a4;
  --text-muted:   #6f7d70;
  --text-on-dark: #ffffff;

  --border:       rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.22);
  --shadow-sm:    0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-md:    0 8px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg:    0 20px 60px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

/* Dark-mode component overrides — !important is required because many components
   use inline style="background:..." which would otherwise win the cascade. */
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .footer,
html[data-theme="dark"] .card,
html[data-theme="dark"] .du-card,
html[data-theme="dark"] .ty-card,
html[data-theme="dark"] .partner-card,
html[data-theme="dark"] .auth-modal-card,
html[data-theme="dark"] .chat-header,
html[data-theme="dark"] .chat-input-bar { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text) !important; }

/* Inputs, selects, textareas */
html[data-theme="dark"] .input,
html[data-theme="dark"] .select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"] { background: var(--bg-soft) !important; border-color: var(--border-strong) !important; color: var(--text) !important; color-scheme: dark; }
html[data-theme="dark"] ::placeholder { color: var(--text-muted) !important; opacity: 1; }

/* Chat bubbles (assistant) */
html[data-theme="dark"] .msg.assistant .bubble { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text) !important; }

/* Headings inherit from parent — but if parent forces dark var(--text) inline,
   it now resolves to light in dark mode, so they remain readable. */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 { color: var(--text); }

/* Utility text colors */
html[data-theme="dark"] .text-soft { color: var(--text-soft) !important; }
html[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
html[data-theme="dark"] .text-green { color: var(--green) !important; }

/* Sample chat preview / dark-on-dark sections that already had dark backgrounds in light mode — leave alone */
html[data-theme="dark"] [style*="#0F1612"],
html[data-theme="dark"] [style*="#1F4B3A"],
html[data-theme="dark"] [style*="#1f4d2c"] { /* dark-bg sections (the sample chat preview) keep light text from body */ }

/* Cream-gold accents (FEATURED tag, Try Dual Reading, Free Consultation pill, partner pickers, etc.)
   keep their cream-gold backgrounds and dark maroon text. They set color inline so they're already readable;
   this rule prevents any descendant flipping to light. */
html[data-theme="dark"] [style*="#fff6d8"],
html[data-theme="dark"] [style*="#f4e7a8"],
html[data-theme="dark"] [style*="#FFF8EC"],
html[data-theme="dark"] [style*="fefcf6"] { color: #1a2e1f; }

/* Borders that hardcode rgba(31,77,44,…) lose contrast on dark bg — soften them */
html[data-theme="dark"] [style*="rgba(31,77,44,0.1)"],
html[data-theme="dark"] [style*="rgba(31,77,44,.1)"],
html[data-theme="dark"] [style*="rgba(31, 77, 44, 0.1)"] { border-color: var(--border) !important; }

/* BaZi logo wordmark — the dark-green "BaZi" is invisible on dark bg.
   Brighten it to a lighter green; the inner "Map" span keeps its gold via its own inline color. */
html[data-theme="dark"] .bz-en,
html[data-theme="dark"] [style*="#184734"]:not(svg):not([fill="#184734"]):not([stroke="#184734"]) { color: #88c89d !important; }
html[data-theme="dark"] svg circle[stroke="#184734"] { stroke: #88c89d !important; }
html[data-theme="dark"] .bz-cn { color: #94A394 !important; }

/* ──────────────────────────────────────────────────────────
   Dark mode — comprehensive component overrides
   These pages all have inline-styled white/cream cards that
   bypass class rules. Force them dark with !important.
   ────────────────────────────────────────────────────────── */

/* Solo chat (chat.php) — trending categories, question lists, ask card, history items */
html[data-theme="dark"] .ty-list,
html[data-theme="dark"] .ty-q,
html[data-theme="dark"] .ty-cat,
html[data-theme="dark"] .ty-ask,
html[data-theme="dark"] .ty-recent .ty-rec-item,
html[data-theme="dark"] .ty-rec-item { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-theme="dark"] .ty-cat.active { background: var(--green) !important; color: #fff !important; border-color: var(--green) !important; }
html[data-theme="dark"] .ty-cat:hover { background: rgba(255,255,255,.04) !important; color: var(--text) !important; }
html[data-theme="dark"] .ty-q:hover { background: rgba(217,183,90,.08) !important; }
html[data-theme="dark"] .ty-q-title { color: var(--text) !important; }
html[data-theme="dark"] .ty-q-text { color: var(--text-soft) !important; }
html[data-theme="dark"] .ty-q-tag { background: rgba(255,255,255,.06) !important; color: var(--green) !important; }
html[data-theme="dark"] .ty-rec-item .t { color: var(--text) !important; }
html[data-theme="dark"] .ty-rec-item .m { color: var(--text-soft) !important; }

/* Solo/Dual toggle pill container at top of /chat */
html[data-theme="dark"] .ty-hero [style*="background:#fff"],
html[data-theme="dark"] .ty-hero [style*="background: #fff"] { background: var(--bg-card) !important; border-color: var(--border) !important; }

/* Dual chat (chat-dual.php) — sample questions, picker pills, partner cards */
html[data-theme="dark"] .dual-list,
html[data-theme="dark"] .dual-q,
html[data-theme="dark"] .rel-cat,
html[data-theme="dark"] .rel-pill,
html[data-theme="dark"] .partner-pick { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-theme="dark"] .partner-pick.active,
html[data-theme="dark"] .rel-pill:has(input:checked) { background: var(--green) !important; color: #fff !important; border-color: var(--green) !important; }
html[data-theme="dark"] .rel-cat:hover { background: rgba(255,255,255,.04) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
html[data-theme="dark"] .dual-q:hover { background: rgba(217,183,90,.08) !important; }
html[data-theme="dark"] .dual-q-title { color: var(--text) !important; }
html[data-theme="dark"] .dual-q-text { color: var(--text-soft) !important; }
html[data-theme="dark"] .dual-q-tag { background: rgba(255,255,255,.06) !important; color: var(--green) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .partner-picker { background: rgba(255,255,255,.04) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .history-partner-name { color: var(--text) !important; }

/* Per-partner history at chat-session bottom */
html[data-theme="dark"] .ph-item { background: var(--bg-card) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .ph-item .t { color: var(--text) !important; }
html[data-theme="dark"] .ph-item .m { color: var(--text-soft) !important; }

/* Sample chat preview on homepage — assistant bubble has inline background:#fff */
html[data-theme="dark"] [style*="background:#fff;"][style*="border-radius:16px"],
html[data-theme="dark"] [style*="background: #fff"][style*="border-radius:16px"] { background: var(--bg-card) !important; border-color: var(--border) !important; color: var(--text) !important; }

/* Hardcoded brand-green inline text colors (dark green #1F4B3A / #1f4d2c) → brighter green for dark bg */
html[data-theme="dark"] [style*="color:#1F4B3A"],
html[data-theme="dark"] [style*="color: #1F4B3A"],
html[data-theme="dark"] [style*="color:#1f4d2c"],
html[data-theme="dark"] [style*="color: #1f4d2c"] { color: var(--green) !important; }

/* Hardcoded soft-text inline colors (#6B7D72) on dark cards */
html[data-theme="dark"] [style*="color:#6B7D72"],
html[data-theme="dark"] [style*="color: #6B7D72"] { color: var(--text-soft) !important; }

/* Cream-gold accent containers — preserve cream bg for inline-styled brand pills,
   ensure their text stays dark. These are supposed to look the same in both modes. */
html[data-theme="dark"] [style*="#fff6d8"],
html[data-theme="dark"] [style*="#f4e7a8"],
html[data-theme="dark"] [style*="#FFF8EC"]:not(.partner-card),
html[data-theme="dark"] [style*="fefcf6"]:not(.card) { color: #1a2e1f !important; }

/* ──────────────────────────────────────────────────────────
   Catch-all: any element with hardcoded white/cream inline
   background gets flipped to a dark card in dark mode.
   :not() selectors exclude the cream-gold accent gradients
   so brand pills keep their cream bg.
   ────────────────────────────────────────────────────────── */
html[data-theme="dark"] [style*="background:#fff;"]:not([style*="#fff6"]):not([style*="#fff8"]):not([style*="fefcf6"]),
html[data-theme="dark"] [style*="background: #fff;"]:not([style*="#fff6"]):not([style*="#fff8"]):not([style*="fefcf6"]),
html[data-theme="dark"] [style*="background:white"]:not([style*="#fff6"]):not([style*="#fff8"]),
html[data-theme="dark"] [style*="background: white"]:not([style*="#fff6"]):not([style*="#fff8"]),
html[data-theme="dark"] [style*="background:#FFFFFF"]:not([style*="#fff6"]):not([style*="#fff8"]),
html[data-theme="dark"] [style*="background: #FFFFFF"]:not([style*="#fff6"]):not([style*="#fff8"]) {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

/* Inputs with hardcoded white backgrounds (caught by the catch-all already, but ensure scheme) */
html[data-theme="dark"] input[style*="background:#fff"],
html[data-theme="dark"] textarea[style*="background:#fff"] { color-scheme: dark; }

/* Gold buttons keep dark text in both modes — gold bg + light text is unreadable */
html[data-theme="dark"] .btn-gold { color: #1a2e1f !important; }

/* Theme toggle button */
.theme-toggle { display:inline-flex; align-items:center; justify-content:center; width:38px; height:38px; flex:0 0 38px; border-radius:999px; border:1px solid var(--border); background:transparent; cursor:pointer; color:var(--text-soft); padding:0; transition: all .15s; }
.theme-toggle:hover { color: var(--green); border-color: var(--green); }
/* Force icon swap with !important — global `img, svg { display: block }` was winning on mobile and revealing both SVGs */
.theme-toggle .icon-sun { display:inline-block !important; }
.theme-toggle .icon-moon { display:none !important; }
html[data-theme="dark"] .theme-toggle .icon-sun { display:none !important; }
html[data-theme="dark"] .theme-toggle .icon-moon { display:inline-block !important; }

/* Mobile: theme-toggle sits in the .nav-links dropdown — keep it 38x38, don't let the column-flex stretch it into a wide pill */
@media (max-width: 720px) {
  .nav-links .theme-toggle { align-self: flex-start; margin: .5rem 0; }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--ff-sans);
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(ellipse at top right, rgba(201, 168, 74, 0.13) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(123, 166, 104, 0.16) 0%, transparent 60%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle grid */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(31, 77, 44, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 77, 44, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

img, svg { max-width: 100%; display: block; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-mid); }

/* ── Layout ───────────────────────────────────────── */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }
section { padding: 4rem 0; }
@media (max-width: 768px) { section { padding: 2.5rem 0; } }

/* ── Topbar / nav ─────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 243, 238, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem 0;
}
.brand { display: inline-flex; align-items: baseline; gap: 0.05em; text-decoration: none; }
.brand-mark {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--green);
  letter-spacing: -0.02em;
}
.brand-mark .accent { color: var(--gold); font-style: italic; }
.brand-tag {
  font-family: var(--ff-cn);
  font-size: 0.78rem;
  letter-spacing: 0.4em;
  color: var(--green-mid);
  margin-left: 0.6rem;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a {
  color: var(--text-soft); font-size: 0.92rem; font-weight: 500;
  padding: 0.4rem 0.2rem;
}
.nav-links a:hover, .nav-links a.active { color: var(--green); }
.nav-cta {
  padding: 0.55rem 1.1rem;
  background: var(--green);
  color: var(--text-on-dark);
  border-radius: var(--radius-pill);
  font-size: 0.88rem; font-weight: 600;
  transition: all .2s ease;
}
.nav-cta:hover { background: var(--text); color: var(--text-on-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.nav-toggle { display: none; background: transparent; border: 0; cursor: pointer; padding: 0.4rem; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--green); margin: 4px 0; border-radius: 2px; transition: all .2s; }

/* Header nav dropdown groups (Reports, Learn BaZi). Hover-triggered on desktop. */
.nav-group { position: relative; }
.nav-group-label {
  color: var(--text-soft); font-size: 0.92rem; font-weight: 500;
  cursor: pointer; padding: 0.4rem 0;
  display: inline-flex; align-items: center; gap: 0.3rem;
  transition: color .15s;
}
.nav-group-label::after { content: '▾'; font-size: 0.7em; opacity: .7; }
.nav-group:hover .nav-group-label,
.nav-group:focus-within .nav-group-label { color: var(--green); }
.nav-group-menu {
  position: absolute; top: 100%; left: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0;
  min-width: 200px; box-shadow: var(--shadow-md);
  display: none; z-index: 60; margin-top: 0.5rem;
}
/* Invisible bridge: extends the dropdown's hover area UPWARD into the gap
   between trigger and menu, so cursor doesn't lose hover when crossing. */
.nav-group-menu::before {
  content: ''; position: absolute;
  top: -0.6rem; left: 0; right: 0; height: 0.6rem;
  background: transparent;
}
.nav-group:hover .nav-group-menu,
.nav-group:focus-within .nav-group-menu { display: block; }
.nav-group-menu a {
  display: block; padding: 0.55rem 1rem; white-space: nowrap;
  color: var(--text-soft); font-size: 0.9rem; text-decoration: none;
  transition: all .12s;
}
.nav-group-menu a:hover { color: var(--green); background: var(--bg-soft); }

@media (max-width: 720px) {
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); flex-direction: column; align-items: stretch; padding: 1rem var(--gutter); border-bottom: 1px solid var(--border); }
  .nav-links.open { display: flex; }
  .nav-links a, .nav-links .nav-cta { padding: 0.7rem 0; text-align: left; border-radius: 0; }
  .nav-toggle { display: inline-block; }
  .brand-tag { display: none; }

  /* Mobile dropdowns: render inline as a labeled subgroup, no hover dropdown */
  .nav-group { width: 100%; padding: 0.5rem 0; border-top: 1px solid var(--border); }
  .nav-group:first-child { border-top: 0; }
  .nav-group-label { padding: 0.5rem 0; font-weight: 600; color: var(--text); cursor: default; }
  .nav-group-label::after { display: none; }
  .nav-group-menu {
    position: static; display: block; box-shadow: none; border: none;
    padding: 0 0 0 1rem; background: transparent; min-width: 0; margin-top: 0;
  }
  .nav-group-menu a { padding: 0.45rem 0; font-size: 0.88rem; }
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.85rem 1.6rem; border-radius: var(--radius-pill);
  font-size: 0.95rem; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--green); color: var(--text-on-dark); }
.btn-primary:hover { background: var(--text); color: var(--text-on-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-card); color: var(--green); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-soft); transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: var(--text); }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { color: var(--green); border-color: var(--green); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}
.card-tight { padding: 1.25rem; border-radius: var(--radius); }
.card h2, .card h3 { color: var(--green); }

.tag {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.95rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.78rem; font-weight: 500;
  color: var(--green);
}
.tag-dot {
  width: 6px; height: 6px;
  background: var(--green-light);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

/* ── Hero ─────────────────────────────────────────── */
.hero { padding-top: 3rem; padding-bottom: 4rem; }
.hero-grid {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 3.5rem;
  align-items: center;
}
.hero h1 {
  font-family: var(--ff-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 1.2rem;
}
.hero h1 .accent {
  background: linear-gradient(135deg, var(--green-mid) 0%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-style: italic;
}
.hero p.lede {
  font-size: clamp(1rem, 1.2vw, 1.1rem);
  line-height: 1.6;
  color: var(--text-soft);
  max-width: 540px;
  margin-bottom: 1.8rem;
}
.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; gap: 2rem; } }

/* ── BaZi pillar cards ────────────────────────────── */
.pillars {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.pillar {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.5rem; text-align: center;
  transition: all .25s ease;
}
.pillar:hover {
  transform: translateY(-2px);
  border-color: var(--green-light);
  box-shadow: var(--shadow-sm);
}
.pillar-label { font-size: 0.7rem; color: var(--text-soft); font-weight: 500; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.08em; }
.pillar-stem, .pillar-branch { font-family: var(--ff-cn); font-weight: 700; font-size: 1.7rem; color: var(--green); line-height: 1; }
.pillar-stem { color: var(--green); }
.pillar-branch { color: var(--green-mid); margin-top: 0.15rem; }
.pillar-tag { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.45rem; font-weight: 500; }

@media (max-width: 480px) {
  .pillars { gap: 0.35rem; }
  .pillar { padding: 0.7rem 0.25rem; }
  .pillar-stem, .pillar-branch { font-size: 1.4rem; }
}

/* ── Element balance bars ────────────────────────── */
.elements { display: grid; gap: 0.65rem; }
.element-row { display: grid; grid-template-columns: 70px 1fr 50px; gap: 0.7rem; align-items: center; font-size: 0.85rem; }
.element-name { font-weight: 600; color: var(--text); display: inline-flex; gap: 0.4rem; align-items: center; }
.element-name .cn { font-family: var(--ff-cn); color: var(--green-mid); }
.bar { height: 10px; background: var(--bg-soft); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-pill); transition: width 1s ease-out; }
.bar-fill.wood   { background: linear-gradient(90deg, #4a7d3a, #7ba668); }
.bar-fill.fire   { background: linear-gradient(90deg, #c97b4f, #e89a6e); }
.bar-fill.earth  { background: linear-gradient(90deg, #b89968, #d4b88a); }
.bar-fill.metal  { background: linear-gradient(90deg, #888c8d, #c0c4c5); }
.bar-fill.water  { background: linear-gradient(90deg, #2d5878, #5a8aaa); }
.element-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-soft); }

/* Dark mode: brighten the element bars + percentages so they pop against dark bg.
   Original colors (especially metal grey + dark green wood) had poor contrast on dark cards. */
html[data-theme="dark"] .bar { background: rgba(255,255,255,.08); }
html[data-theme="dark"] .bar-fill.wood   { background: linear-gradient(90deg, #6fb358, #9ed080); }
html[data-theme="dark"] .bar-fill.fire   { background: linear-gradient(90deg, #e89868, #ffb88d); }
html[data-theme="dark"] .bar-fill.earth  { background: linear-gradient(90deg, #d4b878, #ead09e); }
html[data-theme="dark"] .bar-fill.metal  { background: linear-gradient(90deg, #b8bdc0, #e0e4e6); }
html[data-theme="dark"] .bar-fill.water  { background: linear-gradient(90deg, #5a9bc4, #8bb9d6); }
html[data-theme="dark"] .element-pct { color: var(--text); }
html[data-theme="dark"] .element-name { color: var(--text); }

/* ── Section heads ─────────────────────────────────── */
.section-head { text-align: center; margin-bottom: 2.5rem; }
.section-head h2 {
  font-family: var(--ff-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}
.section-head p { color: var(--text-soft); max-width: 580px; margin: 0 auto; }

/* ── Feature grid ──────────────────────────────────── */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; } }
.feature { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; transition: all .25s; }
.feature:hover { transform: translateY(-3px); border-color: var(--green-light); box-shadow: var(--shadow-md); }
.feature-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bg-soft) 0%, var(--bg) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 1rem;
}
.feature h3 { color: var(--green); font-size: 1.05rem; margin-bottom: 0.4rem; }
.feature p { color: var(--text-soft); font-size: 0.92rem; }

/* ── Forms ────────────────────────────────────────── */
.form-row { display: grid; gap: 0.5rem; margin-bottom: 1.1rem; }
.form-row label { font-size: 0.85rem; color: var(--text-soft); font-weight: 500; }
.form-row label .required { color: var(--terracotta); }
.input, .select, .textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.95rem; color: var(--text);
  transition: all .2s ease;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 77, 44, 0.08);
}
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ── City autocomplete combobox ───────────────────── */
.combobox { position: relative; }
.combobox-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  max-height: 280px; overflow-y: auto;
  z-index: 50;
}
.combobox-dropdown[hidden] { display: none; }
.combobox-option {
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem; color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.combobox-option:last-child { border-bottom: none; }
.combobox-option:hover,
.combobox-option[aria-selected="true"] {
  background: rgba(31, 77, 44, 0.07);
  color: var(--green);
}
.combobox-option .combobox-cc {
  color: var(--text-soft); font-size: 0.8rem; margin-left: 0.4rem;
}
.combobox-empty {
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem; color: var(--text-soft); font-style: italic;
}

.checkbox { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.9rem; color: var(--text-soft); cursor: pointer; }
.checkbox input { margin-top: 0.18rem; accent-color: var(--green); }

.field-error { color: var(--terracotta); font-size: 0.8rem; margin-top: 0.2rem; }
.alert { padding: 0.85rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 1rem; }
.alert-success { background: rgba(123, 166, 104, 0.15); color: var(--green); border: 1px solid rgba(123, 166, 104, 0.3); }
.alert-error { background: rgba(201, 123, 79, 0.13); color: var(--terracotta); border: 1px solid rgba(201, 123, 79, 0.3); }
.alert-info { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }

/* ── Locked / unlock ─────────────────────────────── */
.locked-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .locked-grid { grid-template-columns: 1fr; } }
.locked-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-soft) 100%);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.4rem 3.2rem;
  color: var(--text-soft);
  overflow: hidden;
}
.locked-card::before {
  content: '🔒';
  position: absolute; top: 1.4rem; left: 1.2rem;
  font-size: 1.05rem;
  filter: grayscale(0.3);
}
.locked-card h3 { color: var(--green); font-size: 1rem; margin-bottom: 0.25rem; }
.locked-card p { font-size: 0.88rem; }

.unlock-cta {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
  color: var(--text-on-dark);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  margin-top: 2rem;
}
.unlock-cta h2 { font-family: var(--ff-display); font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 0.5rem; color: var(--text-on-dark); font-weight: 500; }
.unlock-cta .price { font-size: 2.2rem; font-weight: 800; color: var(--gold-light); margin: 0.7rem 0; letter-spacing: -0.02em; }
.unlock-cta p { color: rgba(255,255,255,0.85); margin-bottom: 1.2rem; max-width: 540px; margin-left: auto; margin-right: auto; }
.unlock-cta .btn-gold:hover { background: #fff; }

.sticky-unlock {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.85rem var(--gutter);
  box-shadow: 0 -8px 24px rgba(31,77,44,0.10);
  z-index: 40;
}
@media (max-width: 700px) { .sticky-unlock { display: flex; gap: 0.7rem; align-items: center; } }
.sticky-unlock-text { flex: 1; font-size: 0.85rem; color: var(--text-soft); }
.sticky-unlock-text strong { color: var(--green); display: block; }

/* ── Tables (luck pillars, annual) ─────────────────── */
.bz-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bz-table th, .bz-table td { padding: 0.7rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.bz-table th { font-weight: 600; color: var(--green); background: var(--bg-soft); }
.bz-table tr:last-child td { border-bottom: 0; }
.bz-table .pillar-cell { font-family: var(--ff-cn); color: var(--green); font-weight: 700; font-size: 1.05rem; }

/* ── Footer ───────────────────────────────────────── */
footer.footer {
  margin-top: 4rem;
  padding: 2.5rem 0 2rem;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.4);
  position: relative; z-index: 1;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-col h4 { font-size: 0.85rem; color: var(--green); margin-bottom: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.footer-col a { display: block; padding: 0.3rem 0; color: var(--text-soft); font-size: 0.9rem; }
.footer-col a:hover { color: var(--green); }
.footer-bottom {
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.78rem; color: var(--text-muted);
}
.footer-bottom .cn { font-family: var(--ff-cn); letter-spacing: 0.3em; }

/* ── Disclaimer block ──────────────────────────────── */
.disclaimer {
  background: var(--bg-soft);
  border-left: 3px solid var(--gold);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.55;
  margin-top: 1.5rem;
}

/* ── Pricing cards ─────────────────────────────────── */
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
@media (max-width: 900px) { .pricing-grid { grid-template-columns: 1fr; } }
.price-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.75rem; }
.price-card.featured { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-4px); position: relative; }
.price-card.featured::after {
  content: 'Most Popular'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: var(--text); padding: 0.3rem 1rem; border-radius: var(--radius-pill);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
}
.price-card h3 { font-family: var(--ff-display); font-size: 1.4rem; color: var(--green); margin-bottom: 0.5rem; }
.price-card .price { font-size: 2.2rem; font-weight: 800; color: var(--text); margin: 0.5rem 0; letter-spacing: -0.02em; }
.price-card .price small { font-size: 0.9rem; color: var(--text-soft); font-weight: 500; }
.price-card ul { list-style: none; margin: 1rem 0 1.5rem; }
.price-card ul li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--text-soft); }
.price-card ul li:last-child { border-bottom: 0; }
.price-card ul li::before { content: '✓ '; color: var(--green); font-weight: 700; }

/* ── Admin ─────────────────────────────────────────── */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 800px) { .admin-shell { grid-template-columns: 1fr; } }
.admin-sidebar { background: var(--bg-card); border-right: 1px solid var(--border); padding: 1.5rem 1rem; }
.admin-sidebar h2 { font-family: var(--ff-display); color: var(--green); margin-bottom: 1.2rem; font-size: 1.3rem; }
.admin-sidebar a { display: block; padding: 0.55rem 0.8rem; color: var(--text-soft); font-size: 0.92rem; border-radius: var(--radius-sm); margin-bottom: 0.15rem; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--bg-soft); color: var(--green); }
.admin-main { padding: 1.5rem 2rem; }
.admin-main h1 { font-family: var(--ff-display); color: var(--text); margin-bottom: 1.5rem; font-weight: 500; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 800px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.kpi .label { font-size: 0.78rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi .value { font-size: 1.6rem; font-weight: 800; color: var(--green); margin-top: 0.25rem; }

/* ── Utility ───────────────────────────────────────── */
.muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.flex { display: flex; gap: 0.5rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.fade-in { animation: fadeInUp 0.7s ease-out both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px);} to { opacity: 1; transform: translateY(0);} }

/* ── Print (used by /download — browser save-as-PDF) ─ */
@media print {
  .topbar, footer.footer, .sticky-unlock, .nav-toggle, .btn { display: none !important; }
  body { background: #fff !important; }
  body::before { display: none !important; }
  .container, .container-narrow { max-width: 100% !important; padding: 0 !important; }
  .card, .price-card, .pillar { box-shadow: none !important; break-inside: avoid; }
  section { padding: 1.2rem 0 !important; page-break-inside: avoid; }
  h1, h2, h3 { page-break-after: avoid; }
}
