/* 星见塔罗 · 双主题样式（深墨鎏金 / 浅色简洁） */
:root {
  --gold: #d4af6a;
  --gold-dim: #8a7a50;
  --ink: #e8d9b0;
  --bg: #0f1220;
  --bg2: #171c33;
  --card-bg: #1a2038;
  --card-bg2: #141a2e;
  --text: #e8e4da;
  --text-dim: #9a97ab;
  --border: #2a3150;
  --danger: #c06060;
  --ok: #7fb069;
  --radius: 14px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
html[data-theme="light"] {
  --gold: #8a6d3b;
  --gold-dim: #b8a878;
  --ink: #3f3a55;
  --bg: #f7f4ee;
  --bg2: #ece5d6;
  --card-bg: #ffffff;
  --card-bg2: #f4efe4;
  --text: #2e2c3a;
  --text-dim: #7d7a8a;
  --border: #ddd6c4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg2), var(--bg) 70%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background .3s;
}
button, textarea, input { font-family: inherit; }
button { touch-action: manipulation; cursor: pointer; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 80px; }

/* ---------- header ---------- */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 38px; height: 38px; border: 1.5px solid var(--gold);
  border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--card-bg2), var(--card-bg));
}
.brand .logo svg { width: 22px; height: 22px; stroke: var(--gold); fill: none; }
.brand h1 { font-size: 20px; letter-spacing: 4px; font-weight: 600; color: var(--gold); }
.brand .sub { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; }
.theme-btn {
  background: none; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-dim); font-size: 15px; padding: 6px 10px; transition: all .2s;
}
.theme-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- 新手引导 ---------- */
.guide {
  margin: 10px 0 12px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(212,175,106,.12), rgba(212,175,106,.04));
  border: 1px dashed var(--gold-dim);
}
.guide .g-title { color: var(--gold); font-size: 14px; font-weight: 600; letter-spacing: 1px; margin-bottom: 10px; }
.guide .g-steps { display: grid; gap: 6px; margin-bottom: 8px; }
.guide .g-step { font-size: 13px; color: var(--text); }
.guide .g-step b {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); color: #14100a; font-size: 11px; margin-right: 6px;
}
.guide .g-tip { font-size: 11.5px; color: var(--text-dim); margin-bottom: 10px; }

/* ---------- 问题胶囊 ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.pill-label { font-size: 11.5px; color: var(--text-dim); }
.pill {
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text-dim);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; transition: all .2s;
  touch-action: manipulation;
}
.pill:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- 翻牌牌意 ---------- */
.fwrap .kw {
  position: absolute; bottom: -62px; left: 0; right: 0; text-align: center;
  font-size: 10.5px; color: var(--text-dim); line-height: 1.4;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 4px; opacity: 0; transition: opacity .4s;
  max-height: 2.9em; overflow: hidden;
}
.fcard.revealed .kw { opacity: 1; }

/* ---------- 解读贴士 ---------- */
.r-kw {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 11.5px; color: var(--gold-dim); letter-spacing: .5px;
}

/* ---------- 每日一牌 ---------- */
.daily {
  margin: 14px 0 8px; padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--card-bg), var(--card-bg2));
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.daily .d-ico { font-size: 26px; color: var(--gold); }
.daily .d-txt { flex: 1; }
.daily .d-txt .t1 { font-size: 14px; font-weight: 600; color: var(--gold); letter-spacing: 1px; }
.daily .d-txt .t2 { font-size: 12px; color: var(--text-dim); }
.daily .d-act { flex-shrink: 0; }
.btn {
  border: 1px solid var(--gold); background: linear-gradient(135deg, var(--gold), #b8934f);
  color: #14100a; border-radius: 10px; padding: 9px 18px;
  font-size: 14px; font-weight: 600; letter-spacing: 1px; transition: all .2s;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost {
  background: none; color: var(--gold); border: 1px solid var(--gold-dim); font-weight: 500;
}
.btn.ghost:hover { background: rgba(212,175,106,.08); }

/* ---------- 分区标题 ---------- */
.sec { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.sec h2 { font-size: 15px; letter-spacing: 2px; color: var(--gold); }
.sec .tip { font-size: 11px; color: var(--text-dim); }

/* ---------- 场景入口 ---------- */
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scene {
  border: 1px solid var(--border); background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 8px; text-align: center; transition: all .2s; color: var(--text);
}
.scene .s-ico { font-size: 24px; display: block; margin-bottom: 4px; }
.scene .s-name { font-size: 13px; font-weight: 600; }
.scene .s-desc { font-size: 11px; color: var(--text-dim); }
.scene:hover, .scene.on {
  border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold);
  background: linear-gradient(135deg, var(--card-bg2), var(--card-bg));
}
.scene.on .s-name { color: var(--gold); }

/* ---------- 牌阵 + 问题 ---------- */
.spreads { display: flex; gap: 8px; flex-wrap: wrap; }
.spread {
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text-dim);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; transition: all .2s;
}
.spread.on { border-color: var(--gold); color: var(--gold); background: rgba(212,175,106,.08); }
textarea.q {
  width: 100%; margin-top: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card-bg); color: var(--text); padding: 12px 14px; font-size: 14px;
  resize: vertical; min-height: 68px; outline: none; transition: border .2s;
}
textarea.q:focus { border-color: var(--gold); }
.qbar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.qbar .btn { flex-shrink: 0; }
.q-hint { font-size: 11px; color: var(--text-dim); }

/* ---------- 抽牌区 ---------- */
.deck-zone { margin: 18px 0; display: flex; justify-content: center; min-height: 240px; position: relative; }
.deck {
  position: relative; width: 128px; height: 218px; cursor: pointer;
  transform-style: preserve-3d;
}
.deck .back {
  position: absolute; inset: 0; border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.deck .back svg { width: 100%; height: 100%; display: block; }
.deck.shuffling .back { animation: shuffle .45s ease-in-out infinite; }
@keyframes shuffle {
  0%,100% { transform: rotate(0deg) translateX(0); }
  25% { transform: rotate(-6deg) translateX(-14px); }
  75% { transform: rotate(6deg) translateX(14px); }
}
.deck.shuffling .b2 { animation-delay: .08s; }
.deck.shuffling .b3 { animation-delay: .16s; }
.deck .b2 { top: 3px; left: 5px; opacity: .85; }
.deck .b3 { top: 6px; left: 10px; opacity: .7; }

/* 扇形展开 */
.fan { display: grid; grid-template-columns: repeat(auto-fit, 96px); justify-content: center; gap: 8px; row-gap: 74px; padding: 10px 0 8px; margin-bottom: 90px; }
.fwrap { position: relative; width: 96px; height: 164px; }
.fcard {
  width: 100%; height: 100%; position: relative; border-radius: 8px;
  transform-style: preserve-3d; transition: transform .6s;
}
.fcard .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 8px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.fcard .face svg { width: 100%; height: 100%; display: block; }
.fcard .front { transform: rotateY(180deg); }
.fcard.revealed { transform: rotateY(180deg); }
.fwrap .pos {
  position: absolute; bottom: -26px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: var(--gold-dim); letter-spacing: 1px;
}
.fcard.rev .pos::after { content: " · 逆位"; color: var(--danger); }

/* ---------- 解读区 ---------- */
.reading { margin-top: 26px; }
.r-loading {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center;
  color: var(--gold); font-size: 14px; letter-spacing: 2px;
}
.r-loading .dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}
.r-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(160deg, var(--card-bg), var(--card-bg2));
  padding: 18px; margin-bottom: 12px;
}
.r-card .r-pos { font-size: 12px; color: var(--gold); letter-spacing: 2px; margin-bottom: 4px; }
.r-card .r-cardname { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.r-card .r-cardname .rev { color: var(--danger); font-size: 11px; }
.r-card .r-text { font-size: 14px; white-space: pre-wrap; }
.r-summary {
  border: 1px solid var(--gold-dim); border-radius: var(--radius);
  padding: 16px 18px; margin: 14px 0;
}
.r-summary .t { color: var(--gold); font-size: 13px; letter-spacing: 2px; margin-bottom: 6px; }
.r-summary .c { font-size: 14.5px; white-space: pre-wrap; }
.r-advice { margin: 12px 0; }
.r-advice li {
  margin: 6px 0 6px 18px; font-size: 13.5px; color: var(--text);
}
.r-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.chat-q { display: flex; gap: 8px; margin-top: 10px; }
.chat-q input {
  flex: 1; border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; outline: none;
}
.chat-q input:focus { border-color: var(--gold); }
.chat-q .btn { padding: 9px 14px; font-size: 13px; }
.chat-turn { margin: 8px 0; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }
.chat-turn.you { background: var(--card-bg2); border: 1px solid var(--border); }
.chat-turn.ai { background: var(--card-bg); border: 1px solid var(--gold-dim); white-space: pre-wrap; }

/* ---------- 历史 ---------- */
.hist-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--card-bg); cursor: pointer; transition: border .2s;
}
.hist-item:hover { border-color: var(--gold-dim); }
.hist-item .h-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); }
.hist-item .h-cards { font-size: 13px; margin-top: 4px; color: var(--gold); }
.hist-item .h-sum { font-size: 12.5px; margin-top: 6px; color: var(--text-dim); white-space: pre-wrap; max-height: 96px; overflow: hidden; }
.hist-item.open .h-sum { max-height: none; }
.hist-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px 0; }

/* ---------- footer ---------- */
footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }
footer .privacy { font-size: 11px; color: var(--text-dim); line-height: 1.8; }
footer .links { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; }
footer .links button {
  background: none; border: none; color: var(--gold-dim); font-size: 12px;
}
footer .links button:hover { color: var(--gold); }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(5,6,12,.72); z-index: 50;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(480px, 100%); background: var(--card-bg); border: 1px solid var(--gold-dim);
  border-radius: 16px; padding: 20px; max-height: 86vh; overflow: auto;
}
.modal h3 { color: var(--gold); font-size: 15px; letter-spacing: 2px; margin-bottom: 12px; }
.modal textarea { width: 100%; min-height: 90px; }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.modal .m-msg { font-size: 12px; margin-top: 8px; color: var(--ok); }

/* ---------- 分享卡弹层 ---------- */
.share-card-wrap { text-align: center; }
.share-card-wrap canvas { width: min(320px, 82vw); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.share-hint { font-size: 12px; color: var(--text-dim); margin-top: 10px; }

@media (max-width: 480px) {
  .scenes { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .fcard { width: 88px; height: 150px; }
  .brand h1 { font-size: 17px; letter-spacing: 3px; }
}
