/* 寿生宝鉴 2.2.0 — 现代东方工具设计系统 */
:root {
  --ssz-primary: #7c2026;
  --ssz-primary-strong: #5e1419;
  --ssz-primary-soft: #f7e9e7;
  --ssz-gold: #8d6629;
  --ssz-gold-soft: #f4ead5;
  --ssz-canvas: #f5f0e7;
  --ssz-surface: #fffdf8;
  --ssz-surface-muted: #faf6ef;
  --ssz-text: #2d2925;
  --ssz-text-muted: #6f665d;
  --ssz-border: #ded3c4;
  --ssz-border-strong: #cbbba6;
  --ssz-success: #326b4c;
  --ssz-danger: #a12d2d;
  --ssz-info: #415f75;
  --ssz-shadow: 0 10px 32px rgba(68, 45, 28, 0.07);
  --ssz-radius-sm: 8px;
  --ssz-radius: 14px;
  --ssz-radius-lg: 20px;
  --ssz-focus: 0 0 0 3px rgba(124, 32, 38, 0.2);
  --ssz-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --ssz-font-serif: "Songti SC", "STSong", "SimSun", serif;

  /* 兼容既有页面与脚本中的变量名 */
  --primary: var(--ssz-primary);
  --primary-light: #98333a;
  --primary-dark: var(--ssz-primary-strong);
  --gold: var(--ssz-gold);
  --gold-light: #c9a866;
  --bg: var(--ssz-canvas);
  --bg-card: var(--ssz-surface);
  --text: var(--ssz-text);
  --text-muted: var(--ssz-text-muted);
  --border: var(--ssz-border);
  --shadow: var(--ssz-shadow);
  --radius: var(--ssz-radius);
  --font-main: var(--ssz-font-sans);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--ssz-canvas);
  color: var(--ssz-text);
  font-family: var(--ssz-font-sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--ssz-primary); text-underline-offset: 3px; }
img, svg { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--ssz-primary);
  outline-offset: 3px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ssz-focus); }
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* 顶栏与导航 */
.site-header { position: relative; z-index: 20; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 64px;
  padding: 9px max(18px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #67181e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}
.topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: #fff8ec;
  text-decoration: none;
  font-family: var(--ssz-font-serif);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.logo-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(238, 211, 157, 0.82);
  border-radius: 50%;
  color: #efd59f;
  font-family: var(--ssz-font-serif);
  font-size: 0.9rem;
  line-height: 1;
}
.topbar-nav { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.topbar-nav a, .topbar-nav button {
  min-height: 44px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: var(--ssz-radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-nav a:hover, .topbar-nav button:hover,
.topbar-nav .is-active, .topbar-nav [aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; }
.topbar-nav .btn-topbar-primary { background: #d7b66f; color: #4d1618; font-weight: 700; }
.topbar-user { max-width: 150px; overflow: hidden; color: #efd59f; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle {
  display: none;
  min-width: 64px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--ssz-radius-sm);
  background: transparent;
  color: #fff;
  cursor: pointer;
}

/* 通用布局 */
.container { width: min(100% - 32px, 960px); margin-inline: auto; }
.page-main, .calc-layout, .content-stack { padding-block: 38px 64px; }
.content-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.content-stack > *, .card, .page-intro { min-width: 0; }
.card, .auth-card {
  background: var(--ssz-surface);
  border: 1px solid var(--ssz-border);
  border-radius: var(--ssz-radius-lg);
  box-shadow: var(--ssz-shadow);
}
.card { padding: clamp(22px, 3.2vw, 34px); }
.card + .card { margin-top: 0; }
.card-title {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ssz-text);
  font-family: var(--ssz-font-serif);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  font-weight: 700;
  line-height: 1.35;
}
.eyebrow, .section-kicker, .page-eyebrow, .summary-kicker {
  margin: 0 0 5px;
  color: var(--ssz-primary);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.section-heading, .result-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.section-heading > div { min-width: 0; }
.section-heading > .section-kicker { flex-basis: 100%; }
.section-intro, .page-description, .page-intro p, .muted-text, .card-note { color: var(--ssz-text-muted); }
.section-intro { max-width: 34rem; margin: 4px 0 0; text-align: right; }
.page-intro { margin-bottom: 22px; }
.page-intro h1 { margin: 0 0 8px; font-family: var(--ssz-font-serif); font-size: clamp(1.75rem, 5vw, 2.5rem); }
.page-intro p:last-child { margin-bottom: 0; }
.rich-text { color: var(--ssz-text); }
.rich-text > :last-child, .card > :last-child { margin-bottom: 0; }
.rich-text ul, .rich-text ol, .source-list, .disclaimer-list { padding-left: 1.35rem; }
.rich-text li + li, .source-list li + li, .disclaimer-list li + li { margin-top: 8px; }
.inline-link { margin-inline: 0.3em; font-weight: 700; }

/* 按钮 */
.btn {
  min-height: 44px;
  padding: 10px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.58; transform: none; }
.btn-primary { background: var(--ssz-primary); border-color: var(--ssz-primary); color: #fff; }
.btn-primary:hover { background: var(--ssz-primary-strong); border-color: var(--ssz-primary-strong); }
.btn-secondary { background: var(--ssz-surface); border-color: var(--ssz-border-strong); color: var(--ssz-primary); }
.btn-secondary:hover { background: var(--ssz-primary-soft); border-color: var(--ssz-primary); }
.btn-gold { background: var(--ssz-gold); border-color: var(--ssz-gold); color: #fff; }
.btn-gold:hover { background: #73501f; }
.btn-danger { background: transparent; border-color: #d7aaa7; color: var(--ssz-danger); }
.btn-danger:hover { background: #fff0ef; border-color: var(--ssz-danger); }
.btn-sm, .btn-compact { min-height: 44px; padding: 8px 14px; font-size: 0.9rem; }
.btn-block, .btn-wide { width: 100%; }
.button-row, .form-actions, .result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.form-actions { margin-top: 24px; }
.form-actions .btn-wide { flex: 1 1 240px; }
.form-actions-stacked { display: grid; gap: 12px; }

/* 表单 */
.form-section {
  min-width: 0;
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}
.form-section > legend {
  width: 100%;
  margin-bottom: 12px;
  color: var(--ssz-text);
  font-size: 0.96rem;
  font-weight: 750;
}
.form-group { min-width: 0; margin-bottom: 18px; }
.form-group label, .field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ssz-text);
  font-size: 0.9rem;
  font-weight: 700;
}
.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select, .search-bar input, .manual-copy {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--ssz-border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ssz-text);
}
.form-group input:hover, .form-group select:hover, .search-bar input:hover { border-color: #b9a790; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--ssz-danger) !important; background: #fff9f8 !important; }
.label-optional, .optional-mark { color: var(--ssz-text-muted); font-size: 0.78rem; font-weight: 500; }
.label-required, .required-mark { color: var(--ssz-danger); font-size: 0.78rem; font-weight: 700; }
.form-grid, .form-row, .form-row-3 { display: grid; gap: 14px; }
.form-grid-two, .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-hint { margin: 8px 0 0; color: var(--ssz-text-muted); font-size: 0.82rem; line-height: 1.6; }

.mode-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode-card {
  position: relative;
  min-height: 148px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--ssz-border);
  border-radius: var(--ssz-radius);
  background: var(--ssz-surface-muted);
  cursor: pointer;
}
.mode-card:hover { border-color: #b79d79; }
.mode-card.is-selected { border-color: var(--ssz-primary); background: #fffaf5; box-shadow: inset 0 0 0 1px var(--ssz-primary); }
.mode-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-card:focus-within { box-shadow: var(--ssz-focus); }
.mode-card strong { color: var(--ssz-text); font-family: var(--ssz-font-serif); font-size: 1rem; }
.mode-card > span:last-child { color: var(--ssz-text-muted); font-size: 0.82rem; line-height: 1.55; }
.mode-card-tag, .mode-badge, .pillar-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #c6ae88;
  border-radius: 999px;
  background: var(--ssz-gold-soft);
  color: #6f4c18;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}
.mode-card-folk .mode-card-tag, .mode-badge.is-folk, .pillar-mode-badge.folk { border-color: #c7aaa8; background: var(--ssz-primary-soft); color: var(--ssz-primary); }

.tab-group {
  width: fit-content;
  margin-bottom: 18px;
  padding: 4px;
  display: flex;
  gap: 4px;
  border: 1px solid var(--ssz-border);
  border-radius: 11px;
  background: #eee7dc;
}
.tab-btn {
  min-width: 92px;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ssz-text-muted);
  cursor: pointer;
  font-weight: 700;
}
.tab-btn.active { background: var(--ssz-surface); color: var(--ssz-primary); box-shadow: 0 2px 8px rgba(62, 45, 32, 0.08); }
.segmented-control { display: inline-flex; padding: 4px; gap: 4px; border: 1px solid var(--ssz-border); border-radius: 10px; background: var(--ssz-surface-muted); }
.segmented-control label { margin: 0; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { min-width: 64px; min-height: 44px; padding: 7px 14px; display: grid; place-items: center; border-radius: 7px; }
.segmented-control input:checked + span { background: var(--ssz-primary); color: #fff; }
.segmented-control input:focus-visible + span { box-shadow: var(--ssz-focus); }
.inline-notice { margin-top: 4px; padding: 10px 12px; border-left: 3px solid var(--ssz-gold); background: var(--ssz-gold-soft); color: #5c4830; border-radius: 4px 9px 9px 4px; font-size: 0.86rem; }

.time-primary-row { display: flex; align-items: center; gap: 12px; }
.time-input-group { width: 180px; margin: 0; }
.time-recognition { min-height: 46px; padding: 10px 14px; display: flex; align-items: center; border: 1px solid var(--ssz-border); border-radius: 10px; background: var(--ssz-surface-muted); color: var(--ssz-primary); font-weight: 700; }
.time-fallback { margin-top: 16px; border: 1px solid var(--ssz-border); border-radius: var(--ssz-radius); background: var(--ssz-surface-muted); }
.time-fallback > summary, .result-disclosure > summary { min-height: 46px; padding: 11px 15px; cursor: pointer; color: var(--ssz-primary); font-weight: 700; }
.time-fallback[open] > summary, .result-disclosure[open] > summary { border-bottom: 1px solid var(--ssz-border); }
.shichen-grid { padding: 14px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.shichen-btn { min-height: 58px; padding: 8px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--ssz-border); border-radius: 9px; background: #fff; color: var(--ssz-text); cursor: pointer; }
.shichen-btn:hover, .shichen-btn.selected { border-color: var(--ssz-primary); background: var(--ssz-primary-soft); color: var(--ssz-primary); }
.shichen-name { font-family: var(--ssz-font-serif); font-weight: 700; }
.shichen-time { color: var(--ssz-text-muted); font-size: 0.68rem; }

/* 提示与状态 */
.alert { margin: 14px 0; padding: 12px 14px; border: 1px solid; border-radius: 10px; font-size: 0.9rem; }
.alert-info { border-color: #b9cad4; background: #eff6f8; color: #355568; }
.alert-success { border-color: #abcdb8; background: #eff8f2; color: #285c40; }
.alert-error { border-color: #dfb5b1; background: #fff1ef; color: #842929; }
.form-error { margin-top: 4px; }
.form-message:empty, .copy-status:empty { display: none; }
.copy-status { margin: 10px 0 0; color: var(--ssz-success); font-size: 0.88rem; }
.manual-copy { min-height: 150px; margin-top: 10px; resize: vertical; white-space: pre; }
.copy-proxy { position: fixed; left: -10000px; top: 0; width: 2px; height: 2px; opacity: 0; }

/* 首页 */
.home-hero, .hero { padding: clamp(68px, 9vw, 112px) 16px; background: #67181e; color: #fff; }
.hero-inner { width: min(100%, 760px); margin-inline: auto; text-align: center; }
.hero .eyebrow { color: #e5c889; }
.hero h1 { margin: 8px 0 18px; color: #fffdf7; font-family: var(--ssz-font-serif); font-size: clamp(2.2rem, 8vw, 4rem); letter-spacing: 0.12em; }
.hero-lead { max-width: 700px; margin: 0 auto 28px; color: rgba(255, 255, 255, 0.78); font-size: clamp(1rem, 2vw, 1.15rem); }
.hero-btns { display: flex; justify-content: center; }
.hero .btn-gold { min-width: 180px; }
.home-account-link { display: inline-block; margin-top: 18px; color: #efdcae; }
.home-content { padding-block: 30px 64px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feature-item { min-width: 0; padding: 18px; border: 1px solid var(--ssz-border); border-radius: var(--ssz-radius); background: var(--ssz-surface-muted); }
.feature-index { display: block; margin-bottom: 14px; color: var(--ssz-gold); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.12em; }
.feature-title { margin-bottom: 6px; color: var(--ssz-text); font-family: var(--ssz-font-serif); font-weight: 700; }
.feature-desc { color: var(--ssz-text-muted); font-size: 0.88rem; }
.home-disclaimer { margin: 20px 0 0; color: var(--ssz-text-muted); font-size: 0.82rem; }

/* 计算页与结果 */
.calc-layout { width: min(100% - 32px, 980px); display: grid; gap: 22px; }
.calc-form-card.is-collapsed { padding-block: 18px; }
.calc-form-card.is-collapsed > .section-heading { display: none; }
.form-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.summary-copy { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.summary-copy strong { font-size: 1.05rem; }
.summary-copy > span:not(.summary-kicker):not(.mode-badge) { color: var(--ssz-text-muted); }
.summary-kicker { flex-basis: 100%; margin: 0; }
.result-section { scroll-margin-top: 78px; }
.result-card { overflow: hidden; }
.result-heading-row { align-items: center; }
.result-context { margin-bottom: 18px; padding: 16px 18px; border-left: 3px solid var(--ssz-gold); border-radius: 5px 12px 12px 5px; background: var(--ssz-surface-muted); }
.result-context p { margin: 5px 0 0; color: var(--ssz-text-muted); overflow-wrap: anywhere; }
.result-ganzhi { color: var(--ssz-primary); font-family: var(--ssz-font-serif); font-size: 1.4rem; letter-spacing: 0.12em; }
.result-total {
  margin: 0 0 16px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: var(--ssz-radius);
  background: #67181e;
  color: #fff;
}
.total-label { color: #f1d9a6; font-weight: 700; }
.total-hint { margin-top: 3px; color: rgba(255, 255, 255, 0.66); font-size: 0.78rem; }
.total-value { color: #fff9ec; font-family: var(--ssz-font-serif); font-size: clamp(1.65rem, 5vw, 2.45rem); font-weight: 700; white-space: nowrap; }
.metric-grid, .result-extra, .detail-pillar-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-grid { margin-bottom: 18px; }
.metric-card, .extra-item { min-width: 0; padding: 15px; border: 1px solid var(--ssz-border); border-radius: 12px; background: var(--ssz-surface-muted); }
.metric-card span, .extra-label { display: block; margin-bottom: 5px; color: var(--ssz-text-muted); font-size: 0.75rem; }
.metric-card strong, .extra-value { display: block; color: var(--ssz-primary); font-family: var(--ssz-font-serif); font-size: 1.02rem; font-weight: 700; overflow-wrap: anywhere; }
.result-extra { margin: 16px 0; }

.pillar-panel { margin: 18px 0; overflow: hidden; border: 1px solid var(--ssz-border); border-radius: var(--ssz-radius); background: var(--ssz-surface); }
.pillar-panel-heading { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--ssz-surface-muted); }
.pillar-panel-title { margin: 0; font-family: var(--ssz-font-serif); font-size: 1.08rem; }
.pillar-grid-wrap { max-width: 100%; overflow-x: auto; }
.pillar-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pillar-label-col { width: 84px; }
.pillar-grid th, .pillar-grid td { padding: 10px 6px; border-top: 1px solid var(--ssz-border); border-right: 1px solid var(--ssz-border); text-align: center; overflow-wrap: anywhere; }
.pillar-grid th:last-child, .pillar-grid td:last-child { border-right: 0; }
.pillar-grid thead th, .pillar-grid tbody th { background: #f2ece3; color: var(--ssz-text-muted); font-size: 0.76rem; }
.pillar-ganzhi td { color: var(--ssz-primary); font-family: var(--ssz-font-serif); font-size: 1.3rem; font-weight: 700; }
.pillar-usage td { color: var(--ssz-text-muted); font-size: 0.72rem; }
.pillar-usage td.is-included { background: var(--ssz-primary-soft); color: var(--ssz-primary); font-weight: 700; }
.pillar-note { margin: 0; padding: 11px 15px; border-top: 1px solid var(--ssz-border); color: var(--ssz-text-muted); font-size: 0.78rem; }
.result-disclosure { margin-top: 12px; border: 1px solid var(--ssz-border); border-radius: 12px; background: var(--ssz-surface); overflow: hidden; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
.result-table, .history-table { width: 100%; border-collapse: collapse; background: var(--ssz-surface); }
.result-table { min-width: 620px; }
.result-table th, .result-table td, .history-table th, .history-table td { padding: 12px 14px; border-bottom: 1px solid var(--ssz-border); text-align: left; vertical-align: middle; }
.result-table th, .history-table th { background: #f1e9de; color: var(--ssz-text); font-size: 0.8rem; font-weight: 750; }
.result-table .amount, .history-table .amount-cell { text-align: right; white-space: nowrap; }
.result-row-detail { color: var(--ssz-text-muted); font-size: 0.84rem; }
.result-table .summary-row td { background: #fcf7ee; }
.result-table .total-row td { color: var(--ssz-primary); font-weight: 750; }
.result-source-box { padding: 15px; color: var(--ssz-text-muted); font-size: 0.88rem; line-height: 1.75; }
.result-source-box a { margin-right: 10px; font-weight: 700; }
.result-source-box p { margin: 8px 0 0; }
.result-actions { margin-top: 20px; }

/* 历史与详情 */
.page-heading { margin-bottom: 22px; }
.page-heading .card-title { margin-bottom: 6px; }
.page-description { margin: 0; }
.search-bar { margin-bottom: 18px; display: flex; gap: 10px; }
.search-bar input { flex: 1; min-width: 0; }
.history-table-region { max-width: 100%; overflow-x: auto; }
.history-table { min-width: 760px; }
.history-table .bazi-cell { color: var(--ssz-text-muted); font-size: 0.84rem; }
.history-actions-cell { display: flex; align-items: center; gap: 8px; }
.history-loading { padding: 32px !important; text-align: center !important; color: var(--ssz-text-muted); }
.empty-state { padding: 44px 16px; text-align: center; color: var(--ssz-text-muted); }
.empty-mark { width: 64px; height: 64px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid var(--ssz-border); border-radius: 50%; background: var(--ssz-surface-muted); font-size: 0.78rem; }
.pagination { margin-top: 18px; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.page-btn { min-width: 44px; min-height: 44px; border: 1px solid var(--ssz-border); border-radius: 9px; background: var(--ssz-surface); color: var(--ssz-text); cursor: pointer; }
.page-btn.active { border-color: var(--ssz-primary); background: var(--ssz-primary); color: #fff; }
.record-count { margin: 12px 0 0; color: var(--ssz-text-muted); text-align: center; font-size: 0.82rem; }
.detail-header { padding: 28px; border-radius: var(--ssz-radius-lg); background: #67181e; color: #fff; }
.detail-header .eyebrow { color: #e5c889; }
.detail-name { margin: 0 0 6px; color: #fff; font-family: var(--ssz-font-serif); font-size: 2rem; }
.detail-bazi { color: #f0d59d; font-family: var(--ssz-font-serif); font-size: 1.1rem; overflow-wrap: anywhere; }
.detail-birth-info { margin: 7px 0 0; color: rgba(255, 255, 255, 0.74); }
.detail-pillar-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 14px; }
.detail-pillar-panel .extra-item { text-align: center; }

/* 登录、个人中心、诊断 */
.auth-wrapper { width: min(100% - 32px, 520px); min-height: calc(100vh - 180px); margin-inline: auto; padding-block: 48px 64px; display: grid; align-content: start; }
.auth-card { padding: clamp(24px, 6vw, 38px); }
.auth-logo { margin-bottom: 22px; text-align: center; }
.auth-logo h1 { margin: 0 0 7px; font-family: var(--ssz-font-serif); font-size: 2rem; }
.auth-logo p:last-child { color: var(--ssz-text-muted); }
.auth-switch, .auth-back { margin: 18px 0 0; text-align: center; color: var(--ssz-text-muted); }
.auth-back { margin-top: 8px; font-size: 0.86rem; }
.auth-note { margin-top: 22px; }
.profile-info { border-top: 1px solid var(--ssz-border); }
.profile-row { min-height: 48px; padding: 11px 0; display: grid; grid-template-columns: 130px 1fr; gap: 14px; border-bottom: 1px solid var(--ssz-border); }
.profile-label { color: var(--ssz-text-muted); }
.profile-form { max-width: 560px; }
.danger-card { border-color: #dfbbb7; }
.danger-card .card-title { color: var(--ssz-danger); }
.loading-text { color: var(--ssz-text-muted); }
.diagnose-results { display: grid; gap: 10px; }
.test, .diagnose-status { padding: 13px 15px; border: 1px solid var(--ssz-border); border-radius: 10px; background: var(--ssz-surface-muted); }
.test.pass, .diagnose-status.pass { border-color: #abcdb8; background: #eff8f2; color: #285c40; }
.test.fail, .diagnose-status.fail { border-color: #dfb5b1; background: #fff1ef; color: #842929; }
.test.pending, .diagnose-status.pending { color: var(--ssz-text-muted); }
.diagnose-error { margin-top: 6px; font-size: 0.82rem; overflow-wrap: anywhere; }
.diagnose-actions { margin-top: 18px; }
.disclaimer-card { border-color: #d8bf99; background: #fffaf1; }

/* 页脚 */
.site-footer { padding: 28px 16px 38px; color: var(--ssz-text-muted); text-align: center; font-size: 0.78rem; }
.site-footer p { margin: 2px 0; }
.site-footer-inner { width: min(100%, 960px); }
.auth-footer { padding-top: 0; }

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding-inline: 16px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-nav { display: none; width: 100%; padding: 4px 0 8px; flex-wrap: wrap; justify-content: flex-start; border-top: 1px solid rgba(255, 255, 255, 0.12); }
  .topbar-nav.is-open { display: flex; }
  .topbar-nav a, .topbar-nav button { flex: 1 1 auto; justify-content: center; }
  .topbar-user { flex-basis: 100%; max-width: none; padding: 6px 10px; }
  .mode-card-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: auto; }
  .shichen-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .history-table-region { overflow: visible; }
  .history-table { min-width: 0; border: 0; background: transparent; }
  .history-table thead { display: none; }
  .history-table tbody { display: grid; gap: 12px; }
  .history-table tr { display: block; padding: 10px 14px; border: 1px solid var(--ssz-border); border-radius: var(--ssz-radius); background: var(--ssz-surface); }
  .history-table td { min-height: 42px; padding: 9px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--ssz-border); text-align: right; }
  .history-table td::before { content: attr(data-label); flex: 0 0 34%; color: var(--ssz-text-muted); font-size: 0.78rem; text-align: left; }
  .history-table td:last-child { border-bottom: 0; }
  .history-table .amount-cell { text-align: right; }
  .history-actions-cell { justify-content: flex-end; }
  .history-actions-cell .btn { flex: 1; }
  .history-loading-row { padding: 0 !important; }
  .history-loading::before { content: none !important; }
}

@media (max-width: 640px) {
  .container, .calc-layout { width: min(100% - 24px, 960px); }
  .page-main, .calc-layout, .content-stack { padding-block: 22px 44px; }
  .card, .auth-card { padding: 20px 16px; border-radius: 15px; }
  .section-heading, .result-heading-row { flex-direction: column; gap: 8px; }
  .section-intro { text-align: left; }
  .form-grid-two, .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  .feature-grid { grid-template-columns: 1fr; }
  .time-primary-row { align-items: stretch; flex-direction: column; }
  .time-input-group { width: 100%; }
  .shichen-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-summary { align-items: stretch; flex-direction: column; }
  .form-summary .btn { width: 100%; }
  .result-total { align-items: flex-start; flex-direction: column; }
  .total-value { white-space: normal; overflow-wrap: anywhere; }
  .metric-grid, .result-extra { grid-template-columns: 1fr; }
  .detail-pillar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pillar-label-col { width: 58px; }
  .pillar-grid th, .pillar-grid td { padding: 8px 3px; font-size: 0.72rem; }
  .pillar-ganzhi td { font-size: 1.05rem; }
  .pillar-usage td { font-size: 0.64rem; }
  .result-actions .btn { flex: 1 1 calc(50% - 6px); }
  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }
  .profile-row { grid-template-columns: 1fr; gap: 2px; }
  .hero { padding-block: 64px; }
  .hero h1 { letter-spacing: 0.08em; }
}

@media (max-width: 390px) {
  .topbar-logo { font-size: 1.05rem; }
  .shichen-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-actions .btn { flex-basis: 100%; }
  .pillar-panel-heading { align-items: flex-start; flex-direction: column; }
}

@page { size: A4 portrait; margin: 14mm; }
@media print {
  html, body { min-width: 0; background: #fff !important; color: #000 !important; }
  .topbar, .site-header, .site-footer, .calc-form-card, .result-actions, .copy-status, .manual-copy,
  #saveAlert, #notFound { display: none !important; }
  .container, .calc-layout, .content-stack { width: 100%; max-width: none; margin: 0; padding: 0; }
  .card, .result-card { padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .detail-header { margin-bottom: 12px; padding: 14px; border: 1px solid #777; border-radius: 0; background: #fff; color: #000; }
  .detail-header *, .result-total *, .result-context * { color: #000 !important; }
  .result-total, .result-context, .pillar-panel, .metric-card, .extra-item, .result-disclosure { break-inside: avoid; border: 1px solid #777; border-radius: 0; background: #fff !important; color: #000 !important; box-shadow: none; }
  .metric-grid, .result-extra, .detail-pillar-grid { grid-template-columns: repeat(3, 1fr); }
  .result-disclosure > summary { display: none; }
  .result-disclosure > *:not(summary) { display: block !important; }
  .result-disclosure { margin-top: 10px; }
  .result-table { min-width: 0; font-size: 9pt; }
  .result-table th, .result-table td, .pillar-grid th, .pillar-grid td { padding: 6px; border: 1px solid #777; background: #fff !important; color: #000 !important; }
  a { color: #000 !important; }
}
