/* btkit.css — หน้าตาชุดกลางของ Bow-tie (คู่กับ btkit.js) · ใช้ทั้งหน้าแอปและ shadow DOM ของคลังสากล
   สีของด่านในแผนภาพเดี่ยวใช้ร่วมกับคำกำกับเสมอ (ล้ม/ทำงาน/ไม่มีหลักฐาน) · แผนภาพรวม (m-agg) ใช้ความหนาเส้นและตัวเลข ไม่ใช้สี */

.bt2-term { border-bottom: 1px dotted color-mix(in srgb, currentColor 55%, transparent); cursor: help; }
.bt2-code { font: 500 12px/1 var(--f-m, ui-monospace, monospace); color: var(--muted); letter-spacing: .02em; margin-left: 6px; opacity: .85; }

/* ---------- แบนเนอร์ภาพเหตุการณ์หลัก ---------- */
.bt2-hero {
  position: relative; margin: 0; overflow: hidden; isolation: isolate;
  border-radius: var(--r-l, 18px); background: #0a1120;
  display: flex; flex-direction: column; justify-content: flex-end; min-height: clamp(260px, 30vw, 440px); width: 100%;
  box-shadow: 0 18px 40px -24px rgb(0 0 0 / .65);
}
.bt2-hero.sm { min-height: clamp(220px, 21vw, 300px); }
.bt2-hero-i { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 60% 45%; transition: opacity .45s var(--ease, ease), transform 9s cubic-bezier(.2, .6, .2, 1); transform: scale(1.06); }
.bt2-hero.vis .bt2-hero-i, .bt2-hero:not([data-w]) .bt2-hero-i { transform: scale(1); }
.bt2-hero.swap .bt2-hero-i { opacity: 0; }
.bt2-hero.noimg .bt2-hero-i { display: none; }
.bt2-hero.noimg { background: radial-gradient(120% 140% at 80% 20%, #1d3157 0%, #0a1120 60%); }
.bt2-hero::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgb(6 10 20 / .9) 0%, rgb(6 10 20 / .66) 34%, rgb(6 10 20 / .18) 62%, rgb(6 10 20 / 0) 80%),
    linear-gradient(0deg, rgb(6 10 20 / .7) 0%, rgb(6 10 20 / 0) 45%);
}
.bt2-hero-x {
  position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  padding: clamp(18px, 3.2vw, 40px); max-width: min(720px, 72%); color: #f4f7fc;
}
.bt2-hero-k { font: 600 12.5px/1.2 var(--f-b, inherit); letter-spacing: .04em; color: #f2c66d; }
.bt2-hero-t { margin: 0; font: 700 clamp(26px, 3.6vw, 50px)/1.08 var(--f-d, inherit); letter-spacing: -.01em; color: #fff; text-wrap: balance; text-shadow: 0 2px 18px rgb(0 0 0 / .45); }
.bt2-hero.sm .bt2-hero-t { font-size: clamp(22px, 2.6vw, 34px); }
.bt2-hero-t small, .bt2-hero-t em { display: block; font: 400 clamp(13px, 1.2vw, 16px)/1.3 var(--f-b, inherit); font-style: normal; color: rgb(244 247 252 / .78); margin-top: 6px; letter-spacing: .01em; }
.bt2-hero-s { margin: 0; font: 400 14.5px/1.55 var(--f-b, inherit); color: rgb(244 247 252 / .86); max-width: 60ch; text-wrap: pretty; }
.bt2-hero-n { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.bt2-hero-n span {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .18); backdrop-filter: blur(6px);
  font: 400 13px/1.2 var(--f-b, inherit); color: rgb(244 247 252 / .9);
}
.bt2-hero-n b { font: 600 17px/1 var(--f-m, inherit); color: #fff; }
.bt2-hero-n .bad { border-color: rgb(255 122 133 / .55); }
.bt2-hero-n .bad b { color: #ff9aa3; }
.bt2-hero-n .ok b { color: #7fe0ae; }
.bt2-hero-n .st { background: rgb(255 255 255 / .16); }
.bt2-hero-n .st.on { border-color: rgb(255 122 133 / .6); }
.bt2-hero-n .st.held { border-color: rgb(95 211 154 / .6); }
.bt2-hero-b {
  position: absolute; top: 12px; right: 12px; z-index: 1; padding: 3px 9px; border-radius: 999px;
  font: 500 12px/1.3 var(--f-b, inherit); color: rgb(244 247 252 / .82); background: rgb(6 10 20 / .5); border: 1px solid rgb(255 255 255 / .16);
}
.bt2-hero.noimg .bt2-hero-b { display: none; }
@media (max-width: 760px) {
  .bt2-hero { min-height: 68vw; border-radius: var(--r, 14px); }
  .bt2-hero.sm { min-height: 56vw; }
  .bt2-hero::after { background: linear-gradient(0deg, rgb(6 10 20 / .92) 0%, rgb(6 10 20 / .62) 45%, rgb(6 10 20 / .05) 78%); }
  .bt2-hero-x { max-width: none; padding: 44px 16px 16px; gap: 6px; }
  .bt2-hero-s { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .bt2-hero-n span { padding: 4px 10px; font-size: 12px; }
  .bt2-hero-n b { font-size: 15px; }
}

/* ---------- แผนภาพเชื่อมเส้น ---------- */
.bt2-dia {
  --bt2-cols: minmax(96px, .78fr) minmax(150px, 1.25fr) minmax(150px, 1fr) minmax(150px, 1.25fr) minmax(96px, .78fr);
  --bt2-gap: clamp(30px, 3.6vw, 54px);
  position: relative; container: bt2 / inline-size;
  padding: 18px clamp(12px, 1.8vw, 22px) 20px; border-radius: var(--r-l, 18px);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line2) 70%, transparent) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--surface);
  border: 1px solid var(--line);
}
.bt2-w { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; opacity: 0; transition: opacity .7s var(--ease, ease); }
.bt2-dia.vis .bt2-w, .bt2-dia:not([data-w]) .bt2-w { opacity: 1; }
.bt2-w path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.bt2-w .w-in { stroke: var(--line2); }
.bt2-w .w-fail, .bt2-w .w-on { stroke: var(--bad); stroke-width: 2.6; stroke-dasharray: 9 7; animation: bt2-flow 1.1s linear infinite; }
.bt2-w .w-hold { stroke: var(--ok); opacity: .5; stroke-dasharray: 2 6; }
.bt2-w .w-none { stroke: var(--muted); opacity: .55; stroke-dasharray: 2 6; }
.bt2-w .w-off { stroke: var(--line2); opacity: .55; stroke-dasharray: 2 7; }
.bt2-w .w-unk { stroke: var(--text2); opacity: .55; stroke-dasharray: 5 5; }
.bt2-w .w-esc { stroke: var(--gold); opacity: .75; stroke-dasharray: 3 4; stroke-width: 1.4; }
.bt2-w .w-stop { stroke: var(--ok); stroke-width: 3.2; }
.bt2-w circle { fill: var(--surface); stroke: var(--line2); stroke-width: 1.4; }
.bt2-w circle.f { fill: var(--bad); stroke: none; }
.bt2-w circle.h { fill: var(--ok); stroke: none; }
.bt2-w circle.e { fill: var(--gold); stroke: none; }
.m-agg .bt2-w .w-fail { stroke: var(--text2); opacity: .7; stroke-dasharray: none; animation: none; }
.m-agg .bt2-w .w-none { stroke: var(--line2); }
@keyframes bt2-flow { to { stroke-dashoffset: -32; } }

.bt2-grid { position: relative; display: grid; grid-template-columns: var(--bt2-cols); column-gap: var(--bt2-gap); align-items: stretch; }
.bt2-c { display: flex; flex-direction: column; min-width: 0; }
.bt2-ch { margin: 0 0 12px; font: 600 13px/1.25 var(--f-b, inherit); color: var(--text); text-align: center; }
.bt2-ch small { display: block; font: 400 12px/1.3 var(--f-m, inherit); color: var(--muted); letter-spacing: .03em; margin-top: 2px; }
.bt2-ns { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; }

.bt2-n, .bt2-g { position: relative; z-index: 1; border-radius: var(--r-s, 10px); background: var(--surface2); border: 1px solid var(--line); padding: 9px 11px; min-width: 0; }
.bt2-n b, .bt2-g-n { display: block; font: 600 13.5px/1.35 var(--f-b, inherit); color: var(--text); text-wrap: pretty; overflow-wrap: anywhere; }
.bt2-n small, .bt2-g-o { display: block; margin-top: 3px; font: 400 12px/1.35 var(--f-b, inherit); color: var(--muted); }
.bt2-n.thr { border-style: solid; text-align: left; }
.bt2-n.cons { text-align: left; border-width: 1px 1px 1px 3px; }
.bt2-n.cons.on { border-left-color: var(--bad); }
.bt2-n.cons.ok { border-left-color: var(--ok); }

a.bt2-g { text-decoration: none; color: inherit; transition: transform .18s var(--ease, ease), border-color .18s, box-shadow .18s; }
a.bt2-g:hover, a.bt2-g:focus-visible { transform: translateY(-1px); border-color: var(--sky); box-shadow: 0 6px 18px -10px rgb(0 0 0 / .5); }
.bt2-g { border-width: 1px 1px 1px 3px; }
.bt2-g.fail { border-left-color: var(--bad); }
.bt2-g.hold { border-left-color: var(--ok); }
.bt2-g.none { border-style: dashed dashed dashed solid; border-left-color: var(--line2); background: transparent; }
.bt2-g.nil { border: 1px dashed var(--line2); background: transparent; text-align: center; }
.bt2-g.nil .bt2-g-n { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.bt2-g-s { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 4px; font: 600 12px/1.2 var(--f-b, inherit); color: var(--text2); letter-spacing: .02em; }
.bt2-g-s i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.bt2-g.fail .bt2-g-s { color: var(--bad); }
.bt2-g.fail .bt2-g-s i { background: var(--bad); }
.bt2-g.hold .bt2-g-s { color: var(--ok); }
.bt2-g.hold .bt2-g-s i { background: var(--ok); }
.bt2-g.none .bt2-g-s i { background: transparent; border: 1.5px solid var(--muted); }
.m-agg .bt2-g { border-left-color: var(--line2); }
.m-agg .bt2-g-s, .m-agg .bt2-g.fail .bt2-g-s, .m-agg .bt2-g.hold .bt2-g-s { color: var(--text2); font-family: var(--f-m, inherit); font-weight: 500; }
.m-agg .bt2-g-s i { display: none; }

.bt2-more { margin: 2px 0 0; font: 400 12px/1.4 var(--f-b, inherit); color: var(--muted); text-align: center; }
.bt2-more a { color: var(--sky); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--sky) 40%, transparent); }

/* ปม */
.bt2-c.kn .bt2-ns { align-items: stretch; }
.bt2-k { display: flex; justify-content: center; }
.bt2-k-c {
  position: relative; z-index: 1; width: 100%; max-width: 220px; padding: 12px 12px 14px; text-align: center;
  border-radius: 16px; background: var(--surface2); border: 2px solid var(--line2);
}
.bt2-k.on .bt2-k-c { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--surface2)); box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad) 10%, transparent), 0 14px 30px -18px color-mix(in srgb, var(--bad) 60%, transparent); }
.bt2-k.held .bt2-k-c { border-color: var(--ok); border-style: dashed; }
.bt2-k-svg { width: 74px; height: 40px; display: block; margin: 0 auto 6px; }
.bt2-k-svg path { fill: color-mix(in srgb, var(--text2) 22%, transparent); stroke: var(--text2); stroke-width: 2; stroke-linejoin: round; }
.bt2-k-svg circle { fill: var(--text2); }
.bt2-k.on .bt2-k-svg path { fill: color-mix(in srgb, var(--bad) 28%, transparent); stroke: var(--bad); }
.bt2-k.on .bt2-k-svg circle { fill: var(--bad); }
.bt2-k.held .bt2-k-svg path { fill: color-mix(in srgb, var(--ok) 16%, transparent); stroke: var(--ok); }
.bt2-k.held .bt2-k-svg circle { fill: var(--ok); }
.bt2-k-k { display: block; font: 500 12px/1.2 var(--f-b, inherit); color: var(--muted); letter-spacing: .04em; }
.bt2-k-n { display: block; margin: 3px 0 6px; font: 700 16px/1.3 var(--f-d, inherit); color: var(--text); text-wrap: balance; }
.bt2-k-s { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font: 600 12px/1.3 var(--f-b, inherit); background: var(--surface); border: 1px solid var(--line); color: var(--text2); }
.bt2-k-s i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.bt2-k.on .bt2-k-s { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.bt2-k.on .bt2-k-s i { background: var(--bad); }
.bt2-k.held .bt2-k-s { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.bt2-k.held .bt2-k-s i { background: var(--ok); }

/* มาตรการรักษาด่าน */
.bt2-esc { display: grid; grid-template-columns: var(--bt2-cols); column-gap: var(--bt2-gap); margin-top: 26px; }
.bt2-esc-in { grid-column: 1 / 4; border-top: 1px dashed color-mix(in srgb, var(--gold) 45%, transparent); padding-top: 12px; }
.bt2-esc .bt2-ch { color: var(--gold); text-align: left; margin-bottom: 8px; }
.bt2-esc-ns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.bt2-esc .bt2-g { flex: 0 1 220px; border-left-color: var(--gold); }

/* จอแคบ: เส้นแนวตั้ง ไม่มี SVG (btkit.js ล้าง SVG เมื่อกว้างไม่ถึง 720px) */
@container bt2 (max-width: 719px) {
  .bt2-grid { display: flex; flex-direction: column; gap: 0; }
  .bt2-c { position: relative; padding: 0 0 18px 26px; }
  .bt2-c::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 0; border-left: 2px dotted var(--line2); }
  .bt2-c[data-out="fail"]::before { border-left: 2.5px solid var(--bad); }
  .bt2-c[data-out="hold"]::before { border-left-color: var(--ok); }
  .bt2-c::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line2); box-sizing: border-box; }
  .bt2-c.kn::after { background: var(--text2); border-color: var(--text2); }
  .bt2-dia:has(.bt2-k.on) .bt2-c.kn::after { background: var(--bad); border-color: var(--bad); }
  .bt2-c.cs { padding-bottom: 0; }
  .bt2-c.cs::before { display: none; }
  .bt2-ch { text-align: left; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .bt2-ch small { display: inline; margin: 0; }
  .bt2-ns { gap: 8px; }
  .bt2-c.thr .bt2-ns { flex-direction: row; flex-wrap: wrap; }
  .bt2-c.thr .bt2-n { flex: 1 1 140px; }
  .bt2-k { justify-content: flex-start; }
  .bt2-k-c { max-width: none; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; text-align: left; }
  .bt2-k-svg { grid-row: span 3; margin: 0; width: 58px; height: 32px; }
  .bt2-k-n { margin: 1px 0 4px; }
  .bt2-k-s { justify-self: start; }
  .bt2-more { text-align: left; }
  .bt2-esc { display: block; margin-top: 4px; }
  .bt2-esc-in { padding-left: 26px; }
  .bt2-esc-ns { justify-content: flex-start; }
  .bt2-esc .bt2-g { flex: 1 1 100%; }
}

/* ---------- บรรทัดหลักฐาน ---------- */
.bt2-ev { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.bt2-ev-r { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.bt2-ev-s { display: inline-flex; align-items: flex-start; gap: 7px; font: 600 12.5px/1.4 var(--f-b, inherit); color: var(--text2); padding-top: 1px; }
.bt2-ev-s i { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; flex: none; background: var(--muted); }
.bt2-ev-r.on .bt2-ev-s, .bt2-ev-r.fail .bt2-ev-s { color: var(--bad); }
.bt2-ev-r.on .bt2-ev-s i, .bt2-ev-r.fail .bt2-ev-s i { background: var(--bad); }
.bt2-ev-r.held .bt2-ev-s, .bt2-ev-r.hold .bt2-ev-s { color: var(--ok); }
.bt2-ev-r.held .bt2-ev-s i, .bt2-ev-r.hold .bt2-ev-s i { background: var(--ok); }
.bt2-ev-r.none .bt2-ev-s i, .bt2-ev-r.unk .bt2-ev-s i { background: transparent; border: 1.5px solid var(--muted); }
.bt2-ev-r.conf .bt2-ev-s { color: var(--muted); font-weight: 500; }
.bt2-ev-r.conf .bt2-ev-s i { background: var(--gold); }
.bt2-ev-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.bt2-ev-n { font: 600 14.5px/1.4 var(--f-b, inherit); color: var(--text); }
.bt2-ev-and { font-size: 12px; color: var(--muted); margin: 0 2px; }
.bt2-ev-q { font: 400 12.5px/1.4 var(--f-b, inherit); color: var(--muted); }
.bt2-ev-q::before { content: "("; } .bt2-ev-q::after { content: ")"; }
.bt2-ev-t { margin: 4px 0 0; font: 400 14px/1.6 var(--f-b, inherit); color: var(--text2); text-wrap: pretty; }
.bt2-ev-d { margin: 6px 0 0; font: 400 12px/1.5 var(--f-b, inherit); color: var(--muted); }
.bt2-ev-d b { font-weight: 600; color: var(--text2); }
@media (max-width: 640px) {
  .bt2-ev-r { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- คำศัพท์ ---------- */
.bt2-gl { border: 1px solid var(--line); border-radius: var(--r, 14px); background: var(--surface); }
.bt2-gl > summary { cursor: pointer; list-style: none; padding: 11px 14px; font: 600 13.5px/1.4 var(--f-b, inherit); color: var(--sky); display: flex; align-items: center; gap: 8px; }
.bt2-gl > summary::-webkit-details-marker { display: none; }
.bt2-gl > summary::before { content: "?"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; font: 700 12px/1 var(--f-m, inherit); flex: none; }
.bt2-gl[open] > summary { border-bottom: 1px solid var(--line); }
.bt2-gl dl { margin: 0; padding: 6px 14px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 26px; }
.bt2-gl dl > div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.bt2-gl dt { font: 600 13.5px/1.4 var(--f-b, inherit); color: var(--text); display: flex; align-items: center; gap: 7px; }
.bt2-gl dd { margin: 3px 0 0; font: 400 13px/1.6 var(--f-b, inherit); color: var(--text2); }
.bt2-sw { width: 18px; height: 0; border-top: 3px solid var(--muted); display: inline-block; flex: none; }
.bt2-sw.fail { border-top-color: var(--bad); }
.bt2-sw.hold { border-top: 3px dotted var(--ok); }
.bt2-sw.none { border-top: 2px dashed var(--muted); }

/* ---------- กรอบส่วน Bow-tie ในหน้าเหตุ/หน้าเคส (app.js bowtieBlock) ---------- */
.bt2-sec { margin-top: 36px; padding-top: 26px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.bt2-sec-hd { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.bt2-sec-hd h2 { margin: 0; font: 700 clamp(20px, 2vw, 26px)/1.2 var(--f-d, inherit); color: var(--text); }
.bt2-sec-go { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font: 600 13px/1.3 var(--f-b, inherit); color: var(--sky); text-decoration: none; }
.bt2-sec-go:hover { text-decoration: underline; }
.bt2-sec-go .ic { width: 15px; height: 15px; }
.bt2-hero-a { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font: 500 13px/1.4 var(--f-b, inherit); }
.bt2-hero-a a { color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; border-bottom: 1px solid rgb(255 255 255 / .4); }
.bt2-hero-a a:hover { border-bottom-color: #fff; }
.bt2-hero-a .ic { width: 14px; height: 14px; }
.bt2-hero-a .also { color: rgb(244 247 252 / .72); display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.bt2-hero-a .also a { border-bottom-style: dotted; }
.bt2-hero-n span.st { font-weight: 600; color: #fff; }
.bt2-nilp { margin: -6px 0 0; font: 400 13px/1.5 var(--f-b, inherit); color: var(--muted); }
.bt2-sub { margin: 6px 0 -8px; }
.bt2-sub h3 { margin: 0; font: 600 16px/1.35 var(--f-h, var(--f-b, inherit)); color: var(--text); }
.bt2-sub p { margin: 3px 0 0; font: 400 12.5px/1.5 var(--f-b, inherit); color: var(--muted); }
.bt2-std { margin: 0; font: 400 12.5px/1.6 var(--f-b, inherit); color: var(--muted); max-width: 90ch; }
@media (max-width: 760px) {
  .bt2-sec { margin-top: 28px; padding-top: 20px; gap: 14px; }
  .bt2-sec-go { margin-left: 0; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bt2-w .w-fail, .bt2-w .w-on { animation: none; }
  .bt2-hero-i { transition: opacity .2s; transform: none !important; }
  .bt2-w { transition: none; }
}
@media print {
  .bt2-w .w-fail, .bt2-w .w-on { animation: none; }
  .bt2-hero { box-shadow: none; }
}
