/* หาฤกษ์ (views/lucktime.js + ui/lucktime-cond.js) — tokens from styles.css only.
   The view fills the viewport without measuring: the shell becomes a 100dvh column, the page is its flexible scroller,
   .lt-view grows to fill it. Desktop (≥ 901px): calendar left, day page right, only the tab panel scrolls.
   Mobile (≤ 900px): calendar and day page are separate full screens (data-screen="cal" | "day").
   Every block has a fixed / reserved height so clicking around never shifts the layout. No layout transitions. */
.shell:has(.lt-view) { height: 100vh; height: 100dvh; min-height: 0; }
.page:has(> .lt-view) { flex: 1 1 auto; min-height: 0; overflow-y: auto; max-width: 1600px; padding: 8px 16px; gap: 0; }
.lt-view { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 12px; }
.lt-cal, .lt-dayp { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; padding: 8px 10px; }
.lt-pair { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.08; }
.lt-pair.row { flex-direction: row; gap: 1px; }
.lt-pair .han { font-size: 19px; }
.lt-view .btn.small, .lt-cview .btn.small { min-height: 44px; }   /* every control ≥ 44px (BUILD.md rule 4) */

/* ---------- Calendar: person + system / year + ชนิดฤกษ์ / months / summary / grid / legend ---------- */
.lt-toprow { flex: none; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.lt-person { flex: 1 1 auto; min-width: 0; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 10px;
  border: 1px solid var(--birth-line); border-radius: 8px; background: var(--birth-fill); color: var(--ink); }
.lt-person:hover { color: var(--ink); border-color: var(--accent); }
.lt-pwho { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lt-pwho b, .lt-pwho small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-pwho small { font-size: 12px; }
.lt-p4mini { flex: none; display: flex; gap: 6px; }
.lt-p4mini > span { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.lt-p4mini small { font-size: 12px; color: var(--muted); }
.lt-p4mini .lt-pair { flex-direction: row; }
.lt-p4mini .lt-pair .han { font-size: 17px; }
.lt-sysbox { flex: 0 0 auto; width: 168px; }
.lt-sysbox .input, .lt-type .input { font-weight: 600; padding: 0 6px; font-size: 14px; }

.lt-navrow > .luck-switch a { min-height: 40px; padding: 0 10px; font-size: 14px; }
.lt-navrow > .luck-switch .d-only { display: none !important; } .lt-navrow > .luck-switch .m-only { display: inline !important; }
.lt-navrow { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; }
.lt-yr { display: flex; align-items: center; gap: 4px; }
.lt-ib { min-width: 34px; padding: 0 6px; font-size: 14px; }
.lt-yr [data-yr="-1"], .lt-yr [data-yr="1"] { font-size: 22px; line-height: 1; }
.lt-year { min-width: 4.6em; text-align: center; font-size: 16px; white-space: nowrap; }
.lt-type { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.lt-type .input { width: 106px; }
.lt-condbtn { padding: 0 8px; border-color: var(--accent); color: var(--accent); font-size: 14px; }

.lt-months { flex: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; }
.lt-months > button { min-height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-weight: 600; font-size: 14px; }
.lt-months > button:hover { background: var(--soft); }
.lt-months > button[aria-pressed="true"] { background: var(--band); border-color: var(--band); color: #fff; }
.lt-sum { flex: none; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 20px; height: 20px; }
.lt-sum b { color: var(--ink); }

/* Always 6 week rows: 5- and 6-week months use the same area; rows share the height (≥ 40px). */
.lt-grid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 22px repeat(6, minmax(40px, 1fr)); gap: 3px; }
.lt-wd { text-align: center; font-size: 13px; font-weight: 600; color: #fff; background: var(--control); line-height: 22px; border-radius: 4px; }
.lt-wd.sun { background: var(--accent); } .lt-wd.sat { background: var(--band); }
.lt-blank { border-radius: 6px; }
.lt-day { position: relative; min-width: 0; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 2px;
  padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); overflow: hidden; }
.lt-day:hover { border-color: var(--control); }
.lt-dl { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; align-self: stretch; justify-content: center; }
.lt-dn { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.lt-term { color: var(--birth-line); font-size: 12px; line-height: 1; }
/* The fill is THE signal: at least one hour passes every active condition (F03 MainForm tan day). */
.lt-day.is-pass { background: var(--birth-fill); border-color: var(--birth-line); }
.lt-day.is-pass .lt-dn { font-weight: 700; }
.lt-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.lt-day.is-sel { outline: 2px solid var(--ink); outline-offset: -2px; }
.lt-dots { display: inline-flex; gap: 3px; }
.lt-dots i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--control); }
.lt-dots i.on { background: var(--jade); border-color: var(--jade); }

.lt-legend { flex: none; display: flex; gap: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; height: 20px; line-height: 20px; }
.lt-legend > span { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.lt-sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); background: var(--card); flex: none; }
.lt-sw.pass { background: var(--birth-fill); border-color: var(--birth-line); }
.lt-sw.today { box-shadow: inset 0 0 0 2px var(--accent); }
.lt-sw.sel { border: 2px solid var(--ink); }
.lt-sw.good { background: var(--accent-soft); border-color: var(--accent); }
.lt-sw.bad { background: var(--line); border-color: var(--control); }

/* ---------- Day page: fixed head, fixed strip, tabs, flexible panel, pinned foot ---------- */
.lt-dh { flex: none; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px; align-items: start; height: 196px; overflow: hidden; }
.lt-dinfo { display: grid; grid-template-rows: 40px repeat(6, 22px); justify-items: center; align-items: center; text-align: center; line-height: 1.2; white-space: nowrap; }
.lt-dnum { font-size: 38px; line-height: 1; color: var(--band); font-variant-numeric: tabular-nums; }
.lt-dmon { font-weight: 700; font-size: 15px; }
.lt-hr { font-weight: 600; font-variant-numeric: tabular-nums; }
.lt-hr.pass, .lt-sign.pass { color: var(--jade); } .lt-hr.cut, .lt-sign.cut { color: var(--unfav); }
.lt-sign { font-weight: 700; font-size: 13px; }
.lt-sun { color: var(--unfav); }
.lt-p4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
.lt-col { display: grid; grid-template-rows: 18px 34px 16px 16px 34px 16px 16px 16px 34px; justify-items: center; align-items: center; text-align: center; line-height: 1.15; min-width: 0; padding: 0 2px; }
.lt-col small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lt-ch { font-weight: 700; font-size: 13px; color: var(--muted); }
.lt-g { display: inline-flex; align-items: flex-start; gap: 1px; }
.lt-g .han { font-size: 28px; line-height: 1.15; }
.lt-god { color: var(--link); }
.lt-an { font-weight: 600; }
.lt-hid { display: flex; justify-content: center; gap: 3px; width: 100%; height: 34px; border-top: 1px dashed var(--line); padding-top: 1px; }
.lt-hid > span { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.lt-hid .han { font-size: 15px; }
.lt-hid small { font-size: 12px; }

/* Hour strip: crossed = fails a condition; dot = hour clashes the day/month/year branch (DateShowForm L771-773).
   The dot row (10px above every cell) is always reserved, so 12 / 13 slots and dots never change the height. */
.lt-strip { flex: none; display: grid; grid-template-columns: repeat(var(--n, 12), minmax(0, 1fr)); grid-auto-rows: 58px; gap: 10px 3px; padding-top: 10px; }
.lt-h { position: relative; min-width: 0; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px 1px; border: 1px solid var(--line); border-radius: 6px; background: var(--ground); color: var(--ink); line-height: 1.15; }
.lt-h .lt-pair .han { font-size: 16px; }
.lt-h small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lt-hs { font-variant-numeric: tabular-nums; font-weight: 600; }
.lt-h.is-pass { background: var(--card); border-color: var(--jade); }
.lt-h.is-pass .lt-hs { color: var(--jade); }
.lt-h.is-cut .lt-hs { color: var(--unfav); }
.lt-h.is-sel { box-shadow: inset 0 0 0 3px var(--jade); }
.lt-h.is-cut.is-sel { box-shadow: inset 0 0 0 3px var(--unfav); }
.lt-x { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); pointer-events: none; }
.lt-x path { stroke: var(--unfav); stroke-width: 1.2; vector-effect: non-scaling-stroke; fill: none; opacity: .7; }
.lt-cdot { position: absolute; top: -9px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--accent); }
.lt-cdot.k { position: static; display: inline-block; margin: 0 2px 0 0; vertical-align: middle; }
.lt-stripk { flex: none; height: 18px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-xk { text-decoration: line-through; text-decoration-color: var(--unfav); }

.lt-tabs { flex: none; display: flex; gap: 4px; }
.lt-tabs [role="tab"] { flex: 1 1 0; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-weight: 600; }
.lt-tabs [role="tab"] b { font-size: 16px; }
.lt-tabs [role="tab"][aria-selected="true"] { background: var(--band); border-color: var(--band); color: #fff; }
.lt-panel { flex: 1 1 0; min-height: 96px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--ground); }
.lt-panel > * { flex: none; }
.lt-ftitle { color: var(--link); text-decoration: underline; }
.lt-con { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-weight: 600; }
.lt-ok { color: var(--jade); } .lt-no { color: var(--unfav); } .lt-dirk { color: var(--link); font-size: 12px; }
.lt-rules { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.lt-rule { display: inline-flex; align-items: baseline; gap: 4px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--card); }
.lt-rule small { font-size: 12px; color: var(--muted); font-weight: 500; }
.lt-rule.good { border-color: var(--jade); } .lt-rule.bad { border-color: var(--unfav); }
.lt-verdict { font-weight: 600; padding: 6px 10px; border-radius: 8px; border-left: 4px solid var(--line); background: var(--card); }
.lt-verdict.pass { border-left-color: var(--jade); color: var(--jade); }
.lt-verdict.cut { border-left-color: var(--unfav); color: var(--unfav); }
.lt-verdict.none { color: var(--muted); }
.lt-why { margin: 0; padding: 0 0 0 18px; font-size: 13px; color: var(--unfav); line-height: 1.4; }
.lt-why b { color: var(--ink); font-weight: 600; }

/* "ใช้ทำอะไร" box (F03 texts verbatim; long texts clamped, full text in a dialog) */
.lt-use { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-left: 4px solid var(--control); border-radius: 8px; background: var(--card); font-size: 14px; line-height: 1.4; }
.lt-use.pass { border-left-color: var(--jade); }
.lt-use h3 { font-size: 14px; color: var(--muted); }
.lt-use.pass h3 { color: var(--jade); }
.lt-use1, .lt-use2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.lt-use1 { -webkit-line-clamp: 2; line-clamp: 2; } .lt-use2 { -webkit-line-clamp: 2; line-clamp: 2; }
.lt-src { display: inline-block; min-width: 4.6em; font-size: 12px; font-weight: 700; color: var(--muted); }
.lt-usemore { display: flex; flex-wrap: wrap; gap: 0 12px; }
.lt-usemore .btn.link { min-height: 44px; font-size: 13px; }

.lt-p4person { background: var(--card); border-radius: 8px; padding: 6px 0; }
.lt-p4person .lt-col { grid-template-rows: 18px 34px 16px 16px 34px 16px 16px 16px; }
.lt-p4person .lt-col:nth-child(2) { background: var(--soft); border-radius: 6px; }
.lt-favlg { gap: 2px 12px; }
.lt-warn { color: var(--unfav); }

/* ท วงทิศ (F03 PDirForm "ทิศนอกใน", ui/lucktime-pdir.js). PDirForm colours mapped to tokens: LightPink → accent mix,
   LightGray → --line, Navy lines / centre → --band, Chocolate names → --el-4, Purple degrees → --link, red marks → --unfav.
   Desktop: wheel(s) left at the panel's height, the side column scrolls; mobile: wheel full width, panel scrolls. */
.lt-pd { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; }
.lt-pdwheels { display: flex; gap: 8px; }
.lt-pdw { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lt-pdw figcaption { font-weight: 700; font-size: 13px; color: var(--band); }
.lt-pds { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lt-wheel { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.lt-wheel path { stroke: var(--band); stroke-width: 1.2; }
.lt-wheel path.good { fill: color-mix(in srgb, var(--accent) 24%, var(--card)); }
.lt-wheel path.bad { fill: var(--line); } .lt-wheel path.none { fill: var(--card); }
.lt-wheel text { font-size: 22px; font-weight: 700; fill: var(--ink); text-anchor: middle; pointer-events: none; }
.lt-wheel text.dir { font-size: 18px; fill: var(--el-4); }
.lt-wheel text.deg { font-size: 16px; font-weight: 500; fill: var(--link); }
.lt-wheel .ctr { fill: var(--band); } .lt-wheel .ctrn { fill: #fff; font-size: 23px; }
.lt-wsec { cursor: pointer; outline: none; }
.lt-wsec:hover path, .lt-wsec:focus-visible path { stroke: var(--unfav); stroke-width: 3; }
.lt-pdmarks { display: flex; flex-wrap: wrap; gap: 4px; }
.lt-pdmarks .btn { color: var(--unfav); border-color: var(--unfav); font-weight: 700; padding: 0 10px; }
.lt-pdmo { line-height: 1.35; }
.lt-pdlg { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.lt-pdkey { display: inline-flex; gap: 10px; padding: 3px 10px; border-radius: 4px; background: var(--band); font-weight: 700; }
.lt-pdkey .good { color: color-mix(in srgb, var(--accent) 24%, var(--card)); } .lt-pdkey .bad { color: var(--line); }
.lt-pdbad { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 0 10px 8px; }
.lt-pdbad .btn { padding: 0 8px; font-size: 13px; font-weight: 500; background: var(--line); border-color: var(--control); }
.lt-pdbad .btn b { margin: 0 2px; }
.lt-pdp { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.lt-pdwho { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lt-pdwho b, .lt-pdwho small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-pdwho small { font-size: 12px; }
.lt-pdcols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.lt-pdc { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lt-pdc > small { font-size: 12px; color: var(--muted); font-weight: 600; }
.lt-pdstar { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 18px; font-weight: 700; color: var(--ink); }
.lt-pdstar.is-ref { border: 2px solid var(--band); box-shadow: inset 0 -4px 0 var(--band); }
.lt-pdflow { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.lt-pdflow > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 10px; cursor: pointer; font-weight: 600; }
.lt-pdflow > .lt-ao { padding: 0 10px 6px; }
.lt-pdflow .label { font-size: 13px; }
@media (min-width: 901px) {
  .lt-panel[data-tab="dir"] { overflow: hidden; }
  .lt-panel[data-tab="dir"] > .lt-pd { flex: 1 1 auto; min-height: 0; height: 100%; }
  .lt-pd { grid-template-rows: minmax(0, 1fr); }
  .lt-pdwheels { height: 100%; min-height: 0; }
  .lt-pdw { height: 100%; min-height: 0; }
  .lt-pdw .lt-wheel { flex: 1 1 auto; min-height: 0; width: auto; height: 100%; max-width: 300px; }
  .lt-pd.two .lt-pdw .lt-wheel { max-width: 240px; }
  .lt-pd.two .lt-wheel text.deg { font-size: 17.5px; } .lt-pd.two .lt-wheel text.dir { font-size: 19px; }
  .lt-pds { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
}
@media (max-width: 900px) {
  /* the wheel needs its full width: on a phone the วงทิศ panel grows and the page scrolls instead of a tiny inner box */
  .lt-panel[data-tab="dir"] { flex: none; overflow: visible; }
  .lt-pd { grid-template-columns: minmax(0, 1fr); }
  .lt-pdwheels { flex-direction: column; align-items: center; }
  .lt-pdw { width: 100%; max-width: 360px; }
}
.lt-ao { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.lt-seg > button { padding: 0 12px; }

.lt-dfoot { flex: none; display: flex; align-items: center; gap: 10px; min-height: 44px; border-top: 1px solid var(--line); padding-top: 4px; }
.lt-dnav { flex: none; display: flex; align-items: center; gap: 4px; }
.lt-dnav .btn.icon { font-size: 22px; line-height: 1; }
.lt-sart { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Sub-menu row: ปฏิทินฤกษ์ | เงื่อนไข (values measured from views/xk64.css .xk64-tabs / .xk64-who) ---------- */
.lt-sub { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-width: 0; margin-bottom: 8px; }
.lt-subtabs { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.lt-subtabs button { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; }
.lt-subtabs button:hover { background: var(--soft); }
.lt-subtabs button[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.lt-who { margin-left: auto; min-width: 0; font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-view[hidden], .lt-cview[hidden] { display: none; }

/* ---------- เงื่อนไข sub-view (ui/lucktime-cond.js) — the 64 ข่วย #/pref/N look, measured at 1366×768:
   left card 248px (padding 8, gap 4; item 36px, 14px/500, radius 8, badge 30×26 radius 6 13px/700 on --soft; open item
   = --accent with white text, badge white with accent text), gap 16, right card padding 16 / radius 10, title 18px/700,
   body max 820px gap 10, sub-title 15px/700, buttons ≥44px 2px 10px 1px --control radius 8 14px/600 (pressed --accent),
   grids gap 6, notes 13px muted centred, ‹ › row border-top padding-top 12. ---------- */
.lt-cview { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 16px; }
.lt-cnav { display: flex; flex-direction: column; gap: 4px; padding: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lt-pgrp { display: grid; gap: 2px; }
.lt-plbl { padding: 6px 6px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.lt-pt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); text-align: left; font-weight: 500; font-size: 14px; }
.lt-pt:hover { background: var(--soft); }
.lt-pt.on { background: var(--accent); color: #fff; }
.lt-pt.on:hover { background: #8F2018; }
.lt-ptn { 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; }
.lt-pt.on .lt-ptn { background: var(--card); color: var(--accent); }
.lt-ptl { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.lt-ptl small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-pt.on .lt-ptl small { color: rgba(255, 255, 255, .85); }
.lt-pt.info .lt-ptn { font-size: 12px; }

.lt-cmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.lt-chead { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.lt-chead h2 { font-size: 18px; font-weight: 700; outline: none; }
.lt-cact { display: flex; gap: 6px; }
.lt-cbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.lt-cin { display: flex; flex-direction: column; gap: 10px; max-width: 820px; padding-bottom: 4px; }
.lt-cin hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.lt-cstep { flex: none; display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; max-width: 820px; }
.lt-ph { color: var(--ink); font-size: 15px; font-weight: 700; margin: 2px 0; }
.lt-ph small { font-size: 13px; font-weight: 500; color: var(--muted); }
.lt-ph .lt-pair { flex-direction: row; vertical-align: baseline; }
.lt-ph .lt-pair .han { font-size: 16px; }
.lt-red { color: var(--accent); }
.lt-pn { color: var(--muted); font-size: 13px; text-align: center; }
.lt-phrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: space-between; }
.lt-ao2 { display: inline-flex; gap: 4px; }

.lt-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; display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 4px; text-align: center; min-width: 0; }
.lt-pb:hover { background: var(--soft); }
.lt-pb[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.lt-pb[aria-pressed="true"]:hover { background: #8F2018; }
.lt-pb[aria-pressed="true"] :is(.han, .mark, [class^="el-"], small) { color: #fff; }
.lt-pb.wide { width: 100%; }
.lt-pb small { flex-basis: 100%; font-size: 12px; font-weight: 500; color: var(--muted); }
.lt-pb.ao { min-width: 56px; }
.lt-pb.han-b { font-family: var(--han); font-size: 18px; gap: 1px; flex-wrap: nowrap; padding: 2px; }
.lt-pb.han-b .mark { font-family: var(--font); }
.lt-pb .han { font-size: 16px; }
.lt-pb.hr { gap: 2px; padding: 2px; font-size: 13px; }
.lt-g2, .lt-g3, .lt-g4, .lt-g6, .lt-g7, .lt-g10 { display: grid; gap: 6px; }
.lt-g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lt-g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lt-g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .lt-g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.lt-g7 { grid-template-columns: repeat(7, minmax(0, 1fr)); } .lt-g10 { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.lt-wk { display: flex; flex-direction: column; gap: 10px; }
.lt-elr { display: grid; grid-template-columns: 110px auto 96px; gap: 10px; align-items: center; font-size: 14px; justify-content: start; }
.lt-eic { font-size: 13px; }
.lt-sc { width: 100%; min-height: 44px; border: 1px solid var(--control); border-radius: 8px; text-align: center; font: 600 16px var(--font); background: var(--card); color: var(--ink); }
.lt-off { display: flex; flex-direction: column; gap: 10px; }
.lt-off.is-off { opacity: .55; }

.lt-pcard { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--birth-line); border-radius: 8px; background: var(--birth-fill); }
.lt-pname { display: flex; flex-direction: column; }
.lt-favrow { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.lt-favc { display: flex; flex-direction: column; align-items: center; padding: 2px 0; border: 1px solid var(--line); border-radius: 6px; line-height: 1.15; }
.lt-favc .han { font-size: 18px; }
.lt-stars b { font-family: var(--han); }
.lt-check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lt-chartopt { padding: 8px 10px; border-radius: 8px; background: var(--soft); color: var(--muted); }
.lt-chartopt b { color: var(--ink); }

/* ---------- Desktop ---------- */
@media (min-width: 1200px) { .lt-months { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
@media (min-width: 901px) and (max-width: 1180px) {
  .lt-g .han { font-size: 24px; }
  .lt-h small.lt-an { display: none; }
  .lt-p4mini small { display: none; }
}

/* ---------- Mobile: two full screens ---------- */
@media (max-width: 900px) {
  .page:has(> .lt-view) { padding: 6px max(6px, env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 6px) max(6px, env(safe-area-inset-left)); }
  .lt-view { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lt-view[data-screen="cal"] .lt-dayp, .lt-view[data-screen="day"] .lt-cal { display: none; }
  .lt-cal, .lt-dayp { padding: 6px; gap: 6px; }
  .lt-sysbox { width: 128px; }
  .lt-p4mini { gap: 4px; }
  .lt-p4mini .lt-pair .han { font-size: 15px; }
  .lt-navrow { gap: 6px; }
  .lt-yr { width: 100%; justify-content: space-between; }
  .lt-type { width: 100%; margin-left: 0; }
  /* ซาฮะ | 64 ข่วย shares the ชนิดฤกษ์ row (no extra row on a phone) */
  .lt-navrow > .luck-switch { order: 1; } .lt-navrow > .lt-type { order: 2; flex: 1 1 0; width: auto; min-width: 0; }
  .lt-navrow > .luck-switch a { min-height: 44px; padding: 0 8px; font-size: 13px; }
  .lt-condbtn { padding: 0 6px; font-size: 13px; }
  .lt-type .input { flex: 1 1 0; width: auto; min-width: 0; }
  /* months: 6 × 2 buttons of 40px (below the 44px rule, to keep the 6-week grid on one 375 × 812 screen) */
  .lt-months > button { min-height: 40px; height: 40px; }
  .lt-grid { gap: 2px; }
  .lt-day { flex-direction: row; padding: 2px 3px; }
  .lt-dn { font-size: 14px; }
  .lt-pair .han { font-size: 16px; }
  .lt-legend { font-size: 12px; gap: 8px; }

  .lt-dh { grid-template-columns: 92px minmax(0, 1fr); gap: 4px; height: 178px; }
  .lt-dinfo { grid-template-rows: 34px repeat(6, 20px); font-size: 13px; }
  .lt-dnum { font-size: 32px; }
  .lt-col { grid-template-rows: 16px 28px 15px 15px 28px 15px 15px 15px 30px; padding: 0; }
  .lt-g .han { font-size: 23px; }
  .lt-hid { height: 30px; gap: 1px; }
  .lt-hid .han { font-size: 13px; }
  .lt-strip[data-n="12"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .lt-strip[data-n="13"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .lt-strip { grid-auto-rows: 54px; }
  .lt-h { height: 54px; }
  .lt-stripk { display: none; }
  .lt-dfoot { flex-direction: column; align-items: stretch; gap: 2px; }
  .lt-dnav { justify-content: space-between; }
  .lt-dnav .btn.icon { flex: 1 1 0; }
  .lt-favrow { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  /* sub-menu: 2 equal tabs, 44px; who hidden (the calendar shows the person card) */
  .lt-sub { margin-bottom: 6px; }
  .lt-subtabs { flex: 1 1 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lt-subtabs button { min-height: 44px; padding: 0 2px; font-size: 13px; }
  .lt-who { display: none; }
  /* the day screen has its own ‹ ปฏิทิน back button: no sub-menu there, the day keeps its full height */
  .page:has(> .lt-view[data-screen="day"]:not([hidden])) > .lt-sub { display: none; }
  /* เงื่อนไข: number grid card above the section card; the page scrolls (above the tab bar) */
  .lt-cview { display: flex; flex-direction: column; gap: 12px; flex: none; }
  .lt-cnav { padding: 8px; overflow: visible; display: grid; grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr)); gap: 4px; }
  .lt-pgrp { display: contents; }
  .lt-plbl { display: none; }
  .lt-pt { justify-content: center; padding: 0; min-height: 44px; border: 1px solid var(--line); }
  .lt-ptl { display: none; }
  .lt-ptn, .lt-pt .lt-ptn.info { background: none; min-width: 0; color: inherit; font-size: 15px; }
  .lt-pt.on .lt-ptn { background: none; color: #fff; }
  .lt-cmain { padding: 12px; }
  .lt-chead h2 { font-size: 17px; }
  .lt-cact { width: 100%; }
  .lt-cact .btn { flex: 1 1 0; min-height: 44px; }
  .lt-cbody { overflow: visible; scrollbar-gutter: auto; }
  .lt-cstep .btn { min-height: 44px; min-width: 88px; }
  .lt-g10 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lt-g7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lt-g6 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lt-g6:has(.han-b) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .lt-g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lt-elr { grid-template-columns: 96px 1fr 80px; font-size: 13px; }
  .lt-pb { padding: 2px 6px; }
}

/* Short phones (e.g. 375×667): the calendar must fit without page scroll. The sub-menu row is dropped on the calendar
   screen (the "ตั้งเงื่อนไข" button opens the conditions page; "ดูปฏิทิน" comes back), months and day rows get shorter. */
@media (max-width: 900px) and (max-height: 700px) {
  .page:has(> .lt-view[data-screen="cal"]:not([hidden])) > .lt-sub { display: none; }
  .lt-months > button { min-height: 36px; height: 36px; }
  .lt-grid { grid-template-rows: 20px; grid-auto-rows: minmax(34px, 1fr); }
  .lt-wd { line-height: 20px; }
  .lt-day { min-height: 0; height: 35px; padding: 1px 3px; }
  .lt-day .lt-dl { gap: 0; } .lt-day .lt-dn { line-height: 1.1; } .lt-day .lt-term { font-size: 10px; }
  .lt-day .lt-pair .han { font-size: 15px; line-height: 15px; }
  .lt-day .lt-pair { line-height: 15px; }
  .lt-cal { gap: 4px; }
}

/* ส่งออก .ics */
.lt-icsbtn { flex: none; padding: 0 8px; gap: 4px; font-size: 14px; }
@media (max-width: 900px) { .lt-icsbtn { width: 44px; padding: 0; } }
