/* 大衍筮法 - 水墨国风样式 */

:root {
  --ink: #1a1410;
  --ink-light: #3d3429;
  --paper: #f5f0e6;
  --paper-dark: #e8dfd0;
  --gold: #b8860b;
  --gold-light: #d4a84b;
  --red: #8b2500;
  --red-light: #c44d2a;
  --yang: #1a1410;
  --shadow: rgba(26, 20, 16, 0.12);
  --font-serif: "Noto Serif SC", "Songti SC", serif;
  --font-display: "Ma Shan Zheng", "KaiTi", cursive;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-serif);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.8;
  overflow-x: hidden;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(184, 134, 11, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 37, 0, 0.04) 0%, transparent 50%),
    linear-gradient(180deg, #faf6ee 0%, #f0e8d8 50%, #e8dfd0 100%);
  z-index: -1;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeDown 0.8s ease-out;
}

.header-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.header-top .title {
  margin-bottom: 0;
}

.btn-history {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-serif);
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--paper-dark);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-light);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-history:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(184, 134, 11, 0.08);
}

.history-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--gold);
  color: var(--paper);
  border-radius: 999px;
}

.history-count-badge:empty {
  display: none;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 16, 0.35);
  z-index: 900;
}

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 92vw);
  height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--paper-dark);
  box-shadow: -8px 0 32px var(--shadow);
  z-index: 901;
  display: flex;
  flex-direction: column;
  animation: historySlideIn 0.25s ease-out;
}

@keyframes historySlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}

.history-panel-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.15em;
}

.history-panel-close {
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink-light);
  cursor: pointer;
  border-radius: 4px;
}

.history-panel-close:hover {
  color: var(--red-light);
  background: rgba(196, 77, 42, 0.08);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.history-empty {
  font-size: 0.88rem;
  color: var(--ink-light);
  line-height: 1.8;
  padding: 1rem 0.5rem;
  text-align: center;
}

.history-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.history-item:hover {
  border-color: var(--gold);
  box-shadow: 0 2px 12px rgba(184, 134, 11, 0.12);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-time {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-light);
  margin-bottom: 0.25rem;
}

.history-item-question {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-no-q {
  font-weight: 400;
  font-style: italic;
  color: var(--ink-light);
}

.history-item-hex {
  font-size: 0.82rem;
  color: var(--red);
  margin-bottom: 0.15rem;
}

.history-item-method {
  font-size: 0.7rem;
  color: var(--gold);
}

.history-item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
}

.history-item-view,
.history-item-delete {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--paper-dark);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  color: var(--ink-light);
}

.history-item-view:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.history-item-delete:hover {
  border-color: var(--red-light);
  color: var(--red-light);
}

.history-panel-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--paper-dark);
  flex-shrink: 0;
}

.history-clear-btn {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  padding: 0.45rem;
  border: 1px dashed var(--paper-dark);
  border-radius: 4px;
  background: transparent;
  color: var(--ink-light);
  cursor: pointer;
}

.history-clear-btn:hover {
  border-color: var(--red-light);
  color: var(--red-light);
}

body.history-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .btn-history {
    position: static;
    transform: none;
    margin-top: 0.75rem;
  }

  .header-top {
    flex-direction: column;
  }
}

.title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--ink-light);
  letter-spacing: 0.15em;
  opacity: 0.8;
}

.action-section {
  text-align: center;
  margin-bottom: 3rem;
}

.question-field {
  max-width: 480px;
  margin: 0 auto 1.5rem;
  text-align: left;
}

.question-label {
  display: block;
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.15em;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.question-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-serif);
  font-size: 1rem;
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.question-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

.question-hint {
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-top: 0.4rem;
  line-height: 1.6;
}

.btn-divine {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.3s ease;
}

.btn-divine:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-divine:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-inner {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.5em;
  padding: 1rem 3rem;
  color: var(--paper);
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-light) 100%);
  border-radius: 4px;
  box-shadow: 0 4px 20px var(--shadow);
  border: 2px solid var(--gold);
  transition: all 0.3s ease;
}

.btn-divine:hover:not(:disabled) .btn-inner {
  box-shadow: 0 6px 30px rgba(184, 134, 11, 0.25);
  border-color: var(--gold-light);
}

.btn-divine.loading .btn-inner {
  animation: pulse 1.5s ease-in-out infinite;
}

.status-text {
  margin-top: 1.2rem;
  font-size: 0.95rem;
  color: var(--ink-light);
  min-height: 1.5em;
  letter-spacing: 0.1em;
}

.hexagram-section {
  margin-bottom: 2.5rem;
  animation: fadeUp 0.6s ease-out;
}

.hexagram-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 600px) {
  .hexagram-panels {
    grid-template-columns: 1fr;
  }
}

.hexagram-panel {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 2px 12px var(--shadow);
}

.panel-title {
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
  font-weight: 600;
}

.hexagram-display {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  min-height: 200px;
  padding: 0.5rem 0;
}

.yao-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 14px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.yao-line.visible {
  opacity: 1;
  transform: translateY(0);
  cursor: pointer;
}

.yao-line.visible:focus {
  outline: none;
}

.yao-line.hovered .yao-bar.yang,
.yao-line:focus-visible .yao-bar.yang {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.45);
}

.yao-line.hovered .yao-bar.yin::before,
.yao-line.hovered .yao-bar.yin::after,
.yao-line:focus-visible .yao-bar.yin::before,
.yao-line:focus-visible .yao-bar.yin::after {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.45);
}

.yao-line.moving .yao-bar.yang {
  background: var(--red-light);
  box-shadow: 0 0 6px rgba(196, 77, 42, 0.5);
}

.yao-line.moving .yao-bar.yin::before,
.yao-line.moving .yao-bar.yin::after {
  background: var(--red-light);
  box-shadow: 0 0 6px rgba(196, 77, 42, 0.5);
}

.yao-line.moving.hovered .yao-bar.yang,
.yao-line.moving:focus-visible .yao-bar.yang,
.yao-line.moving.hovered .yao-bar.yin::before,
.yao-line.moving.hovered .yao-bar.yin::after,
.yao-line.moving:focus-visible .yao-bar.yin::before,
.yao-line.moving:focus-visible .yao-bar.yin::after {
  background: var(--red);
  box-shadow: 0 0 10px rgba(196, 77, 42, 0.65);
}

.yao-line.moving.hovered .yao-bar,
.yao-line.moving:focus-visible .yao-bar {
  animation: none;
}

.yao-line.moving .yao-bar {
  animation: glow-red 2s ease-in-out infinite;
}

.yao-moving-badge {
  position: absolute;
  left: -22px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: var(--red-light);
  border-radius: 3px;
  padding: 0 0.25rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.yao-bar {
  height: 8px;
  border-radius: 2px;
  background: var(--yang);
}

.yao-bar.yang {
  width: 100%;
}

.yao-bar.yin {
  display: flex;
  width: 100%;
  gap: 16px;
  background: none;
}

.yao-bar.yin::before,
.yao-bar.yin::after {
  content: "";
  flex: 1;
  height: 8px;
  background: var(--yang);
  border-radius: 2px;
}

.yao-line-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yao-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  width: min(240px, 70vw);
  padding: 0.75rem 0.9rem;
  background: rgba(26, 20, 16, 0.94);
  color: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 6px 24px var(--shadow);
  font-size: 0.8rem;
  line-height: 1.6;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 20;
}

.yao-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.yao-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--gold);
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.tooltip-pos {
  color: var(--gold-light);
  font-weight: 600;
}

.tooltip-label {
  font-weight: 700;
}

.tooltip-tag {
  font-size: 0.65rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
}

.tooltip-tag.moving {
  background: var(--red-light);
}

.tooltip-value {
  font-size: 0.75rem;
  color: rgba(245, 240, 230, 0.75);
  margin-bottom: 0.4rem;
}

.tooltip-text {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.tooltip-meaning {
  font-size: 0.78rem;
  color: rgba(245, 240, 230, 0.85);
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.hex-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-top: 0.8rem;
  letter-spacing: 0.2em;
  transition: opacity 0.5s ease;
}

.hex-trigram {
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-top: 0.3rem;
  transition: opacity 0.5s ease;
}

.hex-name.pending,
.hex-trigram.pending {
  opacity: 0;
  min-height: 1.2em;
}

.yao-detail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

@media (max-width: 600px) {
  .yao-detail {
    grid-template-columns: repeat(2, 1fr);
  }
}

.yao-card {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  padding: 0.8rem;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0;
  animation: fadeUp 0.4s ease-out forwards;
}

.yao-card.moving {
  border: 2px solid var(--red-light);
  background: rgba(196, 77, 42, 0.1);
  box-shadow: 0 0 8px rgba(196, 77, 42, 0.2);
}

.yao-card.moving .pos,
.yao-card.moving .val,
.yao-card.moving .name {
  color: var(--red-light);
}

.yao-card-moving-tag {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.6rem;
  padding: 0 0.3rem;
  background: var(--red-light);
  color: #fff;
  border-radius: 3px;
  vertical-align: middle;
}

.yao-card .pos {
  color: var(--gold);
  font-weight: 600;
}

.yao-card .val {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.2rem 0;
}

.yao-card .name {
  color: var(--ink-light);
}

.interpretation-section {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 16px var(--shadow);
  animation: fadeUp 0.6s ease-out;
}

.interp-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.interp-header h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
}

.interp-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.8rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 20px;
}

.interp-rule {
  font-size: 0.9rem;
  color: var(--red);
  margin-bottom: 1.5rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--gold);
}

/* 解卦：卦辞 / 释义 / 爻解 */
.reading-section {
  margin-bottom: 1.8rem;
}

.reading-section:last-child {
  margin-bottom: 0;
}

.reading-section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.15em;
  color: var(--ink);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--gold);
}

.reading-gua-block {
  margin-bottom: 1.2rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
}

.reading-gua-block.reading-primary {
  border-color: rgba(184, 134, 11, 0.45);
  background: rgba(184, 134, 11, 0.06);
}

.reading-gua-source {
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 0.6rem;
  font-weight: 600;
}

.reading-field {
  margin-bottom: 0.8rem;
}

.reading-field:last-child {
  margin-bottom: 0;
}

.reading-field-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-light);
  background: var(--paper-dark);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.35rem;
}

.reading-gua-ci {
  font-size: 1.1rem;
  line-height: 2;
  color: var(--ink);
}

.reading-shiyi {
  font-size: 0.95rem;
  line-height: 1.9;
  color: var(--ink-light);
}

.reading-yao-block {
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
}

.reading-yao-block.reading-yao-moving {
  border: 2px solid var(--red-light);
  background: rgba(196, 77, 42, 0.08);
}

.reading-yao-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.reading-yao-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.reading-yao-pos {
  font-size: 0.8rem;
  color: var(--gold);
}

.reading-yao-source {
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-left: auto;
}

.reading-emphasis {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: var(--red-light);
  color: #fff;
  border-radius: 3px;
}

.reading-yao-ci {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--ink);
}

.classics-loading,
.classics-error,
.reading-empty {
  text-align: center;
  color: var(--ink-light);
  font-size: 0.9rem;
  padding: 1rem;
}

/* 名家 AI 解卦 */
.ai-section {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 16px var(--shadow);
  animation: fadeUp 0.6s ease-out;
}

.ai-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.ai-header h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
}

.ai-question-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.8rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 20px;
}

.ai-schools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.ai-school-card {
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.45);
}

.ai-school-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.ai-school-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}

.ai-school-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  background: var(--paper-dark);
  color: var(--ink-light);
  border-radius: 3px;
}

.ai-judgment {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-left: auto;
}

.judgment-ji {
  background: #2d6a4f;
  color: #fff;
}

.judgment-xiong {
  background: var(--red-light);
  color: #fff;
}

.judgment-hui {
  background: #b8860b;
  color: #fff;
}

.judgment-zhong {
  background: var(--ink-light);
  color: #fff;
}

.ai-school-focus {
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 0.6rem;
}

.ai-school-body .ai-field p,
.ai-summary .ai-field p {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--ink-light);
}

.ai-field {
  margin-bottom: 0.6rem;
}

.ai-field-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-dark);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  margin-bottom: 0.25rem;
}

.ai-summary {
  border-top: 2px solid var(--gold);
  padding-top: 1.2rem;
}

.ai-summary-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.15em;
  margin-bottom: 0.8rem;
}

.ai-summary-overall {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.ai-field-highlight {
  border-left: 3px solid var(--gold);
  padding-left: 0.8rem;
  background: rgba(184, 134, 11, 0.06);
  border-radius: 0 4px 4px 0;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.ai-loading,
.ai-error {
  text-align: center;
  color: var(--ink-light);
  padding: 2rem;
  font-size: 0.9rem;
}

.ai-error {
  color: var(--red-light);
}

/* 易学离线词典 */
.glossary-term {
  border-bottom: 1px dashed var(--gold);
  cursor: help;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.glossary-term:hover,
.glossary-term:focus {
  color: var(--red-light);
  border-bottom-color: var(--red-light);
  outline: none;
}

.glossary-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 380px;
  padding: 0.75rem 0.9rem;
  background: rgba(26, 20, 16, 0.96);
  color: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 8px 28px var(--shadow);
  pointer-events: none;
  line-height: 1.65;
}

.glossary-tooltip.hidden {
  display: none;
}

.glossary-tip-word {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.glossary-tip-pinyin {
  font-size: 0.85rem;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.glossary-tip-def {
  font-size: 0.82rem;
  color: rgba(245, 240, 230, 0.92);
}

.glossary-tip-para {
  margin: 0 0 0.5rem;
}

.glossary-tip-para:last-child {
  margin-bottom: 0;
}

.glossary-tip-summary {
  font-weight: 500;
  color: rgba(245, 240, 230, 0.98);
}

.glossary-tip-para:not(.glossary-tip-summary) {
  font-size: 0.8rem;
  color: rgba(245, 240, 230, 0.82);
  padding-top: 0.15rem;
  border-top: 1px dashed rgba(184, 134, 11, 0.35);
}

.interp-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--paper-dark);
}

.interp-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.interp-section-primary {
  background: rgba(184, 134, 11, 0.06);
  border: 1px solid rgba(184, 134, 11, 0.25);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 2rem;
}

.interp-section-header {
  margin-bottom: 1rem;
}

.interp-section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.interp-section-desc {
  font-size: 0.85rem;
  color: var(--ink-light);
}

.interp-section-items .interp-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.interp-block {
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px dashed var(--paper-dark);
}

.interp-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.interp-block.highlight {
  border-left: 4px solid var(--red-light);
  padding-left: 0.8rem;
  background: rgba(196, 77, 42, 0.08);
  border-radius: 0 4px 4px 0;
}

.interp-block.highlight .interp-label,
.interp-block.highlight .interp-text {
  color: var(--red);
}

.interp-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.interp-source {
  font-size: 0.8rem;
  color: var(--gold);
}

.interp-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  background: var(--red-light);
  color: white;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.interp-label {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.interp-label .emphasis {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  background: var(--red-light);
  color: white;
  border-radius: 3px;
  margin-left: 0.5rem;
}

.interp-text {
  font-size: 1.05rem;
  line-height: 2;
  margin-bottom: 0.8rem;
}

.interp-meaning {
  font-size: 0.9rem;
  color: var(--ink-light);
  background: var(--paper-dark);
  padding: 0.8rem 1rem;
  border-radius: 4px;
  line-height: 1.8;
}

/* 正本易经 — 多级折叠结构 */
.classics-section {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  padding: 1.5rem 1.5rem 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 16px var(--shadow);
  animation: fadeUp 0.6s ease-out;
}

.classics-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--gold);
}

.classics-main-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  margin: 0;
}

.classics-toolbar {
  display: flex;
  gap: 0.5rem;
}

.classics-tool-btn {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--paper-dark);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-light);
  cursor: pointer;
  transition: all 0.2s;
}

.classics-tool-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(184, 134, 11, 0.08);
}

/* 通用折叠块 */
.classics-fold > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.classics-fold > summary::-webkit-details-marker {
  display: none;
}

.classics-fold > summary::before {
  content: "▸";
  flex-shrink: 0;
  color: var(--gold);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.classics-fold[open] > summary::before {
  transform: rotate(90deg);
}

.classics-fold-body {
  padding: 0.6rem 0 0.4rem 1.1rem;
  border-left: 2px solid var(--paper-dark);
  margin-left: 0.35rem;
}

.classics-fold-title {
  font-weight: 600;
  color: var(--ink);
}

.classics-fold-meta {
  font-size: 0.72rem;
  color: var(--ink-light);
  margin-left: auto;
}

.classics-level-label {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

/* 二级：本卦 / 变卦 */
.classics-l2 {
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  margin-bottom: 0.8rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.35);
}

.classics-l2 > .classics-hex-summary {
  padding: 0.9rem 1rem;
  background: rgba(184, 134, 11, 0.12);
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.12em;
}

.classics-l2 .classics-level-label {
  background: var(--ink);
  color: var(--paper);
}

.classics-hex-body {
  padding: 0.6rem 0.8rem 0.8rem;
  border-left: none;
  margin-left: 0;
}

/* 三级：第一 / 二部分 */
.classics-l3 {
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.4);
}

.classics-l3:last-child {
  margin-bottom: 0;
}

.classics-l3 > .classics-part-summary {
  padding: 0.65rem 0.85rem;
  background: rgba(139, 37, 0, 0.05);
}

.classics-l3 .classics-level-label {
  background: var(--red-light);
  color: #fff;
}

.classics-l3 .classics-fold-title {
  font-size: 0.95rem;
  color: var(--red);
}

.classics-part-full {
  flex: 1 1 100%;
  font-size: 0.72rem;
  color: var(--ink-light);
  padding-left: 1.6rem;
  line-height: 1.5;
  margin-top: 0.15rem;
}

.classics-part-body {
  padding: 0.4rem 0.6rem 0.6rem 0.9rem;
}

/* 四级：卦辞 / 彖传 / 各爻 */
.classics-l4 {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 5px;
  margin-bottom: 0.4rem;
  background: rgba(255, 255, 255, 0.45);
}

.classics-l4:last-child {
  margin-bottom: 0;
}

.classics-l4 > .classics-fold-summary {
  padding: 0.5rem 0.75rem;
}

.classics-l4 .classics-fold-title {
  font-size: 0.9rem;
  color: var(--gold);
}

.classic-line-fold.classic-line-moving {
  border-color: var(--red-light);
  background: rgba(196, 77, 42, 0.06);
}

.classic-line-fold.classic-line-moving .classics-fold-title {
  color: var(--red-light);
}

.classics-moving-tag {
  background: var(--red-light);
  color: #fff;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: 0.65rem;
  margin-left: 0 !important;
}

/* 五级：注释详解 */
.classics-l5 {
  margin-top: 0.5rem;
  border: 1px dashed var(--paper-dark);
  border-radius: 4px;
  background: rgba(232, 223, 208, 0.35);
}

.classics-l5 > .classics-fold-summary {
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
}

.classics-l5 .classics-fold-title {
  font-size: 0.82rem;
  color: var(--ink-light);
  font-weight: 600;
}

.classic-notes-body {
  font-size: 0.82rem;
  color: var(--ink-light);
  line-height: 1.75;
  padding: 0.4rem 0.65rem 0.6rem;
}

.classic-notes-body p {
  margin-bottom: 0.45rem;
}

.classic-notes-body p:last-child {
  margin-bottom: 0;
}

.classic-field {
  margin-bottom: 0.65rem;
}

.classic-field:last-child {
  margin-bottom: 0;
}

.classic-field-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-dark);
  padding: 0.08rem 0.45rem;
  border-radius: 3px;
  margin-bottom: 0.3rem;
}

.classic-field-body {
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--ink-light);
}

.classic-field-body p {
  margin-bottom: 0.35rem;
}

.classic-xiang .classic-field-label {
  color: var(--gold);
  background: rgba(184, 134, 11, 0.12);
}

.classic-xiang .classic-field-body {
  font-style: italic;
}

@media (max-width: 600px) {
  .classics-part-full {
    padding-left: 0;
  }

  .classics-fold-body {
    padding-left: 0.75rem;
  }
}

.process-section {
  animation: fadeUp 0.6s ease-out;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--paper-dark);
  border-radius: 8px;
  overflow: hidden;
}

.process-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.2s ease;
}

.process-summary::-webkit-details-marker {
  display: none;
}

.process-summary:hover {
  background: rgba(184, 134, 11, 0.06);
}

.process-summary-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.2em;
}

.process-summary-hint {
  font-size: 0.75rem;
  color: var(--ink-light);
  letter-spacing: 0.05em;
}

.process-summary-hint::after {
  content: "点击展开";
}

.process-section[open] .process-summary-hint {
  color: var(--gold);
}

.process-section[open] .process-summary-hint::after {
  content: "点击收起";
}

.process-content {
  padding: 0 1.5rem 1.5rem;
  border-top: 1px dashed var(--paper-dark);
}

.process-yao {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--paper-dark);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  font-size: 0.8rem;
  color: var(--ink-light);
}

.process-yao h4 {
  color: var(--ink);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.process-change {
  padding: 0.3rem 0;
  border-bottom: 1px dotted var(--paper-dark);
}

.process-result {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--red);
}

.hidden {
  display: none !important;
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes glow-red {
  0%, 100% { box-shadow: 0 0 0 rgba(196, 77, 42, 0); }
  50% { box-shadow: 0 0 10px rgba(196, 77, 42, 0.55); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 rgba(196, 77, 42, 0); }
  50% { box-shadow: 0 0 8px rgba(196, 77, 42, 0.4); }
}
