    :root {
      --bg-canvas: #0B0F17;
      --bg-surface: #131A28;
      --bg-surface-elevated: #1A2336;
      --border-subtle: rgba(212, 175, 55, 0.18);
      --border-strong: rgba(212, 175, 55, 0.44);
      --gold-primary: #D4AF37;
      --gold-light: #F3DC8B;
      --gold-dim: rgba(212, 175, 55, 0.14);
      --jade: #38B2AC;
      --amber-bg: rgba(236, 201, 75, 0.14);
      --violet-bg: rgba(159, 122, 234, 0.16);
      --rose: #F687B3;
      --rose-bg: rgba(246, 135, 179, 0.14);
      --text-main: #F1F5F9;
      --text-secondary: #CBD5E1;
      --text-muted: #94A3B8;
      --wx-wood: #48BB78;
      --wx-fire: #F56565;
      --wx-earth: #D69E2E;
      --wx-metal: #CBD5E1;
      --wx-water: #4299E1;
      --radius-lg: 16px;
      --radius-md: 12px;
      --radius-sm: 8px;
      --shadow-card: 0 12px 32px -8px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
      --font-sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
      --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Georgia", serif;
      --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    }

    *, *::before, *::after { box-sizing: border-box; }

    html {
      scroll-behavior: smooth;
      -webkit-text-size-adjust: 100%;
      overflow-x: hidden;
    }

    body {
      margin: 0;
      padding: 0;
      background-color: var(--bg-canvas);
      background-image:
        radial-gradient(circle at 15% 0%, rgba(212, 175, 55, 0.09) 0%, transparent 42%),
        radial-gradient(circle at 85% 12%, rgba(159, 122, 234, 0.07) 0%, transparent 38%);
      color: var(--text-main);
      font-family: var(--font-sans);
      line-height: 1.65;
      min-height: 100vh;
      min-height: 100dvh;
      overflow-x: hidden;
      padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }

    button, select, input { font-family: inherit; }

    /* Header & 3 Intuitive Main Modes */
    .site-header {
      position: sticky;
      top: 0;
      z-index: 40;
      background: rgba(11, 15, 23, 0.88);
      border-bottom: 1px solid var(--border-subtle);
      padding: 12px 16px;
    }

    @supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {
      .site-header {
        backdrop-filter: blur(16px) saturate(160%);
        -webkit-backdrop-filter: blur(16px) saturate(160%);
      }
    }

    .header-inner {
      max-width: 1240px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .brand-mark {
      width: 40px;
      height: 40px;
      border-radius: 10px;
      background: linear-gradient(135deg, rgba(212, 175, 55, 0.22), rgba(212, 175, 55, 0.04));
      border: 1px solid var(--border-strong);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .brand-title {
      font-family: var(--font-serif);
      font-size: clamp(1.15rem, 2.2vw, 1.38rem);
      font-weight: 700;
      letter-spacing: 0.08em;
      color: var(--gold-light);
      margin: 0;
      line-height: 1.2;
    }

    .brand-sub {
      font-size: 0.76rem;
      color: var(--text-muted);
      margin: 2px 0 0 0;
    }

    .mode-switch {
      display: flex;
      gap: 6px;
      background: var(--bg-surface);
      padding: 4px;
      border-radius: 12px;
      border: 1px solid var(--border-subtle);
    }

    .mode-btn {
      min-height: 44px;
      padding: 8px 16px;
      border: none;
      border-radius: 8px;
      background: transparent;
      color: var(--text-secondary);
      font-size: 0.92rem;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      white-space: nowrap;
    }

    .mode-btn.active {
      background: linear-gradient(135deg, #E2BE4B 0%, #B88B1E 100%);
      color: #0B0F17;
      box-shadow: 0 4px 14px rgba(212, 175, 55, 0.28);
    }

    @media (max-width: 640px) {
      .header-inner { flex-direction: column; align-items: stretch; }
      .mode-switch { width: 100%; }
      .mode-btn { flex: 1; padding: 8px 8px; font-size: 0.88rem; text-align: center; }
    }

    .main-container {
      max-width: 1240px;
      margin: 0 auto;
      padding: 20px 16px 40px;
    }

    .panel-card {
      background: var(--bg-surface);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-lg);
      padding: clamp(16px, 2.5vw, 24px);
      box-shadow: var(--shadow-card);
      margin-bottom: 20px;
    }

    /* Card Top Bar with Calendar Mode Pill & Subtle Advanced Toggle */
    .card-top-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .seg-control {
      display: inline-flex;
      background: var(--bg-canvas);
      padding: 3px;
      border-radius: 10px;
      border: 1px solid rgba(212, 175, 55, 0.28);
    }

    .seg-btn {
      min-height: 38px;
      padding: 6px 14px;
      border: none;
      border-radius: 7px;
      background: transparent;
      color: var(--text-secondary);
      font-size: 0.88rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.18s;
      white-space: nowrap;
    }

    .seg-btn.active {
      background: var(--gold-dim);
      color: var(--gold-light);
      box-shadow: inset 0 0 0 1px var(--gold-primary);
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(12, minmax(0, 1fr));
      gap: 14px;
      align-items: end;
    }

    .col-2 { grid-column: span 2; }
    .col-3 { grid-column: span 3; }
    .col-4 { grid-column: span 4; }
    .col-6 { grid-column: span 6; }
    .col-12 { grid-column: span 12; }

    @media (max-width: 960px) {
      .col-2, .col-3, .col-4 { grid-column: span 6; }
    }

    @media (max-width: 560px) {
      .col-2, .col-3, .col-4, .col-6 { grid-column: span 12; }
    }

    .field-label {
      display: block;
      font-size: 0.84rem;
      font-weight: 600;
      color: var(--text-secondary);
      margin-bottom: 6px;
    }

    /* Enforce 16px to prevent iOS Safari & LINE WebView auto-zoom */
    .form-control {
      width: 100%;
      min-height: 46px;
      padding: 10px 12px;
      font-size: 16px;
      color: var(--text-main);
      background-color: var(--bg-canvas);
      border: 1px solid rgba(148, 163, 184, 0.28);
      border-radius: var(--radius-sm);
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    .form-control:focus {
      border-color: var(--gold-primary);
      box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
    }

    .gender-group {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .gender-btn {
      min-height: 46px;
      padding: 0 10px;
      white-space: nowrap;
      border-radius: var(--radius-sm);
      border: 1px solid rgba(148, 163, 184, 0.28);
      background: var(--bg-canvas);
      color: var(--text-secondary);
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.18s ease;
    }

    .gender-btn.active {
      border-color: var(--gold-primary);
      background: var(--gold-dim);
      color: var(--gold-light);
    }

    .primary-cta {
      min-height: 48px;
      padding: 10px 22px;
      border: 1px solid var(--gold-light);
      border-radius: var(--radius-sm);
      background: linear-gradient(135deg, #E2BE4B 0%, #B88B1E 100%);
      color: #0B0F17;
      font-size: 16px;
      font-weight: 700;
      letter-spacing: 0.03em;
      cursor: pointer;
      width: 100%;
      transition: transform 0.15s ease, box-shadow 0.2s ease;
      box-shadow: 0 6px 20px rgba(212, 175, 55, 0.24);
    }

    .primary-cta:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 24px rgba(212, 175, 55, 0.34);
    }

    .primary-cta:active { transform: scale(0.985); }

    .ghost-btn {
      min-height: 42px;
      padding: 8px 14px;
      font-size: 0.86rem;
      font-weight: 600;
      border-radius: 8px;
      border: 1px solid rgba(148, 163, 184, 0.3);
      background: var(--bg-surface-elevated);
      color: var(--text-main);
      cursor: pointer;
      transition: all 0.18s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      white-space: nowrap;
    }

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

    /* Saved Family Profiles Bar (Only appears when user saves/names someone) */
    .saved-profiles-row {
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid rgba(255, 255, 255, 0.06);
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
    }

    .profile-chips {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
    }

    .profile-chip {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      background: rgba(212, 175, 55, 0.1);
      border: 1px solid rgba(212, 175, 55, 0.3);
      overflow: hidden;
    }

    .profile-chip-load {
      min-height: 36px;
      padding: 4px 12px;
      border: none;
      background: transparent;
      color: var(--gold-light);
      font-size: 0.84rem;
      font-weight: 600;
      cursor: pointer;
    }

    .profile-chip-del {
      min-height: 36px;
      padding: 4px 10px 4px 6px;
      border: none;
      border-left: 1px solid rgba(212, 175, 55, 0.2);
      background: transparent;
      color: var(--text-muted);
      font-size: 0.88rem;
      cursor: pointer;
    }

    .profile-chip-del:hover { color: #FC8181; }

    /* Contextual Smart Banner (Taiwan DST / Leap Month) */
    .smart-assist-bar {
      margin-top: 12px;
      padding: 10px 14px;
      border-radius: var(--radius-sm);
      background: var(--amber-bg);
      border: 1px solid rgba(236, 201, 75, 0.38);
      color: #FEF08A;
      font-size: 0.86rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
    }

    .smart-assist-btn {
      min-height: 36px;
      padding: 4px 12px;
      border-radius: 6px;
      border: 1px solid #F6E05E;
      background: rgba(11, 15, 23, 0.65);
      color: #FEF08A;
      font-size: 0.82rem;
      font-weight: 700;
      cursor: pointer;
    }

    .smart-assist-btn.applied {
      background: #D4AF37;
      color: #0B0F17;
    }

    /* Summary Banner */
    .astro-banner {
      background: linear-gradient(135deg, rgba(26, 35, 54, 0.95), rgba(19, 26, 40, 0.95));
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      padding: 16px 20px;
      margin-bottom: 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
    }

    .banner-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 12px;
      align-items: center;
    }

    .banner-name {
      font-family: var(--font-serif);
      font-size: 1.22rem;
      font-weight: 700;
      color: var(--gold-light);
    }

    .meta-pill {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 0.82rem;
      background: rgba(255, 255, 255, 0.06);
      color: var(--text-secondary);
      border: 1px solid rgba(255, 255, 255, 0.09);
    }

    .meta-pill strong { color: var(--gold-light); }

    /* Time Horizon Switcher (看天生本命 / 看今年運勢 / 看明年運勢) */
    .horizon-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 16px;
    }

    .chart-tabs {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 18px;
    }

    .chart-tab {
      min-height: 52px;
      padding: 10px 12px;
      border-radius: var(--radius-md);
      border: 1px solid var(--border-subtle);
      background: var(--bg-surface);
      color: var(--text-secondary);
      font-size: clamp(0.9rem, 2vw, 1.02rem);
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      text-align: center;
    }

    .chart-tab small {
      font-size: 0.74rem;
      font-weight: 400;
      color: var(--text-muted);
    }

    .chart-tab.active {
      background: linear-gradient(180deg, rgba(212, 175, 55, 0.22) 0%, rgba(212, 175, 55, 0.06) 100%);
      border-color: var(--gold-primary);
      color: var(--gold-light);
      box-shadow: inset 0 1px 0 rgba(243, 220, 139, 0.35);
    }

    .chart-tab.active small { color: var(--gold-light); opacity: 0.9; }

    /* Yearly Fortune Highlight Card */
    .fortune-spotlight {
      background: linear-gradient(135deg, rgba(212, 175, 55, 0.14) 0%, rgba(26, 35, 54, 0.95) 100%);
      border: 1px solid var(--gold-primary);
      border-radius: var(--radius-lg);
      padding: 18px 20px;
      margin-bottom: 18px;
    }

    /* Zi Wei 4x4 Board & Mobile Cards */
    .zw-view-toggle { display: none; margin-bottom: 12px; justify-content: flex-end; }

    .zw-board {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      grid-template-rows: repeat(4, minmax(156px, auto));
      gap: 8px;
      margin-bottom: 20px;
    }

    .zw-center {
      grid-column: 2 / 4;
      grid-row: 2 / 4;
      background: radial-gradient(circle at center, rgba(212, 175, 55, 0.1) 0%, rgba(13, 18, 29, 0.96) 75%);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-md);
      padding: 18px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      gap: 10px;
    }

    .zw-center-header {
      text-align: center;
      border-bottom: 1px solid rgba(212, 175, 55, 0.2);
      padding-bottom: 10px;
    }

    .zw-center-title {
      font-family: var(--font-serif);
      font-size: 1.25rem;
      color: var(--gold-light);
      margin: 0 0 4px;
      letter-spacing: 0.08em;
    }

    .zw-center-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px 14px;
      font-size: 0.85rem;
    }

    .zw-kv {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
      padding-bottom: 4px;
      gap: 8px;
    }

    .zw-kv span:first-child { color: var(--text-muted); }
    .zw-kv strong { color: var(--text-main); font-weight: 600; text-align: right; }

    .zw-palace {
      background: var(--bg-surface);
      border: 1px solid rgba(148, 163, 184, 0.2);
      border-radius: var(--radius-md);
      padding: 10px 11px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      cursor: pointer;
      transition: border-color 0.18s, transform 0.18s, background-color 0.18s;
      min-width: 0;
    }

    .zw-palace:hover { border-color: rgba(212, 175, 55, 0.55); transform: translateY(-1px); }

    .zw-palace.selected {
      border-color: var(--gold-primary);
      background: linear-gradient(180deg, rgba(212, 175, 55, 0.15) 0%, rgba(19, 26, 40, 0.96) 100%);
      box-shadow: 0 0 0 1px var(--gold-primary);
    }

    .zw-palace.liunian-ming {
      box-shadow: inset 0 0 0 1px #68D391;
    }

    .zw-stars-top {
      display: flex;
      flex-wrap: wrap;
      gap: 5px 8px;
      align-items: flex-start;
      margin-bottom: 8px;
    }

    .star-major {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      font-weight: 700;
      font-size: 0.92rem;
      color: #FDE68A;
    }

    .star-major.empty-borrow { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; }

    .star-bright {
      font-size: 0.7rem;
      padding: 1px 4px;
      border-radius: 4px;
      background: rgba(255, 255, 255, 0.08);
      color: var(--text-secondary);
      font-weight: 500;
    }
    .star-bright.high { background: rgba(212, 175, 55, 0.2); color: var(--gold-light); }
    .star-bright.low { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }

    .sihua-tag { font-size: 0.7rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; line-height: 1.3; }
    .sihua-祿 { background: rgba(72, 187, 120, 0.22); color: #68D391; border: 1px solid rgba(72, 187, 120, 0.4); }
    .sihua-權 { background: rgba(245, 101, 101, 0.22); color: #FC8181; border: 1px solid rgba(245, 101, 101, 0.4); }
    .sihua-科 { background: rgba(66, 153, 225, 0.22); color: #63B3ED; border: 1px solid rgba(66, 153, 225, 0.4); }
    .sihua-忌 { background: rgba(237, 137, 54, 0.25); color: #FBD38D; border: 1px solid rgba(237, 137, 54, 0.5); }

    .zw-stars-minor { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 10px; }
    .star-lucky { font-size: 0.75rem; color: #81E6D9; background: rgba(56, 178, 172, 0.12); padding: 1px 6px; border-radius: 4px; }
    .star-sha { font-size: 0.75rem; color: #FEB2B2; background: rgba(245, 101, 101, 0.12); padding: 1px 6px; border-radius: 4px; }
    .star-aux { font-size: 0.74rem; color: var(--text-secondary); background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 4px; }

    .zw-palace-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-top: 1px solid rgba(255, 255, 255, 0.07);
      padding-top: 6px;
      gap: 4px;
    }

    .zw-palace-name {
      font-weight: 700;
      font-size: 0.84rem;
      padding: 2px 7px;
      border-radius: 5px;
      background: rgba(255, 255, 255, 0.07);
      color: var(--text-main);
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .zw-palace-name.is-ming { background: linear-gradient(135deg, #D4AF37, #B78E20); color: #0B0F17; }
    .shen-badge { font-size: 0.68rem; padding: 1px 5px; border-radius: 4px; background: var(--violet-bg); color: #D6BCFA; border: 1px solid rgba(159, 122, 234, 0.4); }
    .liunian-badge { font-size: 0.68rem; padding: 1px 5px; border-radius: 4px; background: rgba(72, 187, 120, 0.2); color: #68D391; border: 1px solid rgba(72, 187, 120, 0.45); }
    .zw-daxian { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); }
    .zw-ganzhi { font-size: 0.76rem; color: var(--gold-light); font-weight: 600; }

    .zw-mobile-pills {
      display: none;
      gap: 8px;
      overflow-x: auto;
      padding-bottom: 8px;
      margin-bottom: 14px;
      -webkit-overflow-scrolling: touch;
    }

    .zw-pill-btn {
      min-height: 44px;
      padding: 6px 14px;
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.28);
      background: var(--bg-surface);
      color: var(--text-secondary);
      font-size: 0.86rem;
      font-weight: 600;
      white-space: nowrap;
      cursor: pointer;
      flex-shrink: 0;
    }

    .zw-pill-btn.active { background: var(--gold-primary); color: #0B0F17; border-color: var(--gold-primary); }

    @media (max-width: 900px) {
      .zw-view-toggle { display: flex; }
      .zw-mobile-pills { display: flex; }
      .zw-board:not(.force-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
      .zw-board:not(.force-grid) .zw-center { grid-column: 1 / -1; grid-row: 1; }
      .zw-board.force-grid { overflow-x: auto; grid-template-columns: repeat(4, minmax(175px, 1fr)); }
    }
    @media (max-width: 560px) {
      .zw-board:not(.force-grid) { grid-template-columns: 1fr; }
    }

    .reading-card {
      background: var(--bg-surface-elevated);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      padding: clamp(16px, 2.5vw, 24px);
      margin-bottom: 20px;
    }

    .section-title {
      font-family: var(--font-serif);
      font-size: 1.18rem;
      color: var(--gold-light);
      margin: 0 0 12px 0;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
    }

    .reading-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
      margin-top: 14px;
    }
    @media (max-width: 768px) { .reading-grid { grid-template-columns: 1fr; } }

    .info-box {
      background: rgba(11, 15, 23, 0.55);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: var(--radius-md);
      padding: 16px;
    }
    .info-box h4 { margin: 0 0 8px 0; font-size: 0.96rem; color: var(--gold-light); }
    .info-box p { margin: 0; font-size: 0.92rem; color: var(--text-secondary); }

    /* Bazi Pillars & Luck Strips */
    .bazi-pillars-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 18px;
    }
    @media (max-width: 680px) { .bazi-pillars-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

    .pillar-col {
      background: var(--bg-surface);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-md);
      padding: 16px 12px;
      text-align: center;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .pillar-col.day-master {
      border-color: var(--gold-primary);
      background: linear-gradient(180deg, rgba(212, 175, 55, 0.12), var(--bg-surface));
    }

    .pillar-header { font-size: 0.82rem; color: var(--text-muted); border-bottom: 1px solid rgba(255, 255, 255, 0.07); padding-bottom: 6px; }
    .shishen-top { font-size: 0.86rem; font-weight: 600; color: var(--gold-light); min-height: 24px; }
    .gz-char { font-family: var(--font-serif); font-size: 2.05rem; font-weight: 700; line-height: 1.15; display: flex; align-items: center; justify-content: center; gap: 6px; }
    .wx-badge { font-family: var(--font-sans); font-size: 0.72rem; padding: 2px 6px; border-radius: 999px; font-weight: 600; }
    .wx-木 { color: #68D391; background: rgba(72, 187, 120, 0.16); }
    .wx-火 { color: #FC8181; background: rgba(245, 101, 101, 0.16); }
    .wx-土 { color: #F6E05E; background: rgba(214, 158, 46, 0.18); }
    .wx-金 { color: #E2E8F0; background: rgba(203, 213, 225, 0.18); }
    .wx-水 { color: #63B3ED; background: rgba(66, 153, 225, 0.16); }

    .canggan-box { background: rgba(11, 15, 23, 0.55); border-radius: var(--radius-sm); padding: 8px; font-size: 0.8rem; color: var(--text-secondary); min-height: 68px; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
    .nayin-tag { font-size: 0.78rem; color: var(--text-muted); }

    .wx-bars { display: flex; flex-direction: column; gap: 10px; }
    .wx-row { display: grid; grid-template-columns: 64px 1fr 52px; align-items: center; gap: 10px; font-size: 0.88rem; }
    .wx-track { height: 12px; background: rgba(255, 255, 255, 0.07); border-radius: 999px; overflow: hidden; }
    .wx-fill { height: 100%; border-radius: 999px; transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

    .liunian-strip {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 8px;
      margin-top: 12px;
    }
    @media (max-width: 820px) { .liunian-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
    @media (max-width: 480px) { .liunian-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

    .liunian-cell {
      background: rgba(11, 15, 23, 0.65);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: var(--radius-sm);
      padding: 10px;
      text-align: center;
    }
    .liunian-cell.current {
      border-color: var(--gold-primary);
      background: rgba(212, 175, 55, 0.12);
    }

    /* Bone Weight */
    .bone-hero {
      background: radial-gradient(circle at top right, rgba(212, 175, 55, 0.18), rgba(19, 26, 40, 0.96));
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      padding: 24px;
      text-align: center;
      margin-bottom: 20px;
    }
    .bone-weight-num { font-family: var(--font-serif); font-size: clamp(2.1rem, 5vw, 3rem); font-weight: 700; color: var(--gold-light); margin: 6px 0; letter-spacing: 0.06em; }
    .bone-formula-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
    .poem-scroll {
      font-family: var(--font-serif);
      font-size: clamp(1.1rem, 2.5vw, 1.32rem);
      line-height: 1.9;
      color: #FEF3C7;
      background: rgba(11, 15, 23, 0.72);
      border-left: 3px solid var(--gold-primary);
      border-right: 3px solid var(--gold-primary);
      border-radius: var(--radius-md);
      padding: 18px 20px;
      margin: 16px auto;
      max-width: 660px;
      text-align: center;
      letter-spacing: 0.06em;
    }
    .shichen-matrix { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
    @media (max-width: 768px) { .shichen-matrix { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
    .matrix-item {
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      background: rgba(11, 15, 23, 0.55);
      border: 1px solid rgba(255, 255, 255, 0.08);
      font-size: 0.84rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      color: var(--text-secondary);
      min-height: 44px;
    }
    .matrix-item:hover, .matrix-item.active { border-color: var(--gold-primary); color: var(--gold-light); background: var(--gold-dim); }

    /* ================= TWO-PERSON COMPATIBILITY (SYNASTRY) ================= */
    .match-dual-cards {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
      margin-bottom: 18px;
    }
    @media (max-width: 860px) { .match-dual-cards { grid-template-columns: 1fr; } }

    .person-card {
      background: var(--bg-surface);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-lg);
      padding: 18px 20px;
      box-shadow: var(--shadow-card);
    }

    .person-card.partner-b {
      border-color: rgba(246, 135, 179, 0.32);
    }

    .person-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 14px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .person-badge {
      font-family: var(--font-serif);
      font-size: 1.08rem;
      font-weight: 700;
      color: var(--gold-light);
    }
    .person-card.partner-b .person-badge { color: #FBB6CE; }

    .person-form-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }
    @media (max-width: 480px) { .person-form-grid { grid-template-columns: 1fr; } }

    .match-score-hero {
      background: radial-gradient(circle at top center, rgba(212, 175, 55, 0.2), rgba(19, 26, 40, 0.96) 72%);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      padding: 24px 20px;
      margin-bottom: 20px;
      display: grid;
      grid-template-columns: 240px 1fr;
      gap: 24px;
      align-items: center;
    }
    @media (max-width: 768px) {
      .match-score-hero { grid-template-columns: 1fr; text-align: center; }
    }

    .score-ring-box {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 16px;
      border-radius: var(--radius-md);
      background: rgba(11, 15, 23, 0.6);
      border: 1px solid rgba(212, 175, 55, 0.3);
    }

    .score-big-num {
      font-family: var(--font-serif);
      font-size: 3.4rem;
      font-weight: 700;
      line-height: 1;
      color: var(--gold-light);
      margin: 6px 0;
    }

    .score-tier-badge {
      display: inline-block;
      padding: 4px 12px;
      border-radius: 999px;
      font-size: 0.86rem;
      font-weight: 700;
      background: linear-gradient(135deg, #E2BE4B, #B88B1E);
      color: #0B0F17;
      margin-top: 6px;
    }

    .dim-bars { display: flex; flex-direction: column; gap: 11px; }
    .dim-row { display: grid; grid-template-columns: 112px 1fr 48px; align-items: center; gap: 10px; font-size: 0.88rem; text-align: left; }
    .dim-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #D4AF37, #F6E05E); transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

    .bullet-list { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 0.92rem; display: flex; flex-direction: column; gap: 8px; }
    .bullet-list strong { color: var(--text-main); }

    /* Divination */
    .divination-stage {
      text-align: center;
      padding: 28px 20px;
      background: radial-gradient(circle at center, rgba(212, 175, 55, 0.12) 0%, var(--bg-surface) 72%);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      margin-bottom: 24px;
    }
    .topic-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 20px; }
    .preset-btn {
      min-height: 40px;
      padding: 6px 14px;
      font-size: 0.86rem;
      font-weight: 600;
      border-radius: 999px;
      border: 1px solid rgba(212, 175, 55, 0.28);
      background: rgba(212, 175, 55, 0.07);
      color: var(--gold-light);
      cursor: pointer;
    }
    .coins-row { display: flex; justify-content: center; gap: 18px; margin: 20px 0; min-height: 76px; align-items: center; }
    .ancient-coin {
      width: 68px; height: 68px; border-radius: 50%;
      background: radial-gradient(circle at 35% 30%, #F6E05E, #B78E20 70%, #74550B 100%);
      border: 3px solid #F3DC8B;
      display: flex; align-items: center; justify-content: center;
      position: relative; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
      transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .ancient-coin.flipping { transform: rotateY(720deg) scale(1.08); }
    .coin-hole { width: 20px; height: 20px; background: #0B0F17; border: 2px solid #F3DC8B; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; color: var(--gold-light); font-weight: 700; }
    .coin-label { position: absolute; bottom: -24px; font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }
    .hexagram-lines { max-width: 240px; margin: 22px auto 12px; display: flex; flex-direction: column-reverse; gap: 8px; }
    .yao-row { display: flex; align-items: center; gap: 10px; height: 18px; }
    .yao-bar { flex: 1; display: flex; justify-content: space-between; height: 12px; }
    .yao-yang { width: 100%; height: 100%; background: linear-gradient(90deg, #D4AF37, #F3DC8B, #D4AF37); border-radius: 3px; }
    .yao-yin-part { width: 44%; height: 100%; background: linear-gradient(90deg, #94A3B8, #CBD5E1); border-radius: 3px; }
    .yao-moving .yao-yang, .yao-moving .yao-yin-part { background: linear-gradient(90deg, #F56565, #FEB2B2); }
    .yao-label { font-size: 0.76rem; color: var(--text-muted); width: 48px; text-align: left; font-family: var(--font-mono); }

    .toast {
      position: fixed;
      bottom: calc(24px + env(safe-area-inset-bottom, 0px));
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      background: #1E293B;
      color: #F8FAFC;
      border: 1px solid var(--gold-primary);
      padding: 12px 20px;
      border-radius: 999px;
      font-size: 0.9rem;
      font-weight: 600;
      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.22s, transform 0.22s;
      z-index: 100;
      max-width: 92vw;
      text-align: center;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    .site-footer {
      max-width: 1240px;
      margin: 24px auto 0;
      padding: 20px 16px;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      color: var(--text-muted);
      font-size: 0.82rem;
      text-align: center;
    }


    .pattern-banner {
      background: linear-gradient(135deg, rgba(212, 175, 55, 0.16) 0%, rgba(19, 26, 40, 0.92) 100%);
      border: 1px solid rgba(212, 175, 55, 0.42);
      border-radius: var(--radius-md);
      padding: 14px 16px;
      margin-bottom: 16px;
    }
    .pattern-tag {
      display: inline-block;
      padding: 2px 9px;
      border-radius: 999px;
      font-size: 0.76rem;
      font-weight: 700;
      background: linear-gradient(135deg, #E2BE4B, #B88B1E);
      color: #0B0F17;
      margin-right: 8px;
      vertical-align: middle;
    }
    .sub-point {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px dashed rgba(255, 255, 255, 0.08);
      font-size: 0.9rem;
      color: var(--text-secondary);
    }
    .sub-point strong {
      color: var(--gold-light);
    }
    .stage-timeline {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin-top: 14px;
    }
    @media (max-width: 820px) {
      .stage-timeline { grid-template-columns: 1fr; }
    }
    .liunian-detail-list {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      margin-top: 12px;
    }
    @media (max-width: 768px) {
      .liunian-detail-list { grid-template-columns: 1fr; }
    }


    /* Tabular numbers across all numeric readouts */
    .zw-daxian, .score-big-num, .bone-weight-num, .dim-row strong, .wx-row strong, .meta-pill strong, .liunian-cell {
      font-variant-numeric: tabular-nums;
    }

    /* 30-Second Golden Snapshot Card (CRO First-Glance Value) */
    .golden-snapshot {
      background: linear-gradient(135deg, rgba(212, 175, 55, 0.16) 0%, rgba(19, 26, 40, 0.96) 65%);
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-lg);
      padding: 18px 20px;
      margin-bottom: 18px;
      box-shadow: var(--shadow-card);
    }

    .snapshot-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 12px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(212, 175, 55, 0.22);
    }

    .verify-hash {
      font-family: var(--font-mono);
      font-size: 0.75rem;
      color: var(--gold-light);
      background: rgba(212, 175, 55, 0.12);
      border: 1px solid rgba(212, 175, 55, 0.3);
      padding: 3px 9px;
      border-radius: 999px;
    }

    .snapshot-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
    }

    @media (max-width: 820px) {
      .snapshot-grid { grid-template-columns: 1fr; }
    }

    .snap-item {
      background: rgba(11, 15, 23, 0.58);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: var(--radius-md);
      padding: 13px 15px;
    }

    .snap-label {
      font-size: 0.78rem;
      color: var(--gold-light);
      font-weight: 700;
      margin-bottom: 4px;
      letter-spacing: 0.04em;
    }

    .snap-text {
      font-size: 0.9rem;
      color: var(--text-main);
      margin: 0;
      line-height: 1.55;
    }

    /* Sticky Sub-Nav for Chart Tabs so mobile users never have to scroll all the way back up */
    .sticky-tabs-wrap {
      position: sticky;
      top: 65px;
      z-index: 30;
      background: rgba(11, 15, 23, 0.9);
      padding: 8px 0;
      margin-bottom: 14px;
    }

    @supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
      .sticky-tabs-wrap {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
      }
    }

    @media (max-width: 640px) {
      .sticky-tabs-wrap { top: 108px; }
    }

    .sticky-tabs-wrap .chart-tabs {
      margin-bottom: 0;
    }

    /* Bazi ShenSha (Auspicious Symbolic Stars) Badges */
    .shensha-wrap {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .shensha-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 11px;
      border-radius: 8px;
      background: rgba(212, 175, 55, 0.11);
      border: 1px solid rgba(212, 175, 55, 0.34);
      font-size: 0.84rem;
      color: var(--text-main);
    }

    .shensha-pill strong {
      color: var(--gold-light);
    }

    /* Invisible Clean A4 Print MingShu Sheet (@media print) */
    @media print {
      @page { size: A4 portrait; margin: 12mm; }
      body {
        background: #FFFFFF !important;
        color: #111827 !important;
        padding: 0 !important;
        font-size: 11pt;
      }
      .site-header, .card-top-bar, #birthForm, .saved-profiles-row, #smartAssistContainer,
      .horizon-bar, .sticky-tabs-wrap, .zw-view-toggle, .zw-mobile-pills, .toast,
      #btnCopyMatch, #matchSavedQuickBar, .modal-backdrop {
        display: none !important;
      }
      .main-container { max-width: 100% !important; padding: 0 !important; }
      .astro-banner, .golden-snapshot, .reading-card, .info-box, .zw-palace, .zw-center,
      .pillar-col, .bone-hero, .match-score-hero, .person-card, .pattern-banner, .snap-item, .liunian-cell {
        background: #FFFFFF !important;
        color: #111827 !important;
        border: 1px solid #CBD5E1 !important;
        box-shadow: none !important;
        break-inside: avoid;
      }
      .banner-name, .section-title, .zw-center-title, .bone-weight-num, .score-big-num,
      .info-box h4, .snap-label, .star-major, .poem-scroll, .verify-hash {
        color: #78350F !important;
      }
      .meta-pill, .shensha-pill, .zw-palace-name {
        background: #F8FAFC !important;
        color: #1E293B !important;
        border: 1px solid #94A3B8 !important;
      }
      p, li, .sub-point, .zw-kv span, .zw-kv strong {
        color: #1F2937 !important;
      }
    }


    /* ================= PAID SYNASTRY PAYWALL & CHECKOUT MODAL ================= */
.paywall-badge {
      display: inline-block; padding: 4px 14px; border-radius: 999px;
      font-size: 0.8rem; font-weight: 700;
      background: rgba(212, 175, 55, 0.18); color: var(--gold-light);
      border: 1px solid rgba(212, 175, 55, 0.45); margin-bottom: 10px; letter-spacing: 0.06em;
    }
.paywall-features {
      display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px; max-width: 720px; margin: 18px auto; text-align: left;
    }
    @media (max-width: 640px) { .paywall-features { grid-template-columns: 1fr; } }
.pw-feat-icon { color: var(--gold-primary); font-weight: 700; flex-shrink: 0; }
.price-old { font-size: 0.95rem; color: var(--text-muted); text-decoration: line-through; }
.unlock-inline-box {
      max-width: 440px; margin: 18px auto 0; padding-top: 16px;
      border-top: 1px dashed rgba(255, 255, 255, 0.12);
      display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
    }
.unlocked-ribbon {
      display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
      border-radius: 999px; font-size: 0.8rem; font-weight: 700;
      background: rgba(72, 187, 120, 0.18); color: #68D391; border: 1px solid rgba(72, 187, 120, 0.45);
    }
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
      .modal-backdrop { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
    }
.modal-close {
      position: absolute; top: 14px; right: 14px; width: 44px; height: 44px;
      border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.14);
      background: var(--bg-surface-elevated); color: var(--text-secondary); font-size: 1.2rem; cursor: pointer;
    }
.ecpay-cta {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      min-height: 50px; padding: 12px 20px; border-radius: var(--radius-sm);
      background: linear-gradient(135deg, #2F9E44 0%, #237A34 100%);
      border: 1px solid #69DB7C; color: #FFFFFF; font-size: 16px; font-weight: 700;
      text-decoration: none; width: 100%; box-shadow: 0 6px 18px rgba(47, 158, 68, 0.35);
      cursor: pointer; transition: transform 0.15s;
    }
.qr-wrap { background: #FFFFFF; padding: 10px; border-radius: 12px; display: inline-block; margin: 10px auto 4px; }
.hidden { display: none !important; }

/* Public guide: readable without scripts, below the interactive tool. */
.fortune-intro { margin: 0 0 16px; color: var(--text-secondary); line-height: 1.65; }
.fortune-guide { margin-top: 24px; padding: clamp(16px, 3vw, 26px); }
.fortune-guide h2 { color: var(--gold-light); font-size: 1.2rem; margin: 0 0 14px; }
.fortune-guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.fortune-guide h3 { font-size: 1rem; margin: 0 0 5px; }
.fortune-guide p { margin: 0; color: var(--text-secondary); line-height: 1.65; }
@media (max-width: 620px) { .fortune-guide-grid { grid-template-columns: 1fr; } }
.fortune-home-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; margin-bottom: 6px; color: var(--gold-light); }

/* Keep the free calculator controls within the screen on narrow devices. */
@media screen and (max-width: 900px) {
  .zw-mobile-pills { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); overflow: visible; }
  .zw-mobile-pills .zw-pill-btn { min-width: 0; padding-inline: 6px; white-space: normal; }
}
@media screen and (max-width: 560px) {
  .seg-control { max-width: 100%; flex-wrap: wrap; }
  .seg-control .seg-btn { min-height: 44px; white-space: normal; flex: 1 1 auto; }
  .horizon-bar .seg-control { flex: 1 1 100%; }
  .zw-mobile-pills { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* In card mode, ignore the inline positions reserved for the traditional board. */
@media screen and (max-width: 900px) {
  .zw-board:not(.force-grid) {
    grid-auto-rows: auto;
    align-items: start;
    min-width: 0;
  }
  .zw-board:not(.force-grid) > .zw-palace {
    grid-area: auto !important;
    min-height: 0;
    gap: 10px;
  }
  .zw-board:not(.force-grid) .zw-stars-minor { margin-bottom: 0; }
  .zw-board.force-grid { min-width: 0; max-width: 100%; }
}
@media screen and (max-width: 560px) {
  .zw-board:not(.force-grid) .zw-center-grid { grid-template-columns: minmax(0, 1fr); }
  .zw-board:not(.force-grid) .zw-palace-footer { flex-wrap: wrap; }
}

/* Give narrow-screen actions room for touch and long labels. */
@media screen and (max-width: 800px) {
  #btnSaveProfile, #btnJumpToMatch { min-height: 44px !important; max-width: 100%; white-space: normal; }
  .preset-btn, .seg-btn { min-height: 44px; }
}

@media screen and (max-width: 800px) {
  #btnACalSolar, #btnACalLunar, #btnBCalSolar, #btnBCalLunar { min-height: 44px !important; }
}
