/* ===== 命镜 · 神秘玄学风格 v10 ===== */
:root {
  --bg-deep: #08080f;
  --bg-card: #12121f;
  --bg-card-hover: #18182a;
  --border: #252540;
  --border-gold: rgba(201, 168, 76, 0.3);
  --gold: #c9a84c;
  --gold-dark: #a8883a;
  --gold-light: #e8d5a0;
  --gold-dim: rgba(201, 168, 76, 0.6);
  --text: #e0ddd5;
  --text-dim: #7a7a8a;
  --text-muted: #555566;
  --accent-jade: #6bc47a;
  --accent-fire: #d45a4a;
  --accent-water: #5bafd4;
  --danger: #e74c3c;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

body {
  font-family: "PingFang SC", "Noto Serif SC", "Songti SC", "STSong", serif;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== 背景装饰 ===== */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.bg-bagua {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(201,168,76,0.03) 0%, transparent 70%);
  border-radius: 50%;
}
.bg-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 40% 10%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 55% 60%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 70% 25%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 85% 45%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 65% 80%, rgba(201,168,76,0.4), transparent),
    radial-gradient(1px 1px at 90% 70%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 35% 90%, rgba(201,168,76,0.3), transparent);
}

#app {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px;
}

/* ===== 页面切换动画 ===== */
.page { display: none; animation: pageIn 0.3s ease; }
.page.active { display: block; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 导航栏 ===== */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.nav-back {
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
  transition: color var(--transition);
}
.nav-back:active { color: var(--gold); }
.nav-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 4px;
}
.nav-spacer { width: 50px; }

/* ===== 首页 ===== */
.hero {
  text-align: center;
  padding: 60px 0 30px;
}
.hero-symbol {
  font-size: 56px;
  color: var(--gold);
  margin-bottom: 18px;
  animation: symbolPulse 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(201,168,76,0.25));
}
@keyframes symbolPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}
.hero-name {
  font-size: 44px;
  font-weight: 200;
  letter-spacing: 16px;
  color: var(--gold-light);
  text-indent: 16px;
}
.hero-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
}
.sep-line {
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.sep-diamond {
  color: var(--gold);
  font-size: 8px;
}
.hero-tagline {
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 8px;
  text-indent: 8px;
}

/* 功能菜单卡片 */
.menu {
  padding: 8px 0 24px;
}
.menu-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.menu-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  opacity: 0;
  transition: opacity var(--transition);
}
.menu-card:not(.disabled) { cursor: pointer; }
.menu-card:not(.disabled):active {
  transform: scale(0.985);
  border-color: var(--border-gold);
  background: var(--bg-card-hover);
}
.menu-card:not(.disabled):active::before { opacity: 0.6; }
.menu-card.disabled {
  opacity: 0.3;
}
.menu-card-icon {
  font-size: 28px;
  margin-right: 14px;
  width: 40px;
  text-align: center;
}
.menu-card-body { flex: 1; }
.menu-card-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 2px;
}
.menu-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.menu-card-arrow {
  font-size: 18px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* 首页底部 */
.home-footer {
  text-align: center;
  padding: 30px 0 20px;
}
.home-footer p {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 4px;
}
.home-footer-sub {
  margin-top: 6px;
  font-size: 11px !important;
  color: var(--text-muted) !important;
  letter-spacing: 2px !important;
}

/* ===== 表单 ===== */
.form-intro {
  text-align: center;
  margin-bottom: 24px;
}
.form-intro p {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.form {
  padding-bottom: 30px;
}

/* 表单分区 */
.form-section {
  margin-bottom: 22px;
}
.form-section-label {
  font-size: 13px;
  color: var(--gold-dim);
  margin-bottom: 10px;
  letter-spacing: 3px;
  padding-left: 2px;
}

/* 年月日选择行 */
.date-row {
  display: flex;
  gap: 8px;
}
.date-field {
  flex: 1;
}
.date-field:first-child { flex: 1.2; }
.date-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 2px;
}
.date-select {
  width: 100%;
  padding: 13px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.date-select:focus {
  outline: none;
  border-color: var(--gold-dark);
}

/* 文本输入框 */
.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
  outline: none;
  border-color: var(--gold-dark);
}

/* 时分选择行 */
.time-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.time-field {
  flex: 1;
}
.time-sep {
  font-size: 28px;
  color: var(--gold-dim);
  padding-bottom: 8px;
  font-weight: 200;
}

/* 字段提示 */
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 1px;
  line-height: 1.5;
}
.field-hint.hidden { display: none; }

/* 时辰 / 下拉框 */
.form-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.form-select:focus {
  outline: none;
  border-color: var(--gold-dark);
}

/* 性别 / 历法 切换 */
.form-row {
  display: flex;
  gap: 12px;
}
.form-half { flex: 1; }

.toggle-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  position: relative;
}
.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--border);
}
.toggle-btn input { display: none; }
.toggle-btn.active {
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold-light);
  font-weight: 500;
}

/* 提交按钮 */
.btn-submit {
  width: 100%;
  padding: 16px;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--gold-dark), #9a7a2e);
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 500;
  color: #0a0a0a;
  cursor: pointer;
  letter-spacing: 8px;
  text-indent: 8px;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.btn-submit:active {
  transform: scale(0.98);
  opacity: 0.9;
}
.btn-submit-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-submit:active .btn-submit-glow { opacity: 1; }

/* ===== 结果页 ===== */

/* 个人信息摘要 */
.person-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  text-align: center;
}
.person-name-display {
  font-size: 22px;
  font-weight: 500;
  color: var(--gold-light);
  margin-bottom: 8px;
  letter-spacing: 4px;
}
.person-meta {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 2px;
}
.person-meta-sep {
  margin: 0 8px;
  color: var(--text-muted);
}
.person-location {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 2px;
}
.solar-time-note {
  font-size: 11px;
  color: var(--gold-dim);
  margin-top: 8px;
  letter-spacing: 1px;
  line-height: 1.5;
}

/* 四柱八字卡 */
.pillars-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 14px;
}
.pillars-card h3 {
  font-size: 15px;
  color: var(--gold);
  margin-bottom: 18px;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 500;
}
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  text-align: center;
}
.pillar-col {
  padding: 8px 4px;
}
.pillar-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 2px;
}
.tian-gan {
  font-size: 28px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.3;
}
.di-zhi {
  font-size: 28px;
  font-weight: 600;
  color: var(--gold-light);
  line-height: 1.3;
}
.nayin {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
}
.day-master-note {
  text-align: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 2px;
}
.day-master-note strong {
  color: var(--gold-light);
  font-size: 18px;
  margin-left: 4px;
}

/* 通用信息卡 */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.info-card h3 {
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: 3px;
  font-weight: 500;
}

/* 五行统计 */
.wuxing-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wuxing-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wx-label {
  width: 22px;
  font-size: 14px;
  text-align: center;
  font-weight: 500;
}
.wx-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.wx-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.wx-count {
  width: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}
.wuxing-summary {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* 十神 */
.shishen-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.shishen-item {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  text-align: center;
}
.shishen-pos {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.shishen-name {
  font-size: 14px;
  color: var(--gold-light);
  font-weight: 500;
}

/* 大运 */
.dayun-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.dayun-item {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
  min-width: 60px;
}
.dy-gz {
  font-size: 16px;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: 1px;
}
.dy-age {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* AI 解读 */
.ai-btn {
  width: 100%;
  padding: 16px;
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--gold);
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  margin: 6px 0 14px;
  letter-spacing: 3px;
  font-family: inherit;
  transition: all var(--transition);
}
.ai-btn:active {
  background: rgba(201,168,76,0.08);
  border-color: var(--gold);
}
.ai-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-section { animation: pageIn 0.3s ease; }
.ai-section.hidden { display: none; }
.ai-loading {
  text-align: center;
  padding: 30px;
}
.ai-loading p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 14px;
  letter-spacing: 2px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  line-height: 2;
  font-size: 15px;
  color: var(--text);
}
.ai-result.hidden { display: none; }
.ai-result h4 {
  color: var(--gold);
  margin: 20px 0 10px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 2px;
}
.ai-result h4:first-child { margin-top: 0; }
.ai-result h3 {
  color: var(--gold-light);
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 3px;
}
.ai-result p { margin-bottom: 10px; }
.ai-result strong { color: var(--gold-light); }

/* 五行颜色 */
.wx-金 { color: #f5e6a3; }
.wx-木 { color: #6bc47a; }
.wx-水 { color: #5bafd4; }
.wx-火 { color: #d45a4a; }
.wx-土 { color: #c9a84c; }
/* 五行进度条颜色 */
.wx-bar-fill.wx-金 { background: #f5e6a3; }
.wx-bar-fill.wx-木 { background: #6bc47a; }
.wx-bar-fill.wx-水 { background: #5bafd4; }
.wx-bar-fill.wx-火 { background: #d45a4a; }
.wx-bar-fill.wx-土 { background: #c9a84c; }

/* ===== 命典问答页 ===== */
.kb-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px);
  max-height: calc(100vh - 70px);
}

.kb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.8;
  animation: pageIn 0.25s ease;
}

.kb-msg.user {
  align-self: flex-end;
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid var(--border-gold);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.kb-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.kb-msg.assistant h3,
.kb-msg.assistant h4 {
  color: var(--gold);
  margin: 12px 0 6px;
  font-size: 14px;
}

.kb-msg.assistant strong {
  color: var(--gold-light);
}

.kb-msg.assistant p {
  margin-bottom: 8px;
}

.kb-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-source-tag {
  display: inline-block;
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--gold-dim);
}

.kb-input-area {
  padding: 12px 0;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.kb-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
}

.kb-input:focus {
  border-color: var(--gold-dark);
}

.kb-input::placeholder {
  color: var(--text-muted);
}

.kb-send-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--gold-dark), #9a7a2e);
  border: none;
  border-radius: var(--radius);
  color: #0a0a0a;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition);
}

.kb-send-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.kb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.kb-typing {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kb-typing .dot {
  width: 6px;
  height: 6px;
  background: var(--gold-dim);
  border-radius: 50%;
  animation: kbDotPulse 1.2s ease-in-out infinite;
}

.kb-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.kb-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes kbDotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.3); }
}

/* 快速提问 */
.kb-quick-qs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.kb-quick-btn {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}

.kb-quick-btn:active {
  border-color: var(--gold-dark);
  color: var(--gold-light);
  background: rgba(201,168,76,0.08);
}

/* 知识管理页 */
.kb-manage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kb-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.kb-item-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--gold-light);
}

.kb-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.kb-item-source {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.kb-item-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-item-content.expanded {
  -webkit-line-clamp: unset;
}

.kb-item-toggle {
  font-size: 11px;
  color: var(--gold-dim);
  cursor: pointer;
  margin-top: 4px;
  background: none;
  border: none;
  font-family: inherit;
}

/* 上传表单 */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.upload-form textarea.form-input {
  min-height: 120px;
  resize: vertical;
}

.categories-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}

.cat-tag {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.cat-tag.active {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold-dark);
  color: var(--gold-light);
}

.cat-tag:active {
  border-color: var(--gold-dark);
}
