:root {
  --bg-primary: #FAF8F5;
  --bg-secondary: #F2F0EC;
  --bg-card: #FFFFFF;
  --text-primary: #2C2C2C;
  --text-secondary: #6B6B6B;
  --accent: #ae906b;
  --accent-hover: #7A6348;
  --border: #E8E5E0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --line-yang: #1e1e1e;
  --line-yin: #a8a8a8;
  --line-changing: #a60000;
  --line-title: #955b2b;
  --disabled: #CCCCCC;
  --transition: 200ms ease;
  /* z-index 分层 */
  --z-header: 100;
  --z-sidebar-overlay: 190;
  --z-sidebar: 200;
  --z-sidebar-toggle: 210;
  --z-article-modal: 300;
  --z-modal: 500;
  --z-toast: 10000;
}

[data-theme="dark"] {
  --bg-primary: #1C1816;
  --bg-secondary: #262220;
  --bg-card: #2C2826;
  --text-primary: #E8E4E0;
  --text-secondary: #A09890;
  --accent: #C4A77D;
  --accent-hover: #D4B78D;
  --border: #3C3836;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --line-yang: #E0DCDA;
  --line-yin: #686460;
  --line-changing: #DAA520;
  --line-title: #c49e69;
  --disabled: #434235;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

/* 自定义滚动条工具类 */
.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--bg-secondary); border-radius: 3px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: "FangSong", "STFangSong", "仿宋", "华文仿宋", "华文楷体", "KaiTi", "Times New Roman",serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === 基础组件 === */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.close-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* 用户协议弹窗 */
.terms-overlay {
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-modal);
  animation: fadeIn 0.25s ease;
}

.terms-modal {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  max-width: 520px;
  width: 100%;
  animation: fadeInUp 0.3s ease;
}

.terms-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.terms-body {
  padding: 24px;
  line-height: 1.8;
  color: var(--text-primary);
  max-height: 55vh;
  overflow-y: auto;
}

.terms-body p {
  margin-bottom: 0.8em;
}

.terms-body strong {
  color: var(--accent);
}

.terms-footer {
  padding: 16px 24px 20px;
  text-align: center;
}

.btn-terms-agree {
  background-color: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 48px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color var(--transition);
}

.btn-terms-agree:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.btn-terms-agree:disabled {
  background-color: var(--disabled);
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .overlay {
    padding: 16px;
  }
}

/* 今日运势弹窗 */
.fortune-overlay {
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-modal);
  animation: fadeIn 0.25s ease;
}

.fortune-modal {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  max-width: 520px;
  width: 100%;
  animation: fadeInUp 0.3s ease;
}

.fortune-header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.fortune-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  margin-right: 12px;
}

.fortune-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

.fortune-body {
  padding: 24px;
  max-height: 65vh;
  overflow-y: auto;
  line-height: 1.8;
  color: var(--text-primary);
}

.fortune-hexagram {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.fortune-hexagram-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px;
}

.fortune-hexagram-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.fortune-line {
  height: 4px;
  width: 60px;
  border-radius: 2px;
  background-color: var(--line-yang);
}

.fortune-line.yin {
  background-color: transparent;
  display: flex;
  justify-content: space-between;
}

.fortune-line.yin::before,
.fortune-line.yin::after {
  content: '';
  width: 26px;
  height: 4px;
  border-radius: 2px;
  background-color: var(--line-yin);
}

.fortune-hexagram-name {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.fortune-content {
  text-align: left;
}

.fortune-judgment {
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.fortune-lines-text p {
  margin-bottom: 8px;
}

.fortune-lines-text .fl-name {
  font-weight: 600;
  color: var(--line-title);
}

/* 侧边栏样式 */
.sidebar {
  width: 280px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: var(--z-sidebar);
  transform: translateX(0);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-close {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 0.9rem;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.btn-clear-sidebar {
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear-sidebar:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-sidebar-overlay);
}

.sidebar-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: var(--z-sidebar-toggle);
  box-shadow: var(--shadow);
}

.sidebar-toggle:hover {
  background-color: var(--bg-secondary);
  border-color: var(--accent);
}

.hamburger-icon {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

.header-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--line-title);
}

.logo-terms-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  vertical-align: middle;
  cursor: pointer;
  transition: all var(--transition);
  margin-left: 2px;
  font-family: inherit;
}

.logo-terms-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.logo-subtitle {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--accent);
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background-color: var(--bg-secondary);
  border-color: var(--accent);
}

.daily-fortune-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 14px;
  height: 36px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.daily-fortune-btn:hover:not(:disabled) {
  background-color: var(--bg-secondary);
  border-color: var(--accent);
  color: var(--accent);
}

.daily-fortune-btn.used {
  color: var(--disabled);
  cursor: default;
}

.main-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 64px 24px;
  flex: 1;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-primary);
  text-align: center;
}

.help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  text-decoration: none;
  vertical-align: middle;
  transition: all var(--transition);
  cursor: pointer;
}

.help-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background-color: rgba(99, 102, 241, 0.1);
}

.question-section {
  text-align: center;
  margin-bottom: 48px;
}

.question-input {
  width: 100%;
  max-width: 600px;
  min-height: 120px;
  max-height: 360px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  transition: all var(--transition);
  display: block;
  margin: 0 auto 16px;
}

.question-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.2);
}

.question-input::placeholder {
  color: var(--text-secondary);
}

.btn-divination {
  padding: 12px 32px;
  background-color: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-divination:hover:not(:disabled) {
  background-color: var(--accent);
  color: #FFFFFF;
}

[data-theme="dark"] .btn-divination:hover:not(:disabled) {
  color: #1A1A1E;
}

.btn-divination:disabled {
  color: var(--disabled);
  border-color: var(--disabled);
  cursor: not-allowed;
}

.button-group {
  display: flex;
  gap: 12px;
  max-width: 600px;
  margin-top: 36px;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
}

.button-group .btn-ai-interpret,
.button-group .btn-new,
.button-group .btn-divination {
  flex: 1;
  min-width: 100px;
}

.btn-manual {
  padding: 12px 32px;
  background-color: var(--accent);
  color: #FFFFFF;
  border: 2px solid var(--accent);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: block;
}

.btn-manual:hover:not(:disabled) {
  background-color: transparent;
  color: var(--accent);
}

[data-theme="dark"] .btn-manual {
  color: #1A1A1E;
}

[data-theme="dark"] .btn-manual:hover:not(:disabled) {
  color: var(--accent);
}

.btn-manual:disabled {
  background-color: var(--disabled);
  border-color: var(--disabled);
  cursor: not-allowed;
  opacity: 0.7;
}

.hint_s {
  margin-top: 12px;
  padding-top: 10px;
}

.hint_txt {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.manual-section {
  margin-bottom: 48px;
}

.manual-selector {
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-line {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background-color: var(--bg-card);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.manual-line-name {
  width: 40px;
  font-weight: 500;
  color: var(--text-primary);
}

.manual-line-visual {
  width: 80px;
  height: 8px;
  position: relative;
  cursor: pointer;
  transition: all var(--transition);
}

.manual-line-visual.yang {
  background-color: var(--line-yang);
  border-radius: 2px;
}

.manual-line-visual.yin {
  background-color: transparent;
}

.manual-line-visual.yin::before,
.manual-line-visual.yin::after {
  content: '';
  position: absolute;
  top: 0;
  width: 42%;
  height: 8px;
  background-color: var(--line-yin);
  border-radius: 2px;
}

.manual-line-visual.yin::before {
  left: 0;
}

.manual-line-visual.yin::after {
  right: 0;
}

.manual-line-visual.changing {
  box-shadow: 0 0 0 2px var(--line-changing);
  border-radius: 3px;
  animation: pulse 2s ease-in-out infinite;
}

.manual-line-visual.changing.yang {
  background-color: var(--line-changing);
}

.manual-line-visual.changing.yin {
  box-shadow: none;
  border-radius: 0;
  animation: none;
}

.manual-line-visual.changing.yin::before,
.manual-line-visual.changing.yin::after {
  background-color: var(--line-changing);
  animation: pulse-segment 2s ease-in-out infinite;
}

.manual-line-visual.changing.yin::after {
  animation-delay: 0.3s;
}

.changing-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.changing-toggle input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.manual-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.btn-confirm {
  padding: 10px 24px;
  background-color: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-confirm:hover {
  background-color: var(--accent-hover);
}

[data-theme="dark"] .btn-confirm {
  color: #1A1A1E;
}

.btn-cancel {
  padding: 10px 24px;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-cancel:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.process-section {
  text-align: center;
  margin-bottom: 48px;
}

.process-container {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.process-step h3 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.yarrow-sticks {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0;
}

.stick {
  width: 4px;
  height: 30px;
  background-color: var(--accent);
  border-radius: 2px;
  transition: all var(--transition);
}

.divination-result {
  display: flex;
  justify-content: space-around;
  gap: 24px;
  margin: 24px 0;
}

.pile {
  flex: 1;
  text-align: center;
}

.pile h4 {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.pile .sticks {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px;
  margin: 12px 0;
  min-height: 40px;
}

.pile .remainder {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.line-result {
  margin-top: 16px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  font-weight: 500;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skip-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.skip-toggle-center {
  justify-content: center;
  margin: 24px 0 6px;
}

.skip-toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.skip-toggle input {
  display: none;
}

.skip-toggle-slider {
  width: 36px;
  height: 20px;
  background-color: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background-color var(--transition);
}

.skip-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #FFFFFF;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.skip-toggle input:checked + .skip-toggle-slider {
  background-color: var(--accent);
}

.skip-toggle input:checked + .skip-toggle-slider::after {
  transform: translateX(16px);
}

.result-section {
  margin-bottom: 48px;
}

.hexagram-container {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.hexagram {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 200px;
  text-align: center;
}

.hexagram-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.hexagram-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.hexagram-line {
  width: 75px;
  height: 7px;
  position: relative;
}

.hexagram-line.yang {
  background-color: var(--line-yang);
  border-radius: 2px;
}

.hexagram-line.yin {
  background-color: transparent;
}

.hexagram-line.yin::before,
.hexagram-line.yin::after {
  content: '';
  position: absolute;
  top: 0;
  width: 42%;
  height: 7px;
  background-color: var(--line-yin);
  border-radius: 2px;
}

.hexagram-line.yin::before {
  left: 0;
}

.hexagram-line.yin::after {
  right: 0;
}

.hexagram-line.changing {
  box-shadow: 0 0 0 2px var(--line-changing);
  border-radius: 3px;
}

.hexagram-line.changing.yang {
  background-color: var(--line-changing);
}

.hexagram-line.changing.yin {
  box-shadow: none;
  border-radius: 0;
  animation: none;
}

.hexagram-line.changing.yin::before,
.hexagram-line.changing.yin::after {
  background-color: var(--line-changing);
  animation: pulse-segment 2s ease-in-out infinite;
}

.hexagram-line.changing.yin::after {
  animation-delay: 0.3s;
}

.hexagram-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent);
}

.hexagram-structure {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 派生卦（互卦、错卦、综卦）样式 */
.derived-hexagrams {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.derived-hexagram {
  background-color: var(--bg-card);
  border-radius: 6px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 100px;
}

.derived-title {
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.derived-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.derived-lines .hexagram-line {
  width: 50px;
  height: 4px;
}

.derived-lines .hexagram-line.yin::before,
.derived-lines .hexagram-line.yin::after {
  height: 4px;
}

.derived-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
}

.interpretation-section {
  margin-bottom: 48px;
}

.interpretation-card {
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.interpretation-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.interpretation-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition);
}

.interpretation-tab:hover {
  color: var(--text-primary);
}

.interpretation-tab.active {
  color: var(--accent);
  font-weight: 600;
}

.tab-indicator {
  position: absolute;
  bottom: -1px;
  height: 2px;
  background-color: var(--accent);
  border-radius: 1px;
  transition: left 0.3s ease, width 0.3s ease;
  pointer-events: none;
}

.interpretation-panels {
  display: grid;
}

.interpretation-panels > .interpretation-panel {
  grid-area: 1 / 1 / 2 / 2;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.interpretation-panels > .interpretation-panel.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s;
}

.judgment {
  margin-bottom: 24px;
  line-height: 1.8;
}

.judgment p {
  margin-bottom: 12px;
}

.judgment .label {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 8px;
}

.tuan-section,
.xiang-section {
  margin-top: 12px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.tuan-section .label {
  font-weight: 600;
  margin-right: 8px;
}

.xiang-section .label {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 8px;
}

.tuan-text {
  font-size: 0.95rem;
}

.xiang-text {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.lines-interpretation {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.line-interpretation {
  margin-bottom: 16px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: 6px;
}

.line-interpretation .line-name {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.line-interpretation .line-text {
  color: var(--text-primary);
  margin-bottom: 4px;
}

.line-interpretation .line-xiang {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.new-divination {
  text-align: center;
  margin-top: 32px;
  margin-bottom: 48px;
}

.cf-turnstile {
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.btn-new {
  padding: 12px 32px;
  background-color: var(--bg-card);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-new:hover {
  background-color: var(--accent);
  color: #FFFFFF;
}

[data-theme="dark"] .btn-new:hover {
  color: #1A1A1E;
}

.footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px;
  text-align: center;
}

.footer-content {
  max-width: 960px;
  margin: 0 auto;
}

#logotext {
  display: none;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 4px;
}

.footer-note {
  font-size: 0.75rem !important;
  opacity: 0.7;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 1px var(--line-changing);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.4);
  }
}

@keyframes pulse-segment {
  0%, 100% {
    box-shadow: 0 0 0 1px var(--line-changing);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.5);
  }
}

.hexagram-line.changing {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.process-step-item {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  animation: slideDown 0.4s ease forwards;
}

.step-header {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.step-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.sticks-visual {
  display: flex;
  gap: 3px;
  justify-content: center;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  animation: fadeIn 0.5s ease;
  overflow-x: auto;
}

.stick-item {
  width: 3px;
  height: 24px;
  background-color: var(--accent);
  border-radius: 1.5px;
  opacity: 0;
  animation: fadeIn 0.05s ease forwards;
}

.stick-item:nth-child(1) { animation-delay: 0.02s; }
.stick-item:nth-child(2) { animation-delay: 0.04s; }
.stick-item:nth-child(3) { animation-delay: 0.06s; }
.stick-item:nth-child(4) { animation-delay: 0.08s; }
.stick-item:nth-child(5) { animation-delay: 0.10s; }
.stick-item:nth-child(6) { animation-delay: 0.12s; }
.stick-item:nth-child(7) { animation-delay: 0.14s; }
.stick-item:nth-child(8) { animation-delay: 0.16s; }
.stick-item:nth-child(9) { animation-delay: 0.18s; }
.stick-item:nth-child(10) { animation-delay: 0.20s; }
.stick-item:nth-child(n+11):nth-child(-n+20) { animation-delay: 0.25s; }
.stick-item:nth-child(n+21):nth-child(-n+30) { animation-delay: 0.30s; }
.stick-item:nth-child(n+31):nth-child(-n+40) { animation-delay: 0.35s; }
.stick-item:nth-child(n+41) { animation-delay: 0.40s; }

.change-step {
  background-color: var(--bg-secondary);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  animation: fadeIn 0.3s ease;
}

.change-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: 8px;
}

/* 爻步骤折叠功能 */
.line-step {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.line-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.line-step .step-header {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.line-toggle-icon {
  transition: transform 0.3s ease;
  font-size: 10px;
  color: var(--text-secondary);
}

.line-step.collapsed .step-description,
.line-step.collapsed .step-content {
  display: none;
}

.line-step.collapsed .line-toggle-icon {
  transform: rotate(-90deg);
}

.line-step.expanded .step-description,
.line-step.expanded .step-content {
  display: block;
}

.line-step.expanded .line-toggle-icon {
  transform: rotate(0deg);
}

.pile-container {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: center;
}

.pile-divider {
  color: var(--border);
  font-size: 1.25rem;
  padding-top: 20px;
  -webkit-user-select: none;
  user-select: none;
}

.pile-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-align: center;
}

.pile-sticks {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  min-height: 20px;
  padding: 4px;
  background-color: var(--bg-card);
  border-radius: 4px;
  min-width: 80px;
}

.mini-stick {
  font-size: 0.625rem;
  color: var(--accent);
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}

.sticks-more {
  font-size: 0.625rem;
  color: var(--text-secondary);
  margin-left: 4px;
}

.pile-remainder {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 4px;
}

.remaining {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.line-result-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background-color: var(--bg-card);
  border-radius: 6px;
  margin-top: 10px;
  animation: fadeIn 0.4s ease;
}

.yao-symbol {
  font-size: 1.5rem;
  line-height: 1;
}

.yao-symbol.changing {
  color: var(--line-changing);
  animation: pulse 1.5s ease-in-out infinite;
}

.yao-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.history-section {
  margin-bottom: 48px;
}

.history-container {
  max-width: 600px;
  margin: 0 auto;
}

.history-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}

.history-item {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  position: relative;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.history-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.history-item.active {
  border-color: var(--accent);
  background-color: var(--bg-secondary);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-question {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  margin-right: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.history-hexagram {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-hexagram-name {
  font-weight: 600;
  color: var(--accent);
}

.history-method {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 6px;
  background-color: var(--bg-secondary);
  border-radius: 4px;
}

.history-lines {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.mini-line {
  width: 1.5rem;
  height: 4px;
  position: relative;
}

.mini-line.yang {
  background-color: var(--line-yang);
  border-radius: 1px;
}

.mini-line.yin {
  background-color: transparent;
}

.mini-line.yin::before,
.mini-line.yin::after {
  content: '';
  position: absolute;
  top: 0;
  width: 42%;
  height: 4px;
  background-color: var(--line-yin);
  border-radius: 1px;
}

.mini-line.yin::before {
  left: 0;
}

.mini-line.yin::after {
  right: 0;
}

.mini-line.changing.yang {
  background-color: var(--line-changing);
}

.mini-line.changing.yin::before,
.mini-line.changing.yin::after {
  background-color: var(--line-changing);
}

.history-delete {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 4px 8px;
  background-color: transparent;
  color: #e74c3c;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

.history-delete:hover {
  background-color: #e74c3c;
  color: #FFFFFF;
}

.btn-clear-history {
  display: block;
  margin: 16px auto 0;
  padding: 8px 16px;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear-history:hover {
  color: #e74c3c;
  border-color: #e74c3c;
}

@media (max-width: 1056px) {
  .sidebar-toggle {
    bottom: 260px;
    left: 1px;
    top: auto;
    border-radius: 0 40px 40px 0;
    width: 20px;
    height: 40px;
  }
  .hamburger-icon {
  font-size: 0.5rem;
  color: var(--text-primary);
  }
}

/* 移动端响应式 */
@media (max-width: 768px) {
  .header-content {
    padding: 12px 16px;
  }

  .logo {
    font-size: 1.25rem;
  }

  .logo-subtitle {
    display: none;
  }

  #logotext {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .main-content {
    padding: 32px 16px;
  }

  .question-input {
    padding: 12px;
  }

  .hexagram-container {
    gap: 24px;
  }

  .hexagram {
    min-width: 160px;
    padding: 16px;
  }

  .hexagram-line {
    width: 60px;
  }

  .derived-hexagrams {
    gap: 16px;
  }

  .derived-hexagram {
    padding: 10px 14px;
    min-width: 90px;
  }

  .derived-lines .hexagram-line {
    width: 40px;
  }

  .divination-result {
    flex-direction: column;
    gap: 16px;
  }

  .pile-container {
    flex-direction: column;
    align-items: center;
  }

  .pile-divider {
    transform: rotate(90deg);
    padding: 0;
  }

  /* 移动端侧边栏 */
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .sidebar-overlay.open {
    display: block;
  }
}

@media (max-width: 480px) {
  .section-title {
    font-size: 1.125rem;
  }

  .hexagram-container {
    gap: 16px;
  }

  .hexagram {
    min-width: 140px;
    padding: 12px;
  }

  .hexagram-lines {
    gap: 8px;
    padding: 4px 0;
  }

  .hexagram-line {
    width: 50px;
    height: 4px;
  }

  .hexagram-line.yin::before,
  .hexagram-line.yin::after {
    height: 4px;
  }

  .derived-hexagrams {
    gap: 12px;
  }

  .derived-hexagram {
    padding: 8px 10px;
    min-width: 80px;
  }

  .derived-title {
    font-size: 0.7rem;
  }

  .derived-lines .hexagram-line {
    width: 35px;
  }

  .derived-name {
    font-size: 0.8rem;
  }

  .interpretation-panels > .interpretation-panel {
    padding: 16px;
  }

  .interpretation-tab {
    font-size: 0.875rem;
    padding: 10px 12px;
  }
}

/* AI 解读区域样式 */
.ai-interpretation-section {
  margin-bottom: 32px;
}

.ai-interpretation-card {
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.ai-interpretation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ai-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.btn-ai-interpret {
  padding: 12px 32px;
  background-color: var(--bg-card);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-ai-interpret:hover:not(:disabled) {
  background-color: var(--accent);
  color: #FFFFFF;
}

[data-theme="dark"] .btn-ai-interpret:hover:not(:disabled) {
  color: #1A1A1E;
}

.btn-ai-interpret:disabled {
  color: var(--disabled);
  border-color: var(--disabled);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-ai-interpret.streaming {
  background-color: #e74c3c;
  color: #FFFFFF;
  border-color: #e74c3c;
}

.btn-ai-interpret.streaming:hover {
  background-color: #c0392b;
  border-color: #c0392b;
}

.ai-cooldown-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 12px;
  text-align: center;
}

.ai-interpretation-content {
  position: relative;
  min-height: 60px;
}

.ai-typing-indicator {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 富文本内容通用样式 */
.prose { line-height: 1.8; color: var(--text-primary); word-break: break-word; }
.prose p { margin-bottom: 0.8em; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.2em 0 0.6em; color: var(--accent); }
.prose h1 { font-size: 1.4em; }
.prose h2 { font-size: 1.2em; }
.prose h3 { font-size: 1.1em; }
.prose ul, .prose ol { padding-left: 1.5em; margin-bottom: 0.8em; }
.prose li { margin-bottom: 0.3em; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 1em; margin: 0.8em 0; color: var(--text-secondary); }
.prose strong { color: var(--accent); }
.prose code { background: var(--bg-secondary); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
.prose pre { background: var(--bg-secondary); padding: 12px; border-radius: 6px; overflow-x: auto; margin: 0.8em 0; }
.prose pre code { background: none; padding: 0; }

.ai-text {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
}

.ai-error {
  padding: 12px 16px;
  background-color: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 6px;
  color: #e74c3c;
  font-size: 0.9375rem;
}

/* 文章悬浮窗 */
.article-modal-overlay {
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-article-modal);
  animation: fadeIn 0.2s ease;
}

.article-modal {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.3s ease;
}

.article-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.article-modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.article-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

.article-modal-body {
  padding: 24px;
  overflow-y: auto;
}

.article-modal-body h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.article-modal-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.article-modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
}

.article-modal-body th, .article-modal-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.article-modal-body th {
  background-color: var(--bg-secondary);
  font-weight: 600;
}

@media (max-width: 768px) {
  .overlay {
    padding: 12px;
  }

  .article-modal {
    max-height: 90vh;
  }

  .article-modal-header {
    padding: 16px;
  }

  .article-modal-body {
    padding: 16px;
  }
}

/* 长按复制反馈提示 */
.long-press-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: var(--z-toast);
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.long-press-feedback.show {
  opacity: 1;
}

.long-press-feedback.success {
  color: #2ecc71;
  border-color: #2ecc71;
}

.long-press-feedback.error {
  color: #e74c3c;
  border-color: #e74c3c;
}

/* 尊重用户动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


