/* ==================== 基础 ==================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&display=swap');

:root {
  --primary: #8b0000;
  --primary-light: #fff8f8;
  --bg: #f5f0e8;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-hint: #999999;
  --border: #e0d5c5;
  --gold: #daa520;
  --green: #228b22;
  --red: #ff4500;
  --gray: #666666;
  --light-gray: #888888;
  --black: #000000;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  max-width: 400px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 80px;
}

h1, h2, h3, h4 {
  font-family: 'Noto Serif SC', serif;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==================== 通用 ==================== */
.page-title {
  text-align: center;
  font-size: 24px;
  color: var(--primary);
  padding: 24px 16px 16px;
  font-weight: 700;
  letter-spacing: 4px;
}

.page-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-hint);
  margin-bottom: 16px;
}

.container {
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* ==================== 表单 ==================== */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
}

.textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  min-height: 80px;
  resize: vertical;
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  opacity: 0.9;
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-gray {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-sm {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-group .btn {
  flex: 1;
}

/* ==================== 选项卡片 ==================== */
.option-cards {
  display: flex;
  gap: 12px;
}

.option-card {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s;
}

.option-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-card .icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.option-card .label {
  font-size: 15px;
  font-weight: 600;
}

.option-card .sublabel {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 4px;
}

/* ==================== 底部 Tab ==================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  z-index: 100;
}

.tab-item {
  flex: 1;
  text-align: center;
  color: var(--text-hint);
  font-size: 11px;
  padding: 4px 2px;
  cursor: pointer;
  min-width: 0;
}

.tab-item.active {
  color: var(--primary);
}

.tab-item .tab-icon {
  font-size: 20px;
  display: block;
  margin-bottom: 2px;
}

/* ==================== 摇卦页 ==================== */
.shake-progress {
  text-align: center;
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.coin-area {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px 0;
}

.coin {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-image: url('images/coin-zheng.svg');
  background-size: cover;
  background-position: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.coin.spin {
  animation: spin 1.5s ease-in-out;
}

@keyframes spin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1800deg); }
}

.result-area {
  text-align: center;
  min-height: 60px;
  margin-bottom: 16px;
}

.result-coins {
  font-size: 18px;
  margin-bottom: 8px;
}

.result-type {
  font-size: 20px;
  color: var(--primary);
  font-weight: 700;
}

.record-list {
  margin-bottom: 16px;
}

.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.record-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.record-item.dong {
  color: var(--primary);
  font-weight: 600;
}

.record-left {
  font-size: 14px;
}

.record-coins {
  font-size: 12px;
  margin: 0 8px;
  color: var(--text-secondary);
}

.record-right {
  font-size: 14px;
}

/* ==================== 排盘结果页 ==================== */
.time-card {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 16px;
}

.time-half {
  flex: 1;
  padding: 16px;
  text-align: center;
}

.time-half:first-child {
  border-right: 1px solid var(--border);
}

.time-value {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.time-label {
  font-size: 12px;
  color: var(--text-hint);
}

.gua-info {
  text-align: center;
  margin-bottom: 16px;
}

.gua-info .question {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.gua-info .gua-name {
  font-size: 28px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 4px;
}

.gua-info .gua-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 排盘主体 */
.pan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}

.pan-table th, .pan-table td {
  text-align: center;
  padding: 8px 2px;
  vertical-align: middle;
}

.pan-table thead th {
  color: var(--text-hint);
  font-weight: normal;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.pan-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.pan-table tbody tr:last-child {
  border-bottom: none;
}

.pan-divider-red {
  width: 1px;
  background: var(--primary);
}

.pan-divider-gray {
  width: 1px;
  background: var(--border);
}

.yao-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  position: relative;
}

.yao {
  display: inline-block;
  height: 6px;
  background: var(--text);
  border-radius: 2px;
}

.yao.yang {
  width: 40px;
}

.yao.yin {
  width: 15px;
  box-shadow: 18px 0 0 var(--text);
}

.dong-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  margin-left: 6px;
}

.shi-mark, .ying-mark {
  font-size: 10px;
  color: var(--primary);
  font-weight: 700;
  padding: 0 2px;
}

.liu-shen.qing-long { color: var(--green); }
.liu-shen.zhu-que { color: var(--red); }
.liu-shen.gou-chen { color: var(--gold); }
.liu-shen.teng-she { color: var(--gray); }
.liu-shen.bai-hu { color: var(--light-gray); }
.liu-shen.xuan-wu { color: var(--black); }

.bottom-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.info-tag {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.info-tag strong {
  color: var(--text);
}

/* ==================== 解卦页 ==================== */
.section-block {
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--border);
}

.section-block.judgment {
  background: var(--primary-light);
  border-color: var(--primary);
  text-align: center;
}

.section-block.judgment .conclusion {
  font-size: 22px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.section-block.quote {
  background: #f8f5f0;
  border-left: 4px solid var(--gold);
}

.section-block.advice {
  background: #e8f5e9;
  border-color: #c8e6c9;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.status-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.status-wang { background: #e8f5e9; color: var(--green); }
.status-xiu { background: #fff3e0; color: #ef6c00; }
.status-jue { background: #f5f5f5; color: var(--text-secondary); }

.dongyao-card {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin-bottom: 12px;
}

.dongyao-card:last-child {
  margin-bottom: 0;
}

.feedback-options {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-option {
  flex: 1;
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.feedback-option.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.disclaimer {
  font-size: 12px;
  color: var(--text-hint);
  text-align: center;
  padding: 16px;
}

/* ==================== 卦例列表页 ==================== */
.event-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.event-name {
  font-size: 17px;
  font-weight: 600;
}

.event-meta {
  font-size: 12px;
  color: var(--text-hint);
}

.hex-list {
  margin-bottom: 12px;
}

.hex-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.hex-item:last-child {
  border-bottom: none;
}

.hex-gua {
  font-size: 14px;
  color: var(--text);
}

.hex-date {
  font-size: 12px;
  color: var(--text-hint);
}

.status-label {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.status-pending { background: #fff3e0; color: #ef6c00; }
.status-fulfilled { background: #e8f5e9; color: var(--green); }
.status-unfulfilled { background: #ffebee; color: #c62828; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-hint);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ==================== 管理后台 ==================== */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--primary);
  color: #fff;
}

.admin-header h1 {
  font-size: 18px;
}

.admin-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 16px;
}

.admin-section h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-row input, .form-row select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: #fff;
  width: 90%;
  max-width: 360px;
  border-radius: 12px;
  padding: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ==================== 工具类 ==================== */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ==================== 用神分析系统 ==================== */

/* 锁定区域与项目 */
.locked-section {
  background: #faf8f5;
  border: 1px dashed var(--border);
}

.locked-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.locked-item:last-child {
  margin-bottom: 0;
}

/* 用神卡片 */
.yongshen-card {
  background: var(--card);
}

/* 用神选项（单选/多选） */
.yongshen-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.yongshen-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.yongshen-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.yongshen-option .option-text {
  flex: 1;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 六亲标签 */
.god-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  margin-right: 4px;
}

.god-tag.primary {
  background: var(--primary);
  color: #fff;
}

.god-tag.not-rec {
  background: #fff0e8;
  color: var(--red);
}

/* 推荐理由列表 */
.reason-list {
  background: #faf8f5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.reason-item {
  position: relative;
  padding-left: 16px;
  font-size: 14px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 6px;
}

.reason-item:last-child {
  margin-bottom: 0;
}

.reason-item::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--primary);
  font-weight: 700;
}
