:root {
  --bg: #fbf7f4;
  --ink: #5b4446;
  --ink-soft: #9a8285;
  --rose: #c9a1a5;
  --rose-deep: #a87479;
  --line: #ead5d8;
  --glass: rgba(255, 252, 250, .72);
  --card-ratio: 1.5;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --latin: "Cormorant Garamond", "Noto Serif SC", serif;
  --script: "Pinyon Script", cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: var(--bg);
  font-family: var(--serif);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 背景：植物壁纸 + 一层白纱 */
.backdrop {
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(251, 247, 244, .58), rgba(251, 247, 244, .58)),
    url("/img/wallpaper.webp") 0 0 / 560px 560px repeat,
    var(--bg);
}

/* ---------- 通用 ---------- */
.screen { min-height: 100vh; position: relative; animation: fade-in .8s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.script { font-family: var(--script); color: var(--rose); font-size: 34px; line-height: 1; }
.script.big { font-size: 72px; }
.title { margin: 10px 0 8px; font-weight: 300; font-size: 24px; letter-spacing: 12px; text-indent: 12px; }
.note { margin: 0; font-family: var(--latin); font-style: italic; font-size: 17px; color: var(--ink-soft); }
.panel {
  background: var(--glass);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(150, 105, 110, .14);
}
.actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.btn {
  border: 1px solid var(--rose); border-radius: 999px; cursor: pointer;
  padding: 13px 34px; font-size: 15px; letter-spacing: 4px;
  background: rgba(255, 255, 255, .7); color: var(--ink);
  transition: background .3s, box-shadow .3s, transform .2s;
}
.btn:hover { background: #fff; box-shadow: 0 6px 18px rgba(168, 116, 121, .18); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--rose); color: #fff; box-shadow: 0 8px 22px rgba(168, 116, 121, .28); }
.btn.primary:hover { background: var(--rose-deep); }
.btn.small { padding: 9px 22px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: progress; }
.back-link {
  position: absolute; left: 28px; top: 22px; z-index: 20;
  border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 14px; letter-spacing: 2px;
}
.back-link:hover { color: var(--ink); }
.error { color: #b5545f; text-align: center; font-size: 14px; margin: 16px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 11px 24px; border-radius: 999px; font-size: 14px; letter-spacing: 1px;
}

/* ---------- 首页 ---------- */
#home { display: flex; align-items: center; justify-content: center; text-align: center; }
.home-cards { position: relative; height: 230px; width: 360px; margin: 30px auto 6px; }
.home-cards img {
  position: absolute; bottom: 0; left: 50%; width: 130px; border-radius: 9px;
  box-shadow: 0 12px 30px rgba(150, 105, 110, .25); transform-origin: 50% 120%;
}
.home-cards img:nth-child(1) { transform: translateX(-50%) rotate(-14deg); }
.home-cards img:nth-child(2) { transform: translateX(-50%) translateY(-10px); }
.home-cards img:nth-child(3) { transform: translateX(-50%) rotate(14deg); }

/* ---------- 提问与牌阵 ---------- */
#setup { padding: 70px 24px 60px; }
.setup-panel { max-width: 940px; margin: 0 auto; padding: 36px 44px 40px; }
.step + .step { margin-top: 34px; }
.step-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.step-head h2 { margin: 0; font-weight: 400; font-size: 19px; letter-spacing: 5px; }
.step-head .script { font-size: 28px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mode, .spread-opt {
  text-align: left; cursor: pointer; padding: 16px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .6);
  transition: border-color .3s, background .3s, box-shadow .3s;
}
.mode b, .spread-opt b { display: block; font-weight: 400; font-size: 16px; letter-spacing: 3px; }
.mode span, .spread-opt span { display: block; margin-top: 6px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.mode.on, .spread-opt.on { border-color: var(--rose); background: #fff; box-shadow: 0 6px 18px rgba(168, 116, 121, .14); }
.mode-extra { margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { cursor: pointer; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); font-size: 14px; letter-spacing: 2px; }
.chip.on { background: var(--rose); border-color: var(--rose); color: #fff; }
textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  font: inherit; font-size: 15px; line-height: 1.7; color: var(--ink); background: rgba(255, 255, 255, .8);
}
textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px rgba(201, 161, 165, .2); }
.spreads { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.spread-opt { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 10px; }
.spread-opt .mini { height: 74px; width: 100%; position: relative; margin-bottom: 12px; }
.spread-opt .mini i {
  position: absolute; width: 14px; height: 21px; border-radius: 2px;
  border: 1px solid var(--rose); background: #fff;
}
.spread-opt .count { margin-top: 4px; font-family: var(--latin); font-style: italic; color: var(--ink-soft); font-size: 13px; }
.toggle { display: flex; align-items: baseline; gap: 10px; margin-top: 18px; cursor: pointer; font-size: 15px; letter-spacing: 2px; }
.toggle input { accent-color: var(--rose); transform: translateY(2px); }
.toggle small { color: var(--ink-soft); font-size: 13px; letter-spacing: 0; }

/* ---------- 静心 ---------- */
#ritual { display: flex; align-items: center; justify-content: center; text-align: center; }
.breath { position: relative; width: 240px; height: 240px; margin: 0 auto 40px; }
.breath .core, .breath .ring { position: absolute; inset: 0; margin: auto; border-radius: 50%; }
.breath .core {
  width: 120px; height: 120px;
  background: radial-gradient(circle, #fff 0%, rgba(255, 240, 242, .9) 45%, rgba(233, 190, 198, .5) 100%);
  box-shadow: 0 0 60px rgba(233, 180, 192, .6);
  animation: breathe 8s ease-in-out infinite;
}
.breath .ring { border: 1px solid rgba(201, 161, 165, .55); animation: breathe-ring 8s ease-in-out infinite; }
.breath .ring.r2 { animation-delay: -.6s; opacity: .5; }
@keyframes breathe { 0%, 100% { transform: scale(.7); } 45%, 55% { transform: scale(1.45); } }
@keyframes breathe-ring { 0%, 100% { transform: scale(.55); opacity: .2; } 50% { transform: scale(1); opacity: .9; } }
.breath-text { font-size: 22px; letter-spacing: 10px; margin: 0 0 10px; transition: opacity .6s; }
.breath-sub { margin: 0 0 30px; color: var(--ink-soft); font-size: 14px; letter-spacing: 3px; }

/* ---------- 花瓣抽牌 ---------- */
#draw { overflow: hidden; height: 100vh; }
.draw-head { position: absolute; top: 6vh; left: 0; right: 0; text-align: center; z-index: 50; pointer-events: none; }
.count { margin-top: 12px; font-size: 13px; letter-spacing: 4px; color: var(--ink-soft); }
.petal-layer { position: absolute; inset: 0; z-index: 10; perspective: 900px; }
.petal { position: absolute; left: 0; top: 0; cursor: pointer; transform-style: preserve-3d; will-change: transform; padding: 6px; }
.petal img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(140, 95, 100, .22)); }
.petal.hover img { filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 18px rgba(233, 180, 192, .8)); }
#draw.full .petal { cursor: default; }
.tray { position: absolute; left: 0; right: 0; bottom: 3vh; z-index: 40; display: flex; justify-content: center; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.slot .hole {
  border-radius: 8px; border: 1px dashed rgba(201, 161, 165, .75);
  background: rgba(255, 255, 255, .4); backdrop-filter: blur(6px); position: relative;
}
.slot.filled .hole { border-color: transparent; background: none; backdrop-filter: none; }
.slot .label { font-size: 12px; letter-spacing: 3px; color: var(--ink-soft); text-align: center; }

/* ---------- 牌（翻面） ---------- */
.card { position: relative; perspective: 1000px; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.3, .7, .2, 1); }
.card.flipped .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0; border-radius: 8%/5.3%; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 26px rgba(150, 105, 110, .22); background: #f4eee6;
}
.card .face img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card .front { transform: rotateY(180deg); }
.card.reversed .front img { transform: rotate(180deg); }
.card.flying { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; }

/* ---------- 牌阵 ---------- */
#spread { padding: 64px 24px 80px; }
.spread-top { display: flex; justify-content: center; text-align: center; }
.spread-title h2 { margin: 8px 0 6px; font-weight: 400; font-size: 21px; letter-spacing: 8px; }
.board-wrap { display: flex; justify-content: center; margin-top: 26px; }
.board { position: relative; }
.board .pos { position: absolute; display: flex; flex-direction: column; align-items: center; }
.board .card { cursor: pointer; transition: transform .3s; }
.board .card:hover { transform: translateY(-4px); }
.board .pos-label { margin-top: 10px; text-align: center; font-size: 13px; letter-spacing: 3px; color: var(--ink-soft); white-space: nowrap; }
.board .pos-label b { display: block; font-weight: 400; color: var(--ink); font-size: 14px; margin-top: 4px; opacity: 0; transition: opacity .8s; }
.board .pos.open .pos-label b { opacity: 1; }
.board .pos.cross { z-index: 2; }
.board .num { display: none; }
.board.compact .pos-label { display: none; }
.board.compact .num {
  display: flex; align-items: center; justify-content: center; position: absolute; top: -9px; left: -9px; z-index: 3;
  width: 22px; height: 22px; border-radius: 50%; background: var(--rose); color: #fff; font-size: 12px; font-family: var(--latin);
  box-shadow: 0 2px 6px rgba(150, 105, 110, .3);
}
.board.compact .pos.cross .num { left: auto; right: -9px; top: auto; bottom: -9px; }
.board .pos.cross .pos-label { display: none; }
.board .pos.cross .card { transform: rotate(90deg); }
.legend {
  max-width: 760px; margin: 30px auto 0; padding: 18px 28px; columns: 2; column-gap: 40px;
  background: var(--glass); border-radius: 16px; font-size: 14px; line-height: 2.1; letter-spacing: 1px; list-style-position: inside;
}
.legend li { break-inside: avoid; }
.legend li b { font-weight: 400; }
.legend li span { color: var(--ink-soft); }

/* ---------- 解读 ---------- */
.reading-panel { max-width: 820px; margin: 40px auto 0; padding: 30px 46px 36px; }
.reading-head { text-align: center; }
.reading { font-size: 16px; line-height: 2; letter-spacing: .3px; }
.reading:empty { display: none; }
.reading h2 { font-weight: 400; font-size: 18px; letter-spacing: 4px; margin: 28px 0 8px; color: var(--rose-deep); }
.reading h3 { font-weight: 400; font-size: 16px; margin: 20px 0 6px; }
.reading p { margin: 0 0 12px; }
.reading strong { font-weight: 500; }
.reading ul, .reading ol { padding-left: 1.4em; margin: 0 0 12px; }
.reading blockquote {
  margin: 24px 0 8px; padding: 16px 22px; border-left: 0; border-radius: 14px; text-align: center;
  background: rgba(243, 223, 224, .45); font-size: 17px; letter-spacing: 2px;
}
.reading blockquote p { margin: 0; }
.reading .you { margin: 26px 0 10px; text-align: right; }
.reading .you span { display: inline-block; max-width: 80%; text-align: left; background: rgba(201, 161, 165, .18); padding: 10px 16px; border-radius: 14px 14px 4px 14px; }
.reading .thinking { color: var(--ink-soft); font-style: italic; font-family: var(--latin); font-size: 17px; text-align: center; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.reading .err { color: #b5545f; text-align: center; }
.followup { display: flex; gap: 12px; align-items: flex-end; margin-top: 24px; }
.followup textarea { flex: 1; }

/* ---------- 历史 ---------- */
#history { padding: 70px 24px 60px; }
.history-head { text-align: center; margin-bottom: 30px; }
.history-list { max-width: 860px; margin: 0 auto; display: grid; gap: 14px; }
.history-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; cursor: pointer; text-align: left;
  padding: 16px 22px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, .9); background: var(--glass);
  transition: box-shadow .3s;
}
.history-item:hover { box-shadow: 0 10px 28px rgba(150, 105, 110, .16); }
.history-item .thumbs { display: flex; }
.history-item .thumbs img { width: 42px; border-radius: 4px; margin-right: -14px; box-shadow: 0 3px 8px rgba(150, 105, 110, .25); }
.history-item .meta b { display: block; font-weight: 400; font-size: 15px; letter-spacing: 2px; }
.history-item .meta span { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.history-item .no { font-family: var(--latin); font-style: italic; color: var(--ink-soft); font-size: 15px; }
.history-empty { text-align: center; color: var(--ink-soft); padding: 40px 0; line-height: 2; }

/* ---------- 放大看牌 ---------- */
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(70, 48, 52, .55); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.modal-card { display: flex; gap: 34px; align-items: center; max-width: 860px; background: var(--bg); border-radius: 22px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); cursor: default; }
.modal-card img { width: 300px; border-radius: 12px; box-shadow: 0 12px 30px rgba(150, 105, 110, .25); }
.modal-card img.rev { transform: rotate(180deg); }
.modal-text { max-width: 380px; }
.modal-pos { font-size: 13px; letter-spacing: 3px; color: var(--ink-soft); }
.modal-text h3 { margin: 8px 0 2px; font-weight: 400; font-size: 26px; letter-spacing: 6px; }
.modal-en { font-family: var(--latin); font-style: italic; color: var(--ink-soft); font-size: 17px; }
.modal-kw { margin: 18px 0 8px; font-size: 15px; line-height: 1.9; }
.modal-other { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.8; }

@media (max-width: 760px) {
  .modes, .spreads { grid-template-columns: 1fr 1fr; }
  .setup-panel, .reading-panel { padding: 24px 20px; }
  .modal-card { flex-direction: column; }
  .modal-card img { width: 220px; }
  .legend { columns: 1; }
  .script.big { font-size: 52px; }
}

/* ---------- 中英切换 ---------- */
.lang-toggle {
  position: fixed; top: 16px; right: 18px; z-index: 95;
  display: flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--glass);
  cursor: pointer; font-family: var(--latin); font-size: 15px; color: var(--ink-soft);
  backdrop-filter: blur(6px);
}
.lang-toggle span { transition: color .2s; }
.lang-toggle span[data-lang="zh"] { font-family: "Noto Serif SC", serif; font-size: 13px; }
.lang-toggle span.on { color: var(--rose-deep); font-weight: 500; }
.lang-toggle i { font-style: normal; color: var(--line); }
.lang-toggle:hover { border-color: var(--rose); }

/* 英文：换成 Cormorant（字形比宋体小，字号放大一点），中文排版用的宽字距收窄 */
html:lang(en) { --serif: "Cormorant Garamond", "Noto Serif SC", serif; }
html:lang(en) body { font-weight: 500; }
html:lang(en) .title { letter-spacing: 2px; text-indent: 0; font-size: 30px; font-weight: 400; }
html:lang(en) .btn { letter-spacing: 1.5px; font-size: 17px; }
html:lang(en) .back-link { letter-spacing: .5px; font-size: 16px; }
html:lang(en) .step-head h2 { letter-spacing: .5px; font-size: 23px; }
html:lang(en) .mode b, html:lang(en) .spread-opt b { letter-spacing: .5px; font-size: 19px; }
html:lang(en) .mode span, html:lang(en) .spread-opt span { font-size: 15px; }
html:lang(en) .chip { letter-spacing: .5px; font-size: 16px; }
html:lang(en) .toggle { letter-spacing: .5px; font-size: 17px; }
html:lang(en) .toggle small { font-size: 15px; }
html:lang(en) .breath-text { letter-spacing: 2px; font-size: 26px; }
html:lang(en) .breath-sub { letter-spacing: .5px; font-size: 17px; }
html:lang(en) .count { letter-spacing: 1px; font-size: 15px; }
html:lang(en) .slot .label { letter-spacing: .5px; font-size: 14px; }
html:lang(en) .spread-title h2 { letter-spacing: 1.5px; font-size: 26px; }
html:lang(en) .board .pos-label { letter-spacing: .5px; font-size: 15px; }
html:lang(en) .legend { letter-spacing: 0; font-size: 16px; }
html:lang(en) .reading { font-size: 19px; line-height: 1.7; letter-spacing: 0; }
html:lang(en) .reading h2 { letter-spacing: 1px; font-size: 22px; }
html:lang(en) .reading blockquote { letter-spacing: 0; font-size: 20px; }
html:lang(en) .history-item .meta b { letter-spacing: .5px; font-size: 17px; }
html:lang(en) .modal-pos { letter-spacing: .5px; font-size: 15px; }
html:lang(en) .modal-text h3 { letter-spacing: 1px; font-size: 30px; }
html:lang(en) .modal-en { font-family: "Noto Serif SC", serif; font-style: normal; font-size: 14px; }
html:lang(en) textarea { font-size: 17px; }
html:lang(en) .toast { font-size: 15px; letter-spacing: 0; }
html:lang(en) .reading strong { font-weight: 600; }

/* ---------- 展示版 ---------- */
.demo-badge {
  display: inline-block; margin: 14px 0 0; padding: 5px 14px; border-radius: 999px;
  background: rgba(243, 223, 224, .6); color: var(--rose-deep); font-size: 13px; letter-spacing: 1px;
}
.demo-badge[hidden], .demo-note[hidden] { display: none; }
.demo-note { margin: 14px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.8; }
html:lang(en) .demo-badge { font-size: 15px; letter-spacing: .3px; }
html:lang(en) .demo-note { font-size: 16px; }
.toggle[hidden], .mode[hidden] { display: none; }
