/**
 * 每日一卦 · 全站黑白配色
 * 与 eo-theme-bw 一致：白底、墨字、黑按钮
 */

.eo-bugua-page {
  --bu-bg: #ffffff;
  --bu-panel: #ffffff;
  --bu-panel-2: #fafafa;
  --bu-line: rgba(0, 0, 0, 0.14);
  --bu-line-soft: rgba(0, 0, 0, 0.08);
  --bu-ink: #111111;
  --bu-ink-2: #333333;
  --bu-text: #111111;
  --bu-text-dim: rgba(0, 0, 0, 0.55);
  --bu-text-mute: rgba(0, 0, 0, 0.38);
  --bu-accent: #111111;
  --bu-soft: rgba(0, 0, 0, 0.04);
  --bu-mark: #dc2626;
  --bu-mark-soft: rgba(220, 38, 38, 0.1);
  --bu-radius: 14px;
  --bu-font: "Noto Serif SC", "Songti SC", "Source Han Serif SC", "STSong",
    "SimSun", Georgia, serif;
  --bu-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html.eo-bugua,
html.eo-bugua body.eo-bugua-page {
  background: var(--bu-bg) !important;
  color: var(--bu-text) !important;
  color-scheme: light !important;
}

html.eo-bugua body.eo-bugua-page {
  font-family: var(--bu-sans);
  min-height: 100vh;
}

html.eo-bugua .bugua-app {
  color: var(--bu-text);
}

html.eo-bugua .bugua-app a.bugua-btn {
  text-decoration: none;
}

.bugua-app {
  padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0));
}

.bugua-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 32px;
  box-sizing: border-box;
}

/* ── Hero ── */
.bugua-hero {
  text-align: center;
  padding: 8px 0 20px;
}

.bugua-hero__orb {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
}

.bugua-hero__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.22);
  animation: bugua-spin 48s linear infinite;
}

.bugua-hero__ring--inner {
  inset: 14px;
  border-color: rgba(0, 0, 0, 0.12);
  animation-direction: reverse;
  animation-duration: 32s;
}

.bugua-hero__bagua {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: var(--bu-ink);
}

.bugua-hero__tag {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--bu-text-mute);
  margin: 0 0 6px;
  font-family: var(--bu-sans);
}

.bugua-hero__title {
  font-family: var(--bu-font);
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 600;
  color: var(--bu-text);
  margin: 0 0 8px;
  letter-spacing: 0.18em;
}

.bugua-hero__sub {
  font-size: 13px;
  color: var(--bu-text-dim);
  margin: 0;
}

/* ── Tabs ── */
.bugua-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--bu-soft);
  border-radius: 12px;
  border: 1px solid var(--bu-line-soft);
  margin-bottom: 16px;
}

.bugua-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--bu-text-mute);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bugua-tab.is-active {
  background: #111;
  color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

/* ── Cards ── */
.bugua-card {
  background: var(--bu-panel);
  border: 1px solid var(--bu-line);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.bugua-card--center {
  text-align: center;
  padding: 32px 20px;
}

.bugua-card__lead {
  font-size: 14px;
  line-height: 1.65;
  color: var(--bu-text-dim);
  margin: 0 0 24px;
  text-align: center;
}

.bugua-muted {
  color: var(--bu-text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

/* ── Mind button ── */
.bugua-mind-ring {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.bugua-mind-btn {
  position: absolute;
  inset: 20px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--bu-line);
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.08),
    0 1px 0 rgba(0, 0, 0, 0.04);
  cursor: pointer;
  color: var(--bu-text);
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.bugua-mind-btn:active,
.bugua-mind-btn.is-holding {
  transform: scale(0.96);
  background: #f5f5f5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.bugua-mind-btn__icon {
  font-size: 36px;
  opacity: 0.9;
  color: var(--bu-ink);
}

.bugua-mind-btn__text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.bugua-mind-btn__hint {
  font-size: 11px;
  color: var(--bu-text-mute);
}

.bugua-mind-progress {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.bugua-mind-progress__track {
  fill: none;
  stroke: rgba(0, 0, 0, 0.1);
  stroke-width: 4;
}

.bugua-mind-progress__bar {
  fill: none;
  stroke: #111;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 0.05s linear;
}

.bugua-mind-ring.is-ready .bugua-mind-progress__bar {
  stroke: var(--bu-mark);
}

/* ── Question form ── */
.bugua-label {
  display: block;
  font-size: 13px;
  color: var(--bu-ink-2);
  margin-bottom: 8px;
  font-weight: 500;
}

.bugua-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--bu-line);
  background: #fff;
  color: var(--bu-text);
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  font-family: inherit;
}

.bugua-textarea::placeholder {
  color: var(--bu-text-mute);
}

.bugua-textarea:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.bugua-persona-count {
  text-align: right;
  font-size: 11px;
  color: var(--bu-text-mute);
  margin: 6px 0 16px;
}

/* ── Buttons ── */
.bugua-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.04em;
  text-transform: none;
  position: static;
  overflow: visible;
  box-shadow: none;
}

.bugua-btn::before {
  display: none !important;
  content: none !important;
}

.bugua-btn:active {
  transform: scale(0.98);
}

.bugua-btn--primary {
  background: #111 !important;
  color: #fff !important;
  border: 1px solid #111 !important;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18) !important;
}

.bugua-btn--primary:hover {
  background: #333 !important;
  border-color: #333 !important;
  color: #fff !important;
}

.bugua-btn--ghost {
  background: #fff !important;
  color: var(--bu-ink-2) !important;
  border: 1px solid var(--bu-line) !important;
  box-shadow: none !important;
}

.bugua-btn--ghost:hover {
  background: var(--bu-soft) !important;
  border-color: #111 !important;
  color: #111 !important;
}

.bugua-btn--block {
  width: 100%;
}

.bugua-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bugua-link-btn {
  background: none;
  border: none;
  color: var(--bu-ink);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bugua-footnote {
  text-align: center;
  font-size: 11px;
  color: var(--bu-text-mute);
  margin: 20px 0 0;
}

.bugua-footnote--done {
  margin-top: 12px;
}

/* ── Hexagram display ── */
.bugua-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bugua-date {
  font-size: 12px;
  color: var(--bu-text-mute);
}

.bugua-method-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bu-soft);
  color: var(--bu-ink-2);
  border: 1px solid var(--bu-line);
}

.bugua-hex-card {
  background: var(--bu-panel-2);
  border: 1px solid var(--bu-line);
  border-radius: 18px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.bugua-lines {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  min-height: 168px;
}

.bugua-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 140px;
  animation: bugua-line-in 0.4s ease both;
}

.bugua-line__bar {
  height: 8px;
  border-radius: 2px;
  background: #111;
}

.bugua-line--yang .bugua-line__bar {
  width: 100%;
}

.bugua-line--yin {
  justify-content: space-between;
}

.bugua-line--yin .bugua-line__bar {
  width: 42%;
}

.bugua-line.is-changing .bugua-line__bar {
  background: var(--bu-mark);
}

.bugua-line__mark {
  font-size: 10px;
  color: var(--bu-mark);
  min-width: 14px;
}

.bugua-hex-name {
  font-family: var(--bu-font);
  font-size: 22px;
  font-weight: 600;
  color: var(--bu-text);
  margin: 0 0 10px;
  letter-spacing: 0.18em;
}

.bugua-hex-judgment {
  font-size: 13px;
  line-height: 1.7;
  color: var(--bu-text-dim);
  margin: 0;
}

.bugua-hex-transformed {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--bu-ink-2);
}

.bugua-question-echo {
  font-size: 13px;
  color: var(--bu-text-dim);
  padding: 12px 14px;
  border-left: 3px solid #111;
  background: var(--bu-soft);
  border-radius: 0 10px 10px 0;
  margin-bottom: 14px;
}

/* ── 解卦按钮区 ── */
.bugua-ai-teaser {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bu-panel-2);
  border: 1px solid var(--bu-line-soft);
}

.bugua-ai-teaser__label {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--bu-text-mute);
  letter-spacing: 0.08em;
}

.bugua-ai-teaser__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--bu-ink-2);
}

.bugua-btn--interpret {
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  margin-bottom: 14px;
}

.bugua-btn--interpret__main {
  font-size: 16px;
  letter-spacing: 0.1em;
}

.bugua-btn--interpret__sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
}

.bugua-btn--interpret.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ── 解卦弹窗 ── */
.bugua-modal {
  position: fixed;
  inset: 0;
  z-index: 950;
}

.bugua-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  animation: bugua-fade-in 0.22s ease;
}

.bugua-modal__sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--bu-line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
  animation: bugua-slide-up 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bugua-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--bu-line-soft);
  flex-shrink: 0;
}

.bugua-modal__head-text h3 {
  margin: 0 0 4px;
  font-family: var(--bu-font);
  font-size: 18px;
  color: var(--bu-text);
  letter-spacing: 0.1em;
}

.bugua-modal__head-text p {
  margin: 0;
  font-size: 12px;
  color: var(--bu-text-dim);
}

.bugua-modal__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bu-soft);
  color: var(--bu-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.bugua-modal__body {
  overflow-y: auto;
  padding: 16px 18px 24px;
  -webkit-overflow-scrolling: touch;
}

/* ── AI 详情内容 ── */
.bugua-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.bugua-keyword {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--bu-soft);
  color: var(--bu-ink-2);
  border: 1px solid var(--bu-line);
}

.bugua-summary {
  font-size: 16px;
  line-height: 1.65;
  color: var(--bu-text);
  margin: 0 0 16px;
  font-weight: 500;
}

.bugua-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bugua-section {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bu-panel-2);
  border: 1px solid var(--bu-line-soft);
}

.bugua-section__title {
  font-size: 11px;
  color: var(--bu-text-mute);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
}

.bugua-section__body {
  font-size: 13px;
  line-height: 1.65;
  color: var(--bu-text-dim);
  margin: 0;
}

.bugua-lucky {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--bu-line-soft);
}

.bugua-lucky__item {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--bu-soft);
}

.bugua-lucky__label {
  font-size: 10px;
  color: var(--bu-text-mute);
  display: block;
  margin-bottom: 4px;
}

.bugua-lucky__val {
  font-size: 14px;
  color: var(--bu-text);
  font-weight: 500;
}

.bugua-quote {
  margin: 16px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--bu-line-soft);
  font-family: var(--bu-font);
  font-size: 14px;
  font-style: italic;
  color: var(--bu-ink-2);
  text-align: center;
}

.bugua-ai-pending,
.bugua-ai-fail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 12px;
  color: var(--bu-text-dim);
  font-size: 13px;
}

.bugua-ai-fail {
  flex-direction: column;
}

/* ── Actions ── */
.bugua-actions {
  display: flex;
  gap: 10px;
}

.bugua-actions .bugua-btn {
  flex: 1;
}

/* ── Spinner ── */
.bugua-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #111;
  border-radius: 50%;
  animation: bugua-spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.bugua-spinner--sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
  margin: 0;
}

.bugua-loading-text {
  font-size: 14px;
  color: var(--bu-text-dim);
  margin: 0;
}

/* ── History drawer ── */
.bugua-drawer__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
  animation: bugua-fade-in 0.2s ease;
}

.bugua-drawer__sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  z-index: 901;
  background: #fff;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--bu-line);
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: bugua-slide-up 0.28s ease;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.1);
}

.bugua-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bu-line-soft);
}

.bugua-drawer__head h3 {
  margin: 0;
  font-family: var(--bu-font);
  font-size: 16px;
  color: var(--bu-text);
  letter-spacing: 0.08em;
}

.bugua-drawer__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bu-soft);
  color: var(--bu-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.bugua-history-list {
  list-style: none;
  margin: 0;
  padding: 8px 16px 20px;
  overflow-y: auto;
  max-height: calc(70vh - 60px);
}

.bugua-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid var(--bu-line-soft);
  cursor: pointer;
}

.bugua-history-item:active {
  background: var(--bu-soft);
}

.bugua-history-item__date {
  font-size: 13px;
  color: var(--bu-text-mute);
}

.bugua-history-item__name {
  font-size: 15px;
  color: var(--bu-text);
  font-weight: 500;
}

.bugua-history-item__method {
  font-size: 11px;
  color: var(--bu-text-dim);
}

.bugua-history-empty {
  text-align: center;
  padding: 32px;
  color: var(--bu-text-mute);
  font-size: 13px;
}

/* ── Toast ── */
.bugua-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%) translateY(80px);
  padding: 12px 20px;
  border-radius: 24px;
  background: #111;
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.bugua-toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Animations ── */
@keyframes bugua-spin {
  to { transform: rotate(360deg); }
}

@keyframes bugua-line-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bugua-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bugua-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ── Desktop ── */
@media (min-width: 768px) {
  .bugua-shell {
    padding-top: 24px;
  }

  .bugua-hero__orb {
    width: 140px;
    height: 140px;
  }

  .bugua-mind-ring {
    width: 220px;
    height: 220px;
  }

  .bugua-modal__sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 20px;
    max-height: min(82vh, 680px);
    animation: bugua-modal-in 0.28s ease;
  }
}

@keyframes bugua-modal-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.eo-bugua-page [hidden] {
  display: none !important;
}
