:root {
  /* ===== 简约水墨纸本主题 ===== */
  --ink: #1a2a36;
  --ink-soft: #344e5e;
  --paper: rgba(253, 250, 242, 0.82);
  --paper-strong: rgba(250, 245, 232, 0.95);
  --paper-light: rgba(255, 253, 245, 0.6);
  --line: rgba(26, 42, 54, 0.3);
  --cinnabar: #c8382e;
  --cinnabar-soft: rgba(200, 56, 46, 0.6);
  --gold: #b8893a;
  --gold-soft: rgba(184, 137, 58, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "FangSong", "仿宋", "STFangsong", "Source Han Serif SC", "Noto Serif SC", "Palatino Linotype", "Georgia", serif;
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(10, 20, 30, 0.30) 100%),
    url("./background.jpg") center / cover no-repeat fixed,
    #d8dfd6;
  min-height: 100vh;
}

/* ===== 中英文分语言字体 ===== */
html.font-zh body,
html.font-zh button,
html.font-zh textarea,
html.font-zh .classic-quote {
  font-family: "FangSong", "仿宋", "STFangsong", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
}

html.font-en body,
html.font-en button,
html.font-en textarea,
html.font-en .classic-quote {
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden auto;
}

.ink-wash {
  display: none;
}

.water-rings {
  display: none;
}

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 72px clamp(18px, 4vw, 70px) 42px;
  /* 顶部半透米白纸垫——保证标题区文字可读性，不盖山水背景 */
  background: linear-gradient(
    rgba(253, 250, 242, 0.55),
    rgba(253, 250, 242, 0.25) 35%,
    transparent 70%
  );
}

.top-actions {
  position: absolute;
  top: 14px;
  right: clamp(18px, 4vw, 70px);
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  min-height: 28px;
}

.ghost-action {
  font-size: 15px;
}

.ghost-action,
.process-toggle,
.process-title button {
  border: 0;
  background: transparent;
  color: var(--ink);
}

.ghost-action {
  font-size: 15px;
}

.brand {
  text-align: center;
  margin-top: 8px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(46px, 6vw, 78px);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  text-shadow: 0 0 1px rgba(253, 250, 242, 0.9);
}

.subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 14px;
  font-size: 15px;
  color: var(--ink);
  text-shadow: 0 0 1px rgba(253, 250, 242, 0.85);
}

.subtitle span {
  width: min(120px, 20vw);
  height: 1px;
  background: rgba(18, 46, 57, 0.45);
}

.side-poem {
  position: absolute;
  top: 180px;
  display: grid;
  gap: 8px;
  writing-mode: vertical-rl;
  color: #ffffff;
  font-size: 15px;
}

.left-poem {
  left: 5vw;
}

.right-poem {
  right: 6vw;
}

/* 英文模式：侧诗改横排正常可读 */
html.font-en .side-poem {
  display: none;
}

/* 英文全局舒适化 */
html.font-en .reading-panel {
  padding: 28px 30px 30px;
}
html.font-en .reading-head {
  margin-bottom: 20px;
  gap: 22px;
}
html.font-en .reading-grid {
  gap: 18px;
}
html.font-en .reading-grid article {
  padding: 18px 18px 16px;
}
html.font-en .reading-grid p,
html.font-en .reading-summary {
  line-height: 1.85;
  font-size: 14px;
}
html.font-en .reading-body {
  font-size: 14px !important;
  line-height: 1.85;
}
html.font-en .classic-quote {
  font-size: 12.5px !important;
  letter-spacing: 1px;
}
html.font-en .reading-category {
  margin-top: 14px;
  padding-top: 12px;
}
html.font-en .hex-card {
  padding: 16px 16px 18px;
}
html.font-en .talisman-card {
  padding: 22px 22px 24px;
}
html.font-en .question-area {
  margin-top: 38px;
}

.question-area {
  width: min(760px, 88vw);
  margin: 30px auto 0;
  text-align: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.casting .question-area {
  opacity: 0.28;
  transform: translateY(-8px);
}

.omen {
  margin: 0;
  font-size: clamp(21px, 2.5vw, 32px);
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 1px rgba(253, 250, 242, 0.85);
}

.hint {
  margin: 10px 0 22px;
  font-size: 16px;
  color: var(--ink);
}

.support {
  color: #ffffff;
}

.input-wrap {
  display: block;
  position: relative;
  padding: 12px 78px 12px 18px;
  background: var(--paper);
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.35), 0 16px 34px rgba(0, 0, 0, 0.45);
}

textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 23px;
  line-height: 1.5;
}

textarea::placeholder {
  color: rgba(26, 42, 54, 0.35);
}

#charCount {
  position: absolute;
  top: 22px;
  right: 18px;
  font-size: 14px;
  color: rgba(18, 45, 58, 0.72);
}

.support {
  margin: 8px 0 28px;
  text-align: left;
  font-size: 15px;
}

/* 起卦按钮——暗赭石 + 米白字 + 细米白描边 + 隶书 */
.seal-button.cast-seal {
  min-width: 178px;
  height: 52px;
  padding: 0 24px;
  border: 1px solid rgba(253, 250, 242, 0.75);
  color: rgba(253, 250, 242, 0.95);
  background: #8b3a2e;
  font-family: "LiSu", "隶书", "STLiti", "华文隶书", "FangSong", "仿宋", Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 10px;
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 3px 10px rgba(50, 20, 15, 0.30);
  transition: all 0.2s ease;
}

.seal-button.cast-seal:hover:not(:disabled) {
  background: #a04537;
  box-shadow: 0 5px 16px rgba(50, 20, 15, 0.40);
  transform: translateY(-1px);
}

/* 登录/注册——普通按钮样式，避免被印章类影响 */
.seal-button:not(.cast-seal) {
  min-width: 140px;
  height: 44px;
  border: 1px solid var(--cinnabar-soft);
  color: var(--cinnabar);
  background: rgba(248, 242, 228, 0.98);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 8px;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.2s ease;
}

.seal-button:not(.cast-seal):hover:not(:disabled) {
  background: rgba(200, 56, 46, 0.06);
  box-shadow: none;
}

.seal-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.error {
  min-height: 26px;
  color: #8e2320;
  font-size: 16px;
}

/* ===== 悬浮 toast ===== */
#toastStack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  padding: 12px 18px 12px 40px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(40, 25, 10, 0.92);
  background: rgba(253, 250, 242, 0.98);
  border: 1px solid rgba(180, 138, 62, 0.45);
  box-shadow: 0 6px 24px rgba(70, 45, 18, 0.18);
  position: relative;
  animation: toastIn 0.25s ease-out;
  backdrop-filter: blur(4px);
}
.toast::before {
  position: absolute;
  left: 14px;
  top: 12px;
  font-size: 18px;
  line-height: 1;
}
.toast.error {
  background: #fdf2f1;
  border-color: rgba(142, 35, 32, 0.45);
  color: #7a1d1a;
}
.toast.error::before { content: "⚠️"; }
.toast.success {
  background: #f1f8f2;
  border-color: rgba(46, 125, 50, 0.45);
  color: #1f5a23;
}
.toast.success::before { content: "✓"; color: #2e7d32; font-weight: 700; }
.toast.info {
  background: #f1f6fb;
  border-color: rgba(25, 118, 210, 0.4);
  color: #154873;
}
.toast.info::before { content: "ℹ"; }
.toast.out {
  animation: toastOut 0.25s ease-in forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

.casting .water-rings {
  animation: castRipple 2.7s ease-out forwards;
}

.result-panel,
.process-panel {
  width: min(1260px, 92vw);
  margin: 28px auto 0;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(7, 39, 54, 0.16);
  backdrop-filter: blur(8px);
}

.result-panel {
  padding: 20px 24px 18px;
  animation: inkIn 0.7s ease both;
}

.result-title {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px 16px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 21px;
  font-weight: 700;
}

.result-title-icon {
  display: inline-flex;
  align-items: center;
  color: rgb(22, 55, 68);
}

.result-title-icon svg {
  filter: drop-shadow(0 2px 4px rgba(22, 55, 68, 0.12));
}

.result-title i {
  height: 1px;
  background: rgba(22, 55, 68, 0.18);
}

/* ===== SVG 图标通用 ===== */
.ic {
  display: inline-block;
  vertical-align: middle;
}

/* hex-card 里的标签前图标 */
.hex-card-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  color: rgb(22, 55, 68);
  opacity: 0.8;
}

/* reading-grid article 的标题前图标 */
.reading-article-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  color: rgb(173, 51, 47);
  opacity: 0.82;
  vertical-align: middle;
}

.hexagram-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.hex-card {
  min-height: 184px;
  padding: 22px 18px;
  text-align: center;
  background: var(--paper);
}

.hex-card.primary {
  background: var(--paper-strong);
}

.hex-label {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  font-size: 20px;
  font-weight: 700;
}

.plain-hint {
  display: block;
  color: rgba(18, 45, 58, 0.58);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.process-step h3 + .plain-hint {
  margin-bottom: 6px;
  color: rgba(18, 45, 58, 0.55);
}

.reading-grid article b + .plain-hint {
  display: block;
  margin-bottom: 4px;
}

.hex-lines {
  display: grid;
  gap: 7px;
  width: 92px;
  margin: 0 auto 14px;
}

.line {
  position: relative;
  height: 8px;
}

.line.yang {
  background: var(--ink);
}

.line.yin::before,
.line.yin::after {
  content: "";
  position: absolute;
  top: 0;
  width: 42%;
  height: 8px;
  background: var(--ink);
}

.line.yin::before {
  left: 0;
}

.line.yin::after {
  right: 0;
}

.line.moving::after {
  box-shadow: 24px 0 0 -2px var(--cinnabar);
}

.line.yang.moving::before {
  content: "朱";
  position: absolute;
  right: -34px;
  top: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--cinnabar);
  border: 1px solid var(--cinnabar-soft);
  font-size: 12px;
  line-height: 20px;
}

.hex-name {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
}

.hex-meta {
  margin: 7px 0 10px;
  font-size: 14px;
  color: rgba(20, 47, 59, 0.76);
}

.hex-judgement {
  margin: 0;
  font-size: 15px;
  color: rgba(18, 45, 58, 0.8);
}

.reading-panel {
  grid-column: 1 / -1;
  padding: 20px 22px 22px;
  background: var(--paper);
  border-top: 1px solid rgba(22, 55, 68, 0.1);
}

.reading-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.reading-head span {
  font-size: 21px;
  font-weight: 700;
}

.reading-head small {
  color: rgba(20, 47, 59, 0.64);
  font-size: 13px;
}

.reading-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.reading-grid article {
  padding: 14px 14px 12px;
  background: var(--paper);
  border-left: 2px solid rgba(173, 51, 47, 0.28);
}

.reading-grid b {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.reading-grid p,
.reading-summary {
  margin: 0;
  color: rgba(18, 45, 58, 0.78);
  font-size: 15px;
  line-height: 1.72;
}

/* ====== 丰富版解读卡片样式 ====== */
/* 卦辞原文 —— 古文小字体，居中带引号感 */
.classic-quote {
  font-family: "FangSong", "仿宋", "STFangsong", Georgia, serif;
  font-size: 13.5px !important;
  color: var(--cinnabar) !important;
  text-align: center;
  margin: 8px 0 6px !important;
  padding: 5px 0;
  border-top: 1px dashed var(--cinnabar-soft);
  border-bottom: 1px dashed var(--cinnabar-soft);
  letter-spacing: 1.5px;
}

/* 象传白话 —— 灰色小字，区别于主解读 */
.xiang-quote {
  font-size: 12.5px !important;
  color: rgba(18, 45, 58, 0.55) !important;
  margin: 6px 0 6px !important;
  font-style: italic;
}

/* 主解读正文 */
.reading-body {
  font-size: 14.5px !important;
  color: rgba(18, 45, 58, 0.82) !important;
}

.reading-body .tendency {
  display: block;
  margin-top: 4px;
  color: var(--cinnabar);
  font-weight: 600;
}

.reading-body .advice {
  display: block;
  margin-top: 2px;
}

/* 分类建议折叠块 */
.reading-category {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(31, 67, 75, 0.2);
}

.reading-category summary {
  cursor: pointer;
  font-size: 12.5px;
  color: rgba(31, 67, 75, 0.7);
  user-select: none;
  padding: 2px 0;
  list-style: none;
}

.reading-category summary::-webkit-details-marker { display: none; }

.reading-category[open] summary {
  color: rgb(173, 51, 47);
}

.cat-grid {
  margin-top: 8px;
  display: grid;
  gap: 5px;
}

.cat-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.55;
}

.cat-row b {
  flex: 0 0 44px;
  font-size: 13px;
  color: var(--cinnabar);
  margin: 0;
  font-weight: 600;
}

.cat-row span {
  flex: 1;
  color: rgba(18, 45, 58, 0.72);
}

.reading-summary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(22, 55, 68, 0.12);
}

/* ===== 分类分析专栏（从卦意解读拆出） ===== */
.category-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(22, 55, 68, 0.12);
}
.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.category-head span {
  font-size: 17px;
  font-weight: 700;
  color: var(--cinnabar);
  letter-spacing: 1px;
}
.category-head small {
  font-size: 12px;
  color: rgba(18, 45, 58, 0.45);
}
/* 强制单列：一排放一个分类卡片，绝不双列 */
.category-grid {
  display: grid;
  grid-template-columns: 1fr !important;
  gap: 14px;
}
.cat-card {
  padding: 18px 22px;
  background: rgba(255, 251, 243, 0.7);
  border: 1px solid rgba(139, 58, 46, 0.15);
  border-left: 3px solid var(--cinnabar-soft);
  border-radius: 10px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.cat-card:hover {
  box-shadow: 0 2px 10px rgba(139, 58, 46, 0.12);
  transform: translateY(-1px);
}
.cat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.cat-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--cinnabar);
  opacity: 0.75;
}
.cat-card-head b {
  font-size: 14.5px;
  color: var(--cinnabar);
  font-weight: 600;
}
.cat-card-body {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.9;
  color: rgba(18, 45, 58, 0.85);
  text-align: justify;
}

/* === 分类卡片底部迷你法器推荐 === */
.cat-talisman {
  margin-top: 14px;
  padding: 12px 14px;
  border-top: 1px dashed rgba(139, 58, 46, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(253, 250, 242, 0.5);
  border-radius: 6px;
}
.cat-talisman-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(139, 58, 46, 0.15);
  background: #f5eee0;
  display: block;
}
.cat-talisman-svg {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 5px;
  background: #f5eee0;
  border: 1px solid rgba(139, 58, 46, 0.15);
}
.cat-talisman-img-placeholder {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5eee0, #e8dfc8);
  color: #8b3a2e;
  font-size: 18px;
  border: 1px solid rgba(139, 58, 46, 0.15);
}
.cat-talisman-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cat-talisman-info {
  display: flex;
  align-items: baseline;
  gap: 4px 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.cat-talisman-info b {
  font-size: 13.5px;
  color: #7a5a28;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.cat-talisman-info small {
  color: rgba(90, 63, 26, 0.6);
  font-size: 12px;
}
.cat-talisman-reason {
  font-size: 12.5px;
  color: rgba(90, 63, 26, 0.7);
  font-style: italic;
  line-height: 1.5;
}
.cat-talisman-buy {
  align-self: flex-start;
  padding: 3px 12px;
  font-size: 11.5px;
  font-family: inherit;
  background: #8b3a2e;
  color: rgba(253, 250, 242, 0.95);
  border: 1px solid rgba(253, 250, 242, 0.7);
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 3px;
  transition: all 0.12s;
}
.cat-talisman-buy:hover:not(:disabled) {
  background: #a04537;
  transform: translateY(-1px);
}
.cat-talisman-buy:disabled { opacity: 0.55; cursor: wait; }

/* 手机窄屏：分类卡片单列 */
@media (max-width: 480px) {
  .category-grid { grid-template-columns: 1fr; }
}

/* ===== 护佑法器 ===== */
.talisman-card {
  grid-column: 1 / -1;
  margin-top: 22px;
  padding: 18px 22px 20px;
  background: linear-gradient(135deg, var(--gold-soft) 0%, var(--gold-soft) 100%);
  border: 1px solid var(--gold);
  border-radius: 10px;
}

.talisman-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px dashed var(--gold-soft);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.talisman-head span {
  font-size: 19px;
  font-weight: 700;
  color: #7a5a28;
  letter-spacing: 1px;
}

.talisman-head small {
  color: var(--gold);
  font-size: 13px;
}

.talisman-body {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 12px 20px;
}

.talisman-body > .talisman-icon {
  grid-row: 1;
  grid-column: 1;
}
.talisman-body > .talisman-info {
  grid-row: 1;
  grid-column: 2;
}
.talisman-body > .talisman-reason {
  grid-row: 2;
  grid-column: 1 / -1;
}
.talisman-body > .talisman-actions {
  grid-row: 3;
  grid-column: 1 / -1;
}

.talisman-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #b48a3e;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 50%;
  overflow: hidden;
}
.talisman-icon.talisman-img-wrap {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  padding: 0;
  cursor: zoom-in;
  border: 1px solid var(--gold);
  box-shadow: 0 2px 12px rgba(120, 80, 20, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
}
.talisman-icon.talisman-img-wrap:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 18px rgba(120, 80, 20, 0.25);
}
.talisman-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.talisman-info {
  min-width: 0;
}

.talisman-info b {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: #5a3f1a;
  margin-bottom: 4px;
}

.talisman-info small {
  color: rgba(90, 63, 26, 0.65);
  font-size: 13px;
}

.talisman-reason {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gold-soft);
  color: rgba(70, 45, 18, 0.82);
  font-size: 14.5px;
  line-height: 1.85;
  font-style: italic;
}

.talisman-price {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: rgba(70, 45, 18, 0.78);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.talisman-desc {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(70, 45, 18, 0.62);
}

.talisman-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.cat-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(139, 58, 46, 0.12);
  color: rgba(139, 58, 46, 0.85);
  line-height: 18px;
}

.talisman-buy {
  grid-column: 1 / -1;
  align-self: center;
  padding: 10px 28px;
  background: #8b3a2e;
  color: rgba(253, 250, 242, 0.95);
  border: 1px solid rgba(253, 250, 242, 0.85);
  border-radius: 4px;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(50, 20, 15, 0.22);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.talisman-buy:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(50, 20, 15, 0.32);
}
.talisman-buy:active:not(:disabled) { transform: translateY(0); }
.talisman-buy:disabled { opacity: 0.6; cursor: not-allowed; }

.talisman-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
}
.talisman-manage {
  padding: 10px 22px;
  background: rgba(253, 250, 242, 0.72);
  color: #8b3a2e;
  border: 1px solid #8b3a2e;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.15s;
}
.talisman-manage:hover:not(:disabled) {
  background: rgba(139, 58, 46, 0.12);
}
.talisman-manage:disabled { opacity: 0.6; cursor: not-allowed; }

/* 五行颜色映射（可选增强） */
.talisman-card[data-element="金"] .talisman-icon { color: #c0c0c0; background: rgba(192,192,192,0.15); border-color: rgba(192,192,192,0.4); }
.talisman-card[data-element="木"] .talisman-icon { color: #4a9e5c; background: rgba(74,158,92,0.12); border-color: rgba(74,158,92,0.4); }
.talisman-card[data-element="水"] .talisman-icon { color: #3a6a8c; background: rgba(58,106,140,0.12); border-color: rgba(58,106,140,0.4); }
.talisman-card[data-element="火"] .talisman-icon { color: #c0504d; background: rgba(192,80,77,0.12); border-color: rgba(192,80,77,0.4); }
.talisman-card[data-element="土"] .talisman-icon { color: #a87c3f; background: rgba(168,124,63,0.15); border-color: rgba(168,124,63,0.4); }

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.process-toggle {
  display: block;
  margin: 14px 0 -4px;
  padding: 8px 24px;
  border-radius: 999px;
  background: var(--paper-strong);
  box-shadow: 0 8px 18px rgba(12, 44, 58, 0.14);
}

.process-panel {
  padding: 20px;
  margin-top: 26px;
  animation: inkIn 0.5s ease both;
}

.process-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 21px;
  font-weight: 700;
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.process-step {
  padding: 16px;
  background: var(--paper);
}

.step-index {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink);
  font-size: 14px;
}

.process-step h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.process-step p {
  margin: 7px 0;
  font-size: 14px;
  line-height: 1.55;
}

.fallback-stroke small {
  color: var(--cinnabar);
}

.note {
  margin: 18px 0 0;
  font-size: 14px;
  color: rgba(20, 47, 59, 0.72);
}

dialog {
  width: min(520px, 92vw);
  border: 1px solid rgba(31, 67, 75, 0.16);
  padding: 0;
  color: var(--ink);
  background: var(--paper-strong);
  backdrop-filter: blur(8px);
}

dialog form {
  padding: 28px;
}

.dialog-close {
  float: right;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}

@keyframes waterBreath {
  from { transform: scale(1); opacity: 0.55; }
  to { transform: scale(1.05); opacity: 0.82; }
}

@keyframes castRipple {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(1.25); opacity: 0.95; }
}

@keyframes inkIn {
  from { opacity: 0; transform: translateY(14px); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@media (max-width: 980px) {
  .side-poem {
    display: none;
  }

  .hexagram-grid,
  .reading-grid,
  .process-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 18px 14px 34px;
  }

  .top-actions {
    justify-content: center;
    gap: 18px;
  }

  .brand h1 {
    font-size: 42px;
  }

  .subtitle {
    gap: 12px;
    font-size: 14px;
  }

  .question-area {
    width: 94vw;
    margin-top: 32px;
  }

  textarea {
    font-size: 20px;
  }

  .seal-button {
    min-width: 158px;
    height: 54px;
    font-size: 24px;
  }

  .reading-head {
    display: block;
  }

  .reading-head small {
    display: block;
    margin-top: 8px;
  }
}

/* ============ 手机窄屏（≤480px）专项 ============
 * 解决：顶部导航按钮挤爆、英文长单词溢出、卡片高度固定导致文字重叠
 */
@media (max-width: 480px) {
  /* 1. 顶部按钮从 absolute 定位 → 改回文档流顶部，不再悬浮压标题 */
  .top-actions {
    position: static;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 14px;
    padding: 10px 14px 4px;
    min-height: unset;
  }

  .user-area {
    margin-left: 0;
  }

  .hero {
    padding-top: 8px; /* top-actions 已在文档流，hero 不用再留绝对定位空间 */
  }

  /* 2. 卦象卡片高度自适应，不再强制 min-height 撑住 */
  .hex-card {
    min-height: unset;
    padding: 16px 14px;
  }

  .hex-lines {
    width: 76px;
    gap: 5px;
    margin-bottom: 10px;
  }

  .hex-name {
    font-size: 20px;
  }

  .hex-meta,
  .hex-judgement {
    font-size: 12.5px;
    line-height: 1.5;
  }

  /* 3. 所有 p / span / div 加 word-break —— 英文长单词、中文长 URL 不再撑破卡片 */
  .reading-panel article,
  .talisman-card,
  .hex-card,
  .process-step {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .reading-panel article p,
  .reading-summary,
  .talisman-desc,
  .talisman-reason {
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.65;
  }

  /* 4. 分类建议（By context）label + 内容改为上下堆叠，防止左右挤压 */
  .cat-row {
    flex-direction: column;
    gap: 2px;
  }

  .cat-row b {
    font-size: 12px;
    opacity: 0.75;
  }

  /* 5. 法器卡片 grid 改为单列堆叠 */
  .talisman-body {
    grid-template-columns: 1fr;
  }

  .talisman-body > .talisman-icon {
    grid-row: 1;
    grid-column: 1;
    margin: 0 auto;
  }
  .talisman-body > .talisman-info {
    grid-row: 2;
    grid-column: 1;
    text-align: center;
  }
  .talisman-body > .talisman-reason {
    grid-row: 3;
    grid-column: 1;
  }
  .talisman-body > .talisman-actions {
    grid-row: 4;
    grid-column: 1;
    text-align: center;
  }

  /* 6. 输入框 + CAST 按钮在超窄屏下也留够空间 */
  .input-wrap {
    padding-right: 12px;
    padding-bottom: 12px;
  }

  textarea {
    font-size: 16px; /* iOS Safari 输入框 ≥16px 才不会自动缩放页面 */
  }

  /* 7. account-layout 账户布局在手机上也切单列 */
  .account-layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }
}

/* ============ 用户区 ============ */
.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-area .user-name {
  font-size: 13px;
  color: var(--ink);
  opacity: 0.7;
}

/* ===== 账户下拉菜单 ===== */
.user-wrap { position: relative; display: inline-block; }

.user-toggle {
  background: none; border: none; cursor: pointer;
  padding: 6px 10px; border-radius: 4px;
  font-family: inherit; font-size: 13px;
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.12s;
}
.user-toggle:hover { background: rgba(0,0,0,0.05); }
.user-caret { font-size: 10px; opacity: 0.55; }

.user-dropdown {
  position: absolute; right: 0; top: 100%;
  margin-top: 6px; min-width: 180px;
  background: rgba(253, 250, 242, 0.98);
  border: 1px solid rgba(31, 67, 75, 0.15);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(30, 25, 18, 0.18);
  padding: 6px 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
}
.user-dropdown[hidden] { display: none; }

.dd-item {
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 8px 16px; font-size: 13px;
  color: var(--ink); font-family: inherit;
  transition: background 0.12s;
}
.dd-item:hover { background: rgba(139, 58, 46, 0.08); color: #8b3a2e; }
.dd-item.dd-danger { color: #8b3a2e; }
.dd-item.dd-danger:hover { background: rgba(139, 58, 46, 0.12); }
.dd-sep { height: 1px; background: rgba(31, 67, 75, 0.1); margin: 6px 12px; }

/* ===== 地址表单 ===== */
.address-form {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 360px; max-width: 480px;
}
.address-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: rgba(20, 47, 59, 0.7);
}
.address-form input {
  padding: 8px 12px; border: 1px solid rgba(31, 67, 75, 0.18);
  border-radius: 4px; font-size: 14px;
  background: rgba(253, 250, 242, 0.7); color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s;
}
.address-form input:focus {
  outline: none; border-color: #8b3a2e;
}
.address-form input:disabled { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.3); }

.address-row { display: flex; gap: 12px; }
.address-row label { flex: 1; }

.address-form .seal-button {
  margin-top: 6px; align-self: center;
}

/* 结算确认时的法器摘要 */
.address-checkout-summary {
  padding: 10px 14px;
  background: rgba(139, 58, 46, 0.06);
  border: 1px solid rgba(139, 58, 46, 0.25);
  border-radius: 4px;
  margin-bottom: 8px;
}
.address-checkout-summary .acs-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink);
}
.address-checkout-summary .acs-label {
  color: rgba(20, 47, 59, 0.6); font-size: 12px;
}
.address-checkout-summary .acs-name {
  font-weight: 600; flex: 1;
}
.address-checkout-summary .acs-price {
  font-weight: 600; color: #8b3a2e; letter-spacing: 1px;
}

.user-area .ghost-action {
  padding: 3px 10px;
  font-size: 13px;
  border-radius: 3px;
}

/* ============ 登录/注册模态框 ============ */
.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(31, 67, 75, 0.16);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  color: rgba(20, 47, 59, 0.5);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.auth-tab.active {
  color: var(--ink);
  border-bottom-color: rgb(173, 51, 47);
}

.auth-body label {
  display: block;
  margin-bottom: 16px;
}

.auth-body label span {
  display: block;
  font-size: 13px;
  color: rgba(20, 47, 59, 0.7);
  margin-bottom: 6px;
}

.auth-body input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(31, 67, 75, 0.2);
  border-radius: 3px;
  background: var(--paper);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  box-sizing: border-box;
}

.auth-body input:focus {
  outline: none;
  border-color: rgb(173, 51, 47);
  background: var(--paper-strong);
}

/* 密码框小眼睛 */
.pwd-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.pwd-wrap input[type="password"],
.pwd-wrap input[type="text"] {
  flex: 1 1 auto;
  width: auto !important;   /* 覆盖原来 auth-body input 的 width:100% */
  padding-right: 44px;
  box-sizing: border-box;
  min-width: 0;
}
.pwd-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  width: auto !important;
  padding: 6px 8px;
  color: #9aa9b2;
  display: flex;
  align-items: center;
  border-radius: 3px;
  transition: color 0.15s;
}
.pwd-toggle:hover { color: #1a2a36; }
.pwd-toggle:active { background: rgba(0,0,0,0.04); }
.pwd-toggle svg {
  width: 18px;
  height: 18px;
}

.auth-error {
  color: rgb(173, 51, 47);
  font-size: 13px;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--cinnabar-soft);
  border-radius: 3px;
}

/* ============ 历史记录模态框 ============ */
.history-list {
  max-height: 56vh;
  overflow-y: auto;
}

.history-list .history-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(20, 47, 59, 0.45);
  font-size: 14px;
}

.history-list .history-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(31, 67, 75, 0.1);
  cursor: pointer;
  transition: background 0.12s;
}

.history-list .history-item:hover {
  background: rgba(31, 67, 75, 0.04);
}

.history-list .history-item:last-child {
  border-bottom: 0;
}

.history-item .history-input {
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
}

.history-item .history-meta {
  font-size: 12px;
  color: rgba(20, 47, 59, 0.5);
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ===== 订单列表 ===== */
.order-list {
  max-height: 60vh;
  overflow-y: auto;
}

.order-list .order-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(31, 67, 75, 0.1);
}

.order-list .order-item:last-child { border-bottom: 0; }

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.order-name {
  font-size: 15px;
}

/* ====== 法器图片点击放大 Lightbox ====== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.order-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(40, 140, 80, 0.12);
  color: #1a7a3c;
  letter-spacing: 1px;
}

.order-meta {
  font-size: 12px;
  color: rgba(20, 47, 59, 0.55);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.order-addr {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(31, 67, 75, 0.04);
  border-left: 2px solid rgba(139, 58, 46, 0.35);
  border-radius: 2px;
  font-size: 12px;
  color: rgba(20, 47, 59, 0.72);
  line-height: 1.55;
}
.order-addr div { margin: 1px 0; }

/* ===== 账户中心 ===== */
.account-page {
  position: relative;
  z-index: 3;
  padding: 60px 40px 80px;
  min-height: 100vh;
}

.account-layout {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 40px;
  background: rgba(253, 250, 242, 0.85);
  border: 1px solid rgba(31, 67, 75, 0.12);
  border-radius: 6px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(30, 25, 18, 0.1);
}

.account-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid rgba(31, 67, 75, 0.12);
  padding-right: 20px;
}

.acct-back {
  background: none;
  border: none;
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
  color: #8b3a2e;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  transition: all 0.15s;
  letter-spacing: 1px;
  font-weight: 500;
}
.acct-back:hover {
  background: rgba(139, 58, 46, 0.1);
  padding-left: 12px;
}

.acct-tabs-sep {
  height: 1px;
  background: rgba(31, 67, 75, 0.1);
  margin: 8px 0;
}

.acct-tab {
  background: none;
  border: none;
  text-align: left;
  padding: 10px 14px;
  font-size: 14px;
  color: rgba(20, 47, 59, 0.65);
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.acct-tab:hover {
  color: var(--ink);
  background: rgba(139, 58, 46, 0.06);
}

.acct-tab.active {
  color: #8b3a2e;
  background: rgba(139, 58, 46, 0.1);
  font-weight: 600;
  border-left: 2px solid #8b3a2e;
  padding-left: 12px;
}

.account-content h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 4px;
}

.acct-pane {
  min-height: 300px;
}

.account-portal-desc {
  color: rgba(20, 47, 59, 0.6);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.7;
}

/* 账户页里的订单列表复用 .order-item 样式，加一些间距 */
.acct-pane .order-item {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(31, 67, 75, 0.08);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 12px;
}

/* 账户页地址表单用原有 .address-form 样式 */
.acct-pane .address-form {
  max-width: 480px;
}

/* 支付方式 pane */
.mock-cards .mock-banner {
  max-width: 480px;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 12px;
  padding: 18px 20px;
}
.mock-cards .mock-banner strong { color: #c77700; display: block; margin-bottom: 8px; }
.mock-cards .mock-banner p { margin: 6px 0; font-size: 14px; color: #555; line-height: 1.5; }
.mock-card-hint {
  margin-top: 10px; padding: 8px 12px; background: #f3e8ff;
  border-radius: 6px; font-family: monospace; font-size: 13px; color: #6b21a8;
}
.real-cards p { color: #555; margin: 0 0 16px; }

@media (max-width: 720px) {
  .account-layout {
    grid-template-columns: 1fr;
    padding: 24px;
    gap: 24px;
  }
  .account-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid rgba(31, 67, 75, 0.12);
    padding-right: 0;
    padding-bottom: 12px;
  }
  .acct-tab.active {
    border-left: 0;
    border-bottom: 2px solid #8b3a2e;
  }
  .account-page {
    padding: 40px 16px 60px;
  }
}
