:root {
  /* 默认值与默认主题（山海九尾）一致，避免主题加载前闪一下别的配色；实际配色由 theme.json 写入 */
  --bg: #080A0D; --bg2: #101216; --surface: rgba(244,235,217,0.06);
  --accent: #C94B3F; --accent2: #E1C080; --text: #F4EBD9; --muted: #9A958B; --glow: #BA9354;
  --font: 'Noto Serif SC', 'Songti SC', serif;
  --card-w: 96px; --card-h: 166px; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
#particles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.screen { animation: fade .35s ease; padding-top: env(safe-area-inset-top); }
@keyframes fade { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.topbar h1, .topbar h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 2px; }
.brand-glyph { color: var(--accent2); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn { background: var(--surface); border: 1px solid rgba(255,255,255,0.12); color: var(--text); width: 38px; height: 38px; border-radius: 12px; font-size: 18px; cursor: pointer; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: 3px; color: var(--accent2); text-transform: uppercase; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.fineprint { color: var(--muted); opacity: .7; font-size: 12px; margin-top: 28px; text-align: center; line-height: 1.6; }
.section-title { font-size: 14px; letter-spacing: 2px; color: var(--accent2); margin: 26px 0 10px; font-weight: 500; }
.btn {
  appearance: none; border: 1px solid rgba(255,255,255,0.18); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-family: inherit; font-size: 14px; cursor: pointer; transition: transform .15s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent, #2a1240); border: none; font-weight: 600; box-shadow: 0 6px 24px -6px var(--glow); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 18px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* 首页 */
.daily-panel { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 18px; margin-top: 6px; }
.daily-text { flex: 1; min-width: 0; }
.daily-text h2 { margin: 0 0 6px; font-size: 20px; }
.daily-card { width: var(--card-w); flex: none; }
.spread-list { display: grid; gap: 12px; }
.spread-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid rgba(255,255,255,0.1); border-radius: 18px; padding: 14px 16px; cursor: pointer; text-align: left; color: inherit; font-family: inherit; width: 100%; }
.spread-item:active { transform: scale(.985); }
.spread-item .glyph { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(0,0,0,0.25); color: var(--accent2); flex: none; }
.spread-item h4 { margin: 0 0 3px; font-size: 16px; }
.spread-item p { margin: 0; font-size: 13px; color: var(--muted); }
.spread-item .tag { margin-left: auto; font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.12); color: var(--accent2); flex: none; }

/* 提问 */
.positions { display: grid; gap: 8px; margin: 14px 0; }
.positions div { background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.positions b { color: var(--accent2); margin-right: 6px; }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field textarea, .field input, .field select { width: 100%; background: rgba(0,0,0,0.3); color: var(--text); border: 1px solid rgba(255,255,255,0.14); border-radius: 12px; padding: 12px; font-family: inherit; font-size: 15px; resize: vertical; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid rgba(255,255,255,0.18); background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 14px; font-family: inherit; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--accent); color: var(--on-accent, #2a1240); border-color: transparent; font-weight: 600; }

/* 卡牌 */
.card { width: var(--card-w); height: var(--card-h); perspective: 1200px; position: relative; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.card.flipped .card-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: var(--card-radius, 10px); overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 10px 30px -10px rgba(0,0,0,.7); background: #000; }
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.face.front { transform: rotateY(180deg); }
.face.front .frame { pointer-events: none; }
.face.front .art { transition: transform .6s ease .5s; }
.card.reversed .face.front .art { transform: rotate(180deg); }
.card.glow .face.front { box-shadow: 0 0 0 1px var(--accent2), 0 0 28px -4px var(--glow); }
.card-label { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-label b { color: var(--text); }
.card-label .num { font-style: normal; font-size: 10px; letter-spacing: .5px; color: var(--accent2); margin-right: 3px; }

/* 仪式 */
.ritual .ritual-hint { text-align: center; color: var(--muted); min-height: 24px; margin: 6px 0 10px; }
.table { position: relative; height: 62vh; min-height: 380px; border-radius: 24px; background: radial-gradient(60% 50% at 50% 55%, rgba(255,255,255,0.06), transparent); }
.deck-stack { position: absolute; left: 50%; top: 50%; width: var(--card-w); height: var(--card-h); transform: translate(-50%, -50%); }
.deck-stack .card { position: absolute; inset: 0; transition: transform .6s cubic-bezier(.3,.7,.2,1.2), opacity .4s; }
.deck-stack.shuffling .card { animation: shuffle 1.1s ease-in-out infinite; }
.deck-stack .card:nth-child(2n) { animation-delay: .15s; } .deck-stack .card:nth-child(3n) { animation-delay: .3s; }
@keyframes shuffle {
  0% { transform: translate(0,0) rotate(0); } 25% { transform: translate(-70px,-30px) rotate(-14deg); }
  50% { transform: translate(0,10px) rotate(4deg); } 75% { transform: translate(70px,-26px) rotate(12deg); } 100% { transform: translate(0,0) rotate(0); }
}
.layout { position: absolute; inset: 0; }
.slot { position: absolute; width: calc(var(--card-w) * var(--slot-scale, 1)); height: calc(var(--card-h) * var(--slot-scale, 1)); transform: translate(-50%, -50%); }
.slot .placeholder { position: absolute; inset: 0; border: 1px dashed rgba(255,255,255,0.25); border-radius: 10px; display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }
.slot .card { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; animation: land .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes land { from { transform: translate(var(--from-x), var(--from-y)) scale(.7) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.slot .tap-hint { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--accent2); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.ritual-actions { display: flex; justify-content: center; }
@media (max-width: 380px) { :root { --card-w: 80px; --card-h: 138px; } }

/* 解读 */
.reading-cards { display: flex; gap: 36px 20px; justify-content: center; flex-wrap: wrap; margin: 14px 0 34px; }
.reading-cards .card { cursor: default; }
.interpretation { background: var(--surface); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 20px; line-height: 1.9; font-size: 15px; white-space: pre-wrap; min-height: 120px; }
.interpretation.loading { display: grid; place-items: center; color: var(--muted); }
.interpretation .card-meanings { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed rgba(255,255,255,0.15); font-size: 13px; color: var(--muted); }
.interpretation .card-meanings b { color: var(--accent2); }
.source-tag { display: inline-block; margin-top: 12px; font-size: 11px; color: var(--muted); opacity: .7; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions-row .btn { flex: 1 1 45%; }

/* 记录 */
.history-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.history-item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 12px; cursor: pointer; color: inherit; font-family: inherit; text-align: left; width: 100%; }
.history-item .thumbs { display: flex; gap: 3px; flex: none; }
.history-item > div { flex: 1; min-width: 0; }
.history-item .thumbs img { width: 26px; height: 44px; object-fit: cover; border-radius: var(--card-radius, 4px); }
.history-item .thumbs img.rev { transform: rotate(180deg); }
.history-item h4 { margin: 0 0 2px; font-size: 14px; }
.history-item p { margin: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .del { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 设置 */
.theme-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-item { background: var(--surface); border: 2px solid transparent; border-radius: 14px; padding: 10px; cursor: pointer; text-align: center; color: inherit; font-family: inherit; }
.theme-item.active { border-color: var(--accent2); }
.theme-item img { width: 60px; height: 104px; object-fit: cover; border-radius: 6px; display: block; margin: 0 auto 6px; }
.theme-item span { font-size: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch input { accent-color: var(--accent); }
.form .row { display: flex; gap: 10px; }
code { font-family: monospace; font-size: 12px; opacity: .8; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 10; width: max-content; max-width: 90vw; }
