/* ============================================================
   源玛宗源 · 姓名命理分析  H5 样式
   主题：水墨 + 朱红 + 描金
   ============================================================ */
:root {
  --ink: #1f1b16;
  --ink-soft: #4a443c;
  --paper: #f7f2e8;
  --paper-2: #efe7d6;
  --red: #b23a2e;
  --red-deep: #8c2a20;
  --gold: #b8923f;
  --gold-soft: #d9bd7e;
  --line: #d8cbb0;
  --good: #2f7d4f;
  --bad: #b23a2e;
  --shadow: 0 6px 24px rgba(60, 40, 20, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(180, 155, 120, 0.03) 2px, rgba(180, 155, 120, 0.03) 3px
    ),
    radial-gradient(circle at 20% 10%, #fbf6ec 0%, #f1e8d6 60%, #e9dcc2 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, .card-title, .seal-text {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  letter-spacing: 0.05em;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 18px 48px;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 22px;
  background: linear-gradient(135deg, #fffdf8, #f3ead7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.seal {
  display: inline-grid;
  place-items: center;
  width: 56px; height: 56px;
  background: var(--red);
  color: #fff;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  box-shadow: inset 0 0 0 2px var(--gold-soft);
}
.brand-text h1 { margin: 0; font-size: 24px; letter-spacing: 1px; }
.brand-text p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.header-note {
  font-size: 12px; color: var(--red-deep);
  background: #fbeae6; border: 1px dashed var(--red);
  padding: 6px 12px; border-radius: 8px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  margin-top: 20px;
}
.panel {
  position: relative;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
/* 回字纹/云纹角花 —— 纯 CSS SVG inline */
.panel::before {
  content: '';
  position: absolute;
  top: 10px; left: 10px;
  width: 22px; height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='1' y='1' width='20' height='20' rx='2' fill='none' stroke='%238c2a20' stroke-width='1.2'/%3E%3Crect x='5' y='5' width='5' height='5' fill='none' stroke='%238c2a20' stroke-width='1' rx='1'/%3E%3Cpath d='M6,8 L6,16 L14,16 M8,6 L16,6 L16,14' fill='none' stroke='%23d9bd7e' stroke-width='0.8'/%3E%3C/svg%3E") no-repeat;
  opacity: 0.35;
}
.panel::after {
  content: '';
  position: absolute;
  bottom: 10px; right: 10px;
  width: 22px; height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='1' y='1' width='20' height='20' rx='2' fill='none' stroke='%238c2a20' stroke-width='1.2'/%3E%3Crect x='5' y='5' width='5' height='5' fill='none' stroke='%238c2a20' stroke-width='1' rx='1'/%3E%3Cpath d='M6,8 L6,16 L14,16 M8,6 L16,6 L16,14' fill='none' stroke='%23d9bd7e' stroke-width='0.8'/%3E%3C/svg%3E") no-repeat;
  opacity: 0.35;
  transform: rotate(180deg);
}
.panel-title {
  margin: 0 0 16px;
  font-size: 18px;
  padding-left: 12px;
  border-left: 4px solid var(--red);
}

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-weight: 600;
}
.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffdf8;
  font-size: 15px;
  color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 146, 63, 0.18);
}
.date-row { display: flex; align-items: center; gap: 6px; }
.date-row input { text-align: center; padding: 10px 6px; }
.date-row span { color: var(--ink-soft); font-size: 14px; }
.radio-row { display: flex; gap: 18px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 500 !important; cursor: pointer; }
.btn-analyze {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(140, 42, 32, 0.32);
  transition: transform .12s, box-shadow .2s;
}
.btn-analyze:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(140, 42, 32, 0.4); }
.btn-analyze:active { transform: translateY(1px); }
.form-tip { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; }

/* ---------- Placeholder ---------- */
.placeholder {
  display: grid; place-items: center;
  min-height: 420px; text-align: center; color: var(--ink-soft);
}
.ph-icon { font-size: 60px; color: var(--gold); margin-bottom: 14px; }

/* ---------- Result ---------- */
.result { animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.res-head {
  display: flex; align-items: center; gap: 18px;
  padding: 16px; margin-bottom: 18px;
  background: linear-gradient(135deg, #fff8ef, #f6ead2);
  border: 1px solid var(--line); border-radius: 12px;
}
.name-big { font-size: 40px; font-weight: 800; letter-spacing: 4px; color: var(--ink); }
.name-meta { font-size: 13px; color: var(--ink-soft); }

.score-ring {
  --val: 0;
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; margin-left: auto;
  background:
    radial-gradient(closest-side, #fffdf8 70%, transparent 71% 100%),
    conic-gradient(var(--red) calc(var(--val) * 1%), var(--line) 0);
  position: relative;
}
.score-ring .num { font-size: 30px; font-weight: 800; color: var(--red-deep); }
.score-ring .lbl { position: absolute; bottom: 14px; font-size: 11px; color: var(--ink-soft); }

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fffdf8;
}
.card h3 {
  margin: 0 0 12px; font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.card h3::before { content: ""; width: 8px; height: 18px; background: var(--gold); border-radius: 3px; }

/* 八字四柱 */
.bazi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.bazi-cell {
  text-align: center; padding: 10px 4px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbf6ec;
}
.bazi-cell .pillar { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.bazi-cell .lab { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.bazi-cell .wx { font-size: 12px; color: var(--gold); margin-top: 2px; }
.bazi-foot { margin-top: 12px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 13px; background: #f3ead7; color: var(--ink-soft);
  border: 1px solid var(--line);
}
.tag.strong { background: #fbeae6; color: var(--red-deep); border-color: var(--red); }
.tag.weak { background: #e9f3ec; color: var(--good); border-color: #b7d8c2; }
.tag.miss { background: #fff4e0; color: #9a6b13; border-color: var(--gold-soft); }

/* 五行条 */
.wuxing-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.wx-seg { flex: 1; text-align: center; }
.wx-seg .bar {
  height: 10px; border-radius: 6px; background: var(--line);
  position: relative; overflow: hidden;
}
.wx-seg .bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--gold), var(--red));
}
.wx-seg .name { font-size: 12px; margin-top: 4px; }
.wx-seg .cnt { font-size: 13px; font-weight: 700; }

/* 八字四柱（优化版：天干方/地支圆 + 五行着色） */
.pillar-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.g-tag, .z-tag {
  display: inline-block;
  width: 36px; height: 36px; line-height: 36px;
  text-align: center; border-radius: 8px; font-size: 20px; font-weight: 800;
  color: var(--ink); border: 1px solid rgba(0,0,0,0.06);
}
.z-tag { border-radius: 50%; font-size: 18px; width: 32px; height: 32px; line-height: 32px; }
.bazi-cell .lab { margin-top: 6px; font-size: 12px; color: var(--ink-soft); }

/* 五行列表式条图 */
.wuxing-list { display: flex; flex-direction: column; gap: 8px; }
.wx-row { display: flex; align-items: center; gap: 10px; }
.wx-label { width: 24px; font-size: 14px; font-weight: 700; text-align: center; color: var(--ink-soft); }
.wx-bar { height: 10px; flex: 1; background: #f0e8d8; border-radius: 5px; overflow: hidden; }
.wx-fill { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.wx-dots { display: flex; gap: 2px; }
.wx-dots i { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--red-deep); opacity: 0.7; }
.wx-count { width: 20px; font-size: 14px; font-weight: 700; text-align: center; }

/* 五格表 */
.wuge-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wuge-table th, .wuge-table td {
  padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.wuge-table th { color: var(--ink-soft); font-weight: 600; background: #f6efe0; }
.wuge-table td .luck { font-weight: 700; }
.luck-大吉 { color: var(--good); }
.luck-吉 { color: #3f8a5b; }
.luck-半吉 { color: #9a6b13; }
.luck-平 { color: var(--ink-soft); }
.luck-凶 { color: var(--bad); }
.luck-半凶 { color: var(--bad); }

/* 三才 */
.sancai-box { font-size: 14px; }
.sancai-key { font-size: 22px; font-weight: 800; letter-spacing: 3px; color: var(--red-deep); }
.sancai-desc { margin-top: 6px; }
.sancai-advice { margin-top: 6px; color: var(--ink-soft); }

/* 用神 */
.yongshen-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ys-item { background: #fbf6ec; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ys-item .k { font-size: 13px; color: var(--gold); font-weight: 700; }
.ys-item .v { font-size: 14px; margin-top: 4px; }

/* 字明细 */
.chars-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.char-box {
  flex: 1; min-width: 120px; max-width: 180px; text-align: center; padding: 14px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbf6ec;
}
.char-box .c { font-size: 28px; font-weight: 800; }
.char-box .s { font-size: 12px; color: var(--ink-soft); }
.char-box .w { font-size: 13px; color: var(--red-deep); font-weight: 700; margin: 4px 0; }
.char-box .py { font-size: 12px; color: var(--gold); margin: 2px 0; }
.char-box .img { font-size: 11px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }
.char-box .src { font-size: 10px; color: var(--ink-soft); margin-top: 4px; line-height: 1.4; opacity: 0.85; }
.char-box .tag-xi { background: #e9f3ec; color: var(--good); border-color: #b7d8c2; }
.char-box .tag-ji { background: #fbeae6; color: var(--red-deep); border-color: #e8c0b8; }

.dim-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dim { background: #f3ead7; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.dim b { color: var(--red-deep); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 28px; text-align: center; font-size: 12px; color: var(--ink-soft);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 10px; justify-content: center;
  margin: 18px auto 4px; max-width: 920px;
}
.tab {
  flex: 1; max-width: 200px; padding: 11px 0; cursor: pointer;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 10px 10px 0 0; font-size: 15px; font-weight: 700;
  color: var(--ink-soft); transition: all .15s;
}
.tab.active {
  background: var(--red-deep); color: #fff; border-color: var(--red-deep);
  box-shadow: 0 3px 12px rgba(140, 42, 32, .25);
}
.tab-panel { margin-top: 4px; }

/* ---------- 导出栏 ---------- */
.export-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 14px;
}
.eb-tip { font-size: 13px; color: var(--ink-soft); margin-right: auto; }
.eb-btn {
  border: 1px solid var(--gold); background: #fff; color: var(--red-deep);
  border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  font-weight: 600; transition: all .15s;
}
.eb-btn:hover { background: var(--gold); color: #fff; }

/* ---------- 音律分析 ---------- */
.tone-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.tone-item {
  flex: 1; min-width: 70px; text-align: center;
  background: #f3ead7; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px;
}
.t-char { font-size: 22px; font-weight: 700; color: var(--ink); }
.t-py { font-size: 14px; color: var(--red-deep); margin-top: 2px; }
.t-lvl { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.tone-comment {
  margin-top: 10px; font-size: 13px; color: var(--ink-soft);
  background: #f3ead7; border-left: 3px solid var(--gold); padding: 8px 10px; border-radius: 6px;
}

/* ---------- 起名候选列表 ---------- */
.name-list { margin-top: 8px; }
.nl-head { font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; }
.nl-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer; transition: all .15s;
}
.nl-item:hover { border-color: var(--gold); box-shadow: var(--shadow); transform: translateY(-1px); }
.nl-rank {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--paper-2); color: var(--red-deep); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.nl-main { flex: 1; }
.nl-name { font-size: 20px; font-weight: 700; color: var(--ink); }
.nl-name b { color: var(--red-deep); }
.nl-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.nl-score {
  flex: none; min-width: 46px; text-align: center;
  font-size: 24px; font-weight: 800; color: var(--red-deep);
}

/* ---------- 单字拼音 ---------- */
.char-box .py { font-size: 12px; color: var(--gold); margin: 2px 0; }
.char-box .w { font-size: 13px; color: var(--red-deep); font-weight: 700; }

/* ---------- 起名卡片亮点 + 按钮 ---------- */
.nl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn-mini {
  border: 1px solid var(--gold); background: var(--paper-2); color: var(--red-deep);
  border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-mini:hover { background: var(--gold); color: #fff; }
.nl-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; line-height: 1.6;
  background: #f3ead7; color: var(--ink-soft); border: 1px solid var(--line);
}
.tag-tone { background: #eef3f7; color: #2a6f97; border-color: #cfe0ea; }
.tag-img { background: #f6eef0; color: var(--red-deep); border-color: #ecd5d9; }
.nl-hl { margin-top: 5px; font-size: 12px; color: var(--ink-soft); }
.nl-score-unit { font-size: 13px; font-weight: 600; margin-left: 1px; }

/* 导出栏返回按钮 */
.eb-back { margin-right: auto; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink); }
.eb-back:hover { border-color: var(--gold); }

/* 单字意象 */
.char-box .img {
  font-size: 11px; color: var(--ink-soft); margin-top: 3px;
  background: #f3ead7; border-radius: 6px; padding: 1px 6px; display: inline-block;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .res-head { flex-wrap: wrap; }
  .score-ring { margin: 0 auto; }
  .yongshen-grid { grid-template-columns: 1fr; }
  .name-big { font-size: 32px; }
  .tabs { margin: 14px 12px 4px; }
  .nl-name { font-size: 18px; }
}
