/* 五行力 · 暗色对齐八云 */
:root {
  --bg: #0a0a0c;
  --bg2: #101014;
  --card: #141418;
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.14);
  --text: #e8e8ed;
  --muted: #8a8a96;
  --dim: #5c5c68;
  --accent: #3d7eff;
  --accent-hi: #5a92ff;
  --danger: #ff5d6c;
  --ok: #3ddc97;
  /* 与八云 xby.css :root 一致（bazi/.../xby.css L16–20） */
  --wx-木: #3fcf72;
  --wx-火: #ff4f5e;
  --wx-土: #b98552;
  --wx-金: #e8c040;
  --wx-水: #4a7ae8;
  --r: 10px;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 28%, #000 18%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 28%, #000 18%, transparent 78%);
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 20px;
  background: rgba(10, 10, 12, 0.88);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-name { font-size: 20px; font-weight: 650; letter-spacing: .2em; }
.brand-sub { font-size: 13px; color: var(--dim); letter-spacing: .12em; }
.ver-badge {
  display: inline-block;
  align-self: center;
  margin-left: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--accent-hi, #7aa7ff);
  background: rgba(61,126,255,.12);
  border: 1px solid rgba(61,126,255,.35);
  white-space: nowrap;
}

.shell {
  position: relative; z-index: 1;
  max-width: 980px; margin: 0 auto;
  padding: 28px 24px 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px; letter-spacing: .28em; color: var(--muted);
  margin-bottom: 12px; font-weight: 600;
}
.hint { font-size: 14px; color: var(--muted); margin: 0 0 16px; line-height: 1.6; }
.hint-list {
  margin: 0 0 16px; padding: 0 0 0 1.1em;
  color: var(--muted); font-size: 14px; line-height: 1.75;
}
.hint-list li { margin: 0 0 2px; }
.hint-list li::marker { content: "· "; color: var(--dim); }

/* —— 四柱大格：时 日 月 年（右→左录入） —— */
.pillar-board {
  display: grid;
  grid-template-columns: 36px repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
  background: rgba(255,255,255,.02);
}
.pillar-board > .p-lab,
.pillar-board > .p-col-h {
  display: flex; align-items: center; justify-content: center;
  min-height: 44px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--dim); letter-spacing: .2em;
  background: rgba(255,255,255,.02);
}
.pillar-board > .p-lab { border-left: 0; }
.pillar-board > .p-col-h {
  font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: .28em;
  background: rgba(255,255,255,.03);
}
.pillar-board > .p-col-h.day {
  color: var(--text);
  background: rgba(61,126,255,.14);
  box-shadow: inset 0 0 0 1px rgba(61,126,255,.35);
}

.gz-cell {
  display: flex; align-items: center; justify-content: center;
  min-height: 88px;
  border: 0;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-family: var(--serif);
  font-size: 40px; font-weight: 700;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: background .12s, box-shadow .12s;
}
.gz-cell:nth-child(n+11) { border-bottom: 0; }
.gz-cell.day {
  background: rgba(61,126,255,.08);
  box-shadow: inset 0 0 0 1px rgba(61,126,255,.35);
}
.gz-cell.empty { color: var(--dim); font-size: 28px; font-weight: 500; font-family: inherit; }
.gz-cell:hover { background: rgba(61,126,255,.1); }
.gz-cell.active {
  background: rgba(61,126,255,.2) !important;
  box-shadow: inset 0 0 0 3px var(--accent-hi), 0 0 0 1px rgba(61,126,255,.4);
  z-index: 1;
}
.gz-cell.active::after {
  content: "";
  position: absolute; top: 8px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent-hi);
  box-shadow: 0 0 10px rgba(90,146,255,.9);
}

/* 选字面板 */
.picker {
  margin-bottom: 16px;
  padding: 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(61,126,255,.45);
  background: rgba(16,16,20,.98);
  box-shadow: 0 14px 36px rgba(0,0,0,.4), 0 0 0 1px rgba(61,126,255,.15);
}
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px; color: var(--muted); letter-spacing: .14em;
}
.picker-close {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.picker-grid.zhi { grid-template-columns: repeat(6, 1fr); }
.pick-btn {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  font-family: var(--serif);
  font-size: 26px; font-weight: 700;
  cursor: pointer;
}
.pick-btn:hover, .pick-btn:focus {
  outline: none;
  border-color: rgba(61,126,255,.55);
  background: rgba(61,126,255,.12);
}
.pick-btn.on {
  border-color: rgba(61,126,255,.75);
  box-shadow: inset 0 0 0 1px rgba(61,126,255,.45);
  background: rgba(61,126,255,.14);
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.btn {
  min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #fff; font-weight: 600; letter-spacing: .12em; cursor: pointer;
  box-shadow: 0 6px 18px rgba(61,126,255,.25);
}
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line2);
  color: var(--muted);
  box-shadow: none;
}
.btn-danger {
  background: rgba(255,93,108,.12);
  border: 1px solid rgba(255,93,108,.55);
  color: #ff8a95;
  box-shadow: none;
  font-weight: 650;
  letter-spacing: .16em;
}
.btn-danger:hover {
  background: rgba(255,93,108,.22);
  border-color: rgba(255,93,108,.75);
  color: #ffb0b8;
}

.paste-sec {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.paste-sec summary {
  cursor: pointer; color: var(--dim); font-size: 13px;
  letter-spacing: .08em; user-select: none; padding: 4px 0;
}
.paste-row {
  display: flex; gap: 8px; align-items: center; margin-top: 8px;
}
.paste-row input {
  flex: 1; min-height: 40px; padding: 0 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line2); border-radius: 10px;
  letter-spacing: .08em; font-size: 15px;
}
.paste-row input:focus {
  outline: none; border-color: rgba(61,126,255,.55);
  box-shadow: 0 0 0 3px rgba(61,126,255,.15);
}
.paste-colored {
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  letter-spacing: .14em; min-height: 1.2em; margin: 10px 0 0;
}
.paste-colored.empty { display: none; }

.error {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: rgba(255,93,108,.1); border: 1px solid rgba(255,93,108,.35);
  color: #ff8a95; font-size: 14px;
}


/* 桌面默认：短标签 / 合并列隐藏 */
.lab-short { display: none; }
.col-cw { display: none; }

/* —— 结果：命判主卡 → 五行统计 → 明细 → 底部五行力 —— */
.summary {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}
.verdict-card {
  /* 匾额：居中、随字宽、非通栏 */
  width: max-content;
  max-width: min(420px, 92%);
  margin-left: auto; margin-right: auto;
  padding: 36px 40px 34px;
  border-radius: 14px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--day-hex, var(--accent)) 45%, transparent);
  background:
    linear-gradient(160deg,
      color-mix(in srgb, var(--day-hex, var(--accent)) 22%, transparent),
      rgba(255,255,255,.02) 70%);
  box-shadow: 0 14px 40px rgba(0,0,0,.3),
    inset 0 0 0 1px color-mix(in srgb, var(--day-hex, var(--accent)) 25%, transparent);
}
.verdict-name {
  font-size: 56px; font-weight: 800; letter-spacing: .28em;
  line-height: 1.15; padding-left: .14em;
  color: var(--day-hex, var(--text));
  text-shadow: 0 0 36px color-mix(in srgb, var(--day-hex, transparent) 40%, transparent);
  white-space: nowrap;
}
.summary-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: center; margin-top: 4px; }
.summary .day-el { color: var(--muted); font-size: 15px; letter-spacing: .08em; }

.el-block { margin-bottom: 22px; }

.tbl tfoot .total-row td {
  border-top: 1px solid var(--line2);
  border-bottom: 0;
  padding: 14px 12px;
  background: rgba(255,255,255,.03);
}
.tbl tfoot .total-cell {
  text-align: right;
}
.tbl tfoot .total-lab {
  font-weight: 700; letter-spacing: .28em;
  color: var(--muted); font-size: 15px;
  margin-right: 14px; vertical-align: baseline;
}
.tbl tfoot .total-val {
  font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums;
  vertical-align: baseline;
}
.force-foot { margin: 4px 0 0; padding: 0 4px 4px; }
.verdict-rule {
  margin: 8px 0 0;
  font-size: 13px; color: var(--dim); letter-spacing: .04em; line-height: 1.55;
  text-align: center;
}
.verdict-大, .verdict-平, .verdict-小 { }

.table-wrap { overflow-x: auto; margin-bottom: 18px; border-radius: 12px; border: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 12px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--dim); font-weight: 600; background: rgba(255,255,255,.02); letter-spacing: .08em; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .char { font-family: var(--serif); font-size: 22px; font-weight: 700; }
.tbl .pos { color: var(--muted); font-size: 13px; }
.wx { font-weight: 600; }
.wx-木 { color: var(--wx-木); }
.wx-火 { color: var(--wx-火); }
.wx-土 { color: var(--wx-土); }
.wx-金 { color: var(--wx-金); }
.wx-水 { color: var(--wx-水); }
.neg { color: #ff8a95; }
.posi { color: var(--ok); }

/* —— 五行统计卡片 —— */
.el-title { font-size: 14px; color: var(--muted); letter-spacing: .2em; margin-bottom: 12px; }
.el-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
.el-item {
  position: relative;
  text-align: center;
  padding: 18px 10px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  overflow: hidden;
}
.el-item .el-name {
  font-size: 28px; font-weight: 700; margin-bottom: 4px;
  font-family: var(--serif);
}
.el-item .el-w {
  font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.el-item .el-bar {
  margin-top: 12px; height: 5px; border-radius: 999px;
  background: rgba(255,255,255,.08); overflow: hidden;
}
.el-item .el-bar > i {
  display: block; height: 100%; border-radius: 999px;
  width: 0; transition: width .25s ease;
}
.el-item.is-day {
  box-shadow: 0 0 0 1px rgba(61,126,255,.55), 0 8px 24px rgba(61,126,255,.12);
  border-color: rgba(61,126,255,.55);
}
.el-item.is-day::before {
  content: "日元";
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .16em; color: var(--accent-hi);
  background: rgba(61,126,255,.18);
  padding: 2px 8px; border-radius: 999px;
}
.el-item.is-day { padding-top: 28px; }

.foot {
  position: relative; z-index: 1;
  text-align: center; padding: 10px 16px 32px;
  font-size: 13px; color: var(--dim); letter-spacing: .1em;
}

@media (max-width: 720px) {
  .shell { padding: 16px 12px 24px; max-width: 100%; overflow-x: hidden; }
  .card { padding: 16px; max-width: 100%; overflow-x: hidden; }
  .gz-cell { min-height: 64px; font-size: 30px; }
  .gz-cell.empty { font-size: 22px; }
  .picker-grid { gap: 8px; }
  .pick-btn { min-height: 48px; font-size: 22px; }
  .el-block { padding: 0 2px; }
  .el-grid { gap: 6px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .el-item { padding: 12px 4px 10px; min-width: 0; box-sizing: border-box; }
  .el-item .el-name { font-size: 18px; }
  .el-item .el-w { font-size: 20px; }
  .el-item.is-day { padding-top: 22px; }
  .verdict-card {
    width: 68%; max-width: 68%;
    padding: 28px 24px 26px;
  }
  .verdict-name { font-size: 40px; letter-spacing: .2em; }
  .verdict-rule { font-size: 12px; }
  .tbl tfoot .total-val { font-size: 22px; }
  .pillar-board { grid-template-columns: 28px repeat(4, minmax(0, 1fr)); }
}

/* 375–390px：表头不叠、左右留白、按钮一行、五行卡等距 */
@media (max-width: 480px) {
  .shell { padding: 12px 12px 20px; }
  .card { padding: 14px 12px; border-radius: 12px; }
  .hint-list { font-size: 13px; padding-left: 1em; }

  .verdict-card {
    width: 70%; max-width: 70%;
    padding: 26px 18px 24px;
  }
  .verdict-name { font-size: 36px; letter-spacing: .18em; }

  /* 三按钮一行均分 */
  .actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
  }
  .actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 40px;
    padding: 0 6px;
    font-size: 13px;
    letter-spacing: .06em;
    border-radius: 10px;
    white-space: nowrap;
  }
  .actions .btn-danger { letter-spacing: .04em; }

  /* 五行统计：等距左右 gutter，五卡不贴边 */
  .el-block { padding: 0 2px; }
  .el-grid {
    gap: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    box-sizing: border-box;
  }
  .el-item {
    padding: 8px 2px 8px;
    border-radius: 8px;
    min-width: 0;
    box-sizing: border-box;
  }
  .el-item .el-name { font-size: 14px; margin-bottom: 0; }
  .el-item .el-w { font-size: 16px; }
  .el-item .el-bar { margin-top: 6px; height: 3px; }
  .el-item.is-day { padding-top: 18px; }
  .el-item.is-day::before {
    font-size: 9px; top: 3px; padding: 1px 4px; letter-spacing: .08em;
  }

  /* 明细表：内边距离面板边；短表头；列宽防叠 */
  .table-wrap {
    overflow-x: hidden;
    margin: 0 0 14px;
    padding: 0;
    border-radius: 10px;
    box-sizing: border-box;
  }
  .tbl {
    width: 100%;
    table-layout: fixed;
    font-size: 12px;
    border-collapse: collapse;
  }
  .tbl th, .tbl td {
    padding: 7px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    box-sizing: border-box;
  }
  /* 可见 5 列：字 / 五行 / 关系 / 系数×权 / 贡献 */
  .tbl th:nth-child(2), .tbl td:nth-child(2) { width: 14%; }   /* 字 */
  .tbl th:nth-child(3), .tbl td:nth-child(3) { width: 14%; }   /* 五行 */
  .tbl th:nth-child(4), .tbl td:nth-child(4) { width: 22%; }   /* 关系 */
  .tbl th.col-cw, .tbl td.col-cw { width: 28%; }               /* 系数×权 */
  .tbl th:last-child, .tbl td:last-child { width: 22%; }       /* 贡献 */
  .tbl .char { font-size: 15px; }
  .tbl .pos { font-size: 11px; }
  .lab-full { display: none; }
  .lab-short { display: inline; }
  .col-pos, .col-coef, .col-wt { display: none; }
  .col-cw { display: table-cell; }
  .tbl tfoot .total-cell { text-align: center; padding: 10px 8px; }
  .tbl tfoot .total-lab { font-size: 13px; margin-right: 10px; letter-spacing: .16em; }
  .tbl tfoot .total-val { font-size: 22px; }
  .verdict-rule { font-size: 11px; padding: 0 4px; }
}

@media (max-width: 360px) {
  .el-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .verdict-card { width: 78%; max-width: 78%; }
  .tbl { font-size: 11px; }
  .actions .btn { font-size: 12px; padding: 0 4px; letter-spacing: .02em; }
}

@media (min-width: 1100px) {
  .shell { max-width: 1080px; }
  .gz-cell { min-height: 96px; font-size: 44px; }
  .verdict-name { font-size: 60px; }
  .verdict-card { padding: 40px 44px 38px; }
  .tbl tfoot .total-val { font-size: 32px; }
  .el-item .el-name { font-size: 30px; }
  .el-item .el-w { font-size: 36px; }
}
