/* 易承书院 · 姓名六格
 * 青绿山水的页头，古籍朱丝格的输入，深黛绿配金线的结果册页。 */
:root {
  --bg: #EEF1EC;
  --card: #FBFCFA;
  --ink: #23302B;
  --ink-2: #5B6B63;
  --ink-3: #93A199;
  --line: #DCE3DC;
  --green: #2E5A4F;        /* 黛绿 */
  --green-2: #3F7262;
  --sage: #7FA893;
  --dark: #1E3B35;         /* 结果册页底 */
  --dark-2: #274A42;
  --gold: #D2B57C;         /* 泥金 */
  --gold-2: #E8D6AE;
  --zhu: #B4483A;          /* 朱砂 */
  --zhu-soft: #D9796A;
  --l1: #CFE5D8;           /* 结果册页上的浅绿：四字、笔画 */
  --l2: #9EC8B0;           /* 次一级：格名、线 */
  --l3: rgba(158, 200, 176, .62);

  --sans: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "HarmonyOS_Sans_SC", "MiSans", "Source Han Sans SC", "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --num: "DIN Alternate", "Avenir Next", "Roboto", var(--sans);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 背景：西四宫位 2 右上、7 右中、6 右下 连成一片，8 左下收住 ---------- */
.scenery { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(120% 60% at 80% 0%, #F4F7F2 0%, var(--bg) 60%); }
.sc-photo { position: absolute; inset: 0; background: url("icons/bg-photo.jpg") right bottom / cover no-repeat; }
.top, .page, .foot { position: relative; z-index: 1; }

/* ---------- 页头：青绿山水 ---------- */
.top {
  position: relative;
  height: calc(300px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: transparent;
}
.top-in { max-width: 560px; margin: 0 auto; padding: 26px 22px 0; display: flex; align-items: center; gap: 12px; }
.mark { width: 42px; height: 42px; flex: none; }
.brand { display: grid; grid-template-columns: repeat(4, 34px); color: var(--green); }
.brand span { display: flex; flex-direction: column; align-items: center; }
.brand b { font-size: 27px; font-weight: 600; line-height: 1; }
.brand i { margin-top: 6px; font-style: normal; font-size: 9px; font-weight: 600; letter-spacing: .04em; font-family: var(--num); line-height: 1; }

.intro { position: relative; max-width: 560px; margin: 28px auto 0; padding: 0 22px; text-align: left; }
.intro-title { margin: 0 0 16px; font-size: 17px; font-weight: 700; letter-spacing: .3em; color: var(--green); line-height: 1.3; }
.intro-title::after { content: ""; display: block; width: 24px; height: 1.5px; margin-top: 12px; background: var(--sage); }
.intro-line { width: 19.5em; max-width: 100%; margin: 0; font-size: 13px; line-height: 2; color: var(--ink-2); text-align: justify; text-align-last: justify; }
.page { max-width: 560px; margin: -46px auto 0; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); position: relative; }

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(30, 59, 53, .06), 0 12px 32px -16px rgba(30, 59, 53, .25);
}

/* ---------- 输入 ---------- */
.form { padding: 22px 18px 20px; }
.step + .step { margin-top: 22px; }
.step-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; letter-spacing: .3em; color: var(--ink-2); margin-bottom: 10px;
}
.step-title::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--sage); }

.gender { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g-tile {
  position: relative; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  height: 54px; cursor: pointer; display: grid; grid-template-columns: 44px 1fr; grid-template-rows: 1fr 1fr;
  align-items: center; padding: 0 16px; text-align: left; column-gap: 12px;
  transition: background-color .2s, border-color .2s, box-shadow .2s;
}
.g-tile { grid-template-columns: 30px auto 1fr; grid-template-rows: 1fr; justify-content: center; }
.g-char { font-size: 20px; font-weight: 600; line-height: 1; }
.g-sub { font-size: 13px; letter-spacing: .2em; color: var(--ink-3); }
.gua { grid-row: 1; display: flex; flex-direction: column; gap: 3.5px; width: 28px; }
.gua i { display: block; height: 3.5px; border-radius: 1px; background: var(--ink-3); }
.gua.kun i { background: linear-gradient(90deg, var(--ink-3) 0 42%, transparent 42% 58%, var(--ink-3) 58%); }
.g-tile[aria-checked="true"] { background: linear-gradient(160deg, var(--green-2), var(--green)); border-color: var(--green); box-shadow: 0 8px 18px -10px rgba(46, 90, 79, .8); }
.g-tile[aria-checked="true"] .g-char { color: #fff; }
.g-tile[aria-checked="true"] .g-sub { color: #A8D8B9; }
.g-tile[aria-checked="true"] .gua i { background: #A8D8B9; }
.g-tile[aria-checked="true"] .gua.kun i { background: linear-gradient(90deg, #A8D8B9 0 42%, transparent 42% 58%, #A8D8B9 58%); }
.gender.need .g-tile { border-color: var(--zhu-soft); }

.wed { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wed button {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; height: 62px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 16px; font-weight: 600; letter-spacing: .1em;
}
.wed small { font-size: 11.5px; font-weight: 400; color: var(--ink-3); letter-spacing: .08em; }
.wed button[aria-checked="true"] { border-color: var(--green); color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: #F3F8F5; }
.wed button[aria-checked="true"] small { color: var(--green-2); }
.note { margin: 10px 2px 0; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); }
#wedNote { background: #F6F2E8; border-radius: 8px; padding: 9px 12px; color: #6E5D3C; }

/* 姓名：朱丝米字格 */
.cells { display: flex; gap: 12px; justify-content: flex-start; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: text; }
.cell input {
  width: 68px; height: 68px; text-align: center; font-size: 32px; font-weight: 500;
  border: 1.5px solid #D9A79E; border-radius: 4px; outline: none; padding: 0; caret-color: var(--zhu);
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), rgba(180, 72, 58, .22) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), rgba(180, 72, 58, .22) 50%, transparent calc(50% + .5px)),
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(180, 72, 58, .3) 50%, transparent calc(50% + .5px)),
    linear-gradient(0deg, transparent calc(50% - .5px), rgba(180, 72, 58, .3) 50%, transparent calc(50% + .5px)),
    #FFFDFA;
  transition: border-color .2s, box-shadow .2s;
}
.cell input.two { font-size: 22px; letter-spacing: -.02em; }
.cell input:focus { border-color: var(--zhu); box-shadow: 0 0 0 3px rgba(180, 72, 58, .12); }
.cell-tag { font-size: 12.5px; color: var(--ink-2); letter-spacing: .2em; padding-left: .2em; }
.clear { margin: -6px 0 -6px auto; height: 28px; padding: 0 12px 0 13px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-2); font-size: 13px; letter-spacing: .15em; cursor: pointer; white-space: nowrap; }
.clear:active { background: #F1F6F2; }
.c-hus input { border-color: #C9B07D; caret-color: #8C6B2C; }
.c-hus .cell-tag { color: #8C6B2C; }

.err { margin: 16px 0 0; font-size: 13.5px; color: var(--zhu); }
.go {
  margin-top: 22px; width: 100%; height: 54px; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(160deg, var(--green-2), var(--dark));
  color: #fff; font-size: 18px; font-weight: 600; letter-spacing: .5em; padding-left: .5em;
  box-shadow: 0 10px 22px -12px rgba(30, 59, 53, .9), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.go:active { transform: translateY(1px); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- 结果册页 ---------- */
.result { margin-top: 18px; }
.board {
  position: relative; overflow: hidden; border-radius: 16px; color: #F4F1E8;
  background: radial-gradient(120% 80% at 50% 0%, #2B5148 0%, var(--dark) 60%, #18302B 100%);
  padding: 22px 14px 16px;
  box-shadow: 0 18px 40px -20px rgba(20, 40, 35, .8);
}
/* 古籍双线边框 */
.board::before, .board::after { content: ""; position: absolute; pointer-events: none; border-radius: 10px; }
.board::before { inset: 8px; border: 1.5px solid rgba(210, 181, 124, .75); }
.board::after { inset: 12px; border: .8px solid rgba(210, 181, 124, .45); border-radius: 7px; }
.dg-mark { position: absolute; width: 70px; height: 70px; transform: translate(-50%, -50%); pointer-events: none;
  background: url("icons/mark-white.png") center / contain no-repeat; opacity: .14; }
.bd-logo { position: absolute; left: 22px; top: 22px; width: 26px; height: 26px; opacity: .55; pointer-events: none; }
.board-head { position: relative; text-align: center; padding: 10px 0 6px; }
.bh-name { display: block; font-size: 22px; font-weight: 600; letter-spacing: .5em; padding-left: .5em; color: #fff; }
.bh-struct { display: inline-block; margin-top: 6px; font-size: 11.5px; letter-spacing: .3em; padding: 2px 10px 2px 13px; color: var(--l2); border: .8px solid rgba(158, 200, 176, .45); border-radius: 999px; }
.board-foot { position: relative; display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; letter-spacing: .3em; color: var(--l3); }
.board-foot img { width: 16px; height: 16px; opacity: .75; }

.fit { position: relative; overflow: hidden; }
.dg { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.links { position: absolute; left: 0; top: 0; overflow: visible; }
.links path.br { fill: none; stroke: var(--gold); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.links text { dominant-baseline: central; text-anchor: middle; }
.g-ch { font-family: var(--sans); font-size: 34px; font-weight: 600; fill: #fff; }
.g-st { font-family: var(--num); font-size: 19px; font-weight: 600; fill: var(--l1); }
.g-one { font-family: var(--sans); font-size: 34px; font-weight: 600; fill: #fff; }

.lb { position: absolute; width: 58px; transform: translateY(-50%); line-height: 1.15; }
.lb-r { text-align: left; }
.lb-l { text-align: right; }
.lb-name { display: flex; align-items: center; gap: 4px; font-size: 13.5px; font-weight: 600; letter-spacing: .12em; color: var(--l1); white-space: nowrap; }
.lb-l .lb-name, .lb-l .lb-num { justify-content: flex-end; }
.lb-wx { flex: none; box-sizing: border-box; width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; font-size: 11px; line-height: 1; letter-spacing: 0; text-indent: 0; color: var(--l1); border: .8px solid rgba(158, 200, 176, .5); border-radius: 50%; }
.lb-num { display: flex; align-items: center; gap: 4px; margin: 5px 0 4px; }
.lb-n { font-family: var(--num); font-size: 27px; line-height: 1; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; display: inline-block; min-width: 1.15em; text-align: right; }
.lb-word { font-size: 13.5px; font-weight: 600; letter-spacing: .08em; color: var(--l1); white-space: nowrap; text-shadow: 0 1px 6px rgba(15, 32, 28, .9), 0 0 2px rgba(15, 32, 28, .8); }
.lb-name .seal { width: 15px; height: 15px; font-size: 9.5px; }

.jx { font-size: 10.5px; line-height: 1; padding: 3px 4px 3px 5px; border-radius: 3px; letter-spacing: .1em; white-space: nowrap; font-weight: 600; }
.jx.ji { color: var(--dark); background: var(--gold-2); }
.jx.mid { color: var(--dark); background: #B9AC8A; }
.jx.warn { color: #fff; background: #A9784A; }
.jx.xiong { color: #fff; background: var(--zhu); }

.seal {
  display: inline-flex; align-items: center; justify-content: center; flex: none; box-sizing: border-box; padding: 0; letter-spacing: 0; text-indent: 0; width: 18px; height: 18px;
  background: var(--zhu); color: #FBEFE7; font-size: 11px; font-weight: 600; border-radius: 3px;
  line-height: 1; text-align: center; box-shadow: inset 0 0 0 1px rgba(251, 239, 231, .6), inset 0 0 0 2px var(--zhu);
}

.lb-total { position: absolute; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.lb-total .lb-name { justify-content: center; font-size: 13.5px; letter-spacing: .3em; }
.tz { position: relative; display: inline-block; margin: 6px 0 4px; }
.tz .lb-n { font-size: 38px; min-width: 0; }
.bless { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 11.5px; letter-spacing: .3em; padding-left: .3em; color: rgba(255, 255, 255, .5); }
.tz-side { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 8px; display: flex; gap: 6px; align-items: center; }
.lb-total .lb-word { font-size: 17px; letter-spacing: .45em; padding-left: .45em; }
.lb-total .jx { font-size: 11.5px; }

.pend { position: absolute; margin: 0; transform: translateY(-50%); font-size: 13px; color: var(--l2); line-height: 1.8; letter-spacing: .1em; }
.hint { margin: 0; padding: 40px 0; text-align: center; color: rgba(244, 241, 232, .7); }
.it-in {
  position: absolute; transform: translateY(-50%); width: 40px; height: 26px; padding: 0; text-align: center;
  border: 1px dashed var(--gold); border-radius: 4px; background: rgba(255, 255, 255, .95); color: var(--ink); font-size: 14px;
}

.sheet-reveal .lb, .sheet-reveal .lb-total, .sheet-reveal .links { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 80ms); }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 格局速览 / 同数理名人 ---------- */
.notes, .cases { margin-top: 16px; padding: 18px 18px 16px; }
.nt-row { padding: 12px 0; border-top: 1px dashed var(--line); }
.nt-row:first-of-type { border-top: 0; padding-top: 2px; }
.nt-k { display: flex; align-items: center; gap: 8px; }
.nt-g { font-size: 13px; letter-spacing: .15em; color: var(--ink-2); width: 3.4em; }
.nt-n { font-family: var(--num); font-size: 20px; font-weight: 600; color: var(--green); min-width: 1.2em; text-align: right; }
.nt-k .jx.ji { color: var(--dark); background: var(--gold-2); }
.nt-k .jx.mid { color: #8C6B2C; box-shadow: inset 0 0 0 1px #D2B57C; }
.nt-k .jx.warn { color: #8C6B2C; box-shadow: inset 0 0 0 1px #C99B55; background: #FBF4E6; }
.nt-t { margin: 6px 0 0; font-size: 14px; line-height: 1.85; color: var(--ink); }
.nt-t b { font-weight: 600; color: var(--green); margin-right: .6em; letter-spacing: .08em; }
.sec-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 16px; font-weight: 600; letter-spacing: .2em; color: var(--green); }
.sec-title .seal { width: 24px; height: 24px; font-size: 14px; }
.sm-row { display: flex; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 14px; line-height: 1.6; }
.sm-row:first-of-type { border-top: 0; }
.sm-k { flex: none; width: 64px; color: var(--ink-2); letter-spacing: .1em; }
.sm-v { flex: 1; }
.chip { display: inline-block; margin: 0 6px 4px 0; padding: 1px 8px; border-radius: 999px; font-size: 13px; background: #EEF4F0; color: var(--green); }
.chip.red { background: #F8E9E6; color: var(--zhu); }
.chip.gold { background: #F6F0E2; color: #8C6B2C; }
.sm-tip { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: #F8EEEB; color: #8E3E33; font-size: 13.5px; line-height: 1.7; }
.counts { display: flex; gap: 8px; }
.count { flex: 1; text-align: center; padding: 10px 0 8px; border-radius: 10px; background: #F3F6F3; }
.count b { display: block; font-family: var(--num); font-size: 24px; line-height: 1.1; color: var(--green); }
.count.x b { color: var(--zhu); }
.count span { font-size: 12px; color: var(--ink-2); letter-spacing: .15em; }

.case { padding: 14px 0; border-top: 1px solid var(--line); }
.case:first-of-type { border-top: 0; padding-top: 2px; }
.case-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.case-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(160deg, var(--green-2), var(--dark)); color: #fff; font-size: 16px; font-weight: 600; flex: none; }
.case-line { margin: 10px 0 0; font-size: 12.5px; color: var(--green-2); letter-spacing: .06em; }
.case-num { margin-left: auto; display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--ink-2); letter-spacing: .08em; }
.case-num b { font-family: var(--num); font-size: 22px; color: var(--green); }
.case-phase { margin-left: auto; font-size: 12px; color: var(--green); background: #EEF4F0; padding: 2px 10px; border-radius: 999px; letter-spacing: .2em; }
.case-story { font-size: 15px !important; line-height: 1.95 !important; }
.case-life { margin-top: 8px !important; padding: 10px 12px; border-radius: 8px; background: #F1F6F2; font-size: 13.5px !important; line-height: 1.85 !important; color: var(--ink-2) !important; }
.case-life span { display: block; font-size: 12px; letter-spacing: .25em; color: #8C6B2C; margin-bottom: 2px; }
.case-id { display: flex; flex-direction: column; line-height: 1.3; }
.case-field { font-size: 12.5px; color: var(--ink-2); letter-spacing: .05em; }
.case-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.case-who { font-size: 17px; font-weight: 600; letter-spacing: .1em; }
.case-match { font-size: 12.5px; color: #8C6B2C; background: #F6F0E2; padding: 1px 8px; border-radius: 999px; }
.case p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.85; color: var(--ink); }
.case .ana { color: var(--green); background: #F1F6F2; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.case a { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--ink-3); text-decoration: none; border-bottom: 1px dotted var(--ink-3); }

.foot-in { display: inline-grid; width: 15em; }
.foot-in span { text-align: justify; text-align-last: justify; }
.foot-slogan { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.5); font-size: 12.5px; font-weight: 500; }
.foot { text-align: center; font-size: 11.5px; line-height: 1.9; color: rgba(255,255,255,.92);
  padding: 22px 0 calc(28px + env(safe-area-inset-bottom)); text-shadow: 0 1px 6px rgba(15, 32, 28, .75), 0 0 2px rgba(15, 32, 28, .6); }

@media (max-width: 360px) {
  .intro { padding-left: 22px; }
  .intro-line { font-size: 12px; }
  .cell input { width: 58px; height: 58px; font-size: 28px; }
  .cells { gap: 9px; }
  .g-tile { padding: 0 12px; grid-template-columns: 36px 1fr; height: 84px; }
  .gua { width: 34px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- 激活 ---------- */
.gate { padding: 22px 18px 20px; }
.gate-tip { margin: 0 0 14px; font-size: 13.5px; line-height: 1.8; color: var(--ink-2); }
.mid-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #F3F6F3; border: 1px dashed var(--sage); }
.mid { flex: 1; white-space: nowrap; font-family: var(--num); font-size: 19px; font-weight: 600; letter-spacing: .06em; color: var(--green); }
.ghost { border: 1px solid var(--green); background: #fff; color: var(--green); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.gate textarea { width: 100%; margin-top: 14px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; font-family: var(--num); resize: vertical; outline: none; background: #fff; word-break: break-all; }
.gate textarea:focus { border-color: var(--green); }
.lb-name { gap: 0; font-size: 14px; font-weight: 600; letter-spacing: .14em; color: #EEF5F0; }
.lb-wx { width: auto; height: 12px; border: 0; border-radius: 0; border-left: 1px solid rgba(210, 181, 124, .55); margin-left: 3px; padding-left: 7px; font-size: 12.5px; font-weight: 500; color: var(--gold); }
.lb-l .lb-name { flex-direction: row; }
.lb-total .lb-name { font-size: 15px; letter-spacing: .3em; }
.lb-total .lb-wx { letter-spacing: 0; }
/* 五行：五色，前面一条淡白竖线，与格名垂直居中 */
.lb-wx { display: inline-flex; align-items: center; height: auto; border: 0; padding: 0; margin-left: 6px; line-height: 1; }
.lb-wx::before { content: ""; width: 1px; height: 12px; margin-right: 6px; background: rgba(255, 255, 255, .38); transform: translateY(-1px); }
.wx-木 { color: #8FCB9B; } .wx-火 { color: #E39A84; } .wx-土 { color: #D6BC86; } .wx-金 { color: #E8E4D8; } .wx-水 { color: #8FB8D6; }
