:root {
  --bg: #0B0A1A;
  --bg-panel: #0A0817;
  --card: rgba(14, 11, 27, 0.72);
  --gold: #E8C268;
  --gold-soft: #D4AF37;
  --violet: #7B5CD9;
  --text: #F3ECDD;
  --muted: #A89FC4;
  --faint: #6E6790;
  --border: rgba(212, 175, 55, 0.28);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.gold-text { color: var(--gold); }
.serif { font-family: "Noto Serif SC", "Songti SC", serif; }

/* 背景光晕 */
.bg-glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg-glow::before, .bg-glow::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5;
}
.bg-glow::before { width: 760px; height: 760px; left: -220px; top: -180px;
  background: radial-gradient(circle, rgba(123,92,217,0.55), transparent 70%); }
.bg-glow::after { width: 680px; height: 680px; right: -120px; bottom: -160px;
  background: radial-gradient(circle, rgba(232,194,104,0.38), transparent 70%); }

/* ---------- 登录 / 注册 ---------- */
.auth-wrap { display: flex; min-height: 100vh; }
.brand-panel {
  width: 560px; padding: 64px; display: flex; flex-direction: column; gap: 26px;
  background: var(--bg-panel); justify-content: center;
}
.brand-title { font-size: 46px; font-weight: 700; color: var(--gold); letter-spacing: 8px; }
.brand-sub { color: var(--muted); font-size: 18px; }
.brand-tag { color: var(--faint); font-size: 15px; line-height: 26px; margin-top: 12px; }
.divider-v { width: 1px; background: var(--border); }
.form-panel { flex: 1; display: flex; align-items: center; justify-content: center; }
.auth-card {
  width: 420px; padding: 38px; background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}
.auth-card h1 { font-size: 27px; color: var(--text); }
.auth-card .sub { color: var(--muted); font-size: 14px; }
label { font-size: 13px; color: var(--muted); }
.input {
  width: 100%; height: 48px; padding: 0 16px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); border-radius: 11px; color: var(--text); font-size: 14px;
}
.input:focus { outline: none; border-color: var(--gold); }
.input::placeholder { color: var(--faint); }
.btn {
  width: 100%; height: 50px; border: none; border-radius: 13px; cursor: pointer;
  background: var(--gold); color: #1A1206; font-family: "Noto Serif SC", serif;
  font-weight: 700; font-size: 17px; letter-spacing: 4px; transition: opacity .2s;
}
.btn:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--gold);
  height: 44px; border-radius: 11px; cursor: pointer; font-size: 14px;
}
.link-gold { color: var(--gold); font-size: 13px; cursor: pointer; text-align: center; }
.hint { color: var(--faint); font-size: 12px; }
.privacy { color: var(--faint); font-size: 11px; line-height: 16px; }

/* ---------- 应用框架 ---------- */
.topnav {
  height: 72px; display: flex; align-items: center; padding: 0 32px;
  background: rgba(10,8,23,0.85); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topnav .logo { color: var(--gold); font-size: 22px; font-weight: 700; }
.topnav .links { display: flex; gap: 40px; margin: 0 auto; }
.topnav .links a { color: var(--text); font-size: 15px; cursor: pointer; text-decoration: none; }
.topnav .links a.active { color: var(--gold); }
.topnav .user { color: var(--muted); font-size: 14px; }
.container { max-width: 980px; margin: 0 auto; padding: 48px 24px 80px; }
.greeting { font-size: 40px; color: var(--gold); margin-bottom: 32px; }
.tools-grid { display: flex; gap: 32px; flex-wrap: wrap; }
.tool-card {
  flex: 1; min-width: 300px; padding: 36px; background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; display: flex; flex-direction: column; gap: 20px;
}
.tool-card .sym { font-size: 64px; color: var(--gold); }
.tool-card h2 { font-size: 26px; color: var(--text); }
.tool-card p { color: var(--muted); font-size: 15px; line-height: 24px; }

/* 表单通用 */
.field { width: 100%; }
textarea.input { height: 120px; padding: 14px 16px; resize: vertical; line-height: 24px; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 32px; }
.page-title { font-size: 36px; color: var(--gold); }
.instr { color: var(--muted); font-size: 16px; }

.result-card {
  width: 100%; max-width: 760px; padding: 40px; background: var(--card);
  border: 1px solid var(--border); border-radius: 22px; display: flex;
  flex-direction: column; gap: 24px; align-items: center;
}
.hexagram { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.yao { width: 160px; height: 8px; border-radius: 4px; background: var(--gold); }
.gua-name { font-size: 28px; color: var(--text); }
.gua-ci { font-size: 18px; color: var(--text); line-height: 28px; text-align: center; }
.gua-xiang { font-size: 16px; color: var(--muted); line-height: 26px; text-align: center; }

/* AI 解说卡片 */
.ai-explain {
  width: 100%; max-width: 720px; margin-top: 4px; padding: 20px 24px;
  background: linear-gradient(135deg, rgba(123,92,217,0.10), rgba(232,194,104,0.08));
  border: 1px solid var(--border); border-left: 3px solid var(--violet);
  border-radius: 14px; text-align: left; box-sizing: border-box;
}
.ai-title {
  font-family: "Noto Serif SC", serif; font-size: 14px; font-weight: 700;
  color: var(--violet); letter-spacing: 2px; margin-bottom: 8px;
}
.ai-body { font-size: 15px; color: var(--text); line-height: 26px; }
.ai-rec { border-left: 3px solid var(--violet); padding-left: 10px; }

.spread-selector { display: flex; gap: 16px; }
.chip {
  padding: 8px 20px; border-radius: 18px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 14px;
}
.chip.active { background: var(--gold); color: #1A1206; font-weight: 700; border-color: var(--gold); }
.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-txt { color: var(--muted); font-size: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.cards-row { display: flex; gap: 32px; flex-wrap: wrap; justify-content: center; }
.cards-row.spread-celtic { gap: 18px; max-width: 760px; margin: 0 auto; }
.cards-row.spread-celtic .tcard { width: 120px; min-height: 210px; padding: 14px; gap: 8px; }
.cards-row.spread-celtic .cname { font-size: 15px; }
.cards-row.spread-celtic .mean { font-size: 12px; line-height: 18px; }
.tcard {
  width: 180px; min-height: 280px; padding: 20px; background: var(--card);
  border: 1px solid var(--border); border-radius: 20px; display: flex; flex-direction: column;
  gap: 14px; align-items: center; text-align: center;
}
.tcard .role { color: var(--gold); font-size: 14px; }
.tcard .cname { color: var(--text); font-size: 18px; font-weight: 700; }
.tcard .pos { color: var(--violet); font-size: 13px; }
.tcard .mean { color: var(--muted); font-size: 14px; line-height: 22px; }

/* 记录 */
.record-list { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 16px; }
.record {
  padding: 24px; background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; display: flex; flex-direction: column; gap: 8px;
}
.record .meta { color: var(--gold); font-size: 13px; }
.record .q { color: var(--muted); font-size: 13px; }
.record .r { color: var(--text); font-size: 14px; line-height: 22px; }
.banner { color: var(--faint); font-size: 13px; line-height: 20px; margin-top: 8px; }
.error { color: #ff8a8a; font-size: 13px; min-height: 16px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #1A1206; padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 700; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ================= 移动端适配 ================= */

/* --- 平板及以下（≤768px）--- */
@media (max-width: 768px) {
  .topnav { padding: 0 16px; gap: 12px; height: 60px; }
  .topnav .logo { font-size: 20px; }
  .topnav .links { gap: 18px; }
  .topnav .links a { font-size: 14px; }
  .topnav .user { font-size: 12px; }

  .container { padding: 24px 14px 60px; max-width: 100%; }
  .greeting { font-size: 26px; margin-bottom: 20px; }
  .page-title { font-size: 26px; }
  .instr { font-size: 14px; }

  .tools-grid { gap: 16px; flex-direction: column; }
  .tool-card { min-width: 0; padding: 24px; gap: 14px; }
  .tool-card .sym { font-size: 48px; }
  .tool-card h2 { font-size: 22px; }
  .tool-card p { font-size: 14px; line-height: 22px; }

  .center-col { gap: 20px; }
  .btn { height: 46px; font-size: 16px; letter-spacing: 2px; }

  .result-card { padding: 24px 18px; gap: 16px; max-width: 100%; }
  .yao { width: 130px; height: 7px; }
  .gua-name { font-size: 22px; }
  .gua-ci { font-size: 16px; line-height: 24px; }
  .gua-xiang { font-size: 14px; line-height: 22px; }

  .ai-explain { padding: 16px 18px; max-width: 100%; }
  .ai-body { font-size: 14px; line-height: 24px; }

  .spread-selector { flex-wrap: wrap; gap: 8px; justify-content: center; }
  .chip { padding: 6px 14px; font-size: 13px; }

  .cards-row { gap: 16px; }
  .tcard { width: 150px; min-height: 240px; padding: 16px; gap: 10px; }
  .tcard .cname { font-size: 16px; }
  .tcard .mean { font-size: 13px; line-height: 20px; }

  .cards-row.spread-celtic { gap: 12px; max-width: 100%; flex-wrap: wrap; }
  .cards-row.spread-celtic .tcard { width: 100px; min-height: 190px; padding: 10px; gap: 6px; }
  .cards-row.spread-celtic .tcard .role { font-size: 11px; }
  .cards-row.spread-celtic .tcard .cname { font-size: 13px; }
  .cards-row.spread-celtic .tcard .pos { font-size: 11px; }
  .cards-row.spread-celtic .tcard .mean { font-size: 11px; line-height: 16px; }

  .record-list { max-width: 100%; gap: 12px; }
  .record { padding: 16px; }
  .record .r { font-size: 13px; line-height: 20px; }

  .banner { font-size: 12px; line-height: 18px; }
  .loading { padding: 28px 16px; }
  .spinner { width: 36px; height: 36px; border-width: 3px; }
}

/* --- 手机（≤420px，如 iPhone 14 Pro 393px）--- */
@media (max-width: 420px) {
  .topnav { padding: 0 10px; gap: 8px; height: 52px; align-items: center; }
  .topnav .logo { font-size: 18px; letter-spacing: 1px; }
  .topnav .links { gap: 12px; margin: 0; flex-wrap: wrap; justify-content: center; }
  .topnav .links a { font-size: 13px; padding: 4px 0; }
  .topnav .user { font-size: 11px; white-space: nowrap; }

  .container { padding: 18px 10px 50px; }
  .greeting { font-size: 22px; margin-bottom: 14px; }
  .page-title { font-size: 22px; }
  .instr { font-size: 13px; }

  .tool-card { padding: 20px; border-radius: 16px; gap: 10px; }
  .tool-card .sym { font-size: 40px; }
  .tool-card h2 { font-size: 20px; }
  .tool-card p { font-size: 13px; line-height: 20px; }
  .btn { height: 44px; font-size: 15px; letter-spacing: 1px; border-radius: 11px; }

  .center-col { gap: 14px; }
  textarea.input { height: 90px; font-size: 14px; }
  .input { height: 42px; font-size: 14px; }

  .result-card { padding: 18px 12px; gap: 12px; border-radius: 16px; }
  .hexagram { gap: 8px; }
  .yao { width: 110px; height: 6px; }
  .gua-name { font-size: 20px; }
  .gua-ci { font-size: 14px; line-height: 22px; }
  .gua-xiang { font-size: 13px; line-height: 20px; }

  .ai-explain { padding: 12px 14px; border-radius: 10px; }
  .ai-title { font-size: 13px; margin-bottom: 6px; }
  .ai-body { font-size: 13px; line-height: 22px; }

  .spread-selector { gap: 6px; }
  .chip { padding: 6px 10px; font-size: 12px; border-radius: 14px; }

  /* 单张牌：占满宽度，居中 */
  .cards-row { gap: 10px; }
  .tcard { width: 100%; max-width: 200px; min-height: 220px; padding: 16px 12px; gap: 8px; }
  .tcard .role { font-size: 13px; }
  .tcard .cname { font-size: 16px; }
  .tcard .pos { font-size: 12px; }
  .tcard .mean { font-size: 13px; line-height: 20px; }

  /* 三张牌：一行三张，缩小 */
  .cards-row:not(.spread-celtic) .tcard { width: calc((100% - 20px) / 3); min-height: 200px; padding: 12px 8px; gap: 6px; }
  .cards-row:not(.spread-celtic) .tcard .cname { font-size: 14px; }
  .cards-row:not(.spread-celtic) .tcard .pos { font-size: 11px; }
  .cards-row:not(.spread-celtic) .tcard .mean { font-size: 11px; line-height: 16px; }

  /* 凯尔特十字：2 列网格 */
  .cards-row.spread-celtic { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 100%; }
  .cards-row.spread-celtic .tcard { width: 100%; min-height: 160px; padding: 10px 8px; gap: 4px; border-radius: 14px; }
  .cards-row.spread-celtic .tcard .role { font-size: 11px; line-height: 14px; }
  .cards-row.spread-celtic .tcard .cname { font-size: 13px; }
  .cards-row.spread-celtic .tcard .pos { font-size: 10px; }
  .cards-row.spread-celtic .tcard .mean { font-size: 11px; line-height: 15px; }

  .record { padding: 12px; border-radius: 14px; gap: 6px; }
  .record .meta { font-size: 12px; }
  .record .q { font-size: 12px; }
  .record .r { font-size: 12px; line-height: 18px; }

  .banner { font-size: 11px; line-height: 16px; margin-top: 4px; }
  .loading { padding: 20px 12px; gap: 12px; }
  .spinner { width: 32px; height: 32px; border-width: 3px; }
  .loading-txt { font-size: 13px; }

  /* 登录/注册页适配 */
  .auth-wrap { flex-direction: column; }
  .brand-panel { width: 100%; padding: 32px 20px; gap: 16px; }
  .brand-title { font-size: 30px; letter-spacing: 4px; }
  .brand-sub { font-size: 14px; }
  .brand-tag { font-size: 13px; line-height: 20px; }
  .divider-v { display: none; }
  .form-panel { padding: 20px 0; }
  .auth-card { width: 100%; max-width: 340px; padding: 24px 18px; gap: 12px; border-radius: 16px; }
  .auth-card h1 { font-size: 22px; }
  .auth-card .sub { font-size: 13px; }
  .input { height: 40px; font-size: 13px; padding: 0 12px; }
  .btn { height: 42px; font-size: 15px; }
  .btn-ghost { height: 38px; font-size: 13px; }
}
