/* ============ 六爻占卜系统样式 ============ */
:root {
  --ink: #1d1a16;
  --ink-2: #2b2620;
  --paper: #f7f1e3;
  --paper-2: #efe6d2;
  --gold: #b8860b;
  --gold-light: #d4a83c;
  --gold-dark: #8a6a12;
  --red: #a03a2a;
  --green: #3a6b35;
  --text: #3a332b;
  --text-dim: #7a6f5f;
  --line: #d8cba8;
  --shadow: 0 4px 18px rgba(60, 45, 20, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(184, 134, 11, 0.10), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(160, 58, 42, 0.08), transparent 55%),
    var(--paper);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ---------- 头部 ---------- */
.site-header {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 70%);
  color: var(--paper);
  padding: 26px 16px;
  text-align: center;
  border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow);
}
.site-header h1 {
  font-size: 30px;
  letter-spacing: 8px;
  color: var(--gold-light);
  text-shadow: 0 0 18px rgba(212, 168, 60, 0.35);
}
.site-header .subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: rgba(247, 241, 227, 0.75);
  letter-spacing: 3px;
}

/* ---------- 布局 ---------- */
.container { max-width: 860px; margin: 22px auto 40px; padding: 0 14px; }

.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
  margin-bottom: 16px;
  letter-spacing: 2px;
}
.step-no {
  display: inline-block;
  width: 24px; height: 24px;
  line-height: 24px;
  text-align: center;
  background: var(--gold);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  margin-right: 8px;
}
.tiny { font-size: 12px; color: var(--text-dim); font-weight: 400; letter-spacing: 1px; }
.optional { font-size: 12px; color: var(--text-dim); font-weight: 400; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fdfaf2;
  color: var(--text);
  outline: none;
}
textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.18); }

/* 分段选择 */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-item {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfaf2;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
  font-family: inherit;
}
.seg-item:hover { border-color: var(--gold); }
.seg-item.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.35);
}
.seg-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- 摇卦区 ---------- */
.coins-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.coin-sample {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--gold);
}
.coin-sample.yang { background: radial-gradient(circle at 35% 30%, #fff2c9, var(--gold-light)); }
.coin-sample.yin { background: radial-gradient(circle at 35% 30%, #e8dcc0, #b09a5e); }

.throw-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fdfaf2;
  flex-wrap: wrap;
}
.throw-row.complete { border-style: solid; border-color: rgba(184, 134, 11, 0.55); background: #fbf3dd; }
.throw-name { font-size: 13px; font-weight: 600; color: var(--ink); width: 74px; flex-shrink: 0; }
.throw-coins { display: flex; gap: 8px; flex: 1; min-width: 160px; }
.coin-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 2px solid var(--gold-dark);
  cursor: pointer;
  font-size: 12px;
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: all 0.15s;
  background: #fdfaf2;
  user-select: none;
}
.coin-btn:hover { transform: translateY(-2px); }
.coin-btn.yang {
  background: radial-gradient(circle at 35% 30%, #fff6d8, var(--gold-light));
  color: #6b4e05;
  border-color: var(--gold);
  box-shadow: 0 2px 6px rgba(184, 134, 11, 0.4);
}
.coin-btn.yin {
  background: radial-gradient(circle at 35% 30%, #eee3c6, #b49c60);
  color: #5c4a18;
}
.throw-count {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.throw-count b { color: var(--gold-dark); font-size: 15px; }
.btn-rand-one {
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fdfaf2;
  cursor: pointer;
  color: var(--text-dim);
  font-family: inherit;
}
.btn-rand-one:hover { border-color: var(--gold); color: var(--gold-dark); }

.tao-hint {
  margin-top: 14px;
  padding: 12px 14px;
  background: #f6ead0;
  border-left: 4px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text);
}
.tao-hint strong { color: var(--red); }

/* ---------- 按钮 ---------- */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 26px 0 10px;
}
.btn {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #fff;
  padding: 13px 44px;
  font-size: 16px;
  letter-spacing: 4px;
  box-shadow: 0 4px 14px rgba(184, 134, 11, 0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(184, 134, 11, 0.5); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 12px 32px;
  font-size: 15px;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-dark); }
.btn-sm { padding: 6px 12px; font-size: 12px; letter-spacing: 0; }
.btn-lg { padding: 13px 44px; font-size: 16px; }

.disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}
.site-footer {
  text-align: center;
  padding: 18px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
}

/* ---------- 排盘结果 ---------- */
.result-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  font-size: 13px;
  color: var(--text);
  padding: 12px 14px;
  background: #fdfaf2;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
}
.result-head .k { color: var(--text-dim); margin-right: 4px; }
.result-head b { color: var(--gold-dark); }

.gua-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.gua-box {
  background: #fdfaf2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.gua-box .gua-title { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.gua-box .gua-name { font-size: 24px; font-weight: 700; color: var(--gold-dark); letter-spacing: 3px; }
.gua-box .gua-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.gua-box .gua-symbol { font-size: 40px; margin-top: 6px; color: var(--ink); letter-spacing: 2px; }
.gua-box.bian .gua-name { color: var(--green); }
.gua-box .gua-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(184, 134, 11, 0.15);
  color: var(--gold-dark);
  margin-left: 6px;
}

.table-wrap { overflow-x: auto; margin-bottom: 14px; }
table.paipan {
  width: 100%;
  border-collapse: collapse;
  background: #fdfaf2;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
table.paipan th {
  background: var(--ink);
  color: var(--paper);
  padding: 8px 6px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
}
table.paipan td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid #ece2c8;
  white-space: nowrap;
}
table.paipan tr:last-child td { border-bottom: none; }
table.paipan tr.dong td { background: rgba(184, 134, 11, 0.10); }
.yao-line { display: inline-flex; align-items: center; gap: 3px; }
.yao-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 22px; height: 6px;
  border-radius: 2px;
  background: var(--ink);
}
.yao-bar.yin { background: transparent; }
.yao-bar .half {
  display: inline-block;
  width: 9px; height: 6px;
  border-radius: 2px;
  background: var(--ink);
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 4px;
  margin-left: 3px;
  vertical-align: 1px;
}
.badge-dong { background: var(--red); color: #fff; }
.badge-shi { background: var(--gold); color: #fff; }
.badge-ying { background: #8a8a8a; color: #fff; }
.badge-xk { background: #e8dcc0; color: #7a6f5f; }

.fu-box {
  font-size: 13px;
  padding: 10px 14px;
  background: #f6ead0;
  border-radius: 8px;
  margin-bottom: 14px;
}
.fu-box b { color: var(--gold-dark); }

/* ---------- 解卦聊天 ---------- */
.chat-card {
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #fdf8ea, #f7f1e3);
}
.chat-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-title .llm-tag {
  font-size: 12px;
  color: var(--gold-dark);
  background: rgba(184, 134, 11, 0.12);
  padding: 3px 10px;
  border-radius: 12px;
}
#chat-box {
  height: 380px;
  overflow-y: auto;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.msg.user .avatar { background: var(--gold); border-color: var(--gold); }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  background: #fffdf6;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble { background: #f3e3b8; border-color: var(--gold-light); }
.msg .bubble p { margin-bottom: 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul { margin: 4px 0 8px 20px; }
.msg .bubble h3, .msg .bubble h4 { color: var(--gold-dark); margin: 8px 0 4px; }
.msg .bubble strong { color: var(--red); }

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.chat-input-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: #fffdf6;
  outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); }
.chat-send {
  padding: 0 22px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.loading-dots::after {
  content: "";
  animation: dots 1.2s infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "·"; }
  50% { content: "··"; }
  75% { content: "···"; }
}

/* 加载遮罩 */
#loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(29, 26, 22, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99;
}
#loading-mask.show { display: flex; }
.spinner {
  width: 46px; height: 46px;
  border: 4px solid rgba(247, 241, 227, 0.3);
  border-top-color: var(--gold-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  color: var(--paper);
  margin-left: 16px;
  font-size: 15px;
  letter-spacing: 2px;
}

/* 错误提示 */
.err-banner {
  background: #fbe9e4;
  border: 1px solid #e2b8ac;
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: none;
}
.err-banner.show { display: block; }

@media (max-width: 560px) {
  .gua-grid { grid-template-columns: 1fr; }
  .coin-btn { width: 42px; height: 42px; }
}
