/* GENERATED by bazi-web/tools/sync-xk64.mjs from xk64/styles.css (transform v1) — do not edit.
   Every upstream rule is scoped under .xk64; :root / html / body map to the .xk64 element. */
/* xkdg-date-web — light theme only. Design language + tokens copied from bazi-web/styles.css (shell, card, btn, chip, seg,
   table, tabbar). Views must use these tokens, not new colours. Desktop ≥ 901px, mobile ≤ 900px (see BUILD.md "โครง layout"). */
.xk64 {
  color-scheme: light;
  --ground: #F4F5F2; --card: #FFFFFF; --line: #D9DDD6; --ink: #1A1D1B; --muted: #5A625D;
  --control: #8B938D; --soft: #EEF0EB; --accent: #A8271C; --accent-soft: #FBEDEA; --jade: #1E6650;
  --link: #6B2FA0; --birth-fill: #FBF7DA; --birth-line: #C98A3C; --band: #4F5B66; --amber: #9A5B00;
  /* five elements, indexed like engine ELEMENTS: 0 ทอง 1 น้ำ 2 ไม้ 3 ไฟ 4 ดิน (EleColor ExMain.java:1353) */
  --el-0: #4F5B66; --el-1: #1C5FA8; --el-2: #1F7A3D; --el-3: #B3261E; --el-4: #8A5A12;
  --fav: #8A6A00; --unfav: #B3261E; --norm: #5A625D; --midfav: #1C5FA8;
  --radius: 10px; --font: 'IBM Plex Sans Thai', system-ui, sans-serif; --han: 'Noto Serif TC', 'Songti SC', serif;
  /* calendar day colours = MainForm.CheckMark (ChkMarkColor): 0 none, 1 odd groups, 2 even groups, 3 both, 4 เป็นหนึ่ง, 5 all hours */
  --m0: #FFFFFF; --m1: #CFE8D3; --m2: #F3C877; --m3: #BDCB86; --m4: #F6CFD6; --m5: #F6EFD0;
  /* MasMetaColor (9 trigram groups), tuned for >= 4.5:1 on white */
  --mm-1: #0A6F9C; --mm-2: #A94E0C; --mm-3: #447407; --mm-4: #0B725A; --mm-6: #5F656E; --mm-7: #6F6A1E; --mm-8: #8F6A00; --mm-9: #B3261E;
  --topbar-h: 58px;
}
.xk64 * { box-sizing: border-box; }
.xk64 [hidden] { display: none !important; }
.xk64 { margin: 0; }
.xk64 { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.xk64 { background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; overflow-x: hidden; }
.xk64 a { color: var(--link); text-decoration: none; } .xk64 a:hover { color: #4A1F70; }
.xk64 button, .xk64 input, .xk64 select, .xk64 textarea { font: inherit; color: inherit; }
.xk64 button { cursor: pointer; }
.xk64 :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.xk64 h1 { font-size: 20px; margin: 0; } .xk64 h2 { font-size: 16px; margin: 0; } .xk64 h3 { font-size: 15px; margin: 0; }
.xk64 p { margin: 0; }
.xk64 .muted { color: var(--muted); } .xk64 .small { font-size: 13px; } .xk64 .ok { color: var(--jade); } .xk64 .bad { color: var(--unfav); }
.xk64 .warn { color: var(--amber); font-size: 13px; font-weight: 600; } .xk64 .error { color: var(--unfav); }
.xk64 .nowrap { white-space: nowrap; } .xk64 .num { text-align: right; font-variant-numeric: tabular-nums; }
.xk64 .han { font-family: var(--han); font-weight: 700; }

/* ---------- Shell (bazi-web) ---------- */
.xk64 .shell { min-height: 100vh; display: flex; flex-direction: column; }
.xk64 .topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; min-height: var(--topbar-h); }
.xk64 .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); white-space: nowrap; }
.xk64 .brand:hover { color: var(--ink); }
.xk64 .brand-mark { width: 34px; height: 34px; border-radius: 6px; background: var(--accent); color: #fff; font-family: var(--han); font-size: 20px; display: flex; align-items: center; justify-content: center; }
.xk64 .nav { display: flex; flex-wrap: wrap; gap: 4px; }
.xk64 .nav a { color: var(--ink); padding: 10px 14px; border-radius: 6px; font-weight: 500; }
.xk64 .nav a:hover { background: var(--soft); }
.xk64 .nav a[aria-current="page"] { background: var(--accent); color: #fff; }
.xk64 .topbar .who { margin-left: auto; font-size: 13px; color: var(--muted); }
.xk64 .page { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.xk64 .page:focus { outline: none; }
.xk64 .view { display: flex; flex-direction: column; gap: 20px; min-width: 0; min-height: 0; }
@media (min-width: 901px) { .xk64 .m-only { display: none !important; } }

/* ---------- Building blocks (bazi-web) ---------- */
.xk64 .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.xk64 .row.tight { margin-top: 0; gap: 6px; }
.xk64 .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.xk64 .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.xk64 .card.flush { padding: 0; overflow: hidden; }
.xk64 .card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.xk64 .card-head.pad { padding: 12px 16px 0; }
.xk64 .sec-h { font-size: 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; } .xk64 .sec-h small { font-weight: 500; font-size: 13px; }
.xk64 .btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--control); background: var(--card); color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.xk64 .btn:hover { background: var(--soft); color: var(--ink); }
.xk64 .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .xk64 .btn.primary:hover { background: #8F2018; color: #fff; }
.xk64 .btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.xk64 .btn.icon { width: 44px; padding: 0; font-size: 22px; line-height: 1; }
.xk64 .btn.wide { width: 100%; }
.xk64 .btn.danger { color: var(--unfav); }
.xk64 .btn[disabled], .xk64 .btn:disabled { opacity: .45; cursor: not-allowed; }
.xk64 .btn.link { border: 0; background: none; color: var(--link); padding: 0 4px; min-height: 32px; text-decoration: underline; font-weight: 500; }
.xk64 .seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.xk64 .seg > button, .xk64 .chip { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--control); background: var(--card); font-weight: 600; color: var(--ink); }
.xk64 .chip:hover, .xk64 .seg > button:hover { background: var(--soft); }
.xk64 .seg > button[aria-pressed="true"], .xk64 .chip[aria-pressed="true"], .xk64 .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.xk64 .chip:disabled { opacity: .45; cursor: not-allowed; }
.xk64 .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0 0 12px; }
.xk64 .field > span, .xk64 .field > label, .xk64 .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.xk64 .input, .xk64 .select, .xk64 select.input, .xk64 .pform input:not([type=checkbox]) { min-height: 44px; padding: 0 12px; border: 1px solid var(--control); border-radius: 8px; background: #fff; width: 100%; min-width: 0; font-size: 15px; }
.xk64 .table, .xk64 .tbl table { width: 100%; border-collapse: collapse; font-size: 14px; }
.xk64 .table th, .xk64 .table td, .xk64 .tbl th, .xk64 .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.xk64 .table th, .xk64 .tbl thead th, .xk64 .tbl tbody th { font-size: 13px; color: var(--muted); font-weight: 600; }
.xk64 .table tr[aria-selected="true"] td { background: var(--accent-soft); }
.xk64 .tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.xk64 .toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 30; }
.xk64 .toast.show { opacity: 1; transform: translateX(-50%); }
.xk64 .tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid currentColor; color: var(--jade); }

/* toggle switch (ui/common.js toggle) */
.xk64 .tgl { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; padding: 4px 0; position: relative; }
.xk64 .tgl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.xk64 .tgl-ui { flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--control); position: relative; transition: background .15s; }
.xk64 .tgl-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); transition: transform .15s; }
.xk64 .tgl input:checked + .tgl-ui { background: var(--accent); } .xk64 .tgl input:checked + .tgl-ui::after { transform: translateX(16px); }
.xk64 .tgl input:focus-visible + .tgl-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.xk64 .tgl-text { font-size: 15px; font-weight: 500; } .xk64 .tgl-text small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.xk64 .tgl.is-disabled { cursor: not-allowed; opacity: .55; }

/* ---------- Colours of elements / trigram numbers / lines ---------- */
.xk64 .ele0 { color: var(--el-0); } .xk64 .ele1 { color: var(--el-1); } .xk64 .ele2 { color: var(--el-2); } .xk64 .ele3 { color: var(--el-3); } .xk64 .ele4 { color: var(--el-4); }
/* TopColor (c0) / MasMetaColor (c1) for numbers and trigram names (WriteMeta :3546-3553) */
.xk64 .c0-1, .xk64 .c0-6 { color: var(--el-1); } .xk64 .c0-2, .xk64 .c0-7 { color: var(--el-3); } .xk64 .c0-3, .xk64 .c0-8 { color: var(--el-2); } .xk64 .c0-4, .xk64 .c0-9 { color: var(--el-0); }
.xk64 .c1-1 { color: var(--mm-1); } .xk64 .c1-2 { color: var(--mm-2); } .xk64 .c1-3 { color: var(--mm-3); } .xk64 .c1-4 { color: var(--mm-4); } .xk64 .c1-6 { color: var(--mm-6); } .xk64 .c1-7 { color: var(--mm-7); } .xk64 .c1-8 { color: var(--mm-8); } .xk64 .c1-9 { color: var(--mm-9); }
/* ring labels (fill) */
.xk64 .nf0-1, .xk64 .nf0-6 { fill: var(--el-1); } .xk64 .nf0-2, .xk64 .nf0-7 { fill: var(--el-3); } .xk64 .nf0-3, .xk64 .nf0-8 { fill: var(--el-2); } .xk64 .nf0-4, .xk64 .nf0-9 { fill: var(--el-0); } .xk64 .nf0-5, .xk64 .nf1-5 { fill: var(--ink); }
.xk64 .nf1-1 { fill: var(--mm-1); } .xk64 .nf1-2 { fill: var(--mm-2); } .xk64 .nf1-3 { fill: var(--mm-3); } .xk64 .nf1-4 { fill: var(--mm-4); } .xk64 .nf1-6 { fill: var(--mm-6); } .xk64 .nf1-7 { fill: var(--mm-7); } .xk64 .nf1-8 { fill: var(--mm-8); } .xk64 .nf1-9 { fill: var(--mm-9); }
/* trigram line colours: MetaColor (t0, F06 :1359) / MasMetaColor (t1, :1360) — upper = เลขบน, lower = ConvMetaLow */
.xk64 .t0-1 { fill: var(--el-4); } .xk64 .t0-2 { fill: var(--el-2); } .xk64 .t0-3 { fill: var(--el-3); } .xk64 .t0-4 { fill: var(--el-0); } .xk64 .t0-6 { fill: var(--el-4); } .xk64 .t0-7 { fill: var(--el-1); } .xk64 .t0-8 { fill: var(--el-2); } .xk64 .t0-9 { fill: var(--el-0); }
.xk64 .t1-1 { fill: var(--mm-1); } .xk64 .t1-2 { fill: var(--mm-2); } .xk64 .t1-3 { fill: var(--mm-3); } .xk64 .t1-4 { fill: var(--mm-4); } .xk64 .t1-6 { fill: var(--mm-6); } .xk64 .t1-7 { fill: var(--mm-7); } .xk64 .t1-8 { fill: var(--mm-8); } .xk64 .t1-9 { fill: var(--mm-9); }

/* hexagram block (WriteMeta): names above/below, 6 coloured lines, เลขบน coloured, เลขล่าง ink, element below, ▲ */
.xk64 .mb { display: inline-grid; justify-items: center; gap: 0; vertical-align: middle; }
.xk64 .mb-n { font-size: 12px; line-height: 1.15; font-weight: 700; white-space: nowrap; }
.xk64 .mb-body { display: inline-flex; align-items: center; gap: 3px; }
.xk64 .mb-l { display: block; }
.xk64 .mb-nums { display: grid; line-height: 1.05; }
.xk64 .mb-nums b { font: 700 18px/1.05 var(--font); text-align: center; }
.xk64 .mb-nums .mb-low { color: var(--ink); }
.xk64 .mb-mk { display: block; height: 2px; width: 14px; margin: 0 auto; }
.xk64 .mb-mk.mg { background: var(--link); } .xk64 .mb-mk.rb { background: var(--el-1); }
.xk64 .mb-cn { font: 600 15px var(--han); }
.xk64 .mb-ele { font: 700 16px var(--font); margin-top: 4px; }
.xk64 .mb-tri { font-style: normal; font-size: 16px; line-height: 1; margin-top: 2px; } .xk64 .mb-tri.b { color: var(--el-1); } .xk64 .mb-tri.o { color: var(--amber); }
.xk64 .mb.inl { display: inline-flex; align-items: center; gap: 3px; margin: 0 3px; }
.xk64 .mb.inl .mb-l { width: 16px; height: 21px; } .xk64 .mb.inl .mb-nums b { font-size: 12px; }
.xk64 .mb.inl .mb-mk { display: none; }
/* pillar (WriteHESymbol3): stem / ธาตุ± / branch / นักษัตร / ธาตุ± */
.xk64 .pc { display: grid; justify-items: center; line-height: 1.05; }
.xk64 .pc-s { font: 700 30px/1.15 var(--han); }
.xk64 .pc-t { font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.3; }
.xk64 .gz { display: inline-grid; grid-template-rows: auto auto; line-height: 1.05; font-family: var(--han); font-weight: 700; vertical-align: middle; text-align: center; }

/* ---------- Main page: calendar (views/calendar.js) ---------- */
.xk64 .cal-view { display: grid; gap: 16px; min-width: 0; }
.xk64 .cal-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.xk64 .side-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.xk64 .side-card .card-head { margin-bottom: 0; }
.xk64 .side-card h2 { font-size: 15px; }
.xk64 .p4, .xk64 .pdir { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--birth-line); border-radius: 8px; background: var(--birth-fill); color: var(--ink); min-width: 0; }
.xk64 .p4:hover, .xk64 .pdir:hover { color: var(--ink); border-color: var(--accent); }
.xk64 .p4 svg, .xk64 .pdir svg { flex: none; color: var(--accent); }
.xk64 .p4 > span { min-width: 0; } .xk64 .p4 b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .xk64 .p4 small { display: block; font-size: 13px; color: var(--muted); }
.xk64 .pdir span { font-weight: 600; }
.xk64 .dygrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.xk64 .dygrid .chip { padding: 0 4px; min-height: 40px; }
.xk64 .sys-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.xk64 .sys-seg > button:last-child { grid-column: 1 / -1; }
.xk64 .sys-seg > button { padding: 0 4px; min-height: 40px; font-size: 14px; white-space: nowrap; }
.xk64 .side-card .row .chip { min-height: 36px; padding: 0 10px; font-size: 13px; }
.xk64 .sartbar { color: var(--ink); font-size: 14px; line-height: 1.35; min-width: 0; }
.xk64 .sartbar > span { font-weight: 600; } .xk64 .sartbar small { display: block; color: var(--muted); font-size: 13px; }
.xk64 .sartbar .cf { color: var(--el-1); font-family: var(--han); }
.xk64 .mf-range { color: var(--jade); font-weight: 600; font-size: 13px; } .xk64 .mf-range small { font-weight: 400; margin-left: 4px; }
.xk64 .legend summary, .xk64 .monthlist summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-weight: 600; font-size: 14px; }
.xk64 .legend ul { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; font-size: 13px; }
.xk64 .legend li { display: flex; align-items: flex-start; gap: 8px; }
.xk64 .legend li small { display: block; color: var(--muted); font-size: 12px; }
.xk64 .daylist { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
.xk64 .daylist a { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; color: var(--ink); padding: 6px; border: 1px solid var(--line); border-radius: 8px; min-height: 48px; }
.xk64 .daylist a:hover { background: var(--soft); }
.xk64 .daylist small { display: block; color: var(--muted); font-size: 12px; }
.xk64 .li-d { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; font-weight: 700; background: var(--m0); border: 1px solid var(--jade); }
.xk64 .li-d.m1, .xk64 .sw.m1, .xk64 .psw.m1 { background: var(--m1); } .xk64 .li-d.m2, .xk64 .sw.m2, .xk64 .psw.m2 { background: var(--m2); } .xk64 .li-d.m3, .xk64 .sw.m3, .xk64 .psw.m3 { background: var(--m3); } .xk64 .li-d.m4, .xk64 .sw.m4, .xk64 .psw.m4 { background: var(--m4); } .xk64 .li-d.m5, .xk64 .sw.m5 { background: var(--m5); }
.xk64 .sw { display: inline-block; flex: none; width: 16px; height: 16px; border-radius: 4px; background: var(--m0); border: 1px solid var(--line); vertical-align: -3px; }
.xk64 .sw.sel { background: var(--card); box-shadow: inset 0 0 0 2px var(--ink); }
.xk64 .sw.pass { background: var(--jade); border-color: var(--jade); } .xk64 .sw.fail { background: var(--soft); }

.xk64 .cal-main { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; min-width: 0; min-height: 0; }
.xk64 .cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.xk64 .cal-y { display: flex; align-items: center; gap: 6px; }
.xk64 .cal-year { padding: 0 12px; font-size: 15px; }
.xk64 .pm10 { display: inline-flex; gap: 4px; } .xk64 .pm10 .btn { padding: 0 10px; }
.xk64 .cal-title { font-size: 20px; white-space: nowrap; }
.xk64 .cal-tools { display: flex; align-items: center; gap: 4px; }
.xk64 .cal-tools .tool { width: 36px; min-height: 36px; border-color: var(--line); }
.xk64 .calpick { display: flex; align-items: center; gap: 8px; } .xk64 .calpick .input { max-width: 220px; }
.xk64 .mf-months { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 4px; }
.xk64 .mf-months .mm { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.xk64 .mon { min-height: 40px; padding: 0 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; }
.xk64 .mon:hover { background: var(--soft); }
.xk64 .mon.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.xk64 .mon.pm { font-size: 20px; line-height: 1; border-color: var(--control); }
.xk64 .mon:disabled { opacity: .45; cursor: not-allowed; }
.xk64 .cal-grid { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.xk64 .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.xk64 .grid.wk div { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.xk64 .grid.wk div.sun { color: var(--unfav); } .xk64 .grid.wk div.sat { color: var(--link); }
.xk64 .cell { position: relative; min-width: 0; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--m0); color: var(--ink); overflow: hidden; }
.xk64 .cell:hover { color: var(--ink); border-color: var(--control); }
.xk64 .cell.empty { background: var(--ground); border-color: transparent; }
.xk64 .cell .dnum { grid-column: 1; grid-row: 1; font-weight: 700; font-size: 14px; line-height: 1.2; display: flex; align-items: center; gap: 4px; }
.xk64 .cell .dgz { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.xk64 .cell .dcount { grid-column: 1 / -1; grid-row: 3; text-align: center; font-size: 12px; font-weight: 700; color: var(--jade); line-height: 1.2; }
.xk64 .sart { color: var(--amber); font-size: 12px; line-height: 1; font-family: var(--han); }
.xk64 .cell.m1, .xk64 .cell.m2, .xk64 .cell.m3, .xk64 .cell.m4, .xk64 .cell.m5 { border-color: var(--jade); box-shadow: inset 0 0 0 1px var(--jade); }
.xk64 .cell.m1 { background: var(--m1); } .xk64 .cell.m2 { background: var(--m2); } .xk64 .cell.m3 { background: var(--m3); } .xk64 .cell.m4 { background: var(--m4); } .xk64 .cell.m5 { background: var(--m5); }
.xk64 .cell.stopped { background: repeating-linear-gradient(135deg, var(--m0), var(--m0) 6px, var(--soft) 6px, var(--soft) 12px); }
.xk64 .cell.today .dnum { color: #fff; background: var(--ink); border-radius: 999px; padding: 0 6px; }
.xk64 .cell.sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.xk64 .cal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.xk64 .cal-sum b { color: var(--ink); }
.xk64 .legend-inline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.xk64 .legend-inline li { display: inline-flex; align-items: center; gap: 5px; }
.xk64 .mf-adv { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.xk64 .xbtn { width: 36px; height: 36px; flex: none; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font-weight: 700; }
.xk64 .advice { color: var(--unfav); }

/* ---------- Day detail (views/day.js panel; DateShowForm content) ---------- */
.xk64 .ds2 { display: flex; flex-direction: column; min-width: 0; }
.xk64 .ds2-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.xk64 .dsx { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--card); }
.xk64 .dh { min-height: 52px; display: grid; place-items: center; text-align: center; font: 600 15px/1.2 var(--font); background: var(--band); color: #fff; padding: 4px 2px; }
.xk64 .dh-dir { border-right: 1px solid var(--card); } .xk64 .dh-dir.off { opacity: .7; }
.xk64 .dh-dy { background: var(--soft); grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.xk64 .dh-dy.off { opacity: .7; }
.xk64 .dh-dy button { border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: 600 13px/1 var(--font); color: var(--muted); min-height: 32px; padding: 0; min-width: 0; }
.xk64 .dh-dy button:hover { border-color: var(--control); }
.xk64 .dy-cur { display: none; }
.xk64 .dy-seg { display: none; }
.xk64 .dh-dy button.act { color: var(--accent); } .xk64 .dh-dy button.orange { color: var(--amber); } .xk64 .dh-dy button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.xk64 .dsx .dh-t { grid-column: 3 / span 4; grid-template-columns: repeat(4, 1fr); grid-template-rows: auto auto; gap: 0; }
.xk64 .dsx .dh-t .app { grid-column: 1 / -1; font-size: 13px; font-weight: 500; opacity: .85; }
.xk64 .dsx .dh-t .red, .xk64 .dsx .dh-t .mcm { background: var(--accent); border-radius: 4px; padding: 0 6px; }
.xk64 .dsx .dh-t .mcm { position: relative; padding-left: 14px; } .xk64 .dsx .dh-t .mcm::before { content: ''; position: absolute; left: 4px; top: 50%; width: 7px; height: 7px; margin-top: -3px; border-radius: 50%; background: var(--birth-line); }
.xk64 .dc { border-right: 1px solid var(--line); padding: 8px 1px 10px; min-width: 0; }
.xk64 .dc:last-child { border-right: 0; }
.xk64 .dc-b { display: grid; justify-items: center; gap: 10px; }
.xk64 .dc-b.dash { color: var(--muted); font-size: 22px; gap: 40px; padding-top: 16px; }
.xk64 .dc.mcf { outline: 2px solid var(--birth-line); outline-offset: -2px; background: var(--birth-fill); }
.xk64 .bar { padding: 10px 12px; border-top: 1px solid var(--line); }
.xk64 .b-date { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--soft); }
.xk64 .b-date > div { display: grid; gap: 2px; font-size: 15px; } .xk64 .b-date > div > span:first-child { font-weight: 700; } .xk64 .b-date > div > span:last-child { font-size: 14px; color: var(--muted); }
.xk64 .bnav { display: flex; gap: 6px; }
.xk64 .b-fore { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; font-size: 15px; border-left: 4px solid var(--jade); background: var(--ground); }
.xk64 .b-fore > :not(.tip) { grid-column: 1; } .xk64 .b-fore > .tip { grid-column: 2; grid-row: 1; align-self: start; }
.xk64 .fi-what { font-size: 13px; color: var(--muted); line-height: 1.4; }
.xk64 .b-fore b { font-size: 17px; color: var(--jade); }
.xk64 .b-fore.is-none { border-left-color: var(--unfav); } .xk64 .b-fore .none { color: var(--unfav); } .xk64 .b-fore .why { color: var(--muted); font-size: 13px; }
.xk64 .b-n { display: flex; align-items: center; gap: 10px; }
.xk64 .b-n .n { color: var(--jade); font-weight: 700; font-size: 16px; } .xk64 .b-n .score { margin-right: auto; color: var(--ink); }
.xk64 .b-n .btn, .xk64 .bnav .btn { flex: none; }
.xk64 .fore-list { border-top: 1px solid var(--line); }
.xk64 .fore-tbl { font-size: 14px; }
.xk64 .fore-tbl th, .xk64 .fore-tbl td { padding: 6px 10px; vertical-align: middle; }
.xk64 .fore-tbl tbody tr { cursor: pointer; } .xk64 .fore-tbl tbody tr:hover td { background: var(--soft); }
.xk64 .fore-tbl tr[aria-selected="true"] td { background: var(--accent-soft); font-weight: 600; }
.xk64 .fi-b { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--control); background: var(--card); font-weight: 700; font-size: 13px; }
.xk64 .fore-tbl tr[aria-selected="true"] .fi-b { background: var(--accent); border-color: var(--accent); color: #fff; }
.xk64 .b-foot { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; background: var(--soft); }
.xk64 .b-foot .fb { display: grid; gap: 4px; } .xk64 .b-foot .chip { min-height: 36px; font-size: 13px; padding: 0 10px; }
.xk64 .pbox { display: grid; text-align: center; background: var(--birth-fill); border: 1px solid var(--birth-line); border-radius: 8px; padding: 4px 10px; color: var(--ink); min-width: 64px; }
.xk64 .pbox small { font-size: 12px; color: var(--muted); } .xk64 .pbox b { font-size: 14px; }
.xk64 .ds-memo, .xk64 .ds-why { padding: 8px 12px; border-top: 1px solid var(--line); }
.xk64 .ds-memo { font-weight: 600; }

/* day page: extra cards */
.xk64 .day-view { display: grid; gap: 20px; min-width: 0; }
.xk64 .day-extra { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.xk64 .day-extra .card h2 { margin-bottom: 8px; }
.xk64 .day-extra .card p { margin: 4px 0; }
.xk64 .hours { display: grid; gap: 6px; margin-top: 8px; }
.xk64 .hour { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.xk64 .hour.is-pass { border-color: var(--jade); box-shadow: inset 3px 0 0 var(--jade); }
.xk64 .hour summary { list-style: none; display: grid; grid-template-columns: 108px 64px 40px 1fr auto; gap: 4px 8px; align-items: center; padding: 6px 10px; cursor: pointer; min-height: 48px; }
.xk64 .hour summary::-webkit-details-marker { display: none; }
.xk64 .h-time { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.xk64 .h-an { font-size: 13px; color: var(--muted); }
.xk64 .h-gz { font-size: 16px; }
.xk64 .h-hex { justify-self: start; }
.xk64 .st { font-size: 13px; border-radius: 999px; padding: 1px 10px; font-weight: 600; justify-self: end; white-space: nowrap; }
.xk64 .st.pass { background: var(--jade); color: #fff; } .xk64 .st.cut { color: var(--unfav); border: 1px solid var(--unfav); } .xk64 .st.none { color: var(--muted); padding: 0; }
.xk64 .h-body { padding: 4px 12px 12px; border-top: 1px dashed var(--line); font-size: 14px; }
.xk64 .why { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.xk64 .why li { background: var(--ground); border-radius: 8px; padding: 8px 10px; } .xk64 .why p { margin: 4px 0 0; }
.xk64 .cmp { padding: 10px 0; border-top: 1px dashed var(--line); } .xk64 .cmp p { margin: 4px 0; }
.xk64 .cmp-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.xk64 .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--jade); }

/* ---------- ทิศบ้าน (views/direction.js) ---------- */
.xk64 .dir-view { display: grid; gap: 20px; min-width: 0; }
.xk64 .dir-left { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.xk64 .dir-left .card > p { margin: 6px 0; }
.xk64 .angrow { display: grid; grid-template-columns: auto minmax(0, 160px) auto; justify-content: start; gap: 8px; align-items: center; margin: 10px 0; }
.xk64 .dayhead { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; margin-bottom: 8px; }
.xk64 .dayhead .dh-t { text-align: center; } .xk64 .dayhead .dh-t small { display: block; color: var(--muted); font-size: 13px; }
.xk64 .ring { width: 100%; max-width: 440px; display: block; margin: 8px auto; touch-action: manipulation; }
.xk64 .sec { stroke: var(--card); stroke-width: 1; cursor: pointer; }
.xk64 .sec.pass { fill: var(--m1); } .xk64 .sec.fail { fill: var(--soft); } .xk64 .sec.err { fill: var(--m2); }
.xk64 .sec.sel { stroke: var(--accent); stroke-width: 3; }
.xk64 .seclbl { font-size: 7.5px; text-anchor: middle; fill: var(--ink); pointer-events: none; font-weight: 700; }
.xk64 .cardinal { font-size: 10px; text-anchor: middle; fill: var(--muted); }
.xk64 .needle { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; } .xk64 .hub { fill: var(--accent); }
.xk64 p.legend-inline { display: flex; }
.xk64 .dirtbl tr.sel td { background: var(--accent-soft); }
.xk64 .dirtbl td:nth-child(2) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.xk64 .dirtbl thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }

/* ---------- เงื่อนไข (views/settings.js) ---------- */
.xk64 .pf-view { display: grid; gap: 16px; min-width: 0; }
.xk64 .pf-side { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.xk64 .pf-grp { display: grid; gap: 2px; }
.xk64 .pf-lbl { padding: 6px 6px 0; }
.xk64 .pt { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); text-align: left; font-weight: 500; font-size: 14px; }
.xk64 .pt:hover { background: var(--soft); color: var(--ink); }
.xk64 .pt.on, .xk64 .pt[aria-current="page"] { background: var(--accent); color: #fff; }
.xk64 .pt-n { flex: none; min-width: 30px; height: 26px; padding: 0 4px; border-radius: 6px; background: var(--soft); color: var(--ink); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.xk64 .pt.on .pt-n { background: var(--card); color: var(--accent); }
.xk64 .pf-g0 .pt-n { display: none; }
.xk64 .pf-g2 { grid-template-columns: 1fr 1fr; }
.xk64 .pf-g2 .pb.pt { justify-content: center; min-height: 40px; font-size: 14px; }
.xk64 .pf-main { min-width: 0; }
.xk64 .pf-main .card-head h1 { font-size: 18px; }
.xk64 .pf2 { display: flex; flex-direction: column; gap: 12px; }
.xk64 .pf2-body { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.xk64 .pf2-body hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.xk64 .pf-step { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; max-width: 820px; }
.xk64 .lock { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; color: var(--accent); }
.xk64 .ph { color: var(--ink); font-size: 15px; margin: 2px 0; } .xk64 .ph.c { text-align: center; } .xk64 .ph.dred { color: var(--accent); } .xk64 .ph.u { text-decoration: underline; }
.xk64 .pn { color: var(--muted); font-size: 13px; text-align: center; } .xk64 .pl { color: var(--ink); font-weight: 600; margin: 0; }
.xk64 .pb { position: relative; min-height: 44px; padding: 2px 10px; border: 1px solid var(--control); border-radius: 8px; background: var(--card); color: var(--ink); font: 600 14px/1.2 var(--font); cursor: pointer; }
.xk64 .pb:hover:not(:disabled) { background: var(--soft); }
.xk64 .pb.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.xk64 .pb.on:hover:not(:disabled) { background: #8F2018; }
.xk64 .pb.wide { width: 100%; }
.xk64 .pb.grey { background: var(--soft); min-height: 48px; margin-top: 16px; }
.xk64 .pb:disabled { cursor: not-allowed; } .xk64 .pb:disabled:not(.on) { color: var(--muted); }
.xk64 .pb.na { opacity: .5; border-style: dashed; }
.xk64 .na-m { position: absolute; top: 1px; right: 4px; font-size: 12px; font-style: normal; color: var(--accent); }
.xk64 .g2, .xk64 .g3, .xk64 .g4, .xk64 .g6, .xk64 .g10 { display: grid; gap: 6px; }
.xk64 .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .xk64 .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .xk64 .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.xk64 .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } .xk64 .g10 { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.xk64 .g2.indent { padding: 0 10%; }
.xk64 .phrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .xk64 .phrow.r { justify-content: flex-end; }
.xk64 .phrow .pb { flex: 0 1 auto; } .xk64 .phrow .pb.wide { flex: 1 1 auto; width: auto; }
.xk64 .q { color: var(--muted); font-weight: 700; margin-left: auto; }
.xk64 .pf2 .dot { width: 20px; height: 20px; background: var(--control); flex: none; }
.xk64 .elr { display: grid; grid-template-columns: 110px auto 96px 20px; gap: 10px; align-items: center; font-size: 14px; justify-content: start; }
.xk64 .eic { font-size: 13px; } .xk64 .pb.on .eic { color: #fff; }
.xk64 .sc { min-height: 40px; border: 1px solid var(--control); border-radius: 8px; text-align: center; font: 600 16px var(--font); background: var(--card); width: 100%; }
.xk64 .sc.off { display: grid; place-items: center; color: var(--muted); border-color: var(--line); }
.xk64 .fixopt { display: flex; gap: 6px; align-items: center; background: var(--ground); border-radius: 8px; padding: 6px; }
.xk64 .anm { font-family: var(--han); }
.xk64 .ao { display: inline-flex; gap: 4px; }
.xk64 .pb.ttl { flex: 1 1 auto; }
.xk64 .cb { display: grid; justify-items: center; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 0; min-width: 0; }
.xk64 .cb b { font: 700 18px var(--han); } .xk64 .cb small { font-size: 12px; white-space: nowrap; }
.xk64 .cb .fmk { font-style: normal; display: block; font-size: 13px; color: var(--ink); }
.xk64 .grey-box { background: var(--band); padding: 8px; border-radius: 8px; display: grid; gap: 6px; } .xk64 .grey-box .phrow { flex-wrap: nowrap; } .xk64 .grey-box .phrow .pb { flex: 1; }
.xk64 .grey-box .red { color: #fff; }
.xk64 .red { color: var(--accent); } .xk64 .red.big { font-size: 18px; } .xk64 .lbl { color: var(--ink); font-weight: 600; }
.xk64 .tc { display: inline-flex; gap: 4px; } .xk64 .tc .pb { min-width: 44px; }
.xk64 .fnrow .fnc { display: grid; grid-template-columns: auto auto; align-items: center; justify-items: center; gap: 0 4px; }
.xk64 .fnc small:first-child { grid-column: 1 / -1; font-size: 12px; } .xk64 .fnc b { font: 700 28px var(--han); }
.xk64 .fnc .pb.chk { width: 32px; min-height: 32px; padding: 0; grid-row: 2; grid-column: 2; } .xk64 .fnc small:nth-of-type(2) { grid-column: 1; font-size: 12px; }
.xk64 .dec-box { background: var(--ground); padding: 8px; border-radius: 8px; border: 1px solid var(--line); display: grid; gap: 6px; }
.xk64 .pb.sq { min-width: 44px; }
.xk64 .wk10 .lbl { align-self: center; }
.xk64 .pb.hr { font-size: 13px; padding: 2px 2px; } .xk64 .pb.hr small { font-size: 12px; }
.xk64 .psr { display: grid; grid-template-columns: 1fr 40px; gap: 10px; align-items: center; }
.xk64 .psw { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 6px; display: inline-block; flex: none; }
.xk64 .psw.none { border: 0; }
.xk64 .pnote { display: flex; gap: 10px; align-items: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.xk64 .psp { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center; }
.xk64 .psp.sub { grid-template-columns: auto 1fr 1fr auto; color: var(--muted); }
.xk64 .psp.sub1 { grid-template-columns: auto 1fr auto; color: var(--muted); }
.xk64 .pb.ao { min-width: 56px; }
.xk64 .dfx { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.xk64 .df-panel { background: var(--ground); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.xk64 .df-cap { text-align: center; font-weight: 700; font-size: 17px; }
.xk64 .preset .row { margin-top: 4px; }
.xk64 .optf { display: flex; flex-direction: column; gap: 4px; max-width: 820px; }
.xk64 .optf > p { margin: 2px 0; }
.xk64 .optf .btn, .xk64 .dfx .btn { white-space: normal; text-align: center; padding-block: 6px; line-height: 1.3; }

/* ---------- เจ้าของดวง (views/people.js) ---------- */
.xk64 .ppl-view { display: grid; gap: 20px; min-width: 0; }
.xk64 .people { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.xk64 .people li { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; }
.xk64 .people li.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.xk64 .pick { text-align: left; border: 0; background: none; color: var(--ink); cursor: pointer; display: grid; gap: 2px; padding: 4px; min-height: 44px; }
.xk64 .pick small { color: var(--muted); font-size: 13px; }
.xk64 .minis { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.xk64 .mini { display: inline-flex; gap: 4px; align-items: center; font-size: 15px; } .xk64 .mini small { font-size: 12px; color: var(--muted); }
.xk64 .acts { display: flex; gap: 8px; justify-content: flex-end; }
.xk64 .fp { display: flex; flex-direction: column; gap: 10px; }
.xk64 .fpx { display: grid; grid-template-columns: 1.1fr repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.xk64 .fh { background: var(--band); color: #fff; padding: 6px 2px; }
.xk64 .fh-dir { font: 700 17px var(--font); display: grid; place-items: center; border-right: 1px solid var(--card); }
.xk64 .fh-t { grid-column: 2 / span 4; display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.xk64 .fh-t b { display: block; font-size: 16px; } .xk64 .fh-t small { display: block; font-size: 12px; min-height: 1em; opacity: .9; }
.xk64 .fc { padding: 10px 0; display: grid; justify-items: center; min-width: 0; border-right: 1px solid var(--line); } .xk64 .fc:last-child { border-right: 0; }
.xk64 .fc-dir { background: var(--ground); }
.xk64 .fpc-b { display: grid; justify-items: center; gap: 10px; }
.xk64 .fp-birth { border: 1px solid var(--birth-line); border-radius: 8px; background: var(--birth-fill); padding: 8px 12px; }
.xk64 .fp-birth span { color: var(--muted); font-size: 14px; }
.xk64 .pform { max-width: 720px; width: 100%; margin: 0 auto; }
.xk64 .pform .tgl { align-self: end; }

/* =================== Desktop (≥ 901px) =================== */
@media (min-width: 901px) {
  /* main page: side cards | calendar | selected day — one screen, only the side/panel columns scroll */
  .xk64 .shell[data-view~="main"] { height: 100vh; min-height: 0; }
  .xk64 .shell[data-view~="main"] .page { min-height: 0; overflow: hidden; padding: 16px 24px; }
  .xk64 .shell[data-view~="main"] .view { flex: 1; min-height: 0; }
  .xk64 .cal-view { flex: 1; min-height: 0; grid-template-columns: 264px minmax(0, 1fr) minmax(400px, 452px); align-items: stretch; }
  .xk64 .cal-side { overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
  .xk64 .cal-main { min-height: 0; }
  .xk64 .cal-grid { flex: 1 1 auto; }
  .xk64 .grid.days { flex: 1 1 auto; min-height: 0; }
  .xk64 .grid.days.r4 { grid-template-rows: repeat(4, minmax(0, 1fr)); } .xk64 .grid.days.r5 { grid-template-rows: repeat(5, minmax(0, 1fr)); } .xk64 .grid.days.r6 { grid-template-rows: repeat(6, minmax(0, 1fr)); }
  .xk64 .card.flush.cal-day { overflow-y: auto; overscroll-behavior: contain; min-height: 0; max-height: 100%; }
  .xk64 .card.flush.day-main { overflow-y: auto; }
  .xk64 .cal-day .ds2-head { position: sticky; top: 0; z-index: 2; background: var(--card); }

  .xk64 .day-view { grid-template-columns: minmax(420px, 500px) minmax(0, 1fr); align-items: start; }
  .xk64 .day-main { position: sticky; top: 16px; max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; overscroll-behavior: contain; }
  .xk64 .dir-view { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .xk64 .dir-tblcard { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 48px); }
  .xk64 .dir-scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
  .xk64 .ppl-view { grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); align-items: start; }
  .xk64 .pf-view { grid-template-columns: 248px minmax(0, 1fr); align-items: start; }
  .xk64 .pf-side { position: sticky; top: 16px; max-height: calc(100vh - var(--topbar-h) - 48px); overflow-y: auto; }
}
@media (min-width: 901px) and (max-width: 1279px) {
  .xk64 .shell[data-view~="main"] { height: auto; min-height: 100vh; }
  .xk64 .shell[data-view~="main"] .page { overflow: visible; }
  .xk64 .cal-view { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); grid-template-areas: "cal day" "side side"; align-items: start; }
  .xk64 .cal-main { grid-area: cal; height: calc(100vh - var(--topbar-h) - 32px); min-height: 520px; }
  .xk64 .card.flush.cal-day { grid-area: day; height: calc(100vh - var(--topbar-h) - 32px); min-height: 520px; max-height: none; }
  .xk64 .cal-side { grid-area: side; overflow: visible; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
  .xk64 .cal-side > .scroll-cue { display: none; }
}
@media (min-width: 901px) and (max-height: 760px) {
  .xk64 .cal-main { gap: 6px; padding: 10px 12px; } .xk64 .mon { min-height: 34px; } .xk64 .cal-head .btn { min-height: 36px; } .xk64 .cal-head .btn.icon { width: 36px; }
  .xk64 .cell .dgz { font-size: 16px; }
}

/* =================== Mobile (≤ 900px) — bazi-web: compact top bar, cards stacked, bottom tab bar =================== */
@media (max-width: 900px) {
  .xk64 { --tabbar-h: 58px; }
  .xk64 .d-only { display: none !important; }
  .xk64 input, .xk64 select, .xk64 textarea, .xk64 .input { font-size: 16px; }
  .xk64 .topbar { flex-wrap: nowrap; gap: 10px; min-height: 0; padding: calc(6px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
  .xk64 .brand { font-size: 16px; gap: 8px; min-height: 44px; flex: none; }
  .xk64 .brand-mark { width: 30px; height: 30px; font-size: 18px; }
  .xk64 .topbar .who { min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .xk64 .page { padding: 12px max(8px, env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px) max(8px, env(safe-area-inset-left)); gap: 12px; overflow-x: clip; }
  .xk64 .view, .xk64 .day-view, .xk64 .dir-view, .xk64 .dir-left, .xk64 .ppl-view, .xk64 .pf-view, .xk64 .cal-view { gap: 12px; }
  .xk64 .card { padding: 12px; }
  .xk64 .card.flush { padding: 0; }
  .xk64 h1 { font-size: 18px; }
  .xk64 .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; background: var(--card); border-top: 1px solid var(--line);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .xk64 .tabbar a { flex: 1 1 0; min-width: 0; min-height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px; color: var(--ink); font-size: 12px; font-weight: 500; }
  .xk64 .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .xk64 .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
  .xk64 .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }

  /* main page: calendar first, then the side cards */
  .xk64 .cal-view { display: flex; flex-direction: column; }
  .xk64 .cal-main { order: -1; padding: 10px 8px; gap: 8px; }
  .xk64 .cal-head { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title tools" "y y"; }
  .xk64 .cal-title { grid-area: title; font-size: 18px; } .xk64 .cal-tools { grid-area: tools; } .xk64 .cal-y { grid-area: y; justify-content: space-between; }
  .xk64 .cal-tools .tool { display: none; }
  .xk64 .cal-year { flex: 1; }
  .xk64 .mf-months { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .xk64 .mf-months .mm { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .xk64 .mon { min-height: 44px; font-size: 14px; }
  .xk64 .grid { gap: 3px; }
  .xk64 .cell { min-height: 64px; padding: 3px 3px 2px; grid-template-rows: auto 1fr; }
  .xk64 .cell .dnum { font-size: 13px; }
  .xk64 .cell .dgz { font-size: 16px; }
  .xk64 .cell .dcount { display: none; }
  .xk64 .cal-foot { font-size: 12px; } .xk64 .legend-inline { font-size: 12px; gap: 4px 10px; }
  .xk64 .side-card .row .chip, .xk64 .btn.small { min-height: 44px; }
  .xk64 .dygrid .chip, .xk64 .sys-seg > button { min-height: 44px; }

  /* day detail: 6 pillar columns stay on one row at 375px */
  .xk64 .pc-s { font-size: 24px; } .xk64 .pc-t { font-size: 12px; letter-spacing: -.02em; }
  .xk64 .dc .mb-l { width: 22px; height: 30px; } .xk64 .mb-nums b { font-size: 16px; } .xk64 .mb-ele { font-size: 14px; }
  .xk64 .mb-n { font-size: 12px; }
  .xk64 .dh { font-size: 13px; min-height: 48px; } .xk64 .dsx .dh-t .app { font-size: 12px; }
  .xk64 .dh-dy button { display: none; }
  .xk64 .dh-dy { grid-template-columns: 1fr; }
  .xk64 .dy-cur { display: grid; justify-items: center; font-size: 12px; color: var(--muted); line-height: 1.2; } .xk64 .dy-cur b { color: var(--accent); font-size: 14px; }
  .xk64 .dy-seg { grid-column: 1 / -1; display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); align-items: center; gap: 6px; padding: 8px; border-top: 1px solid var(--line); background: var(--soft); }
  .xk64 .dy-seg-l { font-size: 13px; font-weight: 600; color: var(--muted); }
  .xk64 .dy-seg .chip { min-height: 44px; padding: 0 4px; }
  .xk64 .dy-seg .chip.act:not(.on) { color: var(--accent); border-color: var(--accent); } .xk64 .dy-seg .chip.orange:not(.on) { color: var(--amber); border-color: var(--amber); }
  .xk64 .b-date > div { font-size: 14px; }
  .xk64 .b-n .btn.icon, .xk64 .bnav .btn.icon { width: 44px; }
  .xk64 .fi-b { width: 44px; height: 44px; }
  .xk64 .b-foot { grid-template-columns: 1fr auto; } .xk64 .b-foot .sartbar { grid-column: 1 / -1; grid-row: 1; } .xk64 .b-foot .fb { display: flex; flex-wrap: wrap; gap: 6px; }
  .xk64 .b-foot .chip { min-height: 44px; }
  .xk64 .hour summary { grid-template-columns: 1fr auto; grid-template-areas: "t s" "a g" "h h"; gap: 2px 8px; }
  .xk64 .h-time { grid-area: t; } .xk64 .st { grid-area: s; } .xk64 .h-an { grid-area: a; } .xk64 .h-gz { grid-area: g; justify-self: end; } .xk64 .h-hex { grid-area: h; }

  /* direction */
  .xk64 .angrow { grid-template-columns: 1fr 110px auto; }
  .xk64 .angrow .label { grid-column: 1 / -1; }

  /* conditions: page list as a tab grid above the page */
  .xk64 .pf-side { padding: 8px; gap: 6px; }
  .xk64 .pf-lbl { display: none; }
  .xk64 .pf-g0 { grid-template-columns: 1fr 1fr; }
  .xk64 .pf-g1 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .xk64 .pf-g1 .pt { justify-content: center; padding: 0; min-height: 44px; border: 1px solid var(--line); }
  .xk64 .pf-g1 .pt-l { display: none; }
  .xk64 .pf-g1 .pt-n { background: none; min-width: 0; color: inherit; }
  .xk64 .pf-g1 .pt.on .pt-n { background: none; color: #fff; }
  .xk64 .pf-g0 .pt { justify-content: center; border: 1px solid var(--line); min-height: 44px; }
  .xk64 .pf-g2 .pb.pt { min-height: 44px; }
  .xk64 .g10 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .xk64 .elr { grid-template-columns: 96px 1fr 80px 20px; font-size: 13px; }
  .xk64 .pb.hr { font-size: 12px; }
  .xk64 .pf-main .card-head h1 { font-size: 17px; }

  .xk64 .two { grid-template-columns: 1fr 1fr; gap: 8px; }
  .xk64 .fh-dir { font-size: 14px; }
}
@media (max-width: 400px) {
  .xk64 .pc-s { font-size: 22px; }
  .xk64 .dc .mb-l { width: 20px; height: 28px; } .xk64 .mb-nums b { font-size: 15px; }
  .xk64 .mb-body { gap: 2px; }
}

/* ---------- ฤกษ์ explanations (ui/fore-info.js) + ⓘ popover ---------- */
.xk64 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.xk64 .pdesc { font-size: 13px; color: var(--muted); margin: -2px 0 6px; line-height: 1.4; }
.xk64 .fi-list { list-style: none; padding: 0; margin: 4px 0 6px; display: grid; gap: 8px; font-size: 13px; }
.xk64 .fi-list li small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.xk64 .tip { position: relative; display: inline-flex; }
.xk64 .tip-b { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--control); background: var(--card); color: var(--link); font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.xk64 .tip-b:hover, .xk64 .tip.open .tip-b { background: var(--link); border-color: var(--link); color: #fff; }
.xk64 .tip-pop { display: none; position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(360px, calc(100vw - 32px)); max-height: min(60vh, 460px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(26, 29, 27, .18); padding: 12px 14px;
  grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; font-size: 13px; font-weight: 400; line-height: 1.45; color: var(--ink); text-align: left; white-space: normal; cursor: auto; }
.xk64 .tip-pop.flip { right: auto; left: 0; }
.xk64 .tip.open .tip-pop { display: grid; }
@media (hover: hover) and (min-width: 901px) { .xk64 .tip:not(.shut):hover .tip-pop, .xk64 .tip:not(.shut):focus-within .tip-pop { display: grid; } }
.xk64 .tip-h { grid-column: 1 / -1; font-size: 15px; color: var(--jade); } .xk64 .tip-h small { color: var(--muted); font-weight: 500; font-size: 12px; }
.xk64 .tip-k { font-weight: 600; color: var(--muted); white-space: nowrap; }
.xk64 .tip-v { min-width: 0; }
.xk64 .tip-pop .fi-good { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 6px; font-size: 12px; }
.xk64 .tipcell { width: 40px; text-align: right; }
.xk64 .fore-tbl .tip-b { width: 30px; height: 30px; font-size: 15px; }

/* ---------- scroll cue: shadow at the bottom edge while more content is below (app.js wireScroll) ---------- */
.xk64 .scroll-cue { position: sticky; bottom: 0; height: 0; margin: 0; pointer-events: none; z-index: 3; }
.xk64 .scrolly.more-below > .scroll-cue { box-shadow: 0 -2px 14px 6px rgba(26, 29, 27, .22); border-top: 1px solid var(--control); }
.xk64 .scrolly { scrollbar-gutter: stable; }

@media (max-width: 900px) {
  /* ⓘ: 44px target; the popover becomes a sheet above the tab bar so it never leaves the screen */
  .xk64 .tip-b, .xk64 .fore-tbl .tip-b { width: 44px; height: 44px; }
  .xk64 .tip-pop { position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); width: auto; max-height: 60vh; }
  .xk64 .tip-pop.flip { left: 8px; right: 8px; }
}

/* ทิศบ้าน on mobile: 64-row table collapsed by default (views/direction.js tblOpen); 44px tap targets for inline links */
.xk64 .dir-tgl { margin-left: auto; }
@media (max-width: 900px) {
  .xk64 .dir-scroll.m-collapsed { display: none; }
  .xk64 .dayhead .dh-t small a, .xk64 .btn.link { display: inline-flex; align-items: center; min-height: 44px; }
}
