@font-face {
  font-family: "SystemKai";
  src: local("STKaiti"), local("KaiTi"), local("Kaiti SC");
}

:root {
  --ink: #2b1c14;
  --paper: #f3e9d2;
  --paper-dark: #e6d7b3;
  --gold: #b8862c;
  --gold-light: #d9a544;
  --vermilion: #a3312a;
  --vermilion-dark: #7c2521;
  --bg-1: #241512;
  --bg-2: #3a2118;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg-1) 70%);
  color: var(--paper);
  font-family: "SystemKai", "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", serif;
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.coin-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  width: 100%;
  max-width: 760px;
  position: relative;
  z-index: 1;
}

.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.title-row {
  display: inline-flex;
  align-items: flex-end;
  gap: 10px;
}

.app-header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.35em;
  color: var(--gold-light);
  text-shadow: 0 0 18px rgba(216, 165, 68, 0.35);
}

.seal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  border-radius: 4px;
  border: 2px solid var(--gold-light);
  background: linear-gradient(160deg, var(--vermilion), var(--vermilion-dark));
  color: #f8ead0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  transform: rotate(-8deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.subtitle {
  margin: 8px 0 0;
  letter-spacing: 0.25em;
  color: rgba(243, 233, 210, 0.7);
  font-size: 0.95rem;
}

.info-panel {
  margin-bottom: 24px;
  border: 1px solid rgba(216, 165, 68, 0.3);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  padding: 4px 6px;
}

.info-panel summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 0.92rem;
  letter-spacing: 0.1em;
  color: var(--gold-light);
  list-style: none;
}

.info-panel summary::-webkit-details-marker {
  display: none;
}

.info-panel summary::before {
  content: "▸ ";
  color: var(--vermilion);
}

.info-panel[open] summary::before {
  content: "▾ ";
}

.info-content {
  padding: 4px 16px 16px;
  font-size: 0.85rem;
  line-height: 1.75;
  color: rgba(243, 233, 210, 0.85);
}

.info-content h3 {
  margin: 16px 0 8px;
  font-size: 0.9rem;
  color: var(--gold-light);
  letter-spacing: 0.1em;
}

.info-content h3:first-child {
  margin-top: 4px;
}

.info-content p {
  margin: 6px 0;
}

.rule-list {
  margin: 6px 0;
  padding-left: 1.3em;
}

.rule-list li {
  margin: 3px 0;
}

.term-list {
  margin: 6px 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
}

.term-list dt {
  color: var(--gold-light);
  font-weight: 700;
  white-space: nowrap;
}

.term-list dd {
  margin: 0;
}

.bagua-grid {
  list-style: none;
  margin: 6px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.bagua-grid li {
  text-align: center;
  background: rgba(216, 165, 68, 0.08);
  border: 1px solid rgba(216, 165, 68, 0.25);
  border-radius: 8px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bagua-symbol {
  font-size: 1.4rem;
  color: var(--gold-light);
}

.bagua-name {
  font-size: 0.8rem;
}

.bagua-nature {
  font-size: 0.7rem;
  color: rgba(243, 233, 210, 0.55);
}

.orn {
  color: var(--gold);
  opacity: 0.7;
  font-size: 0.7em;
  margin: 0 8px;
}

.ask-panel {
  margin-bottom: 24px;
  border: 1px solid rgba(216, 165, 68, 0.3);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  padding: 16px 18px 18px;
  text-align: center;
}

.ask-panel .panel-title {
  margin-bottom: 12px;
}

.question-input {
  width: 100%;
  max-width: 420px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(216, 165, 68, 0.4);
  background: rgba(0, 0, 0, 0.2);
  color: var(--paper);
}

.question-input::placeholder {
  color: rgba(243, 233, 210, 0.4);
}

.question-input:focus {
  outline: none;
  border-color: var(--gold-light);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(216, 165, 68, 0.35);
  background: transparent;
  color: rgba(243, 233, 210, 0.7);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  border-color: var(--gold-light);
  color: var(--paper);
}

.chip.active {
  background: linear-gradient(160deg, var(--vermilion), var(--vermilion-dark));
  border-color: var(--gold-light);
  color: #f8ead0;
}

.ask-hint {
  margin: 12px 0 0;
  font-size: 0.7rem;
  line-height: 1.6;
  color: rgba(243, 233, 210, 0.45);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(216, 165, 68, 0.25);
  border-radius: 14px;
  padding: 28px;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.corner.tl { top: -2px; left: -2px; border-top: 2px solid var(--gold-light); border-left: 2px solid var(--gold-light); }
.corner.tr { top: -2px; right: -2px; border-top: 2px solid var(--gold-light); border-right: 2px solid var(--gold-light); }
.corner.bl { bottom: -2px; left: -2px; border-bottom: 2px solid var(--gold-light); border-left: 2px solid var(--gold-light); }
.corner.br { bottom: -2px; right: -2px; border-bottom: 2px solid var(--gold-light); border-right: 2px solid var(--gold-light); }

@media (max-width: 640px) {
  .board {
    grid-template-columns: 1fr;
  }
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: var(--gold-light);
  text-align: center;
}

.cast-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.coins {
  display: flex;
  gap: 18px;
}

.coin {
  width: 78px;
  height: 78px;
  perspective: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.coin-inner {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.coin.flipping .coin-inner {
  animation: coin-spin 0.85s linear;
}

.coin.show-back .coin-inner {
  transform: rotateY(180deg);
}

@keyframes coin-spin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(1440deg); }
}

.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.face.back {
  transform: rotateY(180deg);
}

.coin-glyph {
  font-family: "SystemKai", "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", serif;
  font-size: 15px;
  font-weight: 700;
  fill: #2c1a08;
}

.coin-caption {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: rgba(243, 233, 210, 0.55);
  min-height: 1em;
}

.btn-cast,
.btn-reset {
  font-family: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  padding: 10px 30px;
  border-radius: 999px;
  border: 1px solid var(--gold-light);
  background: linear-gradient(180deg, var(--vermilion), var(--vermilion-dark));
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(163, 49, 42, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-cast:hover:not(:disabled),
.btn-reset:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(163, 49, 42, 0.55);
}

.btn-cast:active:not(:disabled),
.btn-reset:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 3px 10px rgba(163, 49, 42, 0.4);
}

.btn-cast:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-reset {
  display: block;
  margin: 28px auto 0;
}

.btn-reset[hidden] {
  display: none;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 0;
  flex-wrap: wrap;
}

.action-row[hidden] {
  display: none;
}

.btn-ghost {
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(216, 165, 68, 0.08);
  color: var(--gold-light);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn-ghost:hover {
  background: rgba(216, 165, 68, 0.18);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(216, 165, 68, 0.25);
}

.btn-ghost:active {
  transform: translateY(0) scale(0.97);
}

.action-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--gold-light);
  letter-spacing: 0.08em;
  margin: 10px 0 0;
  animation: fade-in 0.3s ease;
}

.action-note[hidden] {
  display: none;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.throw-log {
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 24px;
}

.throw-log li {
  font-size: 0.85rem;
  color: rgba(243, 233, 210, 0.85);
  background: rgba(0, 0, 0, 0.2);
  border-left: 2px solid var(--gold);
  padding: 4px 10px;
  border-radius: 4px;
}

.convention-note {
  font-size: 0.75rem;
  line-height: 1.6;
  color: rgba(243, 233, 210, 0.55);
  text-align: center;
  margin: 4px 0 0;
}

.hex-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lines {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  width: 100%;
  max-width: 220px;
  min-height: 190px;
  justify-content: flex-start;
}

.line-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-pos {
  font-size: 0.7rem;
  width: 34px;
  text-align: right;
  color: rgba(243, 233, 210, 0.5);
}

.line-bar {
  flex: 1;
  height: 12px;
  display: flex;
  gap: 12%;
}

.line-bar .seg {
  flex: 1;
  background: var(--gold-light);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.line-bar.yin .seg {
  flex: 1;
}

.line-bar.yin .gap {
  flex: 0 0 12%;
}

.line-mark {
  width: 18px;
  font-size: 0.9rem;
  color: var(--vermilion);
  font-weight: 700;
  text-align: center;
}

.lines-hint {
  font-size: 0.8rem;
  color: rgba(243, 233, 210, 0.5);
  text-align: center;
  margin: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  margin-top: 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: rgba(243, 233, 210, 0.55);
}

.legend-bar {
  width: 22px;
  height: 6px;
  border-radius: 2px;
  background: var(--gold-light);
  display: inline-block;
}

.legend-bar.yin {
  background: linear-gradient(to right, var(--gold-light) 42%, transparent 42%, transparent 58%, var(--gold-light) 58%);
}

.legend-mark {
  color: var(--vermilion);
  font-weight: 700;
}

.result {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  animation: rise-in 0.5s ease;
}

.result[hidden] {
  display: none;
}

.hex-card {
  background: linear-gradient(160deg, var(--paper), var(--paper-dark));
  color: var(--ink);
  border-radius: 12px;
  padding: 22px 26px;
  min-width: 220px;
  max-width: 300px;
  text-align: center;
  border: 1px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.hex-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.hex-card[data-fortune="great"] .hex-symbol {
  text-shadow: 0 0 22px rgba(216, 165, 68, 0.75);
}

.hex-card[data-fortune="good"] .hex-symbol {
  text-shadow: 0 0 14px rgba(163, 49, 42, 0.35);
}

.hex-card[data-fortune="bad"] .hex-symbol {
  opacity: 0.65;
  text-shadow: none;
}

.hex-card-label {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--vermilion-dark);
  margin-bottom: 6px;
}

.hex-symbol {
  font-size: 3rem;
  line-height: 1;
  margin: 4px 0;
}

.hex-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 4px 0 6px;
}

.hex-trigram {
  font-size: 0.72rem;
  color: var(--vermilion-dark);
  opacity: 0.85;
  margin: 0 0 10px;
}

.hex-judgment {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #4a3624;
}

.hex-more {
  margin-top: 10px;
  text-align: left;
}

.hex-more summary {
  cursor: pointer;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--vermilion-dark);
  list-style: none;
}

.hex-more summary::-webkit-details-marker {
  display: none;
}

.hex-more summary::before {
  content: "▸ ";
}

.hex-more[open] summary::before {
  content: "▾ ";
}

.hex-xiang,
.hex-xiang-text {
  font-size: 0.82rem;
  line-height: 1.6;
  color: #4a3624;
  margin: 8px 0 0;
}

.hex-xiang b {
  color: var(--vermilion-dark);
  margin-right: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
}

.hex-xiang-text {
  opacity: 0.85;
}

.hex-yao {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(139, 116, 66, 0.35);
}

.hex-yao-title {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--vermilion-dark);
  margin: 0 0 6px;
}

.yao-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.yao-item {
  font-size: 0.8rem;
  line-height: 1.6;
  color: #4a3624;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(139, 116, 66, 0.08);
  border-left: 2px solid var(--gold);
}

.yao-item b {
  display: inline-block;
  color: var(--vermilion-dark);
  margin-right: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.yao-text {
  display: block;
  margin: 2px 0 3px;
}

.yao-note {
  display: block;
  opacity: 0.75;
  font-size: 0.78rem;
}

.yao-item.yao-empty {
  border-left-color: rgba(139, 116, 66, 0.4);
  opacity: 0.75;
}

.yao-item.yao-special {
  border-left-color: var(--vermilion);
  background: rgba(163, 49, 42, 0.08);
}

.fortune-badge {
  display: inline-block;
  padding: 2px 16px;
  margin: 0 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  border: 1px solid;
}

.fortune-badge.great {
  background: linear-gradient(160deg, var(--vermilion), var(--vermilion-dark));
  border-color: var(--gold-light);
  color: #f8ead0;
}

.fortune-badge.good {
  background: rgba(163, 49, 42, 0.14);
  border-color: rgba(163, 49, 42, 0.4);
  color: var(--vermilion-dark);
}

.fortune-badge.neutral {
  background: rgba(139, 116, 66, 0.14);
  border-color: rgba(139, 116, 66, 0.4);
  color: #6b5636;
}

.fortune-badge.caution {
  background: rgba(180, 120, 40, 0.16);
  border-color: rgba(180, 120, 40, 0.5);
  color: #8a5a1c;
}

.fortune-badge.bad {
  background: #2b2118;
  border-color: #5a4a30;
  color: #d8c9a8;
}

.hex-divider {
  height: 1px;
  margin: 12px 0;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  opacity: 0.6;
}

.hex-interpret {
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.65;
  color: #4a3624;
}

.hex-interpret p {
  margin: 5px 0;
}

.hex-interpret b {
  color: var(--vermilion-dark);
  margin-right: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
}

.hex-arrow {
  font-size: 1.4rem;
  color: var(--gold-light);
}

.ask-result {
  margin: 22px auto 0;
  max-width: 560px;
  border: 1px solid rgba(216, 165, 68, 0.3);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  padding: 14px 20px 18px;
  text-align: center;
  animation: rise-in 0.5s ease;
}

.ask-result[hidden] {
  display: none;
}

.ask-result-label {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--gold-light);
  margin-bottom: 8px;
}

.ask-question {
  font-size: 0.85rem;
  color: rgba(243, 233, 210, 0.75);
  margin: 0 0 8px;
}

.ask-question[hidden] {
  display: none;
}

.ask-derivation {
  font-size: 0.85rem;
  line-height: 1.75;
  color: rgba(243, 233, 210, 0.9);
  text-align: left;
  margin: 0;
}

.ask-auto-cat {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: rgba(243, 233, 210, 0.5);
  margin: 0 0 12px;
}

.ask-auto-cat[hidden] {
  display: none;
}

.ask-referral {
  text-align: left;
  margin: 8px 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(216, 165, 68, 0.35);
  background: rgba(124, 37, 33, 0.22);
}

.ask-referral[hidden],
.ask-primary[hidden] {
  display: none;
}

.ask-referral-title {
  display: block;
  font-size: 0.9rem;
  color: var(--gold-light);
  margin-bottom: 6px;
}

.ask-referral-text,
.ask-referral-note {
  font-size: 0.82rem;
  line-height: 1.7;
  color: rgba(243, 233, 210, 0.88);
  margin: 0 0 6px;
}

.ask-referral-note {
  color: rgba(243, 233, 210, 0.55);
  margin-bottom: 0;
}

.ask-primary {
  text-align: left;
  margin: 4px 0 12px;
}

.ask-primary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.ask-primary-tag {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--gold-light);
  border: 1px solid rgba(216, 165, 68, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
}

.ask-rule {
  font-size: 0.75rem;
  color: rgba(243, 233, 210, 0.55);
}

.ask-primary-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--paper);
  margin: 0 0 6px;
}

.ask-primary-plain {
  font-size: 0.84rem;
  line-height: 1.7;
  color: rgba(243, 233, 210, 0.8);
  margin: 0 0 8px;
}

.ask-primary-plain[hidden],
.ask-primary-extra[hidden] {
  display: none;
}

.ask-primary-extra {
  font-size: 0.84rem;
  line-height: 1.75;
  color: rgba(243, 233, 210, 0.9);
  white-space: pre-line;
  margin: 0;
  padding: 8px 0 0;
  border-top: 1px solid rgba(216, 165, 68, 0.2);
}

.ask-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 12px 0 0;
  text-align: left;
  font-size: 0.82rem;
  line-height: 1.6;
}

.ask-fields dt {
  color: var(--gold-light);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.ask-fields:empty {
  display: none;
}

/* ── 六十四卦图鉴 ─────────────────────────────────── */
.hex-index {
  padding: 8px 6px 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 500px) {
  .hex-index { grid-template-columns: repeat(2, 1fr); }
}

.index-card {
  background: rgba(216, 165, 68, 0.06);
  border: 1px solid rgba(216, 165, 68, 0.22);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.index-card:hover {
  background: rgba(216, 165, 68, 0.13);
  border-color: rgba(216, 165, 68, 0.45);
}

.index-card.open {
  background: rgba(216, 165, 68, 0.12);
  border-color: var(--gold-light);
}

.index-symbol {
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--gold-light);
}

.index-name {
  font-size: 0.72rem;
  margin: 3px 0 5px;
  color: rgba(243, 233, 210, 0.85);
  letter-spacing: 0.04em;
}

.index-card .fortune-badge {
  font-size: 0.65rem;
  padding: 1px 8px;
  letter-spacing: 0.08em;
}

.index-detail {
  display: none;
  text-align: left;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(216, 165, 68, 0.25);
  font-size: 0.76rem;
  line-height: 1.6;
  color: rgba(243, 233, 210, 0.8);
}

.index-card.open .index-detail {
  display: block;
}

.index-judgment {
  color: rgba(243, 233, 210, 0.7);
  margin: 0 0 4px;
  font-size: 0.73rem;
}

.index-detail p {
  margin: 3px 0;
}

.index-detail b {
  color: var(--vermilion-dark);
  margin-right: 5px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.index-xiang {
  margin-top: 5px !important;
  opacity: 0.75;
}

/* ── 错卦 / 综卦 小标签 ──────────────────────────────── */
.hex-related {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 2px;
  justify-content: center;
}

.related-tag {
  font-size: 0.68rem;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(124, 37, 33, 0.4);
  background: rgba(124, 37, 33, 0.08);
  color: var(--vermilion-dark);
  letter-spacing: 0.04em;
}

/* ── 互卦展示带 ───────────────────────────────────────── */
.huxiang-band {
  margin: 18px auto 0;
  max-width: 400px;
  border: 1px solid rgba(216, 165, 68, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  padding: 14px 18px 14px;
  text-align: center;
  animation: rise-in 0.45s ease;
}

.huxiang-band[hidden] {
  display: none;
}

.huxiang-label {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--gold-light);
  margin-bottom: 10px;
}

.huxiang-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.huxiang-symbol {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--gold-light);
}

.huxiang-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.huxiang-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(243, 233, 210, 0.9);
}

.huxiang-note {
  font-size: 0.72rem;
  line-height: 1.65;
  color: rgba(243, 233, 210, 0.5);
  margin: 0 0 6px;
}

.huxiang-judgment {
  font-size: 0.8rem;
  color: rgba(243, 233, 210, 0.7);
  margin: 0;
}

/* ── 动爻解法提示 ─────────────────────────────────────── */
.yao-method {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--vermilion-dark);
  background: rgba(124, 37, 33, 0.07);
  border-left: 2px solid var(--vermilion-dark);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  margin: 0 0 8px;
}

.app-footer {
  text-align: center;
  margin-top: 36px;
  font-size: 0.72rem;
  color: rgba(243, 233, 210, 0.4);
}

.footer-legal {
  margin-top: 6px;
  font-size: 0.68rem;
}

.footer-legal a {
  color: rgba(243, 233, 210, 0.55);
  text-decoration: none;
}

.footer-legal a:hover {
  color: var(--gold-light);
}

/* ── Language navigation ─────────────────────────────── */
.lang-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.lang-current {
  color: var(--gold);
}

.lang-sep {
  color: rgba(243, 233, 210, 0.3);
}

.lang-link {
  color: rgba(243, 233, 210, 0.5);
  text-decoration: none;
  transition: color 0.15s;
}

.lang-link:hover {
  color: var(--gold-light);
}

/* ── Support / Ko-fi band ────────────────────────────── */
.support-band {
  text-align: center;
  padding: 18px 12px;
  margin: 8px 0;
  border-top: 1px solid rgba(184, 134, 44, 0.18);
  border-bottom: 1px solid rgba(184, 134, 44, 0.18);
}

.support-text {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: rgba(243, 233, 210, 0.6);
}

.btn-support {
  display: inline-block;
  padding: 8px 20px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  transition: background 0.15s, color 0.15s;
}

.btn-support:hover {
  background: var(--gold);
  color: var(--bg-1);
}

/* ══════════════════════════════════════════════════════════════════════
   UX additions: skip link, step rail, progress pips, history, exploration
   ══════════════════════════════════════════════════════════════════════ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 18px;
  background: var(--gold);
  color: var(--bg-1);
  text-decoration: none;
  border-radius: 0 0 4px 0;
  font-size: 0.85rem;
}
.skip-link:focus {
  left: 0;
}

/* Screen-reader-only live region for casting announcements */
.live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.site-nav {
  margin-top: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.site-nav a {
  color: rgba(243, 233, 210, 0.55);
  text-decoration: none;
  border-bottom: 1px solid rgba(184, 134, 44, 0.3);
  padding-bottom: 1px;
}
.site-nav a:hover {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}

/* ── three-step rail ─────────────────────────────────────────────────── */
.steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: rgba(243, 233, 210, 0.38);
  border: 1px solid rgba(184, 134, 44, 0.16);
  border-radius: 20px;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.68rem;
  flex: 0 0 auto;
}
.step.is-active {
  color: var(--gold-light);
  border-color: rgba(184, 134, 44, 0.55);
  background: rgba(184, 134, 44, 0.08);
}
.step.is-done {
  color: rgba(243, 233, 210, 0.6);
  border-color: rgba(184, 134, 44, 0.3);
}
.step.is-done .step-num::after {
  content: none;
}

/* ── casting progress pips ───────────────────────────────────────────── */
.progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.pip {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  background: rgba(243, 233, 210, 0.13);
  transition: background 0.3s, box-shadow 0.3s;
}
.pip.filled {
  background: var(--gold);
}
.pip.current {
  background: rgba(184, 134, 44, 0.4);
  box-shadow: 0 0 0 1px rgba(217, 165, 68, 0.45);
}
.progress-label {
  width: 100%;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(243, 233, 210, 0.42);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── secondary cast-all button ───────────────────────────────────────── */
.btn-cast-all {
  display: block;
  margin: 10px auto 0;
  padding: 7px 20px;
  background: transparent;
  color: rgba(243, 233, 210, 0.55);
  border: 1px solid rgba(184, 134, 44, 0.28);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-cast-all:hover:not(:disabled) {
  color: var(--gold-light);
  border-color: var(--gold);
}
.btn-cast-all:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── deep link from a result card to its full reference page ─────────── */
.hex-deep-link {
  display: block;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(184, 134, 44, 0.15);
  font-size: 0.78rem;
  color: rgba(243, 233, 210, 0.5);
  text-decoration: none;
  text-align: center;
}
.hex-deep-link:hover {
  color: var(--gold-light);
}

.info-more {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(184, 134, 44, 0.15);
  font-size: 0.82rem;
}
.info-more a {
  color: var(--gold-light);
}

.btn-support.alt {
  background: transparent;
  color: var(--gold-light);
  border: 1px solid rgba(184, 134, 44, 0.45);
  margin-left: 8px;
}
.btn-support.alt:hover {
  background: rgba(184, 134, 44, 0.12);
}

/* ── recent readings ─────────────────────────────────────────────────── */
.history-panel {
  max-width: 560px;
  margin: 34px auto 0;
  padding: 16px 20px;
  border: 1px solid rgba(184, 134, 44, 0.16);
  border-radius: 6px;
  background: rgba(243, 233, 210, 0.03);
}
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.history-head h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: normal;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.btn-tiny {
  background: transparent;
  border: 1px solid rgba(184, 134, 44, 0.25);
  color: rgba(243, 233, 210, 0.45);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
}
.btn-tiny:hover {
  color: var(--gold-light);
  border-color: var(--gold);
}
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(184, 134, 44, 0.1);
}
.history-list li:last-child {
  border-bottom: none;
}
.history-link {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex: 0 0 auto;
}
.history-sym {
  font-size: 1.25rem;
  color: var(--paper);
  line-height: 1;
}
.history-name {
  font-size: 0.84rem;
  color: var(--gold-light);
}
.history-link:hover .history-name {
  text-decoration: underline;
}
.history-q {
  flex: 1 1 auto;
  font-size: 0.76rem;
  color: rgba(243, 233, 210, 0.42);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-time {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: rgba(243, 233, 210, 0.3);
}
.history-note {
  margin: 10px 0 0;
  font-size: 0.7rem;
  color: rgba(243, 233, 210, 0.32);
  line-height: 1.6;
}

/* ── explore band ────────────────────────────────────────────────────── */
.explore-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  max-width: 720px;
  margin: 34px auto 0;
}
.explore-band a {
  display: block;
  padding: 13px 16px;
  border: 1px solid rgba(184, 134, 44, 0.16);
  border-radius: 6px;
  background: rgba(243, 233, 210, 0.03);
  text-decoration: none;
  transition: border-color 0.18s, background 0.18s;
}
.explore-band a:hover {
  border-color: var(--gold);
  background: rgba(184, 134, 44, 0.07);
}
.explore-band b {
  display: block;
  font-size: 0.87rem;
  font-weight: normal;
  color: var(--gold-light);
  margin-bottom: 3px;
}
.explore-band span {
  display: block;
  font-size: 0.74rem;
  color: rgba(243, 233, 210, 0.45);
  line-height: 1.55;
}

/* ── mobile refinements ──────────────────────────────────────────────── */
@media (max-width: 560px) {
  body {
    padding: 18px 12px 48px;
  }
  .steps {
    gap: 5px;
  }
  .step {
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  .pip {
    width: 16px;
  }
  .history-q {
    display: none;
  }
  .explore-band {
    grid-template-columns: 1fr;
  }
}

/* ── honour the OS reduced-motion preference ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Compliance notice shown directly beneath a completed reading. Deliberately
   restrained: legible and unmissable, but not styled as an alarm. */
.result-disclaimer {
  max-width: 640px;
  margin: 22px auto 0;
  padding: 13px 18px;
  border: 1px solid rgba(184, 134, 44, 0.22);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: rgba(243, 233, 210, 0.035);
  font-size: 0.78rem;
  line-height: 1.85;
  color: rgba(243, 233, 210, 0.62);
}
.result-disclaimer b {
  color: rgba(243, 233, 210, 0.86);
  font-weight: normal;
  border-bottom: 1px solid rgba(184, 134, 44, 0.35);
}

/* Classical Chinese source shown beneath the English rendering of a judgment */
.judgment-src {
  display: block;
  margin-top: 7px;
  font-size: 0.82rem;
  color: rgba(243, 233, 210, 0.42);
  letter-spacing: 0.04em;
}
