:root {
  --bg: #0a0c10;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --gold: #d4a843;
  --gold-soft: rgba(212, 168, 67, 0.18);
  --text: #e8ecf3;
  --dim: #8b95a5;
  --green: #3fb27f;
  --red: #e05252;
  --blue: #4f8ef7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.7;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(212, 168, 67, 0.09), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(79, 142, 247, 0.07), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 18px 60px;
}

/* ── 头部 ── */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 26px;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}
.topbar .sub { color: var(--dim); font-size: 12px; letter-spacing: 0.04em; }

/* ── 卡片 ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
}
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.sec-head h2 {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin: 0;
}
.who { color: var(--dim); font-size: 12px; }
.dim { color: var(--dim); }

/* ── 表单 ── */
.form .row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.form .row:first-child { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 11px; color: var(--dim); letter-spacing: 0.06em; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline input { width: 120px; }

input[type="text"], input[type="number"], select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.18s, background 0.18s;
}
input:focus, select:focus { border-color: rgba(212, 168, 67, 0.55); background: rgba(255, 255, 255, 0.07); }
select option { background: #11141a; }

.loc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.chips { display: flex; gap: 8px; }
.chip {
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 18px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
}
.chip input { display: none; }
.chip i { font-style: normal; color: var(--dim); }
.chip:has(input:checked) { border-color: rgba(212, 168, 67, 0.6); background: var(--gold-soft); }
.chip:has(input:checked) i { color: var(--gold); }

.check { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; margin: 4px 0 16px; }
.check input { width: 14px; height: 14px; accent-color: var(--gold); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: 0.18s;
}
.btn:hover { border-color: rgba(212, 168, 67, 0.4); }
.btn.primary {
  background: linear-gradient(135deg, #d9b154, #b98b2c);
  border-color: transparent;
  color: #1a1200;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 9px 34px;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { color: var(--dim); }
.hint { min-height: 18px; margin: 10px 0 0; font-size: 12px; color: var(--dim); }
.hint.bad { color: var(--red); }

/* ── 信息表 ── */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; }
.kv-row { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px dotted rgba(255, 255, 255, 0.06); }
.kv-row dt { color: var(--dim); font-size: 12px; min-width: 74px; margin: 0; }
.kv-row dd { margin: 0; font-size: 13px; color: var(--text); }

/* ── 十二宫盘 ── */
.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(150px, auto));
  gap: 6px;
}
.cell {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.cell.is-ming { border-color: rgba(212, 168, 67, 0.55); background: rgba(212, 168, 67, 0.07); }
.cell.is-shen { border-color: rgba(79, 142, 247, 0.35); }
.cell-head { display: flex; align-items: baseline; gap: 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.gz { font-size: 11px; color: var(--dim); letter-spacing: 0.06em; }
.pname { font-family: "Songti SC", "SimSun", serif; font-size: 13px; color: var(--gold); letter-spacing: 0.08em; }
.tag {
  font-style: normal; font-size: 10px; padding: 0 4px; border-radius: 4px; line-height: 1.5;
}
.tag.ming { background: var(--gold); color: #1a1200; }
.tag.shen { background: rgba(79, 142, 247, 0.25); color: var(--blue); }

.majors { display: flex; flex-wrap: wrap; gap: 4px 10px; min-height: 24px; }
.star { font-size: 12px; color: #cdd6e3; white-space: nowrap; }
.star.major { font-family: "Songti SC", "SimSun", serif; font-size: 17px; color: #f2e6c8; letter-spacing: 0.03em; }
.sihua { font-size: 11px; margin-left: 1px; font-weight: 700; }
.br { font-style: normal; font-size: 10px; margin-left: 2px; padding: 0 2px; border-radius: 3px; }
.br-good { color: #7fd0a5; }
.br-mid { color: #b9c2ce; }
.br-bad { color: #e08a8a; }

.empty { font-size: 11px; color: var(--dim); }
.others { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.grp { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 11px; color: #93a1b3; }
.grp .star { font-size: 11px; color: #93a1b3; }
.grp.sha .star { color: #d08e8e; }
.grp.minor .star { color: #7d8798; }
.dx { position: absolute; right: 8px; bottom: 6px; font-size: 10px; color: rgba(212, 168, 67, 0.65); }

.center {
  border: 1px solid rgba(212, 168, 67, 0.3);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, rgba(212, 168, 67, 0.12), rgba(255, 255, 255, 0.02) 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 14px;
}
.c-title { font-family: "Songti SC", "SimSun", serif; font-size: 24px; letter-spacing: 0.16em; color: var(--gold); }
.c-line { font-size: 12px; color: #cfd7e4; }
.c-line.dim { color: var(--dim); font-size: 11px; }

/* ── 三方四正 ── */
.read { margin: 0 0 12px; font-size: 13px; color: #c3ccd9; }
.read b { color: var(--gold); font-weight: 600; }
.trio-wrap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.trio { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(255, 255, 255, 0.02); }
.trio-head { display: flex; justify-content: space-between; align-items: baseline; font-family: "Songti SC", "SimSun", serif; color: var(--gold); font-size: 13px; margin-bottom: 6px; letter-spacing: 0.06em; }
.trio-stars { font-size: 12px; display: flex; flex-wrap: wrap; gap: 2px 8px; }

/* ── 四化 ── */
.sh-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px dotted rgba(255, 255, 255, 0.06); }
.sh-badge { text-align: center; font-size: 12px; border-radius: 6px; padding: 2px 0; letter-spacing: 0.1em; }
.sh-star { font-size: 13px; color: #dfe6f0; }
.sh-mean { font-size: 12px; }

/* ── 格局 ── */
.pat { padding: 12px 0; border-bottom: 1px dotted rgba(255, 255, 255, 0.07); }
.pat:last-child { border-bottom: none; }
.pat-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.pat-name { font-family: "Songti SC", "SimSun", serif; font-size: 15px; color: #f0e2bf; letter-spacing: 0.08em; }
.pat-level { font-size: 11px; border: 1px solid; border-radius: 4px; padding: 0 6px; line-height: 1.6; }
.pat-desc { font-size: 12.5px; color: #b8c2d0; }
.pat-break { font-size: 11.5px; color: #d08e8e; margin-top: 3px; }
.pat-src { font-size: 11px; margin-top: 2px; }

/* ── 表格 ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px dotted rgba(255, 255, 255, 0.07); }
.tbl th { color: var(--dim); font-weight: 500; font-size: 11.5px; letter-spacing: 0.06em; }
.tbl tr.cur td { background: rgba(212, 168, 67, 0.1); color: #f0e2bf; }

.ly-bar { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 12px; }

.foot { color: var(--dim); font-size: 11.5px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 26px; }
.foot p { margin: 4px 0; }

/* ── 白话解读 ── */
.verse-intro p { margin: 4px 0; font-size: 13.5px; color: #d6dde8; }
.verse-intro b { color: var(--gold); }
.verse-h {
  font-family: "Songti SC", "SimSun", serif;
  color: var(--gold);
  font-size: 14.5px;
  letter-spacing: 0.1em;
  margin: 18px 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--gold);
}
.verse-huas { display: flex; flex-direction: column; gap: 6px; }
.verse-hua { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: #c6d0dd; }
.verse-hua b { color: #f0e2bf; }
.verse-badge { display: inline-block; min-width: 44px; text-align: center; border-radius: 5px; padding: 1px 0; font-size: 11px; }
.verse-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.verse-list li { font-size: 12.5px; color: #c0cad8; line-height: 1.8; }
.verse-list b { color: #f0e2bf; }
.verse-star { font-style: normal; color: var(--gold); font-weight: 600; margin-right: 2px; }
.verse-line { font-size: 12.5px; color: #c6d0dd; padding: 6px 0; border-bottom: 1px dotted rgba(255,255,255,0.07); }
.verse-line b { color: var(--gold); }
.verse-gloss { margin-top: 16px; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
.verse-gloss summary { cursor: pointer; color: var(--gold); font-size: 13px; letter-spacing: 0.05em; }
.verse-gloss-body p { font-size: 12.5px; color: #b3bdcc; margin: 8px 0; line-height: 1.8; }
.verse-gloss-body b { color: #e6d9b8; }

/* ── 窄屏 ── */
@media (max-width: 860px) {
  .form .row, .form .row:first-child { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .trio-wrap { grid-template-columns: 1fr 1fr; }
  .board { grid-template-rows: repeat(4, minmax(190px, auto)); }
  .sh-row { grid-template-columns: 56px 1fr; }
  .sh-mean { display: none; }
}

/* ── 手机屏 ── */
@media (max-width: 640px) {
  html { font-size: 15px; }
  .wrap { padding: 16px 10px 40px; }
  .topbar { flex-direction: column; gap: 2px; }
  .brand { font-size: 21px; }
  .panel { padding: 14px 12px; border-radius: 12px; }
  .form .row, .form .row:first-child { grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }
  input[type="text"], input[type="number"], select { padding: 12px 12px; font-size: 16px; }
  .chips { flex: 1; }
  .chip { flex: 1; justify-content: center; padding: 10px 0; }
  .actions .btn { flex: 1 1 auto; padding: 12px 0; }
  .actions .btn.primary { flex-basis: 100%; padding: 14px 0; font-size: 15px; }

  .board { grid-template-rows: repeat(4, minmax(118px, auto)); gap: 3px; }
  .cell { padding: 4px 5px; border-radius: 6px; }
  .cell-head { font-size: 10px; padding-bottom: 2px; gap: 3px; }
  .pname { font-size: 11px; }
  .star { font-size: 9px; }
  .star.major { font-size: 13px; }
  .br { font-size: 8px; }
  .grp { font-size: 8.5px; gap: 1px 4px; }
  .grp .star { font-size: 8.5px; }
  .empty { font-size: 8px; }
  .dx { font-size: 8px; right: 3px; bottom: 2px; }
  .center { padding: 6px; }
  .c-title { font-size: 16px; }
  .c-line { font-size: 9.5px; }
  .c-line.dim { font-size: 8.5px; }

  .trio-wrap { grid-template-columns: 1fr; gap: 6px; }
  .kv { grid-template-columns: 1fr; }
  .kv-row dd { font-size: 12.5px; }
  .sh-row { grid-template-columns: 60px 1fr; gap: 8px; }
  .sh-mean { display: none; }
  .verse-list li { font-size: 12px; line-height: 1.7; }
  .verse-intro p { font-size: 13px; }
  .tbl th, .tbl td { padding: 6px 4px; font-size: 11.5px; }
}

/* ── 打印 ── */
@media print {
  body { background: #fff; color: #111; }
  body::before { display: none; }
  .form, .foot, .topbar, .actions, .ly-bar { display: none !important; }
  .panel { break-inside: avoid; border: 1px solid #ddd; background: #fff; }
  .cell { background: #fff; border-color: #ccc; }
  .sec-head h2, .pname, .c-title, .trio-head { color: #6b4a00; }
  .star, .cell .star { color: #222 !important; }
  .pat-desc, .read, .sh-star { color: #222; }
}
