/* 星命阁 FortuneStar — 玄学深色主题 */
:root {
  --bg: #0b0d17;
  --panel: #141828;
  --panel2: #1a1f33;
  --gold: #d4af37;
  --gold2: #f0d78c;
  --text: #dfe3f0;
  --muted: #8b93ad;
  --red: #e05a5a;
  --green: #6fcf97;
  --blue: #6ba6f5;
  --line: #2a3050;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1b2140 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  min-height: 100vh;
}
h1, h2, h3, .logo { font-family: "SimSun", "Noto Serif SC", serif; }
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 24, .8);
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo { font-size: 40px; color: var(--gold); text-shadow: 0 0 18px rgba(212,175,55,.5); }
.brand h1 { font-size: 24px; letter-spacing: 4px; color: var(--gold2); }
.brand h1 em { font-style: normal; font-size: 14px; color: var(--muted); letter-spacing: 1px; }
.brand p { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-top: 3px; }
#todaybar { font-size: 13px; color: var(--gold2); text-align: right; line-height: 1.7; }
.premium-entry { display: inline-block; margin-bottom: 6px; color: #d9b3ff !important;
  background: linear-gradient(135deg, #5b21b6, #a855f7); padding: 6px 14px; border-radius: 20px;
  text-decoration: none; font-size: 13px; letter-spacing: 1px;
  box-shadow: 0 0 14px rgba(168,85,247,.4); }
.lang-btn { background: var(--panel2); color: var(--gold2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 16px; font-size: 12px; cursor: pointer; }
.authbox { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: rgba(212,175,55,.06); border: 1px dashed var(--gold);
  border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.authbox input { background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 12px; border-radius: 8px; font-size: 14px; min-width: 160px; }
.authbox button { padding: 9px 16px; font-size: 13px; letter-spacing: 1px; }
main { max-width: 1200px; margin: 0 auto; padding: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
}
.panel h2 { color: var(--gold2); font-size: 18px; margin-bottom: 12px; letter-spacing: 2px;
  border-left: 3px solid var(--gold); padding-left: 10px; }
.panel h2 small { color: var(--muted); font-size: 12px; font-weight: normal; margin-left: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.form-grid label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.form-grid input, .form-grid select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 14px; outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--gold); }
.form-foot { display: flex; gap: 14px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
button {
  background: linear-gradient(135deg, #b8912f, #d4af37); color: #1a1405;
  border: none; padding: 10px 28px; border-radius: 8px; font-size: 15px; font-weight: bold;
  cursor: pointer; letter-spacing: 3px;
}
button:hover { filter: brightness(1.15); }
#btn-export { background: var(--panel2); color: var(--gold2); border: 1px solid var(--gold); }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.loading { text-align: center; color: var(--gold); padding: 40px; font-size: 18px; letter-spacing: 4px; }
.error { text-align: center; color: var(--red); padding: 20px; }
/* tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 9px 20px; border-radius: 8px; font-size: 14px; letter-spacing: 2px; cursor: pointer;
}
.tab.active { color: #1a1405; background: var(--gold); font-weight: bold; }
.tabpane { display: none; }
.tabpane.active { display: block; }
/* cards */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.card {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center;
}
.card .k { font-size: 12px; color: var(--muted); letter-spacing: 2px; }
.card .v { font-size: 20px; color: var(--gold2); margin-top: 6px; font-weight: bold;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile { line-height: 2; font-size: 14.5px; }
.profile b { color: var(--gold2); }
/* 紫微盘 */
.zw-info { font-size: 14px; line-height: 2; }
.zw-board {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 150px);
  gap: 6px; margin-bottom: 16px;
}
.palace {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; position: relative; overflow: hidden;
}
.palace.ming { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,175,55,.25) inset; }
.palace .palace-head { display: flex; justify-content: space-between; color: var(--gold2);
  font-size: 13px; margin-bottom: 4px; }
.palace .gz { color: var(--muted); font-size: 11px; }
.palace .decadal { color: var(--blue); font-size: 11px; }
.palace .major { color: #ffe9a8; font-size: 14px; font-weight: bold; line-height: 1.6; }
.palace .major .sihua-lu { color: var(--green); }
.palace .major .sihua-quan { color: #ff9f43; }
.palace .major .sihua-ke { color: var(--blue); }
.palace .major .sihua-ji { color: var(--red); }
.palace .lucky { color: var(--green); }
.palace .evil { color: var(--red); }
.palace .flower { color: #ff8fb3; }
.palace .adj { color: var(--muted); font-size: 11px; }
.palace .shen12 { color: #9d8cff; font-size: 11px; }
.palace .marks { position: absolute; top: 6px; right: 8px; color: var(--gold); font-size: 11px; font-weight: bold; }
.palace-center {
  background: linear-gradient(160deg, #1c2138, var(--panel));
  border: 1px dashed var(--line); border-radius: 8px;
  grid-column: 2 / span 2; grid-row: 2 / span 2;
  padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 8px;
  font-size: 13.5px; line-height: 1.9;
}
.palace-center b { color: var(--gold2); }
/* 八字 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: center; }
.pillar { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.pillar .t { color: var(--muted); font-size: 13px; }
.pillar .gz { font-size: 34px; color: var(--gold2); font-family: "SimSun", serif; margin: 8px 0; letter-spacing: 4px; }
.pillar .sub { font-size: 12px; color: var(--muted); line-height: 1.9; }
.wxbar { margin: 6px 0; }
.wxbar .bar { height: 12px; border-radius: 6px; background: var(--panel2); overflow: hidden; }
.wxbar .fill { height: 100%; border-radius: 6px; }
.wxbar .label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 6px; font-size: 12.5px; margin: 3px; color: var(--text); }
.tag.gold { border-color: var(--gold); color: var(--gold2); }
table.yt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.yt th, table.yt td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: center; }
table.yt th { color: var(--gold2); font-weight: normal; }
table.yt tr.now { background: rgba(212,175,55,.08); }
table.yt tr.past { color: var(--muted); }
.score { font-weight: bold; font-size: 15px; }
.s-good { color: var(--green); } .s-mid { color: var(--gold2); } .s-bad { color: var(--red); }
canvas { width: 100%; height: auto; background: var(--panel2); border-radius: 8px; }
.legend { font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend .c2 { color: #ff9f43; } .legend .c3 { color: #ff8fb3; } .legend .c4 { color: var(--green); }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; letter-spacing: 1px; }

/* ===== 新增: 流日条 / AI / 合婚 / 择日 / 海报 ===== */
.flowstrip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.flowcell { min-width: 64px; text-align: center; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; }
.flowcell.fgood { border-color: rgba(111,207,151,.5); }
.flowcell.fmid { border-color: rgba(212,175,55,.5); }
.flowcell.fbad { border-color: rgba(224,90,90,.5); }
.fd-date { font-size: 12px; color: var(--text); }
.fd-date small { color: var(--muted); }
.fd-bar { height: 44px; width: 12px; background: #0d1020; margin: 6px auto; border-radius: 6px;
  display: flex; align-items: flex-end; overflow: hidden; }
.fd-bar i { display: block; width: 100%; border-radius: 6px; }
.fgood .fd-bar i { background: var(--green); }
.fmid .fd-bar i { background: var(--gold); }
.fbad .fd-bar i { background: var(--red); }
.fd-score { font-size: 14px; font-weight: bold; color: var(--gold2); }
.fd-tag { font-size: 11px; color: var(--muted); }
.ai-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.ai-actions select, .match-col select, .match-col input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.ai-result .ai-text { line-height: 2; font-size: 14.5px; }
.ai-result h3 { color: var(--gold2); margin: 14px 0 6px; font-size: 16px; }
.match-form { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
.match-col { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.match-col label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; min-width: 90px; flex: 1; }
.match-go button { padding: 10px 24px; }
.match-score { display: flex; gap: 18px; align-items: center; margin: 14px 0;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ms-num { font-size: 56px; font-weight: bold; line-height: 1; }
.tag-line { font-size: 13px; color: var(--muted); margin: 4px 0; }
#poster-box { margin-top: 12px; max-width: 460px; }
#poster-canvas { display: none; }

/* PDF页内预览覆盖层 */
#pdf-preview { display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(5, 6, 12, .92); }
#pdf-preview .pv-bar { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: #141828; border-bottom: 1px solid var(--gold); }
#pdf-preview .pv-bar span { color: var(--gold2); font-size: 15px; }
#pdf-preview .pv-close { padding: 6px 18px; font-size: 13px; letter-spacing: 1px; }
#pdf-preview iframe { width: 100%; height: calc(100% - 52px); border: none; background: #fff; }

/* ===== 手机端 H5 适配 ===== */
@media (max-width: 760px) {
  header { flex-direction: column; gap: 8px; padding: 12px 14px; }
  #todaybar { text-align: center; font-size: 12px; }
  main { padding: 10px; }
  .panel { padding: 12px; border-radius: 10px; }
  .panel h2 { font-size: 16px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; padding: 8px 14px; font-size: 13px; }
  .zw-board { grid-template-rows: repeat(4, 118px); gap: 4px; }
  .palace { padding: 5px 6px; font-size: 10.5px; }
  .palace .major { font-size: 12px; }
  .palace .palace-head { font-size: 11.5px; }
  .palace .adj { display: none; }
  .palace-center { font-size: 11.5px; padding: 10px; line-height: 1.7; }
  .pillar .gz { font-size: 26px; }
  .form-foot { flex-direction: column; align-items: stretch; }
  .form-foot button { width: 100%; }
  .match-form { flex-direction: column; }
  .table-wrap, #years-table, #match-result { overflow-x: auto; }
  table.yt { min-width: 560px; }
  .brand h1 { font-size: 19px; }
  #poster-box { max-width: 100%; }
}
@media (max-width: 800px) {
  .form-grid, .cards, .pillars { grid-template-columns: repeat(2, 1fr); }
  .zw-board { grid-template-rows: repeat(4, 130px); }
}
