/* 鹊桥命理 · 国风命理助手 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&display=swap');

:root {
  --bg: #f7f2ea;
  --card-bg: #faf6ee;
  --border: #e0d5c5;
  --gold: #c9a96e;
  --gold-hover: #b89555;
  --text: #2c2c2c;
  --text-light: #8a7a6a;
  --text-muted: #b0a090;
  --teal-dark: #1a2a1a;
  --teal-mid: #2a3a2a;
  --danger: #c04040;
  --success: #4a7a4a;
  --quote-bg: #f3ede4;
  --report-pad: 40px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-size: 15px;
  line-height: 1.8;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ═══════ 侧边栏 ═══════ */
.sidebar {
  width: 340px;
  flex-shrink: 0;
  padding: 32px 22px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  position: relative;
}
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; left: 36px; right: 36px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.sidebar h1 {
  font-size: 24px;
  font-weight: 900;
  color: #2a1a0a;
  letter-spacing: 4px;
  margin-bottom: 2px;
}
.sidebar .sub {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 2px;
  margin-bottom: 28px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 1px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--gold); }

.gender-group { display: flex; gap: 12px; }
.gender-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.2s;
  background: #fff;
}
.gender-group label:hover { border-color: var(--gold); }
.gender-group input[type="radio"] { accent-color: var(--gold); }

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { display: inline-block; width: auto; padding: 8px 20px; font-size: 13px; }
.btn-cancel {
  display: inline-block; width: auto; padding: 8px 20px;
  font-size: 13px; font-family: inherit; letter-spacing: 1px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text-light); cursor: pointer;
}

/* ── 命盘卡片 ── */
.pan-card {
  margin-top: 20px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
  position: relative;
}
.pan-card.visible { display: block; }
.pan-card::before {
  content: '';
  position: absolute;
  top: -1px; left: 36px; right: 36px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.pan-sizhu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  text-align: center;
  margin-bottom: 12px;
}
.pan-sizhu .zhu {
  padding: 8px 4px;
  background: var(--quote-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.pan-sizhu .zhu .gz { font-size: 20px; font-weight: 900; color: #2a1a0a; letter-spacing: 2px; }
.pan-sizhu .zhu .btx { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.pan-meta { font-size: 13px; line-height: 1.7; }
.pan-meta strong { color: #2a1a0a; }

/* ═══════ 主区域 ═══════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* ── 工具栏 ── */
.toolbar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.tool-btn {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--gold); color: var(--gold); }
.tool-btn.chat-btn { background: var(--gold); color: #fff; border-color: var(--gold); }
.tool-btn.chat-btn:hover { background: var(--gold-hover); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 导出下拉菜单 ── */
.export-wrap { position: relative; display: inline-block; }
.export-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 100;
  padding: 6px 0;
  margin-top: 6px;
}
.export-item {
  display: block;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
}
.export-item:hover { background: var(--quote-bg); }
.export-item:first-child { border-radius: 8px 8px 0 0; }
.export-item:last-child { border-radius: 0 0 8px 8px; }

/* ── 内容区 ── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--report-pad) 32px;
  scroll-behavior: smooth;
}
.content-area::-webkit-scrollbar { width: 4px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── 欢迎页 ── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 1px;
}
.welcome .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.welcome h2 { font-size: 20px; color: var(--text-light); margin-bottom: 8px; }
.welcome p { font-size: 13px; max-width: 360px; line-height: 1.8; }

/* ═══════ 报告渲染 ═══════ */
.report {
  max-width: 780px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.report h1 {
  font-size: 28px;
  font-weight: 900;
  color: #2a1a0a;
  letter-spacing: 4px;
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
}

.report h2 {
  font-size: 20px;
  font-weight: 700;
  color: #2a1a0a;
  margin-top: 32px;
  margin-bottom: 12px;
  letter-spacing: 2px;
  padding-left: 12px;
  border-left: 3px solid var(--gold);
}

.report h3 {
  font-size: 16px;
  font-weight: 700;
  color: #4a3a2a;
  margin-top: 20px;
  margin-bottom: 8px;
}

.report p {
  margin-bottom: 12px;
  line-height: 2;
}

.report strong {
  color: #2a1a0a;
  font-weight: 700;
}

.report hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.report ul, .report ol {
  margin-bottom: 12px;
  padding-left: 24px;
}
.report li { margin-bottom: 6px; }

.report blockquote {
  margin: 16px 0;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal-mid));
  border-radius: 8px;
  color: #d4d4c0;
  line-height: 1.9;
}
.report blockquote strong { color: #e8e4c0; }

.report table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.report table th, .report table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: center;
}
.report table th {
  background: var(--gold);
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}
.report table td { background: #fff; }

/* ── 预渲染排盘表 ── */
.report .pan-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 28px;
  font-size: 15px;
}
.report .pan-table th {
  background: var(--gold);
  color: #fff;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 10px 16px;
  border: 1px solid var(--gold);
  text-align: center;
}
.report .pan-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
  background: #fff;
}
.report .pan-table .label-cell {
  background: var(--quote-bg);
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 1px;
  white-space: nowrap;
}
.report .pan-table .gz-cell {
  font-size: 20px;
  font-weight: 900;
  color: #2a1a0a;
}
.report .pan-table .gz-cell strong {
  letter-spacing: 4px;
}

/* 打字光标 */
.report .cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s infinite;
}
@keyframes blink { 0%,50%{opacity:1} 51%,100%{opacity:0} }

/* ── 对话消息（混入报告区） ── */
.report .chat-msg {
  margin: 16px 0;
  padding: 16px 20px;
  border-radius: 8px;
  line-height: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
}
.report .chat-msg.user {
  background: var(--quote-bg);
  border: 1px solid var(--border);
}
.report .chat-msg.assistant {
  background: #fff;
  border: 1px solid var(--border);
}
.report .chat-msg.assistant::before {
  content: '';
  position: absolute;
  top: -1px; left: 36px; right: 36px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #8aba8a, transparent);
}
.report .chat-msg .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.report .chat-msg.user .label { color: var(--gold); }
.report .chat-msg.assistant .label { color: var(--success); }
.report .chat-msg .chat-text { white-space: normal; }
.report .chat-msg .chat-text > p:last-child { margin-bottom: 0; }

/* 教材引用 */
.report .ref {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 11px;
  background: #eef2f6;
  color: #2a5a7a;
  border: 1px solid #c8d4dc;
  margin: 0 2px;
}

/* ── 年份选择器 ── */
.year-picker {
  max-width: 780px;
  margin: 16px auto;
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.year-picker label { font-size: 14px; font-weight: 600; }
.year-picker select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

/* ── 输入区（对话模式） ── */
.input-area {
  padding: 14px 28px 18px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  display: none;
}
.input-area.visible { display: block; }

.input-row { display: flex; gap: 12px; }
.input-row input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border 0.2s;
}
.input-row input:focus { border-color: var(--gold); }
.input-row button {
  padding: 12px 28px;
  border: none;
  border-radius: 6px;
  background: var(--gold);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.input-row button:hover { background: var(--gold-hover); }
.input-row button:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ── 加载动画 ── */
.loading-dots::after {
  content: '...';
  animation: dots 1.5s infinite;
}
@keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} }

/* ── 响应式 ── */
@media (max-width: 768px) {
  body { overflow: auto; }
  .app {
    display: block;
    height: auto;
    min-height: 100vh;
  }
  .sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 18px 16px;
    overflow: visible;
    position: static;
  }
  .sidebar::after { display: none; }
  .sidebar h1 { font-size: 20px; }
  .sidebar .sub { margin-bottom: 16px; }
  .form-group { margin-bottom: 10px; }
  .pan-card { margin-top: 12px; }
  .main {
    display: block;
    min-height: auto;
  }
  .toolbar {
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .content-area {
    overflow: visible;
    padding: 20px 16px;
    height: auto;
  }
  .report { padding-bottom: 20px; }
  .report .pan-table { font-size: 13px; }
  .report .pan-table th,
  .report .pan-table td { padding: 6px 8px; }
  .input-area {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  }
  .welcome { padding: 40px 20px; height: auto; }
}
