/* ============ 天机阁 · 玄学测算（浅色模式） ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-page: #f5f2ea;
  --bg-card: #ffffff;
  --bg-soft: #faf7f0;
  --gold: #9a7a1e;
  --gold-strong: #7c6114;
  --gold-bg: #fdf6e3;
  --purple: #6c5cc4;
  --text: #33302a;
  --text-strong: #1f1d18;
  --text-dim: #8a8578;
  --red: #c0392b;
  --green: #2e7d52;
  --blue: #3a6ea5;
  --border: #e3dccb;
  --border-strong: #cdbf9d;
  --shadow: 0 4px 20px rgba(120, 100, 50, 0.10);
  --font-title: "STKaiti", "KaiTi", "Noto Serif SC", "SimSun", serif;
}

html, body {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 18% -8%, rgba(212, 175, 55, 0.10), transparent 55%),
    radial-gradient(ellipse at 88% 105%, rgba(108, 92, 196, 0.07), transparent 55%),
    var(--bg-page);
  color: var(--text);
  font-size: 16px;
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", "SimSun", "Microsoft YaHei", serif;
  overflow-x: hidden;
}

/* 装饰元素在浅色模式下隐藏 */
.stars, .moon { display: none; }

/* 页头 */
.site-header { position: relative; z-index: 1; text-align: center; padding: 42px 16px 10px; }
.site-header .logo { color: var(--gold); font-size: 17px; letter-spacing: 6px; }
.site-header h1 {
  font-size: 42px; letter-spacing: 14px; margin-top: 6px;
  background: linear-gradient(180deg, #a9851f, #7c6114);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.site-header .subtitle { color: var(--text-dim); letter-spacing: 5px; margin-top: 8px; font-size: 16px; }

/* 卡片 */
.card {
  position: relative; z-index: 1;
  max-width: 1000px; margin: 26px auto; padding: 28px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  text-align: center; color: var(--gold-strong); font-size: 22px;
  letter-spacing: 6px; margin-bottom: 8px; font-weight: normal;
}
.card-title::before, .card-title::after { content: "·"; color: var(--gold); margin: 0 12px; }
.hint { color: var(--text-dim); font-size: 16px; line-height: 1.9; text-align: justify; margin-bottom: 18px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.form-item label { display: block; color: var(--gold-strong); font-size: 16px; margin-bottom: 7px; letter-spacing: 1px; }
.form-item input[type="text"], .form-item input[type="number"], .form-item select {
  width: 100%; padding: 10px 12px;
  background: #fff; color: var(--text-strong);
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 16px; font-family: inherit; outline: none;
}
.form-item input:focus, .form-item select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, .18);
}
.leap-label { display: flex; align-items: center; gap: 8px; color: var(--text) !important; cursor: pointer; }
.leap-label input { accent-color: var(--gold); width: 16px; height: 16px; }

.birth-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.birth-actions .save-tip { color: var(--text-dim); font-size: 16px; }
.birth-actions .save-tip.saved { color: var(--green); }

.birth-summary {
  margin-top: 16px; padding: 14px 18px; border-radius: 10px;
  background: var(--gold-bg); border: 1px dashed var(--border-strong);
  color: var(--text-strong); font-size: 16px; line-height: 2; letter-spacing: 1px;
}
.birth-summary b { color: var(--gold-strong); font-weight: normal; }

/* 按钮 */
.btn {
  padding: 11px 26px; font-size: 16px; letter-spacing: 3px;
  border-radius: 10px; cursor: pointer; font-family: inherit;
  transition: all .25s; border: 1px solid transparent;
}
.btn.gold {
  background: linear-gradient(180deg, #c9a737, #a8842c);
  color: #fff; border-color: #9a7a1e;
  box-shadow: 0 3px 12px rgba(168, 132, 44, .35);
  text-shadow: 0 1px 1px rgba(0,0,0,.15);
}
.btn.gold:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(168, 132, 44, .45); }
.btn.gold:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--gold-strong); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--gold-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 8px 20px; font-size: 16px; }
.action-row { text-align: center; margin-top: 18px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.error-box {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  background: #fdf0ef; border: 1px solid #e4b0aa;
  color: var(--red); font-size: 16px; text-align: center;
}

/* 标签页 */
.tabs { position: relative; z-index: 1; display: flex; justify-content: center; gap: 18px; margin: 30px 0 0; }
.tab-btn {
  padding: 12px 34px; font-size: 18px; letter-spacing: 4px; font-family: inherit;
  background: #ece5d5; color: #6b665a;
  border: 1px solid var(--border); border-radius: 12px 12px 0 0; cursor: pointer;
  transition: all .25s;
}
.tab-btn.active { color: var(--gold-strong); border-bottom-color: transparent; background: var(--bg-card); font-weight: bold; }
.tab-btn:hover { color: var(--gold-strong); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ 紫微盘 ============ */
.ziwei-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, minmax(122px, auto));
  gap: 3px; margin-top: 18px;
}
.palace {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 9px; font-size: 13px; position: relative;
  min-height: 122px;
}
.palace.ming-gong { border-color: var(--gold); background: var(--gold-bg); box-shadow: inset 0 0 0 1px rgba(154, 122, 30, .25); }
.palace .p-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.palace .p-name { color: var(--gold-strong); font-size: 15px; letter-spacing: 1px; font-weight: bold; }
.palace .p-name .body-tag { font-size: 12px; color: var(--red); margin-left: 3px; }
.palace .p-ganzhi { color: var(--text-dim); font-size: 13px; }
.palace .p-ganzhi .orig { color: var(--purple); }
.palace .p-main { margin-top: 4px; line-height: 1.75; color: var(--text-strong); }
.palace .star-main { color: #8a6d14; font-weight: bold; margin-right: 6px; }
.palace .star-bright { color: var(--text-dim); font-size: 12px; }
.palace .mutagen { border-radius: 3px; padding: 0 3px; font-size: 12px; margin-left: 2px; font-weight: bold; }
.palace .mutagen.mu-lu { color: #1e7d3c; border: 1px solid #9ccfae; background: #eef8f0; }
.palace .mutagen.mu-quan { color: #2456a0; border: 1px solid #a3c1e4; background: #edf4fb; }
.palace .mutagen.mu-ke { color: #6d3fa0; border: 1px solid #c4aade; background: #f5effb; }
.palace .mutagen.mu-ji { color: var(--red); border: 1px solid #e4a49c; background: #fdf0ee; }
.palace .p-minor { color: var(--blue); margin-top: 3px; line-height: 1.75; }
.palace .p-adjective { color: var(--text-dim); font-size: 12px; margin-top: 3px; line-height: 1.65; }
.palace .da-xian { position: absolute; top: 6px; right: 8px; color: var(--purple); font-size: 12px; }

.ziwei-center {
  grid-column: 2 / 4; grid-row: 2 / 4;
  background: linear-gradient(180deg, #fffdf6, #faf3df);
  border: 1px solid var(--border-strong); border-radius: 8px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 14px; text-align: center;
}
.ziwei-center .big-gua { font-size: 34px; color: var(--gold-strong); letter-spacing: 8px; margin-bottom: 10px; }
.ziwei-center .info-line { font-size: 16px; color: var(--text-strong); line-height: 2.1; letter-spacing: 1px; }
.ziwei-center .info-line b { color: var(--gold-strong); font-weight: bold; }

.ziwei-extra { margin-top: 16px; color: var(--text); font-size: 16px; line-height: 2; }
.ziwei-extra b { color: var(--gold-strong); font-weight: bold; }

/* ============ 六爻 ============ */
.liuyao-ask { display: flex; gap: 16px; flex-wrap: wrap; }
.liuyao-ask .form-item { flex: 0 0 220px; }
.liuyao-ask .form-item.grow { flex: 1 1 300px; }

.coin-stage { display: flex; justify-content: center; gap: 26px; margin: 26px 0 10px; min-height: 96px; }
.coin {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #4a3808;
  background: radial-gradient(circle at 35% 30%, #f7e6a6, #d4af37 55%, #9d7d1e);
  border: 3px solid #b8942a;
  box-shadow: 0 4px 12px rgba(120, 90, 20, .35), inset 0 0 12px rgba(120,90,10,.4);
  transition: transform .5s cubic-bezier(.2,.7,.3,1.2);
}
.coin.flip { animation: coinflip .6s ease; }
@keyframes coinflip {
  0% { transform: rotateX(0) translateY(0); }
  50% { transform: rotateX(720deg) translateY(-26px); }
  100% { transform: rotateX(1440deg) translateY(0); }
}
.coin.front-show { color: #5a430c; }
.coin.back-show { color: #6b4d0d; background: radial-gradient(circle at 40% 35%, #ecd488, #c2a032 60%, #8a6d16); }
.coin .face-back { font-size: 18px; letter-spacing: 2px; }

.cast-log { text-align: center; color: var(--text-dim); font-size: 16px; min-height: 24px; margin-bottom: 8px; }

.gua-title { text-align: center; margin: 18px 0 6px; }
.gua-title .gua-main-name { font-size: 26px; color: var(--gold-strong); letter-spacing: 3px; font-weight: bold; }
.gua-title .gua-sub { color: var(--text-dim); font-size: 16px; margin-top: 6px; letter-spacing: 1px; }
.gua-title .gua-bian { color: var(--purple); font-size: 17px; margin-top: 4px; }

.gua-lines { max-width: 640px; margin: 14px auto 0; }
.yao-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px;
  border-bottom: 1px dashed var(--border);
}
.yao-row .yao-shiying { flex: 0 0 52px; color: var(--gold-strong); font-size: 16px; letter-spacing: 2px; }
.yao-row .yao-shiying .ying { color: var(--purple); }
.yao-row .yao-symbol { flex: 0 0 150px; display: flex; justify-content: center; align-items: center; position: relative; }
.yao-bar { height: 12px; background: linear-gradient(180deg, #d9b545, #a8842c); border-radius: 3px; }
.yao-bar.solid { width: 130px; }
.yao-bar-wrap { width: 130px; display: flex; justify-content: space-between; }
.yao-bar-wrap .yao-bar { width: 54px; }
.yao-row .yao-mark { position: absolute; right: -14px; font-size: 14px; }
.yao-row .yao-mark-col {
  flex: 0 0 22px; text-align: center; font-size: 16px; color: var(--red);
  letter-spacing: 0; font-weight: bold;
}
.yao-mark.dong-yang { color: var(--red); }
.yao-mark.dong-yin { color: var(--red); }
.yao-row .yao-label { flex: 1; color: var(--text-strong); font-size: 16px; letter-spacing: 1px; }
.yao-row .yao-liushen { flex: 0 0 58px; color: var(--purple); font-size: 16px; text-align: right; }
.yao-row .yao-desc { flex: 0 0 auto; color: var(--text-dim); font-size: 16px; width: 100%; text-align: right; }
.yao-row.moving { background: #fdf1ef; }

.gua-note { margin-top: 16px; padding: 14px 18px; border-radius: 10px; background: #f3f0fa; border: 1px solid #d5cdf0; color: var(--text); font-size: 16px; line-height: 2; }
.gua-note b { color: var(--purple); font-weight: bold; }

/* ============ 聊天 ============ */
.chat-card { max-width: 1000px; }
.chat-box {
  display: flex; flex-direction: column; gap: 14px;
  max-height: 540px; overflow-y: auto; padding: 6px 4px;
  scroll-behavior: smooth;
}
.chat-box::-webkit-scrollbar { width: 6px; }
.chat-box::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.msg { max-width: 92%; padding: 14px 18px; border-radius: 12px; font-size: 16px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg.ai {
  align-self: flex-start;
  width: 100%; max-width: 100%;
  background: #fff; border: 1px solid var(--border);
  border-top-left-radius: 3px;
  /* 断语正文用无衬线字体，清晰易读（参考简洁排版） */
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  color: #333;
}
/* 渲染完成后的富文本：交给段落标签排版，不再用 pre-wrap */
.msg.ai .msg-body.rich { white-space: normal; }
.msg.ai .msg-body.rich .md-p { margin: 0 0 12px; line-height: 1.75; color: #333; }
.msg.ai .msg-body.rich .md-p:last-child { margin-bottom: 0; }
.msg.ai .msg-body.rich .md-h {
  font-size: 17px; font-weight: 700; color: #1f1d18;
  margin: 22px 0 12px; padding-left: 12px; line-height: 1.5;
  border-left: 4px solid var(--gold); letter-spacing: 0;
}
.msg.ai .msg-body.rich .md-h:first-child { margin-top: 4px; }
.msg.ai .msg-body.rich .md-h-sub { border-left-color: var(--purple); font-size: 16px; }
.msg.ai .msg-body.rich .md-sep {
  height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent);
  margin: 18px 0;
}
.msg strong { color: #7c5a12; font-weight: 700; }
.msg.ai .msg-body.rich strong { color: #8a6410; font-weight: 700; background: linear-gradient(transparent 62%, rgba(212,175,55,.22) 62%); padding: 0 1px; }
.msg em { font-style: normal; color: var(--purple); }
.msg code { background: #f1ece0; border-radius: 3px; padding: 1px 4px; font-size: 15px; }
.msg .msg-h {
  display: block; color: var(--gold-strong); font-weight: bold;
  margin: 10px 0 2px; letter-spacing: 1px;
}
.msg.user {
  align-self: flex-end;
  background: var(--gold-bg); border: 1px solid var(--border-strong);
  border-top-right-radius: 3px;
}
.msg .msg-tag { display: block; font-size: 13px; color: var(--gold-strong); margin-bottom: 8px; letter-spacing: 2px; font-family: var(--font-title); }
.msg.user .msg-tag { color: var(--gold-strong); text-align: right; }
.msg.loading-dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.chat-input-row { display: flex; gap: 12px; margin-top: 16px; }
.chat-input-row input {
  flex: 1; padding: 11px 14px; border-radius: 10px; font-size: 16px;
  background: #fff; color: var(--text-strong);
  border: 1px solid var(--border-strong); font-family: inherit; outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, .18); }

.quick-asks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-asks button {
  padding: 7px 16px; font-size: 16px; font-family: inherit; letter-spacing: 1px;
  background: #f3f0fa; color: var(--purple);
  border: 1px solid #cdbfe8; border-radius: 20px; cursor: pointer;
  transition: all .2s;
}
.quick-asks button:hover { background: #e7e0f7; color: #5647ad; }

/* 页脚 */
.site-footer { position: relative; z-index: 1; text-align: center; padding: 34px 16px 44px; color: var(--text-dim); font-size: 16px; line-height: 2; }
.key-warn { color: var(--red); font-size: 16px; opacity: .85; }

@media (max-width: 720px) {
  .card { padding: 18px 14px; margin: 16px 10px; }
  .site-header h1 { font-size: 32px; letter-spacing: 8px; }
  .ziwei-grid { grid-template-columns: repeat(4, 1fr); }
  .palace { padding: 5px 5px; min-height: 96px; font-size: 12px; }
  .palace .p-name { font-size: 13px; }
  .palace .star-main { margin-right: 3px; }
  .ziwei-center .big-gua { font-size: 22px; letter-spacing: 4px; }
  .ziwei-center .info-line { font-size: 13px; }
  .coin { width: 62px; height: 62px; font-size: 22px; }
  .yao-row .yao-symbol { flex-basis: 100px; }
  .yao-bar.solid { width: 84px; }
  .yao-bar-wrap { width: 84px; }
  .yao-bar-wrap .yao-bar { width: 34px; }
}

/* ============ 用户栏 ============ */
.user-bar {
  position: relative; z-index: 2;
  max-width: 1000px; margin: 0 auto; padding: 14px 4px 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.user-bar .ub-left { color: var(--gold-strong); font-size: 17px; letter-spacing: 4px; }
.user-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ub-user { color: var(--gold-strong); font-size: 16px; letter-spacing: 1px; }
.ub-credits {
  background: var(--gold-bg); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 4px 14px; font-size: 15px; color: var(--text);
}
.ub-credits b { color: var(--gold-strong); font-size: 17px; }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(40, 34, 20, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: 0 10px 40px rgba(80, 60, 20, 0.25);
  max-width: 420px; width: 100%; padding: 26px 28px;
  max-height: 86vh; overflow-y: auto;
}
.modal-title {
  text-align: center; color: var(--gold-strong); font-size: 20px;
  letter-spacing: 6px; margin-bottom: 16px; font-weight: normal;
}
.modal-form label { display: block; color: var(--gold-strong); font-size: 15px; margin: 12px 0 6px; }
.modal-form input {
  width: 100%; padding: 10px 12px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 8px; outline: none;
  background: #fff; color: var(--text-strong);
}
.modal-form input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,.18); }
.modal-err { color: var(--red); font-size: 15px; min-height: 20px; margin-top: 8px; }
.modal-tip { color: var(--text-dim); font-size: 15px; line-height: 1.8; margin-top: 14px; }
.modal-tip a { color: var(--gold-strong); }
.modal-need {
  background: #fdf0ee; border: 1px solid #e4b0aa; color: var(--red);
  border-radius: 8px; padding: 10px 14px; font-size: 15px; line-height: 1.8;
}
.modal-need b { font-size: 17px; }

/* ============ 提示气泡 ============ */
.tj-toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  z-index: 60; background: #3d382c; color: #f5f0e0;
  padding: 10px 22px; border-radius: 24px; font-size: 15px; letter-spacing: 1px;
  opacity: 0; pointer-events: none; transition: all .3s;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.tj-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tj-toast.bad { background: #8e3a30; }

/* ============ 价格标注 ============ */
.price-tag {
  display: inline-block; background: rgba(154,122,30,.12); color: var(--gold-strong);
  border-radius: 10px; padding: 0 8px; font-size: 15px;
}

/* ============ 小标题 ============ */
.sub-title {
  color: var(--gold-strong); font-size: 18px; letter-spacing: 3px;
  margin: 22px 0 12px; font-weight: bold;
}

/* ============ 大运表 ============ */
.yun-start {
  background: var(--gold-bg); border: 1px dashed var(--border-strong);
  border-radius: 8px; padding: 10px 16px; font-size: 16px; line-height: 1.9;
  color: var(--text); margin-bottom: 12px;
}
.yun-start b { color: var(--gold-strong); }
.dayun-row, .liunian-row { display: flex; flex-wrap: wrap; gap: 8px; }
.dayun-cell, .liunian-cell {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; text-align: center; min-width: 86px;
  position: relative;
}
.dayun-cell.cur, .liunian-cell.cur {
  background: var(--gold-bg); border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(154,122,30,.3);
}
.dy-gz, .ln-gz { font-size: 19px; color: var(--gold-strong); letter-spacing: 2px; font-weight: bold; }
.dy-age, .ln-age { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.dy-year, .ln-year { font-size: 14px; color: var(--text); margin-top: 2px; }
.dy-tag {
  position: absolute; top: -9px; right: -6px;
  background: var(--gold); color: #fff; font-size: 12px;
  border-radius: 10px; padding: 1px 8px;
}

/* ============ 签卡 ============ */
.sign-card {
  max-width: 560px; margin: 20px auto;
  background: linear-gradient(180deg, #fffdf6, #f9f1dc);
  border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 28px 30px; text-align: center;
  box-shadow: var(--shadow);
}
.sign-lv { font-size: 22px; color: var(--red); letter-spacing: 6px; font-weight: bold; }
.sign-title { font-size: 19px; color: var(--gold-strong); letter-spacing: 3px; margin-top: 8px; }
.sign-poem {
  margin: 18px 0 12px; font-size: 17px; line-height: 2.2;
  color: var(--text-strong); letter-spacing: 2px;
}
.sign-day { font-size: 14px; color: var(--text-dim); border-top: 1px dashed var(--border); padding-top: 12px; }

/* ============ 姓名测算 ============ */
.name-form { display: flex; gap: 16px; flex-wrap: wrap; }
.name-form .form-item { flex: 1 1 150px; }
.name-headline {
  text-align: center; font-size: 24px; color: var(--gold-strong);
  letter-spacing: 4px; margin: 18px 0 6px; font-weight: bold;
}

@media (max-width: 720px) {
  .user-bar { flex-direction: column; align-items: center; }
  .dayun-cell, .liunian-cell { min-width: 72px; padding: 6px 8px; }
  .dy-gz, .ln-gz { font-size: 16px; }
}

/* ============ 游客体验标识 ============ */
.ub-guest {
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: .5px;
  background: #f2ede0;
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 3px 12px;
}
@media (max-width: 720px) {
  .ub-guest { font-size: 14px; padding: 2px 10px; }
}
