/* BaZi Compass — dark ink & gold */
:root {
  --bg: #0c0b09;
  --bg2: #14120f;
  --card: #191612;
  --card2: #211d17;
  --line: rgba(201, 164, 92, 0.14);
  --line-soft: rgba(236, 229, 216, 0.07);
  --gold: #c9a45c;
  --gold-bright: #e8cd90;
  --gold-dim: #8a7347;
  --ink: #ece5d8;
  --ink-dim: #a89e8c;
  --ink-faint: #6f675a;
  --wood: #7cc49a;   /* wood — green */
  --fire: #e0654a;   /* fire — red */
  --earth: #b0793f;  /* earth — brown tan 棕褐 */
  --metal: #e5bd55;  /* metal — golden yellow 金黄 */
  --water: #6aa8d8;  /* water — blue */
  --good: #7cc49a;
  --bad: #e07257;
  --radius: 16px;
  --maxw: 600px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='360'%20height='240'%3E%3Ctext%20x='180'%20y='120'%20fill='%23c9a45c'%20fill-opacity='0.035'%20font-family='Georgia,serif'%20font-size='19'%20text-anchor='middle'%20transform='rotate(-26%20180%20120)'%3EBaZi%20Compass%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Georgia", "Songti SC", "Noto Serif SC", serif;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: 76px;
}
.sans { font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(13,12,10,.97), rgba(13,12,10,.88));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
}
.logo { display: flex; align-items: center; gap: 9px; flex: 1; }
.logo svg { width: 30px; height: 30px; }
.logo .name { font-size: 1.05rem; letter-spacing: .06em; color: var(--gold-bright); }
.logo .name b { font-weight: 600; }
.profile-chip {
  font-family: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 13px; font-size: .82rem; cursor: pointer;
  max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-chip:hover { border-color: var(--gold-dim); }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 16px; }
.tab-page { display: none; animation: fadein .25s ease; }
.tab-page.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card {
  background: linear-gradient(165deg, var(--card2), var(--card) 55%);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset, 0 12px 28px -18px rgba(0, 0, 0, 0.65);
}
.card h2 {
  font-size: .8rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 12px; font-weight: 600;
}
.card h3 { font-size: .95rem; color: var(--gold-bright); margin: 14px 0 6px; }
.card p { font-size: .92rem; color: var(--ink); margin-bottom: 8px; }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); font-size: .8rem; }
.small { font-size: .82rem; }

/* ---------- bottom tab bar ---------- */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(18,16,13,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar button {
  background: none; border: none; color: var(--ink-faint);
  font-family: inherit; font-size: .66rem; letter-spacing: .09em;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: color .2s ease;
}
.tico {
  width: 21px; height: 21px; fill: none;
  stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.tabbar button.active { color: var(--gold-bright); }
.tabbar button.active .tico { filter: drop-shadow(0 0 6px rgba(232, 205, 144, .45)); }

/* ---------- pillars display ---------- */
.pillars-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center;
}
.pillar { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; }
.pillar .plabel { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.pillar .stem, .pillar .branch { font-size: 1.7rem; line-height: 1.25; font-weight: 500; }
/* Ten-god labels differ in length ("Guardian" vs "Steady Wealth"), and a
 * wrapped one used to push its branch out of line with the other pillars.
 * Reserving two lines in every cell keeps all four branches on one row. */
.pillar .tg {
  font-size: .62rem; color: var(--ink-dim); margin-top: 2px;
  line-height: 1.25; min-height: 2.5em;
  display: flex; align-items: center; justify-content: center;
}
/* hidden-stem lists run 1–3 deep; a shared floor keeps the cards even */
.pillar .hidden {
  font-size: .64rem; color: var(--ink-faint); margin-top: 6px;
  border-top: 1px dashed var(--line); padding-top: 5px; line-height: 1.7;
  min-height: 3.4em;
}
.el-wood { color: var(--wood); } .el-fire { color: var(--fire); } .el-earth { color: var(--earth); }
.el-metal { color: var(--metal); } .el-water { color: var(--water); }

/* big day pillar on Today */
.today-pillar { display: flex; align-items: center; gap: 16px; }
.today-pillar .chars { font-size: 2.6rem; line-height: 1.15; text-align: center; }
.today-pillar .meta { flex: 1; }
.today-pillar .meta .headline { font-size: 1.02rem; color: var(--gold-bright); margin-bottom: 4px; }

/* stars */
.stars { color: var(--gold); font-size: 1.05rem; letter-spacing: .12em; }
.stars .off { color: var(--line); }

/* date nav */
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.date-nav button {
  background: var(--card); border: 1px solid var(--line); color: var(--gold);
  border-radius: 9px; width: 38px; height: 34px; font-size: 1rem; cursor: pointer;
}
.date-nav .dlabel { font-size: .92rem; color: var(--ink); }
.date-nav .dlabel .sub { display: block; text-align: center; font-size: .7rem; color: var(--ink-faint); }

/* domain bars */
.domains { display: grid; gap: 8px; margin-top: 10px; }
.domain { display: grid; grid-template-columns: 84px 1fr 34px; align-items: center; gap: 10px; font-size: .8rem; }
.domain .bar { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.domain .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); }
.domain .val { text-align: right; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  font-size: .78rem; padding: 5px 11px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card2); color: var(--ink-dim);
}
.chip.do { border-color: rgba(111,191,143,.4); color: var(--good); }
.chip.avoid { border-color: rgba(226,105,79,.4); color: var(--bad); }
.chip.gold { border-color: var(--gold-dim); color: var(--gold-bright); }

/* callout blocks */
.callout {
  border-left: 3px solid var(--gold); background: var(--card2);
  border-radius: 0 10px 10px 0; padding: 10px 13px; margin: 10px 0; font-size: .88rem;
}
.callout .cname { color: var(--gold-bright); font-size: .78rem; letter-spacing: .06em; margin-bottom: 3px; }
.callout.warn { border-left-color: var(--bad); }
.callout.good { border-left-color: var(--good); }

/* strength gauge */
.gauge { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.gauge .track { flex: 1; height: 9px; background: var(--bg2); border-radius: 5px; position: relative; }
.gauge .track i { position: absolute; top: -3px; width: 15px; height: 15px; border-radius: 50%; background: var(--gold-bright); border: 2px solid var(--bg); transform: translateX(-50%); }
.gauge .glabel { font-size: .8rem; color: var(--gold-bright); white-space: nowrap; }

/* element bars */
.elements { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: end; height: 110px; margin: 12px 0 4px; }
.element-col { display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.element-col .ebar { width: 26px; border-radius: 6px 6px 0 0; min-height: 4px; }
.element-col .ename { font-size: .72rem; color: var(--ink-dim); }
.ebar.wood { background: var(--wood); } .ebar.fire { background: var(--fire); }
.ebar.earth { background: var(--earth); } .ebar.metal { background: var(--metal); }
.ebar.water { background: var(--water); }

/* luck cycles */
.luck-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.luck-cell {
  min-width: 64px; text-align: center; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px;
}
.luck-cell.current { border-color: var(--gold); background: rgba(201,164,92,.08); }
.luck-cell .age { font-size: .64rem; color: var(--ink-faint); }
.luck-cell .gz { font-size: 1.15rem; margin: 2px 0; }
.luck-cell .yr { font-size: .62rem; color: var(--ink-dim); }

/* stars list */
.star-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.star-item:last-child { border-bottom: none; }
.star-item .sname { color: var(--gold-bright); font-size: .88rem; white-space: nowrap; }
.star-item .swhere { font-size: .76rem; color: var(--ink-faint); margin-left: auto; white-space: nowrap; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.cal .cd {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--card2); border: 1px solid var(--line);
  font-size: .8rem; color: var(--ink-dim); cursor: pointer;
}
.cal .cd.green { border-color: rgba(111,191,143,.5); color: var(--good); }
.cal .cd.red { border-color: rgba(226,105,79,.5); color: var(--bad); }
.cal .cd.today { outline: 2px solid var(--gold); }
.cal .cd .dot { font-size: .5rem; line-height: 1; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; font-size: .62rem; color: var(--ink-faint); text-align: center; margin-top: 8px; }

/* ---------- lock / premium ---------- */
.locked-section { position: relative; }
.locked-section .blurred {
  filter: blur(7px); opacity: .55; pointer-events: none; user-select: none;
}
/* skeleton preview — suggests the depth of the locked reading without
 * shipping a single word of it */
.locked-section .skel { padding: 2px 0 10px; min-height: 300px; }
.locked-section .skel i {
  display: block; height: 10px; border-radius: 5px; margin: 10px 0;
  background: linear-gradient(90deg, rgba(201,164,92,.08), rgba(201,164,92,.20), rgba(201,164,92,.08));
}
.locked-section .skel i.h {
  height: 13px; width: 42% !important; margin-top: 20px;
  background: rgba(201,164,92,.26);
}
.lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px;
}
.btn {
  font-family: inherit; cursor: pointer; border-radius: 11px;
  padding: 11px 22px; font-size: .92rem; border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, #2a2317, #201a10); color: var(--gold-bright);
}
.btn:hover { border-color: var(--gold); }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #201a10; border: none; font-weight: 600;
}
.btn.small { padding: 7px 14px; font-size: .8rem; }
.btn.block { width: 100%; }
.btn.ghost { background: none; border-color: var(--line); color: var(--ink-dim); }

/* ---------- forms ---------- */
label.f { display: block; font-size: .76rem; color: var(--ink-dim); letter-spacing: .04em; margin: 12px 0 4px; }
input, select {
  width: 100%; font-family: inherit; font-size: .95rem;
  background: var(--bg2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--gold-dim); }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frow3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 9px; margin-top: 12px; font-size: .85rem; color: var(--ink-dim); }
.check input { width: auto; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  width: 100%; max-width: var(--maxw); max-height: 88vh; overflow-y: auto; padding: 22px 20px 34px;
}
@media (min-width: 640px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal h2 { color: var(--gold-bright); font-size: 1.05rem; margin-bottom: 4px; }
.modal .x { float: right; background: none; border: none; color: var(--ink-faint); font-size: 1.3rem; cursor: pointer; }

/* profile list */
.plist-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.plist-item .pn { flex: 1; cursor: pointer; }
.plist-item .pn .sub { font-size: .72rem; color: var(--ink-faint); }
.plist-item button { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: .9rem; }

/* misc */
.divider { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.center { text-align: center; }
.badge {
  display: inline-block; font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(201,164,92,.15); color: var(--gold); border-radius: 5px; padding: 2px 8px; margin-left: 6px;
}
.footer-note { text-align: center; font-size: .7rem; color: var(--ink-faint); padding: 18px 24px 8px; line-height: 1.7; }
a { color: var(--gold); }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--card2); color: var(--ink); border: 1px solid var(--gold-dim);
  padding: 10px 18px; border-radius: 12px; font-size: .85rem; z-index: 60;
  opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }

/* ---------- solar-term almanac card ---------- */
.term-card { cursor: pointer; transition: border-color .25s ease, transform .15s ease; }
.term-card:hover { border-color: var(--gold-dim); }
.term-card:active { transform: scale(.995); }
.term-row { display: flex; align-items: center; gap: 15px; }
.term-glyph {
  font-size: 1.5rem; line-height: 1.15; width: 52px; min-width: 52px;
  text-align: center; color: var(--gold-bright);
  writing-mode: vertical-rl; letter-spacing: .2em;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 0;
  background: radial-gradient(circle at 50% 0%, rgba(201,164,92,.12), transparent 70%);
}
.term-meta { flex: 1; }
.term-name { color: var(--gold-bright); font-size: .95rem; }
.term-arrow { color: var(--ink-faint); font-size: 1.2rem; }

/* pinyin annotation row */
.pinyin {
  font-size: .58rem; letter-spacing: .2em; color: var(--ink-faint);
  text-transform: lowercase; line-height: 1.3; text-align: center;
}
.today-pillar .chars .pinyin { margin: -2px 0 3px; }

/* universal per-stem fortune list */
.uni-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 9px 6px; border-bottom: 1px dashed var(--line);
}
.uni-item:last-of-type { border-bottom: none; }
.uni-item.me {
  background: rgba(201, 164, 92, .07);
  border: 1px solid var(--gold-dim); border-radius: 10px; margin: 4px -6px;
}
.uni-stem { min-width: 40px; text-align: center; padding-top: 2px; }
.uni-body { flex: 1; }
.uni-god { font-size: .82rem; color: var(--gold-bright); margin-bottom: 2px; }

/* time-cycle rows & VIP tier boxes */
.cycle-label {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-dim); margin: 14px 0 8px; font-weight: 600;
}
.tier-table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .78rem;
}
.tier-table th, .tier-table td {
  padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center;
}
.tier-table td:first-child { text-align: left; color: var(--ink-dim); }
.tier-table th { color: var(--gold-bright); font-weight: 600; }
.tier-table th span { font-size: .64rem; color: var(--ink-faint); font-weight: 400; }
.tier-table tr.price td { color: var(--gold-bright); font-weight: 600; border-bottom: none; }
.tier-box {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin: 10px 0;
  background: linear-gradient(165deg, var(--card2), var(--card));
}
.tier-box .tier-name { color: var(--gold-bright); font-size: .95rem; margin-bottom: 4px; }

/* master reading card */
.master-card { border-color: rgba(201, 164, 92, .3); }
.master-card h2 { color: var(--gold-bright); }

/* refined touches */
::selection { background: rgba(201, 164, 92, .35); }
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: #2a251e; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
.btn { transition: border-color .2s ease, transform .12s ease, box-shadow .2s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { box-shadow: 0 6px 18px -8px rgba(201, 164, 92, .55); }
.pillar { box-shadow: 0 1px 0 rgba(255,255,255,.02) inset; }
.star-item:hover .sname { color: var(--gold); }
input, select { transition: border-color .2s ease; }
h2, .plabel, .badge { font-feature-settings: "case"; }
