/* 揲蓍 · 深色墨色仪式感
   动效：150ms 微交互 / 200ms 默认 / 300ms 强调
   圆角：12 常规 / 18 卡片 / 999 胶囊
   分隔：1px 发丝线代灰底卡片
   正文不加粗
*/

:root {
  --ink: #14171a;
  --ink-1: #1b1f23;
  --ink-2: #232830;
  --paper: #efe9d8;
  --paper-2: rgba(239, 233, 208, 0.66);
  --paper-3: rgba(239, 233, 208, 0.42);
  --gold: #d8c381;
  --gold-dim: rgba(216, 195, 129, 0.28);
  --line: rgba(239, 233, 208, 0.14);
  --line-soft: rgba(239, 233, 208, 0.08);
  --stalk: #9a8f6a;
  --stalk-lit: #c9bf95;
  --stalk-dim: #57533f;
  --danger: #c9705f;

  --r-sm: 12px;
  --r-md: 18px;
  --r-full: 999px;
  --t-fast: 150ms;
  --t-base: 200ms;
  --t-slow: 300ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { overflow-x: hidden; }

button { font-family: inherit; }

::selection { background: var(--gold-dim); color: var(--paper); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(20px, 5vw, 48px);
  background: rgba(20, 23, 26, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.brand-name {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.14em;
  color: var(--paper);
}

.brand-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-3);
}

.nav { display: flex; gap: 4px; }

.nav-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--paper-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-btn:hover { background: rgba(239, 233, 208, 0.06); color: var(--paper); }
.nav-btn.is-active { background: rgba(239, 233, 208, 0.1); color: var(--paper); }

/* ---------- 视图容器 ---------- */
#main { max-width: 720px; margin: 0 auto; padding: 32px clamp(20px, 5vw, 32px) 120px; }

.view { animation: rise var(--t-slow) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.kicker {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-3);
}

/* ---------- 问事 ---------- */
.ask-wrap { padding-top: clamp(24px, 8vh, 72px); }

.ask-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 46px);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.ask-desc { margin: 0 0 28px; color: var(--paper-2); font-size: 14.5px; max-width: 44ch; }

.ask-input {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(239, 233, 208, 0.03);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.ask-input::placeholder { color: var(--paper-3); }
.ask-input:focus { border-color: var(--gold-dim); background: rgba(239, 233, 208, 0.05); }

.ask-meta { display: flex; justify-content: flex-end; margin: 8px 0 24px; }
.counter { font-size: 12px; color: var(--paper-3); font-variant-numeric: tabular-nums; }

.ask-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ask-foot { margin-top: 22px; font-size: 13px; color: var(--paper-3); max-width: 46ch; }

/* ---------- 按钮 ---------- */
.btn-primary {
  min-height: 44px;
  padding: 0 26px;
  border: 1px solid var(--gold-dim);
  border-radius: var(--r-full);
  background: rgba(216, 195, 129, 0.12);
  color: var(--gold);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--t-base) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-base) var(--ease);
}
.btn-primary:hover:not(:disabled) { background: rgba(216, 195, 129, 0.2); }
.btn-primary:active:not(:disabled) { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.34; cursor: not-allowed; }

.btn-ghost {
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--paper-2);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color var(--t-base) var(--ease), color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.btn-ghost:hover { border-color: rgba(239, 233, 208, 0.3); color: var(--paper); background: rgba(239, 233, 208, 0.04); }

.btn-quiet {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--paper-3);
  font-size: 14px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}
.btn-quiet:hover { color: var(--paper-2); }

/* ---------- 仪轨 ---------- */
.ritual-head { text-align: center; margin-bottom: 4px; }

.ritual-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--paper-3);
  font-variant-numeric: tabular-nums;
}
.ritual-progress .dot { opacity: 0.5; }
#r-line, #r-change { font-family: var(--serif); letter-spacing: 0.08em; }

.ritual-status {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: clamp(17px, 3.6vw, 21px);
  letter-spacing: 0.08em;
  color: var(--paper);
  min-height: 1.8em;
  transition: opacity var(--t-base) var(--ease);
}

.stage {
  position: relative;
  margin: 8px 0 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

#stalks-svg { width: 100%; height: auto; display: block; touch-action: none; }

.stalk { transition: transform var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease), fill var(--t-base) var(--ease); }
.stalk.is-spent { opacity: 0.18; }
.stalk.is-hidden { opacity: 0; }

.split-guide { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.85; }

.ritual-hint {
  min-height: 22px;
  margin-top: 6px;
  text-align: center;
  font-size: 13px;
  color: var(--paper-3);
  transition: opacity var(--t-base) var(--ease);
}

.ritual-foot { margin-top: 18px; }

.line-track {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  min-height: 34px;
}

.track-cell {
  width: 34px;
  height: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  opacity: 0.28;
  transition: opacity var(--t-slow) var(--ease);
}
.track-cell.is-done { opacity: 1; }
.track-cell.is-current { opacity: 0.6; }

.track-bar { height: 4px; border-radius: 2px; background: var(--paper); }
.track-bar.is-yin { background: transparent; box-shadow: none; }
.track-cell[data-kind="yin"] .track-bar { width: 40%; }
.track-cell[data-kind="yin"] .track-bar:last-child { margin-left: 60%; }
.track-cell[data-moving="1"] .track-bar { background: var(--gold); }

.ritual-buttons { display: flex; justify-content: center; gap: 10px; }

/* ---------- 结果 ---------- */
.result-card {
  padding: 30px clamp(20px, 5vw, 34px) 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(239, 233, 208, 0.045), rgba(239, 233, 208, 0.015));
}

.result-question {
  margin: 0 0 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--serif);
  font-size: 16px;
  color: var(--paper-2);
}

.hex-block { display: flex; align-items: flex-start; justify-content: center; gap: clamp(28px, 8vw, 60px); margin-bottom: 26px; }

.hex-unit { text-align: center; }

.hex-label { font-size: 11.5px; letter-spacing: 0.14em; color: var(--paper-3); margin-bottom: 10px; }

.hex-svg { width: 108px; height: auto; display: block; }

.hex-name {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: 0.1em;
  color: var(--paper);
}

.hex-symbol { font-family: var(--serif); font-size: 13px; color: var(--paper-3); letter-spacing: 0.1em; }

.arrow { align-self: center; color: var(--gold); font-size: 18px; opacity: 0.7; }

.text-block { margin-bottom: 22px; }
.text-label {
  margin: 0 0 6px;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--paper-3);
}
.text-body {
  margin: 0;
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.9;
  color: var(--paper);
}
.text-body.sub { color: var(--paper-2); font-size: 15.5px; }

.moving-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line-soft); }

.moving-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.moving-item:last-child { border-bottom: 0; }

.moving-name {
  flex: 0 0 auto;
  min-width: 4.4em;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.moving-text { margin: 0; font-family: var(--serif); font-size: 15.5px; line-height: 1.85; color: var(--paper-2); }

.moving-item.is-main .moving-text { color: var(--paper); }
.moving-item.is-main .moving-name::after {
  content: '主';
  display: inline-block;
  margin-left: 7px;
  padding: 0 6px;
  border: 1px solid var(--gold-dim);
  border-radius: var(--r-full);
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--gold);
  vertical-align: 1px;
}

/* ---------- 断 ---------- */
.judge-block {
  margin: 0 0 26px;
  padding: 22px 22px 18px;
  border: 1px solid var(--gold-dim);
  border-radius: var(--r-sm);
  background: rgba(216, 195, 129, 0.06);
}
.judge-item { margin-bottom: 16px; }
.judge-item:last-of-type { margin-bottom: 14px; }
.judge-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.judge-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.85;
  color: var(--paper);
}
.judge-rule {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid rgba(216, 195, 129, 0.18);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--paper-3);
}
.judge-bai {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed rgba(216, 195, 129, 0.16);
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--paper-2);
}

/* ---------- 卦义 ---------- */
.sense-block { margin: 0 0 26px; }
.sense-item { margin-bottom: 16px; }
.sense-item:last-child { margin-bottom: 0; }
.sense-name {
  display: block;
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--paper-3);
}
.sense-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--paper);
}

/* ---------- 解（模型嫁接，可选能力） ---------- */
.interpret-slot { margin: 0 0 26px; }
.interpret-hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--paper-3);
}
.interpret-box {
  margin: 18px 0 0;
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(239, 233, 208, 0.03);
}
.interpret-lines { display: flex; flex-direction: column; gap: 10px; }
.interpret-line {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--paper);
}
.interpret-fallback { margin: 0; font-size: 13.5px; line-height: 1.8; color: var(--paper-3); }
.interpret-foot {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--paper-3);
}

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }

.note-box { margin-top: 30px; }
.note-field { margin-bottom: 18px; }
.note-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(239, 233, 208, 0.03);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: border-color var(--t-base) var(--ease);
}
.note-input:focus { border-color: var(--gold-dim); }
.note-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.note-hint { font-size: 12.5px; color: var(--paper-3); }

/* ---------- 卦历 ---------- */
.history-head { margin-bottom: 22px; }
.page-title { margin: 0 0 6px; font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: 0.08em; }
.page-desc { margin: 0; font-size: 13.5px; color: var(--paper-3); }

.history-list { display: flex; flex-direction: column; gap: 12px; }

.record {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(239, 233, 208, 0.025);
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.record:hover { border-color: rgba(239, 233, 208, 0.26); background: rgba(239, 233, 208, 0.045); }

.record-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.record-gua { font-family: var(--serif); font-size: 20px; letter-spacing: 0.1em; }
.record-gua em { font-style: normal; font-size: 13px; color: var(--paper-3); margin-left: 8px; letter-spacing: 0.06em; }
.record-time { font-size: 12px; color: var(--paper-3); font-variant-numeric: tabular-nums; }

.record-question {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--paper-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.record-note {
  margin: 10px 0 0;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--paper-3);
  line-height: 1.7;
}

.record-actions { display: flex; gap: 6px; margin-top: 14px; }
.record-btn {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--paper-3);
  font-size: 12.5px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.record-btn:hover { color: var(--paper); border-color: var(--line); }
.record-btn.is-on { color: var(--gold); border-color: var(--gold-dim); }
.record-btn.danger:hover { color: var(--danger); border-color: rgba(201, 112, 95, 0.4); }

.empty { text-align: center; padding: 60px 0; color: var(--paper-3); }
.empty p { margin: 0 0 18px; }

/* ---------- 动效补充 ---------- */
.fade-swap { opacity: 0; }

@media (max-width: 760px) {
  .hex-block { gap: 20px; }
  .hex-svg { width: 88px; }
  .hex-name { font-size: 22px; }
  .result-card { padding: 24px 18px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---------- 顶栏登录入口 ---------- */
.auth-entry {
  min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-full);
  background: transparent; color: var(--paper-3); font: inherit; font-size: 13px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.auth-entry:hover { color: var(--paper-2); border-color: var(--line); }
.auth-entry.is-on { color: var(--gold); border-color: var(--gold-dim); }
.auth-quit {
  min-height: 32px; padding: 0 6px; border: 0; background: transparent;
  color: var(--paper-3); font: inherit; font-size: 12px; cursor: pointer;
}
.auth-quit:hover { color: var(--danger); }

/* ---------- 登录框 ---------- */
.auth-dialog {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(10, 12, 14, .72);
}
.auth-dialog[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 380px; padding: 28px 26px 22px;
  background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--r-md);
}
.auth-title { margin: 0 0 6px; font-family: var(--serif); font-size: 22px; color: var(--paper); letter-spacing: .06em; }
.auth-desc { margin: 0 0 20px; font-size: 13px; color: var(--paper-3); line-height: 1.7; }
.auth-input {
  width: 100%; min-height: 44px; padding: 0 14px; margin-bottom: 10px;
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--paper); font: inherit; font-size: 14px;
  transition: border-color var(--t-fast) var(--ease);
}
.auth-input:focus { outline: none; border-color: var(--gold-dim); }
.auth-row { display: flex; gap: 10px; }
.auth-row .auth-input { flex: 1; margin-bottom: 10px; }
.auth-row .btn-ghost { flex: none; min-height: 44px; white-space: nowrap; }
.auth-card .btn-primary { width: 100%; margin-top: 4px; }
.auth-msg { min-height: 20px; margin: 12px 0 0; font-size: 13px; color: var(--danger); }
.auth-msg.is-ok { color: var(--gold); }
.auth-close {
  display: block; margin: 8px auto 0; padding: 6px 2px; border: 0; background: transparent;
  color: var(--paper-3); font: inherit; font-size: 13px; cursor: pointer;
}
.auth-close:hover { color: var(--paper-2); }

/* ---------- 结果页锁定区 ---------- */
.lock-block { padding-top: 8px; }
.unlock-list { margin: 0 0 20px; padding: 0; list-style: none; }
.unlock-list li {
  position: relative; padding: 7px 0 7px 18px; font-size: 14px; color: var(--paper-2);
  border-bottom: 1px solid var(--line-soft);
}
.unlock-list li:last-child { border-bottom: none; }
.unlock-list li::before {
  content: ''; position: absolute; left: 2px; top: 17px;
  width: 4px; height: 4px; border-radius: 999px; background: var(--gold-dim);
}
.lock-hint { margin: 12px 0 0; font-size: 12.5px; color: var(--paper-3); }

/* ---------- 三档 ---------- */
.tier-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.tier-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 8px; background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--paper); font: inherit; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tier-btn:hover { border-color: var(--gold-dim); background: var(--ink-2); }
.tier-btn small { font-size: 11.5px; color: var(--paper-3); }
.tier-btn.is-on { border-color: var(--gold); }
.redeem-row { display: flex; gap: 10px; }
.redeem-input {
  flex: 1; min-height: 42px; padding: 0 14px; background: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--paper); font: inherit; font-size: 14px; letter-spacing: .04em;
}
.redeem-input:focus { outline: none; border-color: var(--gold-dim); }

@media (max-width: 520px) {
  .tier-row { grid-template-columns: 1fr; }
  .auth-row { flex-direction: column; }
}
