/* ============================================
   纳甲六爻AI版 - 主样式表
   配色方案参考 奇门遁甲 qimen.chat
   字体：楷体/宋体系列 · 典雅中国风
   ============================================ */

/* ========== CSS 变量（奇门遁甲配色） ========== */
:root {
  --ink: #1a3a52;
  --ink-light: #3d4a52;
  --ink-muted: #82776b;
  --surface: #fffdfa;
  --surface-soft: #f8f2e9;
  --bg-body: #F5F0E6;
  --accent: #b8905b;
  --accent-strong: #9a7545;
  --accent-soft: #f4ede3;
  --warm: #a8763d;
  --warm-soft: #f6eee3;
  --border: #dcd3d1;
  --border-light: #e4d8c8;
  --border-strong: #d4c1aa;
  --gold: #c8a96e;
  --gold-light: #e0cfa0;
  --cinnabar: #a8763d;
  --cinnabar-light: #d4b896;

  --text-primary: #2f3a35;
  --text-secondary: #82776b;
  --text-muted: #a09080;
  --text-light: #fffdfa;

  --shadow-sm: 0 1px 3px rgba(44, 62, 80, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 62, 80, 0.08);
  --shadow-lg: 0 8px 30px rgba(44, 62, 80, 0.1);
  --shadow-gold: 0 0 20px rgba(200, 169, 110, 0.2);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-serif: 'Noto Serif SC', 'Songti SC', 'STSong', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
  --font-sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --nav-height: 64px;
  --max-width: 1200px;
}

/* ========== Reset ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

::selection { background: var(--accent-soft); color: var(--ink); }

/* ========== 导航栏 ========== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: linear-gradient(135deg, var(--ink) 0%, #143040 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 20px rgba(26, 58, 82, 0.15);
  border-bottom: 1px solid var(--warm);
}

.navbar-inner {
  width: 100%;
  max-width: var(--max-width);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.3em;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-brand .logo-icon { font-size: 1.4em; }
.navbar-brand .logo-sub {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--gold-light);
  margin-left: 4px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--surface);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover { background: rgba(200, 169, 110, 0.15); color: var(--gold-light); }
.nav-link.active { background: rgba(200, 169, 110, 0.2); color: var(--gold); }
.nav-link .nav-icon { font-size: 1.1em; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--warm));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85em;
  color: var(--ink);
  cursor: pointer;
  border: 2px solid var(--gold);
}

.user-name { color: var(--surface); font-size: 0.85em; font-weight: 500; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1.5em;
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 767px) {
  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    background: #143040;
    flex-direction: column;
    padding: 12px;
    gap: 2px;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    border-bottom: 2px solid var(--warm);
    box-shadow: var(--shadow-lg);
  }
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-link { width: 100%; padding: 12px 16px; }
  .nav-toggle { display: block; }
  .user-name { display: none; }
  .navbar-brand { font-size: 1.1em; }
}

/* ========== 页面容器 ========== */
.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
}

.page-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 40px 20px 32px;
  background: linear-gradient(180deg, var(--surface) 0%, transparent 100%);
  border-radius: var(--radius-lg);
}

.page-header h1 {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.8em;
  color: var(--ink);
  letter-spacing: 4px;
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95em;
  margin-top: 8px;
  letter-spacing: 2px;
}

.page-header .divider {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(184, 144, 91, 0.2));
  margin: 16px auto 0;
  border-radius: 2px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.3s, border-color 0.3s;
}

.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.card-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1em;
  color: var(--ink);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.card-title .card-icon { font-size: 1.1em; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9em;
  color: var(--ink-light);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95em;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 144, 91, 0.15);
}

.form-textarea { resize: vertical; min-height: 80px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 0.95em;
  font-weight: 600;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 1px;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: rgba(184, 144, 91, 0.08);
  color: var(--accent);
  border-color: rgba(184, 144, 91, 0.35);
}
.btn-primary:hover:not(:disabled) {
  background: rgba(184, 144, 91, 0.16);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184, 144, 91, 0.2);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-danger {
  background: rgba(168, 118, 61, 0.08);
  color: var(--cinnabar);
  border-color: rgba(168, 118, 61, 0.35);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(168, 118, 61, 0.16);
}

.btn-sm { padding: 6px 14px; font-size: 0.85em; }
.btn-lg { padding: 14px 32px; font-size: 1.05em; }
.btn-full { width: 100%; }

/* ========== 排盘布局 ========== */
.paipan-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

.paipan-input-panel { position: sticky; top: calc(var(--nav-height) + 24px); }

/* 右侧排盘结果卡片宽度：让星煞正好两列排开 */
.paipan-layout > div:last-child .card { max-width: 660px; }

@media (max-width: 900px) {
  .paipan-layout { grid-template-columns: 1fr; }
  .paipan-input-panel { position: static; }
  .paipan-layout > div:last-child .card { max-width: none; }
}

/* ========== 六爻选择器（悬停弹出式） ========== */
.yao-container {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin: 12px 0;
}

.yao-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border-light);
}
.yao-row:last-child { border-bottom: none; }

.yao-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.9em;
  color: var(--ink);
  min-width: 42px;
}

/* 选择器包装器 */
.yao-selector-wrapper {
  position: relative;
  width: 150px;
}

.yao-selector-current {
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}

.yao-selector-wrapper.selected .yao-selector-current {
  border-color: var(--accent);
  background: var(--surface);
}

/* 当前选中爻的状态颜色 */
.yao-selector-current.cur-syang {
  border-color: var(--ink-light);
  color: var(--ink-light);
}
.yao-selector-current.cur-syin {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}
.yao-selector-current.cur-lyang {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}
.yao-selector-current.cur-lyin {
  border-color: var(--warm);
  color: var(--warm);
}

/* 弹出面板 */
.yao-options-popover {
  display: none;
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  margin-left: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(44, 62, 80, 0.12);
  z-index: 100;
  width: 150px;
  padding: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.yao-options-popover.visible {
  display: block;
  opacity: 1;
  visibility: visible;
}

.yao-option {
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  transition: background 0.15s;
}
.yao-option:hover { background: var(--surface-soft); }

.yao-option.syang { color: var(--ink-light); }
.yao-option.syin  { color: var(--text-secondary); }
.yao-option.lyang { color: var(--cinnabar); }
.yao-option.lyin  { color: var(--warm); }

/* 移动端：弹出改为垂直方向 */
@media (max-width: 767px) {
  .yao-selector-wrapper { width: 120px; }
  .yao-options-popover {
    left: auto;
    right: 0;
    top: auto;
    bottom: 100%;
    transform: none;
    margin-left: 0;
    margin-bottom: 6px;
    width: 130px;
  }
}

/* 摇卦动画 */
@keyframes coinFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.coin-animating .yao-selector-current {
  animation: coinFlash 0.25s ease-in-out;
}

/* ========== 随机起卦区域 ========== */
.random-section {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.random-section .btn { flex: 1; }

/* 摇卦按钮 — 乾隆铜钱图样 */
#coinTossBtn::before {
  content: '';
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='46' fill='%23c49a3c' stroke='%238a6a1f' stroke-width='3'/%3E%3Crect x='30' y='30' width='40' height='40' rx='4' fill='%23c49a3c' stroke='%238a6a1f' stroke-width='2'/%3E%3Ctext x='50' y='38' text-anchor='middle' font-size='14' font-weight='700' fill='%238a6a1f' font-family='serif'%3E乾隆%3C/text%3E%3Ctext x='50' y='60' text-anchor='middle' font-size='11' font-weight='600' fill='%238a6a1f' font-family='serif'%3E通宝%3C/text%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  vertical-align: middle;
  flex-shrink: 0;
}
.paipan-input-panel .random-section .btn,
#generateBtn {
  color: #5b7fa0;
}

/* ========== 排盘结果 ========== */
.gua-header {
  background: var(--surface);
  color: var(--text-primary);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.gua-header-top {
  margin-bottom: 8px;
}

.gua-header .gua-question {
  font-family: var(--font-sans);
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.gua-header .gua-label {
  font-weight: 700;
  color: var(--ink);
}

.gua-header .gua-meta {
  font-size: 0.88em;
  color: var(--text-secondary);
  line-height: 1.7;
}

.gua-header .gua-main {
  font-size: 1em;
  font-weight: 600;
  color: var(--accent-strong);
  font-family: var(--font-serif);
}

/* 星煞紧凑版 — 置于卦头内 */
.shensha-compact {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shensha-chip {
  font-size: 0.82em;
  color: var(--text-secondary);
  background: var(--surface-soft);
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.shensha-chip .shensha-name {
  font-weight: 600;
  color: var(--ink-light);
  margin-right: 0;
}

.shensha-sep {
  margin: 0 2px;
  color: var(--text-muted);
}

.paipan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.paipan-table td {
  padding: 5px 2px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  white-space: nowrap;
}

/* 六神列 */
.paipan-table td.liu-shen-cell {
  text-align: left;
  color: var(--ink-light);
  font-weight: 500;
  width: 10%;
  padding-left: 6px;
  padding-right: 4px;
}

/* 伏藏列 */
.paipan-table td.fucang-cell {
  text-align: left;
  width: 14%;
  padding-left: 2px;
  padding-right: 4px;
  font-size: 0.85em;
}

/* 主卦列 */
.paipan-table td.gua-cell {
  text-align: left;
  padding-left: 4px;
  padding-right: 4px;
  font-size: 1em;
  white-space: nowrap;
}

/* 本卦中的箭头标记，嵌入本卦末尾 */
.paipan-table .gua-arrow {
  color: var(--warm);
  font-weight: 700;
  font-size: 0.9em;
  margin-left: 2px;
}

/* 变卦列 */
.paipan-table td.bian-cell {
  text-align: left;
  padding-left: 0;
  padding-right: 6px;
  font-size: 1em;
  white-space: nowrap;
}

/* 删除废弃样式 */
.paipan-table .gua-gap,
.paipan-table td.arrow-cell,
.paipan-table td.gua-cell.bian-cell,
.paipan-table td.gua-cell .gua-arrow-suffix {
  display: none;
}

/* 宫·卦名行 — 与数据行风格一致，无上下分隔线 */
.paipan-table tr.gua-info-row td {
  border-bottom: 1px solid var(--border-light);
  padding: 8px 6px;
  font-size: 0.95em;
}
.paipan-table tr.gua-info-row td.liu-shen-cell {
  font-family: var(--font-serif);
  color: var(--ink);
  letter-spacing: 1px;
  font-size: 1em;
  text-align: left;
  padding-left: 6px;
}
.paipan-table tr.gua-info-row td.gua-cell {
  text-align: left;
  padding-left: 4px;
}
.paipan-table tr.gua-info-row td.gua-cell strong {
  color: var(--accent-strong);
}
.paipan-table tr.gua-info-row td.bian-cell {
  text-align: left;
  padding-left: 0;
}

.paipan-table tr:nth-child(even) { background: var(--surface-soft); }
.paipan-table tr:hover { background: var(--warm-soft); }

.yao-symbol-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
}

.yao-symbol-css {
  height: 14px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.yao-symbol-css .line {
  background: var(--text-primary);
  height: 3px;
  border-radius: 2px;
  width: 22px;
}

.yao-symbol-css.yin {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.yao-symbol-css.yin .line.broken { width: 9px; }

.move-mark { color: var(--warm); font-weight: 700; font-size: 1.1em; }
.bian-info { color: var(--accent) !important; font-weight: 600; }
.world-mark { color: var(--warm) !important; font-weight: 700; }
.response-mark { color: var(--accent) !important; font-weight: 700; }
.fucang-info { color: var(--text-muted); font-size: 0.85em; font-style: italic; }

/* ========== 星煞 ========== */
.shensha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.shensha-item {
  background: var(--surface-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

.shensha-name { color: var(--ink-light); font-weight: 600; }
.shensha-item .shensha-sep { margin: 0 3px; color: var(--text-muted); }

/* ========== 解卦区域 ========== */
.jiegua-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid var(--accent);
}

.jiegua-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.2em;
  color: var(--ink);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.jiegua-card {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}

.jiegua-card-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

/* ========== 操作按钮区 ========== */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.action-bar .btn { flex: 1; min-width: 120px; }

/* ========== 案例列表 ========== */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.case-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s;
}

.case-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 144, 91, 0.12);
  transform: translateY(-2px);
}

.case-card .case-question {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-card .case-preview { font-size: 0.85em; color: var(--text-secondary); margin-bottom: 8px; }
.case-card .case-date { font-size: 0.8em; color: var(--text-muted); }
.case-card .case-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

/* ========== 模态框 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26, 58, 82, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: modalFadeIn 0.3s ease;
  border: 1px solid var(--border-strong);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: none;
  border: none;
  font-size: 1.5em;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal h2 { font-family: var(--font-serif); font-weight: 700; margin-bottom: 24px; color: var(--ink); }

/* ========== 登录/注册 ========== */
.auth-container { max-width: 420px; margin: 60px auto; padding: 0 20px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  border: 1px solid rgba(184, 144, 91, 0.35);
}

.auth-card h1 {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.8em;
  text-align: center;
  color: var(--ink);
  margin-bottom: 4px;
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.auth-error {
  background: #fef2f2;
  color: var(--cinnabar);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  margin-bottom: 16px;
  display: none;
}

.auth-success {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  margin-bottom: 16px;
  display: none;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  min-width: 200px;
  max-width: 360px;
  border-left: 4px solid var(--accent);
}

.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--cinnabar); }
.toast.info { border-left-color: var(--gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== AI 断卦 ========== */
#aiContent {
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  padding: 8px 4px;
}

.ai-msg {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.ai-msg:last-child {
  border-bottom: none;
}

.ai-msg-label {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ai-msg.user .ai-msg-label {
  color: var(--accent-strong);
}

.ai-msg-body {
  font-size: 0.92em;
  line-height: 1.7;
  color: var(--text-primary);
}

.ai-msg.user .ai-msg-body {
  background: var(--accent-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 4px;
}

.msg-actions .btn {
  font-size: 0.75em;
  padding: 3px 8px;
  min-width: auto;
}

/* 追问输入区 */
.followup-area {
  margin-top: 16px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.followup-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.followup-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 144, 91, 0.12);
}

.followup-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.followup-actions .btn {
  font-size: 0.85em;
}

/* ========== 加载动画 ========== */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(245, 240, 230, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  font-family: var(--font-serif);
  color: var(--ink);
  gap: 12px;
  font-size: 1.1em;
}

.loading-overlay.hidden { display: none; }

/* ========== 空状态 ========== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3em; margin-bottom: 16px; }
.empty-state p { font-size: 1em; margin-bottom: 20px; }

/* ========== 响应式 ========== */
@media (max-width: 767px) {
  body { padding-top: 56px; }
  :root { --nav-height: 56px; }

  .page-container { padding: 16px 12px; }
  .page-header { padding: 24px 16px 20px; }
  .page-header h1 { font-size: 1.4em; }

  .card { padding: 16px; border-radius: var(--radius-md); }

  .row-3 { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .row-2 { grid-template-columns: 1fr 1fr; gap: 6px; }

  .gua-header { padding: 16px; }
  .gua-header .gua-main { font-size: 1.1em; }
  .paipan-table { font-size: 0.8em; }
  .paipan-table th, .paipan-table td { padding: 6px 4px; }

  .shensha-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }

  .action-bar { flex-direction: column; }
  .action-bar .btn { width: 100%; }

  .cases-grid { grid-template-columns: 1fr; }
  .modal { padding: 24px 20px; }
  .random-section { flex-direction: column; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .paipan-layout { grid-template-columns: 320px 1fr; gap: 16px; }
}

/* ========== 页面过渡 ========== */
.page-transition { animation: pageIn 0.3s ease; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (display-mode: standalone) {
  .navbar { padding-top: env(safe-area-inset-top, 0); }
  body { padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0)); }
}
