:root{
  --bg:#f6f3ec; --card:#fffdf8; --ink:#23201a; --muted:#8a8275;
  --green:#2e5d32; --green2:#3d7a42; --red:#a4161a; --red2:#c1272d;
  --gold:#b8860b; --line:#e4ddcd; --bar:#cdeacb; --bar2:#63be7b;
  --shadow:0 2px 10px rgba(60,50,20,.08);
}
*{box-sizing:border-box}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:"Tahoma","Segoe UI","Microsoft YaHei",system-ui,sans-serif;
  font-size:14px; line-height:1.5;
}
h1,h2,h3{margin:0 0 .3em}
.muted{color:var(--muted); font-size:.86em}
button{cursor:pointer; font-family:inherit}

/* topbar */
.topbar{
  display:flex; justify-content:space-between; align-items:center; gap:16px;
  padding:14px 22px; background:linear-gradient(100deg,var(--green),var(--green2));
  color:#fff; box-shadow:var(--shadow);
}
.brand{display:flex; align-items:center; gap:14px}
.logo{
  font-size:30px; font-family:"Microsoft YaHei",serif; font-weight:700;
  background:rgba(255,255,255,.15); width:54px; height:54px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
}
.topbar h1{font-size:22px; letter-spacing:.5px}
.topbar .sub{margin:0; font-size:12px; opacity:.85}
.latest{
  background:var(--gold); color:#fff; padding:8px 14px; border-radius:10px;
  font-weight:700; font-size:13px; white-space:nowrap; box-shadow:var(--shadow);
}

/* tabs */
.tabs{display:flex; gap:4px; padding:10px 22px 0; background:var(--bg); flex-wrap:wrap}
.tab{
  border:none; background:transparent; padding:10px 18px; font-size:15px;
  border-radius:10px 10px 0 0; color:var(--muted); font-weight:600;
}
.tab.active{background:var(--card); color:var(--green); box-shadow:var(--shadow)}

main{padding:18px 22px 40px; max-width:1100px; margin:0 auto}
.panel{display:none; animation:fade .25s}
.panel.active{display:block}
@keyframes fade{from{opacity:0;transform:translateY(4px)}to{opacity:1}}

.card{background:var(--card); border:1px solid var(--line); border-radius:14px;
  padding:18px 20px; margin-bottom:16px; box-shadow:var(--shadow)}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:16px}
@media(max-width:760px){.grid2{grid-template-columns:1fr}}

.row{display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; margin-top:10px}
label{display:flex; flex-direction:column; gap:4px; font-size:.85em; color:var(--muted); font-weight:600}
input,select{
  font-family:inherit; font-size:14px; padding:8px 10px; border:1px solid var(--line);
  border-radius:8px; background:#fff; color:var(--ink)
}
button.primary{background:var(--green); color:#fff; border:none; padding:9px 20px; border-radius:8px; font-weight:700}
button.ghost{background:#fff; color:var(--green); border:1px solid var(--green); padding:9px 16px; border-radius:8px; font-weight:600}

/* toolbar / search */
.toolbar{display:flex; gap:12px; align-items:center; margin-bottom:12px; flex-wrap:wrap}
#search{flex:1; min-width:240px; font-size:15px}

/* table */
.tablewrap{overflow:auto; max-height:70vh; border:1px solid var(--line); border-radius:12px; background:var(--card)}
table{border-collapse:collapse; width:100%; font-size:13.5px}
thead th{position:sticky; top:0; background:var(--green); color:#fff; padding:10px 8px; font-weight:700; white-space:nowrap; z-index:2}
tbody td{padding:7px 8px; border-bottom:1px solid var(--line); text-align:center; white-space:nowrap}
tbody tr:hover{background:#f0ece0}
.gz{font-family:"Microsoft YaHei",serif; font-weight:600}
.gz.y{color:var(--green)} .gz.m{color:var(--gold)} .gz.d{color:var(--red)} .gz.t{color:#4a4a8a}
.first{font-weight:700; color:var(--red); letter-spacing:1px; font-size:15px}
.two{font-weight:700; background:var(--red); color:#fff; padding:2px 8px; border-radius:6px}
.viewlink{color:var(--green); text-decoration:none; font-size:12px}

/* pillar cards */
.pillars{display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:16px}
@media(max-width:640px){.pillars{grid-template-columns:repeat(2,1fr)}}
.pcard{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; text-align:center; box-shadow:var(--shadow)}
.pcard .plabel{font-size:.8em; color:var(--muted); font-weight:700}
.pcard .pgz{font-family:"Microsoft YaHei",serif; font-size:42px; font-weight:700; margin:6px 0; line-height:1}
.pcard .ptc{font-size:.82em; font-weight:700; color:#9a6a14; margin:2px 0}
.pcard .pdetail{font-size:.78em; color:var(--muted)}

/* อภิธานศัพท์แต้จิ๋ว (60甲子 tab) */
#tcGlossary h2{font-size:1.05em}
#tcGlossary .g-h{font-size:.92em; color:var(--green); margin:14px 0 6px}
.g-term{border-collapse:collapse; margin:8px 0; width:100%; max-width:460px}
.g-term th,.g-term td{border:1px solid var(--line); padding:4px 10px; text-align:left; font-size:.9em}
.g-term th{background:#f1ede2; color:var(--muted)}
.g-term .g-zh{font-family:"Microsoft YaHei",serif; font-weight:700; font-size:1.1em; text-align:center; width:60px}
.g-term .g-tc{color:#9a6a14; font-weight:700}
.g-row{display:flex; flex-wrap:wrap; gap:8px}
.g-cell{display:flex; flex-direction:column; align-items:center; min-width:54px; padding:6px 4px; border:1px solid var(--line); border-radius:9px; background:#fafafa; line-height:1.25}
.g-cell b{font-family:"Microsoft YaHei",serif; font-size:1.3em; color:var(--ink)}
.g-cell i{font-style:normal; font-size:.85em; font-weight:700; color:#9a6a14}
.g-cell u{text-decoration:none; font-size:.7em; color:var(--muted)}
/* อภิธานศัพท์ — โหมดแก้ไข */
.g-head{display:flex; align-items:flex-start; justify-content:space-between; gap:12px; flex-wrap:wrap}
.g-head h2{margin:0}
.g-inp{font-family:inherit; font-size:.9em; padding:3px 6px; border:1px solid var(--line); border-radius:6px; background:#fffdf8; color:var(--ink); width:100%; max-width:150px}
.g-inp:focus{outline:none; border-color:var(--gold); background:#fff}
.g-cell{min-width:78px; gap:3px}
.g-cell .g-inp{max-width:72px; text-align:center; font-size:.82em; padding:2px 4px}
.g-cell u{margin-top:1px}
.g-term td .g-inp{max-width:none}
.g-pref{background:#fbf6f0; border:1px solid #e8d8c0; border-radius:10px; padding:10px 14px; margin:10px 0}
.g-prow{display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:5px 0; font-size:.92em}
.g-prow b{min-width:170px; color:var(--ink)}
.g-radio{display:inline-flex; align-items:center; gap:5px; cursor:pointer; padding:3px 10px; border:1px solid var(--line); border-radius:20px; background:#fff}
.g-radio input{margin:0}
.g-radio:hover{border-color:var(--gold)}
.g-btns{display:flex; gap:8px; flex-wrap:wrap; align-items:flex-start}
.g-impbtn{cursor:pointer; display:inline-flex; align-items:center; background:#fff; color:var(--green); border:1px solid var(--green); padding:9px 16px; border-radius:8px; font-weight:600; font-size:1em}
.g-impbtn:hover{background:#f4f8f4}
.pcard.y .pgz{color:var(--green)} .pcard.m .pgz{color:var(--gold)}
.pcard.d .pgz{color:var(--red)} .pcard.t .pgz{color:#4a4a8a}

/* bars */
.bars{display:flex; flex-direction:column; gap:4px}
.barrow{display:grid; grid-template-columns:54px 1fr 70px; align-items:center; gap:8px; font-size:13px}
.barrow .bnum{font-weight:700; text-align:center; font-family:"Microsoft YaHei",serif}
.bartrack{background:var(--bar); border-radius:6px; height:18px; overflow:hidden}
.barfill{background:var(--bar2); height:100%; border-radius:6px}
.barrow .bval{text-align:right; color:var(--muted); font-size:12px}

/* digit freq */
.digits{display:grid; grid-template-columns:repeat(10,1fr); gap:8px; text-align:center}
.digits .d{background:#f0ece0; border-radius:10px; padding:10px 4px}
.digits .d b{font-size:22px; color:var(--red); display:block}
.digits .d span{font-size:11px; color:var(--muted)}

/* jiazi grid */
.jiazi-grid{display:grid; grid-template-columns:repeat(6,1fr); gap:6px; max-width:560px; margin-top:10px}
.jiazi-grid .jz{
  font-family:"Microsoft YaHei",serif; text-align:center; padding:10px 2px;
  background:#f0ece0; border-radius:8px; font-size:18px; font-weight:600
}
.jiazi-grid .jz.head{background:var(--green); color:#fff}
.jiazi-grid .jz.hot{outline:3px solid var(--gold); background:#fff7e0}

footer{text-align:center; color:var(--muted); font-size:12px; padding:20px}
.empty{padding:30px; text-align:center; color:var(--muted)}

/* ===== 命盤 BaZi chart ===== */
.bazi-input{background:linear-gradient(170deg,#fbf3d8,#f5e9c0); border-color:#e6d9a8}
.bi-row{display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:10px}
.seg{display:inline-flex; border:1px solid #c9b97a; border-radius:9px; overflow:hidden}
.seg button{border:none; background:#fff; padding:8px 18px; font-weight:700; color:#7a6a30; font-size:15px}
.seg button.on{background:var(--green); color:#fff}
.ex-sel{max-width:260px; border:1px solid var(--green); color:var(--green); font-weight:600; cursor:pointer}

/* ===== ฐานข้อมูลดวง ===== */
.db-wrap{display:flex; gap:12px; align-items:flex-start}
.db-cats{flex:0 0 130px; background:var(--card); border:1px solid var(--line); border-radius:12px; overflow:hidden; max-height:75vh; overflow-y:auto}
.db-cat{padding:10px 12px; border-bottom:1px solid var(--line); cursor:pointer; font-size:.9em; display:flex; justify-content:space-between; align-items:center; gap:6px}
.db-cat:hover{background:#f0ece0}
.db-cat.on{background:var(--green); color:#fff; font-weight:700}
.db-cat i{font-style:normal; font-size:.8em; opacity:.7; font-family:Tahoma}
.db-main{flex:1; min-width:0}
.db-toolbar{display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:10px}
.db-toolbar #dbSearch{flex:1; min-width:140px}
.db-list{background:var(--card); border:1px solid var(--line); border-radius:12px; overflow:hidden; min-height:120px}
.db-item{display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:10px 12px; border-bottom:1px solid var(--line)}
.db-py{font-style:normal; color:var(--muted); font-weight:400; font-size:.78em; margin-left:7px}
.db-desc{flex-basis:100%; width:100%; color:var(--muted); font-size:.8em; line-height:1.45; padding-left:34px; margin-top:-2px}
.db-item:hover{background:#fbfaf5}
.db-item .db-chk{width:18px; height:18px; flex-shrink:0}
.db-g{width:24px; height:24px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; flex-shrink:0}
.db-g.m{background:#4a6ad1} .db-g.f{background:#c1559a}
.db-name{flex:1; min-width:0; color:var(--green); font-weight:700; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.db-name:hover{text-decoration:underline}
.db-tag{background:#eef0e6; color:var(--muted); font-size:.72em; padding:2px 8px; border-radius:6px; white-space:nowrap}
.db-born{color:#1a4ad1; font-family:Tahoma; font-size:.82em; flex-shrink:0}
.db-edit{background:none; border:none; cursor:pointer; font-size:1.05em; color:var(--muted); padding:2px 6px; flex-shrink:0}
.db-edit:hover{color:var(--green)}
.db-rev{background:none; border:none; cursor:pointer; font-size:.9em; color:#79c0ff; padding:2px 5px; flex-shrink:0; opacity:.8}
.db-rev:hover{opacity:1}
.db-bio{background:none; border:none; cursor:pointer; font-size:.9em; padding:2px 5px; flex-shrink:0; opacity:.7}
.db-bio:hover{opacity:1}
.db-actions{display:flex; gap:6px; flex-wrap:wrap; margin-top:10px}
.db-actions button{font-size:.85em; padding:7px 12px}
.ghost.danger{color:var(--red); border-color:var(--red)}
/* modal */
.db-modal{position:fixed; inset:0; background:rgba(30,25,10,.45); display:flex; align-items:center; justify-content:center; z-index:50; padding:16px}
.db-modal[hidden]{display:none}
.db-modal-box{background:var(--card); border-radius:16px; padding:20px; max-width:440px; width:100%; box-shadow:var(--shadow); max-height:90vh; overflow-y:auto}
.db-modal-box h3{color:var(--green); margin-bottom:12px}
.db-modal-box label{display:flex; flex-direction:column; gap:4px; margin-bottom:10px; font-size:.85em; color:var(--muted); font-weight:600}
.db-modal-box .dm-row{display:flex; gap:14px; align-items:flex-end; margin-bottom:10px; flex-wrap:wrap}
.db-modal-box .numgrid{display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin-bottom:10px}
.dm-actions{display:flex; gap:10px; justify-content:flex-end; margin-top:8px}
@media(max-width:560px){ .db-cats{flex-basis:96px} .db-modal-box .numgrid{grid-template-columns:repeat(3,1fr)} }
/* วิเคราะห์คู่ */
.pair-head{font-size:1.05em; text-align:center; margin-bottom:6px} .pair-head b{color:var(--green)}
.pair-level{text-align:center; font-size:1.3em; font-weight:800; margin-bottom:12px}
.pair-tbl{width:100%; border-collapse:collapse; font-size:.9em}
.pair-tbl td{padding:7px 8px; border-bottom:1px solid var(--line); vertical-align:top}
.pair-tbl .pt-t{font-weight:700; white-space:nowrap; color:var(--muted)}
.pair-tbl .pt-s{font-weight:800; text-align:center; width:24px}
.pair-tbl .pt-s.pos{color:var(--green2)} .pair-tbl .pt-s.neg{color:var(--red2)}
.pair-disc{font-size:.78em; color:var(--muted); margin-top:10px; line-height:1.5; border-top:1px dashed var(--line); padding-top:6px}
.bi-name{flex:1; min-width:160px}
.bi-mode{margin-top:6px}
.bi-mode[hidden]{display:none}
.numgrid{display:grid; grid-template-columns:repeat(5,1fr); gap:8px; max-width:560px}
.numgrid label{font-size:.8em}
.numgrid input,.numgrid select{width:100%}

/* ===== Numpad input ===== */
.np-mode-seg{width:100%}
.np-mode-seg button{flex:1}
.np-cal-row{margin:6px 0}
.np-cal-seg button{flex:1; padding:7px 12px; font-size:.88em}
.np-wrap{display:flex; gap:10px; margin-top:8px; align-items:flex-start}
.np-left{display:flex; flex-direction:column; gap:6px; flex:0 0 auto}
.np-buf{width:150px; padding:8px 10px; font-size:1.1em; font-weight:700; border:2px solid #c9b97a; border-radius:8px; background:#fffdf0; text-align:right; color:#4a3a10; letter-spacing:.1em}
.np-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:5px; width:150px}
.np-btn{padding:12px 0; font-size:1.15em; font-weight:700; background:#fff; border:1px solid #d4c07a; border-radius:8px; color:#4a3a10; cursor:pointer; text-align:center; transition:background .12s}
.np-btn:active,.np-btn:hover{background:#f5e89a}
.np-zero{grid-column:1/2}
.np-clr{grid-column:2/4; background:#fdf0e8; border-color:#e4b890; color:#a06030}
.np-clr:hover{background:#fad8b8}
.np-right{display:flex; flex-direction:column; gap:4px; flex:1}
.np-field{display:flex; align-items:center; gap:6px; padding:5px 0; border-bottom:1px solid #ede0b0}
.np-field:last-child{border-bottom:none}
.np-fbtn{flex:0 0 auto; padding:6px 10px; font-size:.88em; font-weight:700; background:#fffdf0; border:1px solid #c9b97a; border-radius:7px; color:#7a6a30; cursor:pointer; white-space:nowrap}
.np-fbtn:hover{background:#f0e080}
.np-fval{font-size:1.2em; font-weight:800; color:#1a56b0; min-width:34px; text-align:right}
.np-fzhi{font-size:.82em; color:#7a6a30; background:#f5e89a; border-radius:5px; padding:1px 6px; margin-left:2px; font-family:"Microsoft YaHei",serif}
@media(max-width:480px){
  .np-wrap{flex-direction:column}
  .np-left{flex-direction:row; align-items:flex-start; gap:8px}
  .np-buf{width:100px; font-size:1em}
  .np-grid{width:110px}
  .np-btn{padding:10px 0; font-size:1em}
}
.pillpick{display:grid; grid-template-columns:repeat(4,1fr); gap:10px; max-width:560px; margin:6px 0}
.pillpick .pp{background:#fff; border:1px solid #d8c894; border-radius:10px; padding:8px; text-align:center}
.pillpick .pp .ppl{font-weight:700; color:#7a6a30; margin-bottom:4px}
.pillpick .pp select{width:100%; text-align:center; font-family:"Microsoft YaHei",serif; font-size:16px; margin-bottom:4px}
#searchResult{margin-top:8px; max-height:160px; overflow:auto; font-size:13px}
#searchResult .sr{padding:4px 8px; border-bottom:1px solid var(--line); cursor:pointer}
#searchResult .sr:hover{background:#f0ece0}

/* element colors */
.el-mu{color:#1a8a1a} .el-huo{color:#d11a1a} .el-tu{color:#9a6a14} .el-jin{color:#c8920a} .el-shui{color:#1a4ad1}

/* chart */
.bz-wrap{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:14px; box-shadow:var(--shadow); overflow-x:auto}
.bz-head{font-family:"Microsoft YaHei",serif; line-height:1.7; border-bottom:2px solid var(--line); padding-bottom:8px; margin-bottom:10px}
.bz-head .hk{color:var(--red); font-weight:700} .bz-head .hb{color:#1a4ad1; font-weight:700} .bz-head .hg{color:var(--green); font-weight:700}
.bz-head .name{font-weight:700; font-size:1.1em}

.bz-main{display:grid; grid-template-columns:repeat(5,minmax(60px,1fr)); gap:6px; min-width:560px}
.bz-pillar.ly{background:#eef4ff; border-color:#9bb8e8}
.bz-pillar.tr{background:#fff0f0; border-color:#e0a0a0}
.bz-pillar.tr-label{background:transparent; border:none; box-shadow:none; display:flex; align-items:center; justify-content:center}
.bz-pillar.tr-label .lab{color:var(--muted); writing-mode:vertical-rl; font-size:.9em}
.bz-transit{background:#fbfaf5; border:1px dashed var(--line); border-radius:12px; padding:10px 12px}
.bz-tr-ctrl{display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin:4px 0 8px}
.bz-tr-ctrl .inl{flex-direction:row; align-items:center; gap:6px; color:var(--ink)}
.bz-tr-ctrl input,.bz-tr-ctrl select{padding:6px 8px}
.bz-pillar{border:1px solid var(--line); border-radius:10px; padding:8px 4px; text-align:center; background:#fffdf8}
.bz-pillar.cur{background:#fff7e0; border-color:var(--gold)}
.bz-pillar .lab{font-size:.78em; color:var(--muted); font-weight:700; margin-bottom:4px}
.bz-pillar .lab small{display:block; color:var(--gold); font-weight:700}
.bz-line{display:flex; align-items:center; justify-content:center; gap:3px; font-family:"Microsoft YaHei",serif}
.bz-char{font-size:34px; font-weight:700; line-height:1.1}
.bz-shen{font-size:.7em; color:#8a7a55; font-weight:700; writing-mode:vertical-rl}
.bz-hide{display:flex; flex-direction:column; font-size:.62em; color:#8a7a55; gap:1px; line-height:1.1; font-family:"Microsoft YaHei",serif}
.bz-hide b{font-weight:700}
.bz-nayin{font-size:.66em; color:var(--muted); margin-top:5px; font-family:"Microsoft YaHei",serif}
.bz-dishi{font-size:.66em; color:#a08; margin-top:1px}

.bz-section{margin-top:12px}
.bz-section h3{font-size:.9em; color:var(--green); margin-bottom:5px}
.bz-strip{display:grid; gap:3px; min-width:560px}
.bz-strip.c10{grid-template-columns:repeat(10,1fr)}
.bz-cell{border:1px solid var(--line); border-radius:7px; padding:5px 1px; text-align:center; cursor:pointer; background:#fbfaf5; font-family:"Microsoft YaHei",serif}
.bz-cell:hover{background:#f0ece0}
.bz-cell.on{background:#fff7e0; outline:2px solid var(--gold)}
.bz-cell .age{font-size:.62em; color:var(--muted); font-family:Tahoma}
.bz-cell .gz{font-size:20px; font-weight:700; line-height:1.15}
.bz-cell .yr{font-size:.62em; color:#1a4ad1; font-family:Tahoma}
.bz-cell .sx{font-size:.58em; color:#8a7a55; display:block}
.bz-jieqi{grid-template-columns:repeat(12,1fr); min-width:680px}
.bz-jieqi .bz-cell{cursor:default}
.bz-jieqi .jq{font-size:.6em; color:var(--muted)}
.bz-extra{display:flex; gap:14px; flex-wrap:wrap; font-size:.8em; color:var(--muted); margin-top:10px; font-family:"Microsoft YaHei",serif}
.bz-extra b{color:var(--ink)}

/* คำทำนาย 命理解讀 */
.bz-pred{margin-top:16px; border-top:2px solid var(--line); padding-top:6px}
.bz-pred summary{cursor:pointer; list-style:none}
.bz-pred summary::-webkit-details-marker{display:none}
.bz-pred summary h3{display:inline-flex; align-items:center; gap:8px; margin:6px 0}
.bz-pred summary::before{content:"▾"; color:var(--gold); font-weight:700; margin-right:4px}
.bz-pred details:not([open]) summary::before{content:"▸"}
.pred-body{display:flex; flex-direction:column; gap:12px; margin-top:6px}
.pred-blk.pred-overview{background:linear-gradient(100deg,var(--green),var(--green2)); border-color:var(--green); color:#fff}
.pred-blk.pred-overview .pred-t{color:#fff}
.pred-blk.pred-overview .pred-p{color:#fff; font-size:.95em; line-height:1.7}
.pred-blk.pred-overview b{color:#fff7e0}
.pred-blk.pred-overview .bz-char,.pred-blk.pred-overview b[class^="el-"]{color:#fff7e0; font-family:"Microsoft YaHei",serif}
.pred-blk{background:#fbfaf5; border:1px solid var(--line); border-radius:12px; padding:12px 14px}
.pred-blk.pred-ln{background:#fff7e8; border-color:#ecd9a8}
.pred-t{font-weight:700; color:var(--green); font-size:.95em; margin-bottom:6px}
.pred-t b{font-family:"Microsoft YaHei",serif; font-size:1.15em}
.pred-p{margin:4px 0; line-height:1.65; font-size:.9em}
.pred-sw{font-size:.85em; margin-top:3px; line-height:1.5}
.pred-sw .pos{color:var(--green2); font-weight:700} .pred-sw .neg{color:var(--red2); font-weight:700}
.pred-god{border-top:1px dashed var(--line); padding:7px 0}
.pred-god:first-of-type{border-top:none}
.pred-god-h{font-family:"Microsoft YaHei",serif; font-weight:700; display:flex; align-items:center; gap:6px; flex-wrap:wrap}
.pred-god-h .pl{background:var(--green); color:#fff; border-radius:6px; padding:1px 7px; font-size:.78em}
.pred-god-h .bz-char,.pred-god-h span.gd,.pred-god-h{font-size:1em}
.pred-god-h .gd{color:var(--gold)}
.pred-god-b{font-size:.86em; line-height:1.6; color:var(--ink); margin-top:3px}
.pred-god-b .ch{color:var(--muted); font-size:.95em; margin-top:2px}
.pred-god-b .ch.sp{color:var(--red2)}
.pred-stgs{display:flex; gap:8px; flex-wrap:wrap}
.pred-stg{background:#fff; border:1px solid var(--line); border-radius:8px; padding:5px 10px; font-size:.85em; font-family:"Microsoft YaHei",serif; cursor:help}
.pred-stg .pl{color:var(--muted); font-weight:700; margin-right:3px}
.pred-stg b{color:var(--red)}
.pred-stg i{color:var(--muted); font-style:normal; font-size:.85em}
.pred-ln .gd{color:var(--gold)}
.rel-row{font-size:.82em; color:var(--muted); margin:4px 0 6px; display:flex; gap:6px; flex-wrap:wrap; align-items:center}
.rel-chip{font-family:"Microsoft YaHei",serif; font-size:.92em; font-weight:700; border-radius:6px; padding:1px 8px}
.rel-chip.chong{background:#fde8e8; color:var(--red2)}
.rel-chip.triad{background:#e6f2e6; color:var(--green)}
.rel-chip.he{background:#eef0fb; color:#4a4a8a}
.pred-star{border-top:1px dashed var(--line); padding:7px 0}
.pred-star:first-of-type{border-top:none}
.pred-star-h{font-family:"Microsoft YaHei",serif; font-weight:700; display:flex; align-items:center; gap:6px; flex-wrap:wrap}
.pred-star.good .dot{color:var(--green2)} .pred-star.bad .dot{color:var(--red2)}
.pred-star.good b{color:var(--green)} .pred-star.bad b{color:var(--red)}
.pred-star .whr{background:#efeadf; color:var(--muted); border-radius:6px; padding:1px 7px; font-size:.72em; font-weight:700}
.fam-grid{display:flex; flex-direction:column; gap:4px}
.fam-row{display:grid; grid-template-columns:84px 110px 1fr; align-items:center; gap:8px; font-size:.86em; padding:3px 0; border-bottom:1px dashed var(--line)}
.fam-row:last-child{border-bottom:none}
.fam-row .fr-role{font-weight:700; color:var(--ink)}
.fam-row .fr-god{font-family:"Microsoft YaHei",serif; color:var(--gold); font-weight:700}
.fam-row .fr-at{color:var(--green); font-family:"Microsoft YaHei",serif}
.fam-notes{margin-top:8px; border-top:1px solid var(--line); padding-top:6px}
.fam-notes .pred-god-b{margin-top:3px}
.str-bar{display:flex; height:22px; border-radius:7px; overflow:hidden; margin:4px 0 6px; font-size:.72em; font-weight:700; color:#fff}
.str-bar .str-help{background:var(--green2); display:flex; align-items:center; justify-content:center; min-width:0; white-space:nowrap}
.str-bar .str-drain{background:#b9742b; display:flex; align-items:center; justify-content:center; min-width:0; white-space:nowrap}
.pred-blk .str-bar+.pred-god-b .el-mu,.pred-blk .el-huo,.pred-blk .el-tu,.pred-blk .el-jin,.pred-blk .el-shui{font-weight:700; font-family:"Microsoft YaHei",serif}
.pred-blk.pred-special{background:linear-gradient(100deg,#fbf3ff,#fff7e8); border-color:#d9c2ec}
.pred-blk.pred-special .pred-t{color:#7b3fa0}
.pred-blk.pred-special .pred-t b{color:#7b3fa0}

/* 🎲 เลขเด่นประจำงวด */
.bz-lotto{margin-top:16px; border:2px solid var(--gold); border-radius:14px; padding:14px 16px; background:linear-gradient(135deg,#fffdf5,#fff7e8)}
.bz-lotto h3{color:#9a6a14; font-size:.98em; margin-bottom:8px}
.bz-lotto .hb{color:#1a4ad1; font-weight:700}
.lt-best{display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:var(--gold); color:#fff; border-radius:10px; padding:8px 14px; margin-bottom:10px}
.lt-best-l{font-size:.8em; font-weight:700; opacity:.9}
.lt-best-n{font-size:1.5em; font-weight:800; letter-spacing:4px; font-family:Tahoma}
.lt-best .muted{color:#fff; opacity:.85}
.lt-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:8px}
@media(max-width:560px){.lt-grid{grid-template-columns:1fr}}
.lt-box{background:#fff; border:1px solid var(--line); border-radius:10px; padding:10px 12px}
.lt-h{font-size:.8em; color:var(--muted); font-weight:700; margin-bottom:6px}
.lt-h .hot-k{color:var(--gold)} .lt-h .stat-k{color:var(--green2)}
.lt-nums{font-size:1.6em; font-weight:800; letter-spacing:6px; color:var(--gold); font-family:Tahoma}
.lt-digits{display:flex; gap:4px; flex-wrap:wrap}
.lt-d{width:30px; height:30px; display:flex; align-items:center; justify-content:center; border:1px solid var(--line); border-radius:7px; font-weight:700; font-size:1.05em; background:#fafafa; color:var(--ink); position:relative}
.lt-d.stat{border-bottom:3px solid var(--green2)}
.lt-d.hot{background:var(--gold); color:#fff; border-color:var(--gold)}
.lt-tails{display:flex; gap:6px; flex-wrap:wrap}
.lt-tails span{background:#f6f3ea; border:1px solid var(--line); border-radius:7px; padding:3px 9px; font-weight:700; font-family:Tahoma}
.lt-tails span i{color:var(--muted); font-style:normal; font-size:.75em; margin-left:4px}
.lt-disc{font-size:.78em; color:var(--muted); margin-top:6px; line-height:1.5; border-top:1px dashed var(--line); padding-top:6px}
.lt-disc b{color:var(--red2)}

/* ทำนายตามวันออกรางวัล (predict.js) */
.pd-card{margin-top:14px}
.pd-hit{background:#eef7ee; border:1px solid #bfe0bf; border-radius:9px; padding:8px 12px; font-size:.85em; margin-bottom:10px; line-height:1.7}
.pd-hit .ok{color:var(--green2)} .pd-hit .no{color:var(--muted)}
.pd-top{display:flex; flex-wrap:wrap; gap:7px; margin:4px 0 6px}
.pd-num{display:flex; flex-direction:column; align-items:center; min-width:46px; padding:5px 6px; border:1px solid var(--line); border-radius:9px; background:#fafafa; line-height:1.15}
.pd-num i{font-style:normal; font-size:.62em; color:var(--muted)}
.pd-num b{font-family:Tahoma; font-size:1.25em; font-weight:800; color:var(--ink)}
.pd-num em{font-style:normal; font-size:.66em; color:var(--muted)}
.pd-num.fav{border-color:var(--gold)}
.pd-num.inA{background:var(--gold); border-color:var(--gold)} .pd-num.inA b,.pd-num.inA i,.pd-num.inA em{color:#fff}
.pd-legend{font-size:.74em; margin-bottom:4px}
.pd-legend .k{display:inline-block; width:11px; height:11px; border-radius:3px; vertical-align:middle; margin:0 4px 2px 8px}
.pd-legend .k.inA{background:var(--gold)} .pd-legend .k.fav{background:#fff; border:1px solid var(--gold)}
.pd-a{font-size:.8em; margin:2px 0 6px; line-height:1.9}
.pd-ax{display:inline-block; background:#f1ede2; border-radius:6px; padding:1px 7px; margin:0 3px}
.pd-vote{font-size:.82em; line-height:2}
.pd-vl{color:var(--muted); font-weight:700; margin-right:4px}
.pd-vk{display:inline-block; background:#fafafa; border:1px solid var(--line); border-radius:6px; padding:1px 7px; margin:0 3px; font-weight:700; font-family:Tahoma}
.pd-vk i{font-style:normal; font-size:.72em; color:var(--muted); margin-left:3px}
.pd-truth{margin-top:10px; background:#fbf6f0; border:1px solid #e8d8c0; border-radius:9px; padding:4px 12px}
.pd-truth summary{cursor:pointer; font-size:.84em; font-weight:700; color:#9a6a14; padding:6px 0}
.pd-truth-body{font-size:.8em; line-height:1.6; color:var(--ink); padding-bottom:8px}
.pd-cmp{border-collapse:collapse; margin:6px 0; width:100%; max-width:420px}
.pd-cmp th,.pd-cmp td{border:1px solid var(--line); padding:3px 8px; text-align:center; font-size:.92em}
.pd-cmp th{background:#f1ede2}
.pd-warn{background:#fdeeee; border:1px solid #ecc; border-radius:7px; padding:6px 10px; margin-top:6px}
.pd-warn b{color:var(--red2)}

/* ผลรางวัลในแท็บคำนวณสด */
.draw-result h3{color:var(--green)}
.draw-result.none{background:#fbfaf5; border-style:dashed}
.dr-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top:8px}
@media(max-width:560px){.dr-grid{grid-template-columns:1fr}}
.dr-box{background:#f6f3ea; border:1px solid var(--line); border-radius:10px; padding:12px; text-align:center}
.dr-box .drl{display:block; font-size:.8em; color:var(--muted); font-weight:700; margin-bottom:6px}
.dr-box .big{font-size:26px; letter-spacing:2px}
.dr-box .two.big{font-size:24px; padding:4px 12px}

/* ===== BaZi 2-panel layout ===== */
/* bazi layout — single-column, toggle input/output */
.bazi-layout{display:block}
.bazi-panel-output[hidden]{display:none}
.bi-actions{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.bi-open-btn{font-size:.9em}

/* output top bar: back + save inline */
.bazi-output-topbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.bazi-edit-btn{font-size:.9em}
.bazi-savebar-inline{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-left:auto}
.bazi-sync-ok{font-size:.82em;color:#2da06a;background:#e8f9f1;border:1px solid #a8e6c8;border-radius:10px;padding:2px 10px}

/* ===== DB more menu ===== */
.db-more-wrap{position:relative}
.db-more-menu{position:absolute;top:calc(100% + 6px);right:0;z-index:100;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:6px;min-width:210px;box-shadow:0 8px 24px rgba(0,0,0,.18);display:flex;flex-direction:column;gap:2px}
.db-more-item{display:flex;flex-direction:column;align-items:flex-start;padding:8px 12px;border:none;background:transparent;border-radius:6px;cursor:pointer;font-size:.9em;color:var(--text);text-align:left;width:100%}
.db-more-item:hover{background:var(--hover,#f5f1e8)}
.db-more-item span{font-size:.78em;color:var(--muted);margin-top:1px}

/* ===== Slide-in panel ===== */
.db-slidein-overlay{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:200}
.db-slidein{position:fixed;top:0;right:0;bottom:0;width:min(380px,95vw);background:#fff;z-index:201;display:flex;flex-direction:column;box-shadow:-4px 0 24px rgba(0,0,0,.18);overflow:hidden}
.db-slidein-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--line);font-weight:700;font-size:1rem}
.db-slidein-close{font-size:1rem;padding:4px 10px}
#dbSlideinSearch{margin:10px 12px;padding:8px 12px;border:1px solid var(--line);border-radius:8px;font-size:.95em;outline:none}
.db-slidein-section-label{font-size:.75em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);padding:4px 14px 2px}
.db-slidein-presets{padding:4px 8px 8px;border-bottom:1px solid var(--line);display:flex;flex-direction:column;gap:3px}
.db-slidein-preset{padding:8px 12px;border:1px solid var(--line);border-radius:7px;background:transparent;text-align:left;cursor:pointer;font-size:.88em;color:var(--text)}
.db-slidein-preset:hover{background:var(--hover,#f5f1e8);border-color:#c9b97a}
.db-slidein-list{flex:1;overflow-y:auto;padding:6px 8px}
.db-slidein-item{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;cursor:pointer;border-bottom:1px solid var(--line)}
.db-slidein-item:hover{background:var(--hover,#f5f1e8)}
.db-slidein-item-name{font-weight:600;font-size:.92em}
.db-slidein-item-meta{font-size:.78em;color:var(--muted)}
.db-slidein-empty{padding:20px;text-align:center;color:var(--muted);font-size:.9em}

/* ===== DB back bar (เปิดจากคลัง) ===== */
.db-backbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:10px 14px;background:#f5f1e4;border:1px solid #e0d9b8;border-radius:10px;margin-bottom:12px}
.db-backbar[hidden]{display:none}
.db-preset-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-left:auto}
.db-preset-label{font-size:.8em;color:#8a7a50;white-space:nowrap}
.db-preset-btn{padding:5px 11px;border:1px solid #c9b97a;border-radius:6px;background:#fff;color:#5a4a20;font-size:.82em;cursor:pointer;white-space:nowrap}
.db-preset-btn:hover{background:#c9b97a;color:#fff}
