/* ============================================================
   八字排盘 · 命盘
   设计语言：「玄机」——深墨底、鎏金线、朱砂点缀，宋体大字写干支
   ============================================================ */

:root {
  color-scheme: dark;

  /* 底色 */
  --bg: #0E1014;
  --bg-glow-1: rgba(200, 166, 86, .09);
  --bg-glow-2: rgba(90, 143, 191, .07);
  --surface: #161A22;
  --surface-2: #1D222C;
  --surface-3: #232935;

  /* 文字 */
  --ink: #EDE6D6;
  --ink-2: #A8A196;
  --ink-3: #8B857A;

  /* 线条 */
  --line: rgba(214, 196, 148, .15);
  --line-strong: rgba(214, 196, 148, .3);

  /* 强调 */
  --gold: #C8A656;
  --gold-soft: rgba(200, 166, 86, .14);
  --gold-line: rgba(200, 166, 86, .45);
  --cinnabar: #B4462F;
  --cinnabar-soft: rgba(180, 70, 47, .16);

  /* 五行 */
  --wx-mu: #5FA97C;
  --wx-huo: #C9584A;
  --wx-tu: #C9A25A;
  --wx-jin: #9EB3C4;
  --wx-shui: #5A8FBF;

  /* 十神分组 */
  --ss-self: #C8A656;
  --ss-output: #5FA97C;
  --ss-wealth: #C9584A;
  --ss-officer: #9EB3C4;
  --ss-resource: #A98BC4;

  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);

  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(90% 50% at 100% 8%, var(--bg-glow-2), transparent 72%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  animation: fade-up .5s var(--ease) both;
}
.view[hidden] { display: none; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ================= 首页 ================= */

.hero { text-align: center; padding: 18px 0 26px; }

.hero-mark {
  width: 96px; height: 96px;
  margin: 0 auto 18px;
  color: var(--gold);
  opacity: .92;
  animation: spin-slow 90s linear infinite;
}
.hero-mark svg { width: 100%; height: 100%; display: block; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

.hero h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .22em;
  margin: 0 0 10px;
  text-indent: .22em;
  background: linear-gradient(180deg, #F3EAD3 20%, var(--gold) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 0;
  font-size: 13px;
  letter-spacing: .16em;
  color: var(--ink-2);
}

.hero-note {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--ink-3);
}

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 18px 40px -28px rgba(0, 0, 0, .9);
}

.form { padding: 20px 16px 18px; }

.field { margin-bottom: 18px; position: relative; }
.field:last-of-type { margin-bottom: 16px; }

.label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.label em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;         /* ≥16px 防止 iOS 聚焦缩放 */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none;
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.input::-webkit-calendar-picker-indicator {
  filter: invert(.75) sepia(.4) saturate(2) hue-rotate(5deg);
  cursor: pointer;
  opacity: .8;
}

.hint {
  margin: 7px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-3);
}
.hint.is-warn { color: var(--cinnabar); }

/* 性别分段 */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.seg-btn {
  min-height: 40px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .1em;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.seg-btn.is-on {
  color: #16110A;
  background: linear-gradient(180deg, #E3C878, var(--gold));
  box-shadow: 0 2px 10px -4px var(--gold);
  font-weight: 700;
}

/* 城市组合框 */
.combo { position: relative; }
.combo-clear {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1;
  color: var(--ink-3);
  background: transparent; border: 0; border-radius: 50%;
  cursor: pointer;
}
.combo-list {
  position: absolute;
  z-index: 30;
  left: 0; right: 0;
  top: calc(100% + 6px);
  max-height: 244px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, .95);
}
.combo-list[hidden] { display: none; }
.combo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 15px;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.combo-item span { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.combo-item:hover, .combo-item.is-active { background: var(--gold-soft); }

/* 更多选项 */
.more {
  margin: 4px 0 18px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}
.more summary {
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--gold);
  border-bottom: 1.5px solid var(--gold);
  transform: rotate(-45deg) translate(-1px, -1px);
  transition: transform .2s var(--ease);
}
.more[open] summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.more-body { padding-top: 16px; }

/* 主按钮 */
.submit {
  position: relative;
  width: 100%;
  min-height: 54px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3em;
  text-indent: .3em;
  color: #16110A;
  background: linear-gradient(180deg, #E7CE84, #C8A656 60%, #B08F41);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 14px 30px -14px rgba(200, 166, 86, .7);
  transition: transform .15s var(--ease), box-shadow .25s var(--ease), filter .2s;
}
.submit:active { transform: translateY(1px) scale(.995); box-shadow: 0 8px 20px -12px rgba(200, 166, 86, .7); }
.submit[disabled] { filter: grayscale(.5) brightness(.8); cursor: default; }

.err {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #F0C3B8;
  background: var(--cinnabar-soft);
  border: 1px solid rgba(180, 70, 47, .4);
  border-radius: 8px;
}
.err[hidden] { display: none; }

/* 示例 */
.quick { margin-top: 26px; }
.quick-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--ink-3);
  margin: 0 0 10px 2px;
}
.quick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 100px;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.chip:active { background: var(--gold-soft); border-color: var(--gold-line); color: var(--ink); }

.foot {
  margin-top: 34px;
  padding: 0 4px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-3);
  text-align: center;
}
.foot p { margin: 0 0 6px; }
.foot-dim { opacity: .8; }

/* ================= 结果页 ================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -20px -16px 16px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: linear-gradient(180deg, rgba(14, 16, 20, .97) 60%, rgba(14, 16, 20, .6));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-btn {
  min-height: 40px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--gold);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.topbar-btn:active { background: var(--gold-soft); }
.topbar-title {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .18em;
  color: var(--ink-2);
}

.result > * + * { margin-top: 16px; }

/* 命主信息 */
.ident {
  padding: 18px 16px;
  text-align: center;
}
.ident-name {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: .14em;
  margin: 0 0 4px;
  color: var(--ink);
}
.ident-bazi {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .28em;
  text-indent: .28em;
  color: var(--gold);
  margin: 10px 0 12px;
}
.ident-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
}
.ident-row b { color: var(--ink); font-weight: 600; }
.ident-row .dim { color: var(--ink-3); }

/* 四柱盘 */
.plate {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  overflow: hidden;
}
.pillar {
  padding: 14px 4px 12px;
  text-align: center;
  border-right: 1px solid var(--line);
  animation: fade-up .5s var(--ease) both;
}
.pillar:nth-child(1) { animation-delay: .04s; }
.pillar:nth-child(2) { animation-delay: .1s; }
.pillar:nth-child(3) { animation-delay: .16s; }
.pillar:nth-child(4) { animation-delay: .22s; }
.pillar:last-child { border-right: 0; }
.pillar.is-day { background: radial-gradient(80% 60% at 50% 0%, var(--gold-soft), transparent 70%); }

.pillar-label {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.pillar.is-day .pillar-label { color: var(--gold); }

.glyph {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  margin: 0;
  color: var(--c);
}
.glyph + .glyph { margin-top: 2px; }

.pillar-wx {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .05em;
  opacity: .65;
  margin-top: 1px;
}

.pillar-shishen {
  margin: 9px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ss, var(--ink-2));
}

.pillar-meta {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  line-height: 1.5;
}
.pillar-meta div { margin-bottom: 5px; }
.pillar-meta dt { color: var(--ink-3); font-size: 10px; letter-spacing: .04em; }
.pillar-meta dd { margin: 1px 0 0; color: var(--ink-2); letter-spacing: .06em; }

/* 通用区块 */
.block { padding: 16px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.block-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-title::before {
  content: "";
  width: 3px; height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold), rgba(200, 166, 86, .2));
}
.block-sub { font-size: 11.5px; color: var(--ink-3); }

/* 五行 */
.wx-list { display: grid; gap: 9px; }
.wx-row {
  display: grid;
  grid-template-columns: 22px 1fr 62px;
  align-items: center;
  gap: 10px;
}
.wx-name {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--c);
  text-align: center;
}
.wx-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}
.wx-fill {
  height: 100%;
  width: 0;
  border-radius: 100px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
  transition: width .8s var(--ease);
}
.wx-num {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.wx-num b { color: var(--ink); font-size: 14px; font-weight: 700; }
.wx-legend {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.wx-summary {
  margin: 14px 0 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 0 10px 10px 0;
}
.wx-summary b { color: var(--gold); font-weight: 700; }

/* 标签组 */
.taggroup + .taggroup { margin-top: 14px; }
.taggroup-name {
  font-size: 11.5px;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  padding: 6px 11px;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 100px;
}
.tag.is-none { color: var(--ink-3); background: transparent; border-style: dashed; }
.tag.is-warn { color: #F0C3B8; background: var(--cinnabar-soft); border-color: rgba(180, 70, 47, .35); }
.tag.is-good { color: #F0DFB0; background: var(--gold-soft); border-color: var(--gold-line); }

/* 神煞 */
.ss-cols { display: grid; gap: 14px; }
.ss-col-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 0 0 8px;
}
.ss-col-name b {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: .08em;
}

/* 大运 */
.dayun-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 2px 16px 12px;
  scrollbar-width: none;
}
.dayun-scroll::-webkit-scrollbar { display: none; }
.dayun-card {
  flex: 0 0 auto;
  width: 92px;
  padding: 12px 8px;
  scroll-snap-align: start;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.dayun-card:active { background: var(--surface-3); }
.dayun-card.is-now {
  border-color: var(--gold-line);
  background: linear-gradient(180deg, var(--gold-soft), var(--surface-2));
}
.dayun-card.is-now::after {
  content: "当前";
  display: block;
  margin-top: 6px;
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--gold);
}
.dayun-gz {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .06em;
  margin: 0;
}
.dayun-gz .g { color: var(--c); }
.dayun-age {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.dayun-year { margin: 1px 0 0; font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dayun-ss {
  margin: 7px 0 0;
  font-size: 10.5px;
  color: var(--ss, var(--ink-3));
}
.dayun-tip {
  margin: 4px 2px 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* 流年 */
.liunian-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.liunian-gz {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .1em;
  line-height: 1;
}
.liunian-meta { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.liunian-meta b { color: var(--ink); }

/* 节气 */
.terms { display: grid; gap: 8px; }
.term {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.term-name { font-family: var(--serif); font-size: 14px; color: var(--ink); }
.term-desc { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-time { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 11px; white-space: nowrap; }
.term.is-birth { border-color: var(--gold-line); background: var(--gold-soft); }

/* 底部抽屉 */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(6, 7, 9, .72);
  backdrop-filter: blur(3px);
  animation: fade-in .25s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, .9);
  animation: sheet-up .34s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip {
  flex: 0 0 auto;
  width: 100%;
  padding: 12px 0 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sheet-grip::after {
  content: "";
  width: 42px; height: 4px;
  border-radius: 100px;
  background: var(--line-strong);
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet-title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .1em;
  margin: 0 0 4px;
  color: var(--ink);
}
.sheet-sub { font-size: 12px; color: var(--ink-3); margin: 0 0 16px; }
.sheet-row {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-row dt { color: var(--ink-3); font-size: 12px; }
.sheet-row dd { margin: 0; color: var(--ink); }

/* 提示条 */
.toast {
  position: fixed;
  left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  max-width: 84vw;
  padding: 11px 18px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .95);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast[hidden] { display: none; }
.toast.is-on { opacity: 1; transform: translateX(-50%); }

/* 打印 / 分享卡片 */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .foot, .submit { display: none; }
}

/* 窄屏微调 */
@media (max-width: 374px) {
  .glyph { font-size: 26px; }
  .pillar { padding: 12px 2px 10px; }
  .pillar-meta { font-size: 10px; }
  .hero h1 { font-size: 26px; }
}

/* 大屏：四柱盘更宽松 */
@media (min-width: 560px) {
  .glyph { font-size: 34px; }
  .pillar { padding: 18px 6px 14px; }
}

/* 降低动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .hero-mark { animation: none; }
}
