﻿/* 玄机 v2 · 宣纸墨 —— 编辑式排版，无卡片堆叠 */
:root {
  --paper: #f4f0e7;
  --paper-2: #ece6d9;
  --ink: #1e1b17;
  --ink-2: #4a443c;
  --ink-3: #8b8274;
  --rule: #d8cfbe;
  --rule-2: #c6bba6;
  --zhu: #a8342a;              /* 朱砂：只给动爻、世应、关键数字 */
  --jin: #a8842f;
  --mu: #4e7748;
  --shui: #3a6584;
  --huo: #a8342a;
  --tu: #8a6a45;

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

  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

body {
  background-image:
    radial-gradient(circle at 50% -20%, rgba(168, 132, 47, 0.07), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(30, 27, 23, 0.04), transparent 45%);
  min-height: 100vh;
}

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 26px 20px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- 页头 ---------- */
.masthead { padding: 6px 0 18px; border-bottom: 1px solid var(--ink); }
.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  line-height: 1.2;
}
.masthead .kicker {
  font-size: 10.5px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.masthead .lede { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; letter-spacing: 0.06em; }

/* ---------- 文字型 tab ---------- */
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.tab {
  appearance: none; border: 0; background: none; padding: 14px 0 12px;
  font-family: var(--sans); font-size: 15px; letter-spacing: 0.14em;
  color: var(--ink-3); cursor: pointer; position: relative;
}
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--ink);
}

.panel { display: none; }
.panel.active { display: block; animation: rise 0.3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- 表单：只留底线 ---------- */
.field { display: block; margin-bottom: 22px; }
.field > .lab {
  display: block; font-size: 10.5px; letter-spacing: 0.24em;
  color: var(--ink-3); margin-bottom: 3px; text-transform: uppercase;
}
.field input {
  width: 100%; appearance: none; background: transparent;
  border: 0; border-bottom: 1px solid var(--rule-2);
  padding: 7px 0 9px; font-family: var(--sans); font-size: 19px; color: var(--ink);
  outline: none; border-radius: 0;
}
.field input:focus { border-bottom-color: var(--ink); }
.field input::placeholder { color: #b3a894; }

.seg { display: flex; gap: 28px; padding-top: 4px; }
.seg button {
  appearance: none; border: 0; background: none; padding: 4px 0;
  font-family: var(--sans); font-size: 17px; color: var(--ink-3);
  cursor: pointer; border-bottom: 1px solid transparent;
}
.seg button.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

details.adv { margin: -6px 0 22px; border-top: 1px solid var(--rule); padding-top: 2px; }
details.adv summary {
  font-size: 11px; letter-spacing: 0.16em; color: var(--ink-3);
  padding: 10px 0 2px; cursor: pointer; list-style: none;
}
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: "＋ "; color: var(--ink-3); }
details.adv[open] summary::before { content: "－ "; }

.btn {
  width: 100%; appearance: none; border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper);
  padding: 15px 0; font-family: var(--sans); font-size: 15.5px;
  letter-spacing: 0.3em; text-indent: 0.3em; cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.82; }
.btn[disabled] { background: transparent; color: var(--ink-3); border-color: var(--rule-2); }

.btn-text {
  display: block; width: 100%; appearance: none; border: 0; background: none;
  color: var(--ink-3); font-family: var(--sans); font-size: 13px;
  letter-spacing: 0.2em; padding: 20px 0 0; cursor: pointer; text-align: center;
}
.note { font-size: 11px; letter-spacing: 0.08em; color: var(--ink-3); margin-top: 14px; text-align: center; }

/* ---------- 结果通用 ---------- */
.result { margin-top: 34px; animation: rise 0.35s ease; }
.sec { margin-bottom: 30px; }
.sec-h {
  display: flex; align-items: baseline; gap: 10px;
  border-bottom: 1px solid var(--ink); padding-bottom: 7px; margin-bottom: 16px;
}
.sec-h b { font-size: 12px; letter-spacing: 0.32em; font-weight: 600; }
.sec-h span { font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; margin-left: auto; }

.kv { display: flex; flex-wrap: wrap; gap: 5px 18px; font-size: 13px; color: var(--ink-2); }
.kv i { font-style: normal; color: var(--ink-3); margin-right: 5px; font-size: 11.5px; }
.kv b { font-weight: 600; color: var(--ink); }

/* ---------- 四柱 ---------- */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); }
.pillar { padding: 14px 0 12px; text-align: center; border-right: 1px solid var(--rule); }
.pillar:last-child { border-right: 0; }
.pillar .pl { font-size: 10px; letter-spacing: 0.22em; color: var(--ink-3); margin-bottom: 8px; }
.pillar .gz {
  font-family: var(--serif); font-size: 33px; line-height: 1.16; font-weight: 600;
  display: block; letter-spacing: 0.02em;
}
.pillar .ss { font-size: 11px; color: var(--ink-2); margin-top: 8px; }
.pillar .ny { font-size: 10px; color: var(--ink-3); margin-top: 2px; }

.wx-金 { color: var(--jin); } .wx-木 { color: var(--mu); }
.wx-水 { color: var(--shui); } .wx-火 { color: var(--huo); } .wx-土 { color: var(--tu); }

/* ---------- 五行 ---------- */
.wx { display: grid; gap: 9px; }
.wx-row { display: grid; grid-template-columns: 16px 1fr 22px; align-items: center; gap: 12px; font-size: 12px; }
.wx-row .n { color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.wx-track { height: 3px; background: var(--rule); position: relative; }
.wx-track i { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.6s cubic-bezier(.2,.8,.2,1); }

/* ---------- 大运 ---------- */
.dy {
  display: flex; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory; padding-bottom: 6px;
}
.dy::-webkit-scrollbar { display: none; }
.dy-item { flex: 0 0 auto; width: 74px; scroll-snap-align: start; text-align: center; padding: 4px 0; }
.dy-item + .dy-item { border-left: 1px solid var(--rule); }
.dy-item .g { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.dy-item .a { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* ---------- 六爻：真·爻线 ---------- */
.hexfig { display: flex; flex-direction: column; gap: 6px; width: 92px; }
.hexfig.sm { width: 52px; gap: 4px; }
.hl { height: 6px; }
.hexfig.sm .hl { height: 4px; }
.hl.yang { background: var(--ink); }
.hl.yin { display: flex; gap: 26%; }
.hl.yin i { flex: 1; background: var(--ink); }
.hl.mv.yang { background: var(--zhu); }
.hl.mv.yin i { background: var(--zhu); }

.cast-head { display: flex; align-items: flex-start; justify-content: center; gap: 26px; padding: 4px 0 2px; }
.cast-side { text-align: center; }
.cast-tag { font-size: 10px; letter-spacing: 0.24em; color: var(--ink-3); margin-bottom: 8px; }
.cast-name { font-family: var(--serif); font-size: 23px; font-weight: 600; margin-top: 10px; letter-spacing: 0.04em; }
.cast-arrow { align-self: center; color: var(--ink-3); font-size: 16px; padding-top: 18px; }
.cast-meta { text-align: center; font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.08em; margin-top: 16px; }

.yao { border-top: 1px solid var(--rule); }
.yao-row {
  display: grid; grid-template-columns: 16px 38px 1fr 54px 38px;
  align-items: center; gap: 10px; padding: 9px 0;
}
.yao-row .pos { font-size: 10px; color: var(--ink-3); letter-spacing: 0.05em; }
.yao-row .god { font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; }
.yao-row .gz { font-family: var(--serif); font-size: 15px; }
.yao-row .lq { font-size: 11px; color: var(--ink-2); margin-right: 6px; letter-spacing: 0.04em; }
.yao-row .sy { font-size: 11px; color: var(--zhu); letter-spacing: 0.08em; text-align: right; }
.yao-row .fig { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.yao-row .fig .dot { font-size: 10px; color: var(--zhu); }
.yao-row .fig .hl { width: 40px; height: 5px; }

.quote {
  border-left: 3px solid var(--zhu); padding: 2px 0 2px 15px;
  font-family: var(--serif); font-size: 17px; line-height: 1.75; color: var(--ink);
}
.quote small { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.2em; color: var(--ink-3); margin-bottom: 6px; }

.qmark {
  font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule); padding: 10px 0; margin-bottom: 22px;
}
.qmark i { font-style: normal; color: var(--ink-3); letter-spacing: 0.1em; margin-right: 8px; font-size: 11px; }

/* 摇卦进度 */
.slots { display: flex; gap: 0; justify-content: space-between; padding: 6px 0 20px; }
.slot {
  flex: 1; text-align: center; font-size: 11px; color: #b3a894;
  padding-top: 9px; border-top: 2px solid var(--rule);
}
.slot.done { color: var(--ink); border-top-color: var(--ink); }
.slot.done.mv { color: var(--zhu); border-top-color: var(--zhu); }

.coins { display: flex; justify-content: center; gap: 16px; height: 40px; align-items: center; }
.coin {
  width: 30px; height: 30px; border: 1px solid var(--rule-2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--ink-2);
}
.coin.back { color: #b3a894; border-style: dashed; }

footer {
  margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: 10.5px; color: var(--ink-3); line-height: 1.9; letter-spacing: 0.04em;
}


/* ===================== v3 新增 ===================== */
/* 四 tab */
.tabs { gap: 20px; }
.tabs .tab { font-size: 14.5px; letter-spacing: .1em; }

/* ---------- 铜钱舞台 ---------- */
.coin-stage {
  position: relative; height: 132px; display: flex; justify-content: center;
  align-items: flex-end; gap: 16px; padding-bottom: 10px;
  perspective: 900px; margin-bottom: 4px;
}
.coin3d {
  width: 74px; height: 74px; position: relative; transform-style: preserve-3d;
  will-change: transform; filter: drop-shadow(0 5px 9px rgba(40,32,20,.26));
}
.coin3d .face {
  position: absolute; inset: 0; background-repeat: no-repeat; background-position: center;
  background-size: contain; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.coin3d .front { background-image: url(assets/coin-front-clean.png); }
.coin3d .back  { background-image: url(assets/coin-back-clean.png); transform: rotateY(180deg); }
.coin3d.settled { filter: drop-shadow(0 3px 6px rgba(40,32,20,.22)); }

.coin-caption {
  text-align: center; font-size: 12.5px; color: var(--ink-3);
  letter-spacing: .06em; margin: 6px 0 16px; min-height: 19px;
}
.coin-caption b { color: var(--ink); }
.coin-caption .zhu { color: var(--zhu); }

/* ---------- 紫微斗数盘 ---------- */
.zw-stage { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 92px); gap: 0; border: 1px solid var(--ink); }
.zw-cell {
  border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
  padding: 5px 4px 6px; position: relative; cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column;
}
.zw-cell:nth-child(4n) { border-right: 0; }
.zw-cell.bottom { border-bottom: 0; }
.zw-cell.ming { background: rgba(168,52,42,.05); }
.zw-cell .hd { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.zw-cell .pn { font-size: 9.5px; letter-spacing: .04em; color: var(--ink-2); }
.zw-cell .mn { font-size: 8.5px; color: var(--ink-3); }
.zw-cell .stars { line-height: 1.35; margin-bottom: auto; }
.zw-cell .st { font-size: 10.5px; letter-spacing: .02em; }
.zw-cell .st .br { font-size: 8px; color: var(--ink-3); margin-left: 1px; }
.zw-cell .st .mu { font-size: 8px; color: var(--zhu); margin-left: 1px; vertical-align: super; }
.zw-cell .sm { font-size: 8.5px; color: var(--ink-3); line-height: 1.3; margin-top: 2px; }
.zw-cell .ft { font-size: 8.5px; color: var(--ink-3); margin-top: 3px; display: flex; justify-content: space-between; }
.zw-cell.is-body .pn { color: var(--zhu); }

.zw-center {
  grid-column: 2 / 4; grid-row: 2 / 4;
  border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
  padding: 12px 10px; display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.zw-center .t { font-family: var(--serif); font-size: 19px; letter-spacing: .1em; text-align: center; }
.zw-center .l { font-size: 10.5px; color: var(--ink-3); text-align: center; line-height: 1.7; letter-spacing: .04em; }
.zw-center .l b { color: var(--ink-2); font-weight: 500; }

.zw-detail { border: 1px solid var(--rule); padding: 14px 16px; margin-top: 16px; }
.zw-detail h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .18em; font-weight: 600; }
.zw-detail .li { font-size: 12px; color: var(--ink-2); line-height: 1.9; }
.zw-detail .li i { font-style: normal; color: var(--ink-3); margin-right: 8px; font-size: 10.5px; letter-spacing: .1em; }

/* ---------- 抽签 ---------- */
.qiandao { position: relative; display: flex; justify-content: center; height: 380px; align-items: flex-end; padding-top: 96px; }
.qiandao .tube {
  height: 272px; width: auto; display: block; transform-origin: 50% 96%;
  filter: drop-shadow(0 10px 16px rgba(40,32,20,.2));
}
.qiandao .tube.shake { animation: shake .62s ease-in-out 2; }
@keyframes shake {
  0%,100% { transform: rotate(0); }
  15% { transform: rotate(-2.2deg) translateY(-2px); }
  35% { transform: rotate(2deg) translateY(-5px); }
  55% { transform: rotate(-1.6deg) translateY(-2px); }
  75% { transform: rotate(1.2deg) translateY(-4px); }
}
.qstick {
  position: absolute; left: 50%; bottom: 108px; width: 30px; height: 190px; margin-left: -34px;
  border-radius: 3px 3px 1px 1px; opacity: 0; transform: translateY(36px) scaleY(.6);
  background: linear-gradient(170deg, #e7d3a6, #d8bf8c 45%, #c9ad77);
  box-shadow: 0 0 0 1px rgba(120,95,55,.4), inset -3px 0 5px rgba(120,90,50,.35), 0 6px 14px rgba(60,45,25,.32);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12px;
  writing-mode: vertical-rl; font-family: var(--serif); font-size: 14px; letter-spacing: .16em;
  color: #2a2118; font-weight: 600; text-align: center; z-index: 3;
}
.qstick.show { opacity: 1; transform: translateY(0) scaleY(1); transition: opacity .22s, transform .55s cubic-bezier(.2,.9,.3,1.1); }
.qstick.rise { transform: translateY(-88px) scaleY(1); transition: transform .85s cubic-bezier(.3,.8,.2,1); }

.qian-result { margin-top: 8px; }
.qian-result .qn { font-family: var(--serif); font-size: 22px; text-align: center; letter-spacing: .1em; margin-bottom: 10px; }

/* ---------- v3.1 大白话断语 ---------- */
.quote { padding: 16px 18px; }
.quote small { display: block; font-family: var(--sans); font-size: 10px; letter-spacing: .28em; color: var(--ink-3); margin-bottom: 10px; }
.quote .tag {
  display: inline-block; font-size: 11px; letter-spacing: .12em; color: var(--zhu);
  border: 1px solid rgba(168,52,42,.45); padding: 3px 10px; margin-bottom: 11px; line-height: 1.4;
}
.q-short { font-family: var(--serif); font-size: 17.5px; line-height: 1.7; color: var(--ink); }
.q-plain { font-size: 13.5px; color: var(--ink-2); line-height: 1.95; margin-top: 10px; }
.q-advice {
  font-size: 13.5px; color: var(--ink); line-height: 1.8; margin-top: 12px;
  padding-top: 11px; border-top: 1px dashed var(--rule-2);
}
.q-advice i { font-style: normal; color: var(--zhu); margin-right: 9px; font-size: 10.5px; letter-spacing: .16em; }

.bian-line {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.8;
}
.bian-line i { font-style: normal; color: var(--ink-3); font-size: 10.5px; letter-spacing: .16em; margin-right: 9px; }

/* ---------- 八字人话版 ---------- */
.read-block { padding: 17px 0; border-top: 1px solid var(--rule); }
.read-block:first-child { border-top: 0; padding-top: 4px; }
.rb-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.rb-l { font-size: 12px; letter-spacing: .14em; color: var(--ink-2); }
.rb-tag {
  margin-left: auto; flex: 0 0 auto; font-size: 11px; letter-spacing: .06em;
  color: var(--zhu); border: 1px solid rgba(168,52,42,.4); padding: 2px 8px; line-height: 1.4;
}
.read-block p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.95; color: var(--ink); }
.read-block p:last-of-type { margin-bottom: 0; }
.rb-foot {
  margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--rule-2);
  font-size: 13px; line-height: 1.85; color: var(--ink-2);
}

details.raw { border-top: 1px solid var(--rule); margin-top: 22px; }
details.raw > summary {
  cursor: pointer; list-style: none; font-size: 12.5px; letter-spacing: .1em;
  color: var(--ink-3); padding: 16px 0 4px;
}
details.raw > summary::-webkit-details-marker { display: none; }
details.raw > summary::before { content: "▸ "; color: var(--ink-3); }
details.raw[open] > summary::before { content: "▾ "; }

.gloss-list { padding: 12px 0 6px; }
.gl { font-size: 12.5px; line-height: 1.9; color: var(--ink-2); margin-bottom: 10px; }
.gl b { color: var(--ink); margin-right: 9px; font-weight: 600; }

.rb-lead {
  font-family: var(--serif); font-size: 16px; line-height: 1.8; color: var(--ink);
  padding: 14px 0 18px; border-bottom: 1px solid var(--rule); margin-bottom: 4px;
}

/* ---------- 人话版：列表块 ---------- */
.rb-list { margin: 4px 0 2px; }
.rb-li {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: baseline; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid rgba(216,207,190,.7); font-size: 12.5px;
}
.rb-li:last-child { border-bottom: 0; }
.rb-li .n { color: var(--ink); letter-spacing: .06em; }
.rb-li .w { color: var(--ink-2); }
.rb-li .s { color: var(--ink-3); font-size: 11px; text-align: right; }
.rb-extra {
  margin-top: 10px !important; padding: 9px 12px; background: rgba(168,52,42,.045);
  border-left: 2px solid rgba(168,52,42,.35); font-size: 12.5px !important; color: var(--ink-2) !important;
}

/* ---------- 抽签卦象 ---------- */
.qian-hex { display: flex; justify-content: center; margin: 6px 0 12px; }
.qian-hex .hexfig { width: 104px; gap: 7px; }
.qian-hex .hl { height: 7px; }
.qian-meta {
  text-align: center; font-size: 11.5px; letter-spacing: .12em; color: var(--ink-3);
  margin-bottom: 10px;
}

/* ---------- 分享图遮罩 ---------- */
.share-mask {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(20, 17, 14, .86);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: rise .22s ease;
}
.share-panel {
  max-width: 420px; width: 100%; max-height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.share-tip { color: #efe6d8; font-size: 13px; letter-spacing: .1em; }
.share-img {
  max-width: 100%; max-height: 68vh; object-fit: contain;
  border-radius: 2px; box-shadow: 0 14px 40px rgba(0,0,0,.5);
  -webkit-touch-callout: default; user-select: auto;
}
.share-actions { display: flex; gap: 12px; width: 100%; }
.share-dl, .share-close {
  flex: 1; text-align: center; text-decoration: none; cursor: pointer;
  font-family: var(--sans); font-size: 14px; letter-spacing: .14em;
  padding: 13px 0; border-radius: 2px;
}
.share-dl { background: #efe6d8; color: #1e1b17; border: 0; }
.share-close { background: transparent; color: #efe6d8; border: 1px solid rgba(239,230,216,.4); }
.share-hint { color: rgba(239,230,216,.45); font-size: 11px; letter-spacing: .04em; text-align: center; }
