:root {
  --bg: #0B0E14;
  --bg-accent: #131926;
  --surface: #131822;
  --surface-2: #1A2130;
  --surface-card: linear-gradient(165deg, rgba(22, 28, 40, 0.96) 0%, rgba(15, 19, 28, 0.98) 100%);
  --border: rgba(214, 178, 110, 0.30);
  --border-soft: rgba(214, 178, 110, 0.14);
  --gold: #D6B26E;
  --gold-bright: #EED49F;
  --cinnabar: #C94A38;
  --cinnabar-bg: rgba(201, 74, 56, 0.14);
  --jade: #4EAD7B;
  --jade-bg: rgba(78, 173, 123, 0.14);
  --amber: #E0A44B;
  --text: #EDE7DA;
  --muted: #9AA3B5;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "PMingLiU", "SimSun", Georgia, serif;
  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
  --bg: #F6F1E6;
  --bg-accent: #EDE4D3;
  --surface: #FFFDF8;
  --surface-2: #F4ECDD;
  --surface-card: linear-gradient(165deg, #FFFDF8 0%, #FAF4E8 100%);
  --border: rgba(181, 148, 91, 0.44);
  --border-soft: rgba(181, 148, 91, 0.22);
  --gold: #B5945B;
  --gold-bright: #8A6826;
  --cinnabar: #B53D2C;
  --cinnabar-bg: rgba(181, 61, 44, 0.10);
  --jade: #2F7D57;
  --jade-bg: rgba(47, 125, 87, 0.10);
  --amber: #B47119;
  --text: #1F242D;
  --muted: #646D7D;
  --shadow: 0 8px 24px rgba(48, 34, 14, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 68% 36% at 50% 0%, rgba(214, 178, 110, 0.11) 0%, transparent 64%),
    radial-gradient(ellipse 52% 28% at 16% 6%, rgba(56, 98, 132, 0.12) 0%, transparent 66%),
    radial-gradient(ellipse 50% 28% at 84% 8%, rgba(201, 74, 56, 0.06) 0%, transparent 66%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.62;
  min-height: 100vh;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

[data-theme="light"] body,
html[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 72% 38% at 50% 0%, rgba(181, 148, 91, 0.14) 0%, transparent 66%),
    radial-gradient(ellipse 46% 24% at 18% 8%, rgba(181, 61, 44, 0.04) 0%, transparent 64%);
}

a {
  color: var(--gold);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ---- Top Header ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-seal {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(145deg, #CF4E3B 0%, #A63322 100%);
  color: #FFF7EA;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 17px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(246, 214, 152, 0.56);
  box-shadow: 0 3px 10px rgba(166, 51, 34, 0.35);
  flex: none;
}

.brand-seal::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 232, 189, 0.45);
  border-radius: 3px;
  pointer-events: none;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 1.5px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 410px;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: var(--text);
  border-color: var(--border-soft);
}

.nav-tab.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 18%, var(--surface-2)), var(--surface-2));
  color: var(--gold-bright);
  border-color: var(--border);
  font-weight: 600;
}

.global-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ctrl-btn, .ctrl-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  height: 33px;
}

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

.wallet-pill {
  background: linear-gradient(135deg, rgba(214, 178, 110, 0.16), rgba(201, 74, 56, 0.10));
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  max-width: 280px;
}

.wallet-pill.is-supreme {
  background: linear-gradient(135deg, rgba(201, 74, 56, 0.24), rgba(214, 178, 110, 0.22));
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 1px rgba(238, 212, 159, 0.2);
}

.wallet-pill.is-vip {
  background: linear-gradient(135deg, rgba(214, 178, 110, 0.24), rgba(168, 131, 61, 0.14));
  border-color: var(--gold-bright);
}

.pill-username {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-code {
  font-family: monospace;
  font-size: 11px;
}

.pill-sep {
  opacity: 0.55;
}

.pill-credits {
  font-weight: 700;
  color: var(--gold-bright);
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.35;
  flex: none;
}

.tier-badge.tier-supreme {
  background: linear-gradient(135deg, #C94A38, #B8863B);
  color: #FFF8EE;
  border: 1px solid rgba(255, 226, 170, 0.55);
}

.tier-badge.tier-vip {
  background: rgba(214, 178, 110, 0.22);
  color: var(--gold-bright);
  border: 1px solid var(--gold);
}

.tier-badge.tier-free {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}

.announce-bar {
  background: color-mix(in srgb, var(--surface) 86%, var(--gold) 14%);
  border-bottom: 1px solid var(--border-soft);
  padding: 6px 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---- Main Container ---- */
.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px 18px 36px;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 15px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-compact {
  padding: 13px 16px 12px;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Forms & Slim Collapsible Paipan Bar ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.paipan-primary-bar {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(105px, 0.95fr) minmax(245px, 1.95fr) minmax(145px, 1.25fr) auto;
  gap: 10px 12px;
  align-items: end;
}

.dt-pair {
  display: grid;
  grid-template-columns: minmax(126px, 1.2fr) minmax(96px, 1fr);
  gap: 8px;
}

.advanced-toggle-row {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.advanced-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--gold-bright);
}

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

.adv-pill {
  font-size: 11px;
  color: var(--muted);
}

.advanced-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.advanced-panel .field label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  min-width: 0;
}

.field label {
  font-size: 11px;
  color: var(--muted);
}

.input, .select, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  color: var(--text);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
}

.textarea {
  resize: vertical;
  min-height: 92px;
}

.city-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  margin-top: 3px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.city-option {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.city-option:hover {
  background: var(--surface-2);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, filter 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, #B58A43 0%, #DFBE7E 55%, #C79C52 100%);
  color: #1A1309;
  border-color: var(--gold-bright);
  box-shadow: 0 3px 12px rgba(214, 178, 110, 0.22), inset 0 1px 0 rgba(255, 250, 235, 0.45);
}

.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--cinnabar);
  color: #FFF8F0;
  border-color: var(--cinnabar);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

/* ---- Alerts ---- */
.alert-dst {
  background: var(--cinnabar-bg);
  border: 1px solid var(--cinnabar);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alert-dst strong {
  color: var(--cinnabar);
}

.alert-info {
  background: var(--jade-bg);
  border: 1px solid var(--jade);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
}

/* ---- Module A Two-Column Workspace ---- */
.paipan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

/* ---- Traditional 4x4 Square Chart (High-End Double-Line Gold Frame + Corner Frets) ---- */
.chart-wrap {
  position: relative;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 5px var(--border), var(--shadow);
  border-radius: 10px;
  padding: 10px;
}

.chart-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--gold-bright);
  border-style: solid;
  pointer-events: none;
  z-index: 6;
}
.chart-corner.tl { top: 4px; left: 4px; border-width: 2px 0 0 2px; }
.chart-corner.tr { top: 4px; right: 4px; border-width: 2px 2px 0 0; }
.chart-corner.bl { bottom: 4px; left: 4px; border-width: 0 0 2px 2px; }
.chart-corner.br { bottom: 4px; right: 4px; border-width: 0 2px 2px 0; }

.chart-grid-outer {
  position: relative;
  width: 100%;
}

.sanfang-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.chart-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(132px, auto));
  gap: 5px;
}

.palace-cell {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 6px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
  text-align: left;
}

.palace-cell:hover {
  border-color: var(--gold);
}

.palace-cell.is-sanfang {
  background: color-mix(in srgb, var(--surface-2) 86%, var(--gold) 14%);
  border-color: var(--gold);
}

.palace-cell.is-active {
  background: color-mix(in srgb, var(--surface-2) 76%, var(--gold) 24%);
  border: 1.5px solid var(--gold-bright);
  box-shadow: 0 0 12px rgba(214, 178, 110, 0.24), inset 0 0 0 1px var(--gold);
}

.palace-cell.is-active::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 9px 9px;
  border-color: transparent transparent var(--gold-bright) transparent;
  pointer-events: none;
}

.mobile-bazi-card {
  display: none;
}

.palace-top-zone {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.palace-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 0;
}

.mini-badge {
  font-size: 9px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(214, 178, 110, 0.18);
  color: var(--gold-bright);
  border: 1px solid var(--border-soft);
  line-height: 1.45;
}

.mini-badge.shen {
  background: var(--cinnabar-bg);
  color: var(--cinnabar);
  border-color: rgba(201, 74, 56, 0.35);
}

.palace-stars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.star-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}

.star-major {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.3px;
}

.star-bright {
  font-size: 9.5px;
  padding: 0 3.5px;
  border-radius: 3px;
  border: 1px solid var(--border-soft);
  line-height: 1.4;
}

.star-bright.is-peak {
  color: var(--gold-bright);
  border-color: rgba(214, 178, 110, 0.45);
  background: rgba(214, 178, 110, 0.12);
}

.star-bright.is-mid {
  color: var(--text);
  opacity: 0.78;
}

.star-bright.dim {
  color: var(--muted);
  opacity: 0.75;
}

.sihua-chip {
  font-size: 9.5px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--cinnabar);
  color: #FFF8EE;
  line-height: 1.45;
}

.sihua-chip.lu { background: #2F7D57; }
.sihua-chip.quan { background: #A86C1E; }
.sihua-chip.ke { background: #2F6899; }
.sihua-chip.ji { background: var(--cinnabar); }

.palace-mid-zone {
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.star-aux {
  font-size: 10.5px;
  color: var(--jade);
}

.star-sha {
  font-size: 10.5px;
  color: var(--cinnabar);
}

.star-minor {
  font-size: 9.5px;
  color: var(--muted);
  opacity: 0.78;
}

.palace-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
  font-size: 10px;
  color: var(--muted);
}

.palace-foot-right {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.palace-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--gold-bright);
}

.palace-sb {
  font-size: 10.5px;
  color: var(--muted);
}

/* ---- Center 2x2 Panel + Compass Watermark ---- */
.center-panel {
  position: relative;
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
}

.center-watermark-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.055;
  pointer-events: none;
  z-index: 1;
}

.center-head,
.center-kv,
.center-bazi-wrap {
  position: relative;
  z-index: 4;
}

.center-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 6px;
}

.center-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
}

.center-kv {
  font-size: 12px;
  line-height: 1.56;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.center-kv span.k {
  color: var(--muted);
}

.center-sihua-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.sihua-mini-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}

/* ---- Tablet Four Pillars & 5-Element Progress Bars ---- */
.bazi-pillars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.pillar-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(214, 178, 110, 0.08);
}

.pillar-lbl {
  font-size: 10px;
  color: var(--muted);
}

.pillar-val {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 1px;
  margin: 1px 0;
}

.pillar-dot-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
}

.elem-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.elem-wood { background: #4EAD7B; }
.elem-fire { background: #C94A38; }
.elem-earth { background: #D6B26E; }
.elem-metal { background: #C4CCD8; }
.elem-water { background: #4B88C7; }

.elem-ratio-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.elem-ratio-item {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 4px 6px;
}

.elem-ratio-head {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  margin-bottom: 3px;
}

.elem-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(154, 163, 181, 0.16);
  overflow: hidden;
}

.elem-fill {
  height: 100%;
  border-radius: 999px;
}

/* ---- Chinese Seal Badges & Quotes ---- */
.badge-level {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-serif);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  border: 1px solid transparent;
}

.lvl-excellent {
  background: linear-gradient(135deg, rgba(201, 74, 56, 0.24), rgba(214, 178, 110, 0.22));
  color: var(--gold-bright);
  border-color: var(--gold);
}
.lvl-good {
  background: rgba(214, 178, 110, 0.16);
  color: var(--gold-bright);
  border-color: rgba(214, 178, 110, 0.42);
}
.lvl-neutral {
  background: var(--jade-bg);
  color: var(--jade);
  border-color: rgba(78, 173, 123, 0.36);
}
.lvl-caution {
  background: var(--cinnabar-bg);
  color: var(--cinnabar);
  border-color: rgba(201, 74, 56, 0.42);
}

.quote-box {
  background: var(--surface-2);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.quote-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ---- Premium Pay SKU Cards & Wallet ---- */
.sku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.sku-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.sku-card.sku-premium {
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 8%, var(--surface-2)), var(--surface));
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(214, 178, 110, 0.08);
}

.sku-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sku-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-bright);
}

.sku-cache-tag {
  font-size: 10.5px;
  color: var(--jade);
  background: var(--jade-bg);
  border: 1px solid rgba(78, 173, 123, 0.35);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.sku-deliverables {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--muted);
}

.sku-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-bright);
}

/* ---- Heming Symmetric Layout & Score Ring ---- */
.heming-pair-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.heming-party-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 13px;
}

.heming-emblem-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.heming-emblem-ring {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 5px var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  padding: 6px;
  line-height: 1.2;
}

.heming-score-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.score-seal-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  flex: none;
  display: grid;
  place-items: center;
}

.score-seal-wrap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-seal-num {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1;
  text-align: center;
}

.score-seal-num small {
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Shendeng Chat & Micro-Action Highlight ---- */
.chat-log {
  max-height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  margin-bottom: 12px;
}

.chat-msg {
  padding: 11px 14px;
  border-radius: 10px;
  max-width: 90%;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 20%, var(--surface)), var(--surface-2));
  border: 1px solid var(--gold);
  border-bottom-right-radius: 3px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.chat-msg.crisis {
  align-self: stretch;
  max-width: 100%;
  background: var(--cinnabar-bg);
  border: 1.5px solid var(--cinnabar);
}

.sd-advisor-head {
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sd-micro-action-card {
  margin-top: 10px;
  padding: 9px 12px;
  border-left: 3px solid var(--gold-bright);
  background: color-mix(in srgb, var(--gold) 10%, var(--surface-2));
  border-radius: 0 7px 7px 0;
  color: var(--text);
}

.safe-md h2, .safe-md h3 {
  font-family: var(--font-serif);
  color: var(--gold-bright);
  margin: 10px 0 6px;
  font-size: 15px;
}

.safe-md p, .safe-md li {
  margin: 4px 0;
}

.safe-md blockquote {
  margin: 8px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--gold);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}

.safe-md code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
}

/* ---- Modals & Account 3-Tab Styles ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 8, 12, 0.74);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.modal-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
}

.modal-tab {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
}

.modal-tab.active {
  background: linear-gradient(135deg, rgba(214, 178, 110, 0.22), rgba(201, 74, 56, 0.14));
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.auth-subtabs {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 12px;
}

.auth-subtab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.auth-subtab.active {
  background: var(--surface-2);
  color: var(--gold-bright);
}

.tier-perks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.tier-perk-box {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.tier-perk-box.is-supreme {
  border-color: var(--gold);
  background: linear-gradient(155deg, rgba(201, 74, 56, 0.12), rgba(214, 178, 110, 0.10));
}

.tier-perks-list {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--muted);
}

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--border-soft);
  padding: 18px;
  font-size: 12px;
  color: var(--muted);
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

/* ---- Table (Admin & Heming) ---- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.data-table th, table.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

table.data-table th {
  color: var(--gold-bright);
  font-weight: 600;
}

/* ---- Responsive Breakpoints ---- */
@media (max-width: 1100px) {
  .paipan-primary-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .paipan-submit-field {
    grid-column: 1 / -1;
  }
  .advanced-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .paipan-layout {
    grid-template-columns: 1fr;
  }
  .heming-pair-grid {
    grid-template-columns: 1fr;
  }
  .heming-emblem-col {
    padding: 0;
  }
  .heming-emblem-ring {
    width: auto;
    height: auto;
    border-radius: 999px;
    padding: 4px 16px;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    padding: 8px 10px;
    gap: 8px;
  }
  .brand-sub {
    max-width: 220px;
  }
  .wallet-pill {
    max-width: 100%;
    padding: 4px 9px;
    font-size: 11.5px;
    gap: 4px;
  }
  .pill-username {
    max-width: 68px;
  }
  .paipan-primary-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .paipan-dt-field {
    grid-column: 1 / -1;
  }
  .advanced-panel {
    grid-template-columns: 1fr;
  }
  .center-bazi-wrap {
    display: none;
  }
  .mobile-bazi-card {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
  .mobile-bazi-card .bazi-pillars {
    margin-top: 6px;
    gap: 5px;
  }
  .mobile-bazi-card .pillar-val {
    font-size: 14px;
  }
  .mobile-bazi-card .elem-ratio-list {
    gap: 4px;
  }
  .mobile-bazi-card .elem-ratio-item {
    padding: 3px 4px;
  }
  .container {
    padding: 10px 8px 28px;
  }
  .card {
    padding: 12px 10px;
  }
  .chart-wrap {
    padding: 6px;
  }
  .chart-grid {
    grid-template-rows: repeat(4, minmax(112px, auto));
    gap: 3px;
  }
  .palace-cell {
    padding: 4px 3px 4px;
    overflow: hidden;
  }
  .palace-name {
    font-size: 10.5px;
  }
  .palace-sb {
    font-size: 8.5px;
  }
  .palace-foot {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1px;
    margin-top: 3px;
    padding-top: 2px;
    font-size: 8.5px;
    line-height: 1.25;
  }
  .star-major {
    font-size: 10.5px;
  }
  .star-bright, .sihua-chip, .mini-badge {
    font-size: 8.5px;
    padding: 0 2.5px;
    line-height: 1.3;
  }
  .star-aux, .star-sha, .star-minor {
    font-size: 8.5px;
    line-height: 1.25;
  }
  .center-panel {
    padding: 7px 6px;
    gap: 4px;
    justify-content: flex-start;
  }
  .center-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .center-title {
    font-size: 11.5px;
    line-height: 1.3;
  }
  .center-kv {
    font-size: 9.5px;
    line-height: 1.4;
    word-break: break-word;
  }
}
