:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #14202e; --mute: #5d6b7a; --line: #dfe4ea;
  --accent: #0b6bcb; --accent-ink: #ffffff; --ok: #1a8f4c; --warn: #c26a00; --bad: #c62828;
  --s1: #0b6bcb; --s2: #13a3a0; --s3: #d9480f; --s4: #7b4cc2; --s5: #a0802b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --card: #18212b; --ink: #e8edf2; --mute: #94a3b3; --line: #2a3644;
    --accent: #4a9df0; --accent-ink: #0b1520; --ok: #4cc27f; --warn: #f0a640; --bad: #ef6b6b;
    --s1: #4a9df0; --s2: #3fd0c9; --s3: #ff8a4c; --s4: #b08cf0; --s5: #d8b65a;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --card: #18212b; --ink: #e8edf2; --mute: #94a3b3; --line: #2a3644;
  --accent: #4a9df0; --accent-ink: #0b1520; --ok: #4cc27f; --warn: #f0a640; --bad: #ef6b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Sarabun", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mute); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.old { background: var(--warn); }
select, input, textarea, button { font: inherit; color: var(--ink); }
select, input, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
#session { max-width: 62%; }
main { padding: 12px 16px; max-width: 760px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h3 { margin: 18px 0 8px; font-size: 15px; color: var(--mute); font-weight: 600; }
.status { font-size: 14px; color: var(--mute); margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.card .k { font-size: 13px; color: var(--mute); }
.card .v { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card .v small { font-size: 13px; font-weight: 500; color: var(--mute); margin-left: 4px; }
.card .v.ir { font-size: 17px; font-weight: 600; }
.sub { font-size: 13px; color: var(--mute); }
.temps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.temps .card .v { font-size: 26px; }
.temps .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.row { display: flex; gap: 8px; margin: 6px 0; } .row input { flex: 1; }
button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
button:disabled { opacity: .55; }
button.wide { width: 100%; padding: 12px; margin: 6px 0; }
textarea { width: 100%; resize: vertical; }
.install { background: var(--card); border: 1px solid var(--accent); border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.install .row button { flex: 1; }
button.ghost { background: none; color: var(--mute); border: 1px solid var(--line); }
.notes { margin-top: 10px; font-size: 13px; }
.notes div { padding: 4px 0; border-top: 1px dashed var(--line); color: var(--mute); }
.notes .warn { color: var(--warn); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; background: none; color: var(--mute); border-radius: 0; padding: 12px 0; font-size: 13px; }
.remote .row select { flex: 1; }
.rm-top { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; gap: 12px; }
button.power { width: 64px; height: 64px; border-radius: 50%; font-size: 17px; padding: 0; background: var(--line); color: var(--mute); }
button.power.on { background: var(--ok); color: #fff; }
.rm-temp { display: flex; align-items: center; gap: 10px; }
.rm-temp span { font-size: 18px; color: var(--mute); min-width: 92px; text-align: center; }
.rm-temp b { font-size: 44px; color: var(--ink); font-variant-numeric: tabular-nums; }
.rm-temp button { width: 52px; height: 52px; border-radius: 50%; font-size: 26px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button { background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 7px 12px; font-weight: 500; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cmd { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px; }
.cmd .lv-ok { color: var(--ok); font-weight: 700; } .cmd .lv-weak, .cmd .lv-wait { color: var(--warn); } .cmd .lv-none, .cmd .lv-failed { color: var(--bad); }
.cmd ul { list-style: none; margin: 4px 0 0 2px; padding: 0; font-size: 13px; color: var(--mute); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--accent); }
.tabs button.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px 8px; margin-bottom: 10px; }
.chart h3 { margin: 8px 0 2px; }
.chart svg { width: 100%; height: 170px; display: block; touch-action: pan-y; }
.chart svg text { fill: var(--mute); font-size: 10px; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .irl { stroke: var(--mute); stroke-dasharray: 3 3; stroke-width: 1; }
.legend { font-size: 12px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend i { display: inline-block; width: 10px; height: 3px; vertical-align: middle; margin-right: 4px; }
.tip { position: fixed; z-index: 9; background: var(--ink); color: var(--bg); font-size: 12px; padding: 6px 8px; border-radius: 8px; pointer-events: none; white-space: pre; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 10px 0; }
.group h4 { margin: 0 0 4px; }
.tgt { margin-top: 12px; }
.tgt b { font-size: 14px; }
.tbl { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 600; }
.yes { color: var(--ok); font-weight: 700; } .maybe { color: var(--warn); font-weight: 600; } .no { color: var(--mute); }
.formula { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.ai { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 8px; min-height: 2em; }
.ai:empty { display: none; }
pre { white-space: pre-wrap; font-size: 12px; background: var(--card); padding: 10px; border-radius: 10px; }
.names .row span { flex: 0 0 150px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; align-self: center; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .card .v { font-size: 24px; } .names .row span { flex-basis: 110px; } }
/* คู่มือช่าง */
.kb-search input { width: 100%; margin-bottom: 10px; }
.kgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kgrid button, .menu button { background: var(--card); color: var(--ink); border: 1px solid var(--line); text-align: left; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.kgrid .ic { font-size: 22px; }
.kgrid span:last-child, .menu span { font-size: 12px; color: var(--mute); font-weight: 400; }
.menu { display: flex; flex-direction: column; gap: 8px; }
#kbTitle { font-size: 19px; margin: 10px 0; }
details.acc, details.code { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; }
details.acc summary, details.code summary { padding: 10px 12px; cursor: pointer; font-weight: 600; }
.dbody, .cfix { padding: 0 12px 10px; font-size: 14px; }
.dbody ol { padding-left: 20px; margin: 6px 0; } .dbody p { margin: 6px 0; }
.chip { font-size: 11px; background: var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 4px; font-weight: 500; }
.chip.red { background: var(--bad); color: #fff; }
.kwarn { border-left: 3px solid var(--bad); padding: 6px 10px; margin: 8px 0; background: color-mix(in srgb, var(--bad) 8%, transparent); border-radius: 6px; }
.knote { border-left: 3px solid var(--accent); padding: 6px 10px; margin: 8px 0; font-size: 13px; color: var(--mute); border-radius: 6px; }
.kcard { margin-bottom: 10px; } .kcard h4 { margin: 0 0 6px; }
.kimg { max-width: 100%; border-radius: 8px; }
.say { border-left: 3px solid var(--line); padding: 4px 10px; margin: 6px 0; }
.chk { display: flex; gap: 8px; padding: 4px 0; align-items: flex-start; }
.cb { display: inline-block; min-width: 42px; text-align: center; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 1px 6px; margin-right: 6px; font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
button.hit { width: 100%; text-align: left; background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 500; margin-bottom: 6px; }
label.f { display: flex; flex-direction: column; font-size: 13px; color: var(--mute); flex: 1; gap: 2px; margin: 4px 0; }
.cres { font-size: 15px; margin: 8px 0; } .cres b { font-size: 26px; color: var(--accent); }
/* บริการของเรา — เบาๆ ไม่แย่งสายตา */
.promo { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 10px; font-size: 13px; color: var(--mute); }
.promo b { color: var(--ink); } .promo a { color: var(--accent); font-weight: 600; }
.ptag { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-right: 6px; }
#kbBrands { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
#kbBrands button { flex: 0 0 auto; }
