/* Ultrafast-TH view — the FusionCharge design language (tokens mirror design-system/tokens and the wiki's
   css/wiki.css), scoped to .ufx so the flood dashboard around it keeps its own "chart paper" look.
   White / #F6F6F4 surfaces, Huawei red #E9002F as the only accent, hairline #DDDDDD borders, 10 px radius,
   the red accent bar as the signature device, Hanken Grotesk + Noto Sans Thai + IBM Plex Mono. */
.ufx, .ufx-pop, .ufx-lightbox, .view-seg [data-view="ufx"], .ufx-goto, .sw-ufx {
  --u-red: #E9002F; --u-red-deep: #C7000B; --u-red-tint: #FCE5EA; --u-amber: #FCC800; --u-green: #21C45A; --u-green-eco: #61B230;
  --u-ink: #1D1D1A; --u-ink-2: #3C3C3A; --u-ink-3: #666666; --u-ink-4: #8A8A88;
  --u-line: #DDDDDD; --u-line-soft: #ECECEC; --u-surface: #FFFFFF; --u-surface-2: #F6F6F4; --u-surface-3: #EFEFED; --u-inkbg: #141413;
  --u-radius: 10px; --u-radius-lg: 16px; --u-pill: 999px;
  --u-shadow-xs: 0 1px 2px rgba(29,29,26,.06); --u-shadow: 0 2px 10px rgba(29,29,26,.07); --u-shadow-lg: 0 14px 40px rgba(29,29,26,.16);
  --u-sans: "Hanken Grotesk", "Noto Sans Thai", system-ui, sans-serif;
  --u-thai: "Noto Sans Thai", "Hanken Grotesk", system-ui, sans-serif;
  --u-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --u-ease: cubic-bezier(.22,.61,.36,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ufx, :root:not([data-theme="light"]) .ufx-pop {
    --u-ink: #F4F4F2; --u-ink-2: #D6D6D2; --u-ink-3: #A9A9A5; --u-ink-4: #8A8A88;
    --u-line: #34342F; --u-line-soft: #2A2A26; --u-surface: #1D1D1A; --u-surface-2: #141413; --u-surface-3: #262622; --u-red-tint: #3A0D16;
  }
}
:root[data-theme="dark"] .ufx, :root[data-theme="dark"] .ufx-pop {
  --u-ink: #F4F4F2; --u-ink-2: #D6D6D2; --u-ink-3: #A9A9A5; --u-ink-4: #8A8A88;
  --u-line: #34342F; --u-line-soft: #2A2A26; --u-surface: #1D1D1A; --u-surface-2: #141413; --u-surface-3: #262622; --u-red-tint: #3A0D16;
}

/* the tab itself carries a small red mark so the reader sees it is the Huawei part of the page */
.view-seg [data-view="ufx"]::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--u-red); margin-right: 7px; vertical-align: 1px; }
.ufx-goto { color: var(--u-red-deep); font-weight: 600; }
.sw-ufx { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--u-red); box-shadow: 0 0 0 1.5px #fff inset; margin: 0 4px 0 2px; vertical-align: -1px; }
body[data-view="city"] .ufx-ly { order: 9; }
/* "Around Bangkok" (ThaiWater): the checkbox and legend exist only while a usable feed does */
.layers label[hidden], .legend-row .ufx-rg-leg[hidden] { display: none; }   /* .layers label sets display:flex, which beat [hidden] (the traffic row showed empty) */
.sw-rg { display: inline-block; width: 16px; height: 0; border-top: 2px dashed #5F5F5B; margin: 0 2px; vertical-align: middle; }
.legend-row i.lg-rg-prov { width: 16px; height: 0; border-radius: 0; background: none; border-top: 2px dashed #5F5F5B; vertical-align: middle; }
.legend-row i.lg-rg-road { width: 9px; height: 9px; border-radius: 1px; transform: rotate(45deg); margin: 0 6px 0 2px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(0,0,0,.12); }
.legend-row i.lg-rg-rain { width: 8px; height: 8px; background: rgba(47,127,216,.5); box-shadow: 0 0 0 1px #2F7FD8 inset; }

/* ── base */
.ufx { font-family: var(--u-sans); color: var(--u-ink); font-feature-settings: normal; }
html[lang="th"] .ufx { font-family: var(--u-thai); }
.ufx h2, .ufx h3 { font-family: inherit; color: var(--u-ink); }
.ufx a { color: var(--u-red-deep); }
.ufx :focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(233,0,47,.32); border-radius: 6px; }
section.ufx { padding-top: 40px; }
.ufx-head { max-width: 780px; margin-bottom: 18px; }
.ufx-h { font-size: clamp(21px, 2.6vw, 27px); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; padding-left: 12px; border-left: 4px solid var(--u-red); }
html[lang="th"] .ufx-h { letter-spacing: 0; line-height: 1.35; }
.ufx-lead { color: var(--u-ink-3); font-size: 15.5px; margin-top: 8px; }
.ufx-meta { color: var(--u-ink-4); font-size: 13px; margin-top: 6px; }

/* ── buttons (wiki .btn geometry) */
.ufx-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.ufx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: var(--u-pill); padding: 10px 22px;
  font-family: inherit; font-weight: 700; font-size: 15px; line-height: 1.2; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; max-width: 100%;
  transition: transform 120ms var(--u-ease), box-shadow 120ms var(--u-ease), background 120ms var(--u-ease); }
.ufx-btn:hover { text-decoration: none; transform: translateY(-1px); }
.ufx-btn:active { transform: translateY(0); }
.ufx-btn.primary { background: var(--u-red); color: #fff; box-shadow: 0 8px 26px rgba(233,0,47,.26); }
.ufx-btn.primary:hover { background: var(--u-red-deep); }
.ufx-btn.ghost { background: var(--u-surface); color: var(--u-ink); border-color: var(--u-line); }
.ufx-btn.ghost:hover { border-color: var(--u-ink); }
.ufx-btn.ghost.on-dark { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.ufx-btn.ghost.on-dark:hover { border-color: #fff; }
.ufx-btn.line { background: transparent; color: #fff; border-color: rgba(6,199,85,.85); }
.ufx-btn.line .line-glyph { color: #06C755; flex: none; }
.ufx-btn.line:hover { background: #06C755; border-color: #06C755; }
.ufx-btn.line:hover .line-glyph { color: #fff; }
.ufx-btn.sm { min-height: 38px; padding: 7px 16px; font-size: 14px; }
.ufx-btn[aria-busy="true"] { opacity: .6; cursor: progress; }

/* ── hero: ink block, amber eyebrow, product render right (wiki .hero) */
.ufx-hero { padding-top: 24px !important; }
.ufx-hero-in { position: relative; overflow: hidden; background: var(--u-inkbg); color: #fff; border-radius: var(--u-radius-lg);
  padding: clamp(24px, 4.4vw, 48px); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 20px; align-items: center; }
.ufx-hero-in::before { content: ""; position: absolute; right: -8%; top: 50%; width: 60%; aspect-ratio: 1; transform: translateY(-50%);
  background: radial-gradient(closest-side, rgba(233,0,47,.34), rgba(233,0,47,0)); pointer-events: none; }
.ufx-hero-txt { position: relative; }
.ufx-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--u-amber); font-family: var(--u-sans); }
.ufx-title { color: #fff !important; font-size: clamp(30px, 4.8vw, 50px); line-height: 1.06; letter-spacing: -0.02em; font-weight: 800; margin: 10px 0 14px; }
html[lang="th"] .ufx-title { line-height: 1.22; letter-spacing: 0; }
.ufx-sub { color: rgba(255,255,255,.72); font-size: clamp(15px, 1.7vw, 17.5px); max-width: 58ch; margin-bottom: 16px; }
.ufx-now { display: inline-flex; align-items: flex-start; gap: 9px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--u-radius); padding: 9px 14px; font-size: 14.5px; font-weight: 600; color: #fff; margin-bottom: 18px; max-width: 60ch; }
.ufx-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--u-ink-4); margin-top: 6px; }
.ufx-now[data-k="clear"] .ufx-dot { background: var(--u-green); }
.ufx-now[data-k="water"] .ufx-dot { background: var(--u-amber); }
.ufx-now[data-k="flood"] .ufx-dot { background: var(--u-red); animation: ufx-pulse 2s infinite; }
@keyframes ufx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.ufx-hero-img { position: relative; margin: 0; display: flex; justify-content: center; }
.ufx-hero-img img { width: auto; max-width: 100%; height: auto; max-height: 340px; filter: drop-shadow(0 18px 30px rgba(0,0,0,.45)); }
.ufx .nw { white-space: nowrap; }
.ufx-title { max-width: 14em; }

/* ── station filter + list */
.ufx-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 14px; }
.ufx-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ufx-seg button { font-family: inherit; font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--u-ink-2); background: var(--u-surface); border: 1px solid var(--u-line);
  border-radius: var(--u-pill); padding: 8px 15px; min-height: 38px; cursor: pointer; }
.ufx-seg button:hover { border-color: var(--u-ink); }
.ufx-seg button[aria-pressed="true"] { background: var(--u-ink); border-color: var(--u-ink); color: var(--u-surface); }
.ufx-geo-msg { font-size: 14px; color: var(--u-ink-3); margin: -4px 0 12px; }
.ufx-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.ufx-st { background: var(--u-surface); border: 1px solid var(--u-line-soft); border-left: 4px solid var(--u-line); border-radius: var(--u-radius);
  padding: 16px 16px 14px; box-shadow: var(--u-shadow-xs); display: grid; gap: 8px; align-content: start; min-width: 0;
  transition: box-shadow 220ms var(--u-ease); }
.ufx-st:hover { box-shadow: var(--u-shadow); }
.ufx-st[data-acc="flood"] { border-left-color: var(--u-red); }
.ufx-st[data-acc="water"] { border-left-color: var(--u-amber); }
.ufx-st[data-acc="clear"] { border-left-color: var(--u-green-eco); }
.ufx-st.hl { box-shadow: 0 0 0 2px var(--u-red), var(--u-shadow); }
.ufx-st h3 { font-size: 16.5px; line-height: 1.3; margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.ufx-st .app { font-size: 13px; color: var(--u-ink-3); }
.ufx-st .app b { color: var(--u-ink-2); font-weight: 600; }
.ufx-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.ufx-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; border-radius: var(--u-pill);
  padding: 3px 10px; border: 1px solid var(--u-line); color: var(--u-ink-2); background: var(--u-surface-2); line-height: 1.5; }
.ufx-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--u-ink-4); flex: none; }
.ufx-badge.st-open { color: #157F3A; border-color: rgba(33,196,90,.45); background: rgba(33,196,90,.10); }
.ufx-badge.st-open i { background: var(--u-green); }
.ufx-badge.st-check { color: #8A5A00; border-color: rgba(252,200,0,.7); background: rgba(252,200,0,.14); }
.ufx-badge.st-check i { background: #E0A800; }
.ufx-badge.acc-flood { color: var(--u-red-deep); border-color: rgba(233,0,47,.4); background: var(--u-red-tint); }
.ufx-badge.acc-flood i { background: var(--u-red); }
.ufx-badge.acc-water { color: #8A5A00; border-color: rgba(252,200,0,.7); background: rgba(252,200,0,.14); }
.ufx-badge.acc-water i { background: #E0A800; }
.ufx-badge.acc-clear i { background: var(--u-green-eco); }
.ufx-st .acc { font-size: 14px; color: var(--u-ink-2); }
.ufx-st .dist { font-family: var(--u-mono); font-size: 12.5px; color: var(--u-ink-3); }
.ufx-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.ufx-empty { color: var(--u-ink-3); font-size: 15px; padding: 18px; border: 1px dashed var(--u-line); border-radius: var(--u-radius); background: var(--u-surface); }
.ufx-foot { font-size: 13px; color: var(--u-ink-3); margin-top: 14px; max-width: 90ch; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ufx-badge.st-open { color: #7BE3A1; }
  :root:not([data-theme="light"]) .ufx-badge.st-check, :root:not([data-theme="light"]) .ufx-badge.acc-water { color: #FFD95A; }
  :root:not([data-theme="light"]) .ufx-badge.acc-flood { color: #FF8FA3; }
}
:root[data-theme="dark"] .ufx-badge.st-open { color: #7BE3A1; }
:root[data-theme="dark"] .ufx-badge.st-check, :root[data-theme="dark"] .ufx-badge.acc-water { color: #FFD95A; }
:root[data-theme="dark"] .ufx-badge.acc-flood { color: #FF8FA3; }

/* ── driver cards (wiki .card: white, hairline, red left bar) */
.ufx-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
@media (min-width: 900px) { .ufx-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ufx-card { background: var(--u-surface); border: 1px solid var(--u-line-soft); border-left: 4px solid var(--u-red); border-radius: var(--u-radius);
  padding: 18px; box-shadow: var(--u-shadow-xs); }
.ufx-card.ok { border-left-color: var(--u-green-eco); }
.ufx-card.stop { background: linear-gradient(0deg, var(--u-red-tint), var(--u-red-tint)) padding-box; }
.ufx-card h3 { font-size: 17px; line-height: 1.3; margin: 0 0 6px; font-weight: 700; }
.ufx-card p { font-size: 14.5px; color: var(--u-ink-3); }
.ufx-card.stop p { color: var(--u-ink-2); }

/* ── owners: the four steps + the approved safety cards */
.ufx-owner-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
.ufx-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 10px; }
.ufx-steps li { counter-increment: s; position: relative; background: var(--u-surface); border: 1px solid var(--u-line-soft); border-radius: var(--u-radius);
  padding: 14px 16px 14px 60px; box-shadow: var(--u-shadow-xs); font-size: 14.5px; color: var(--u-ink-2); display: grid; gap: 3px; }
.ufx-steps li::before { content: counter(s); position: absolute; left: 14px; top: 14px; width: 32px; height: 32px; border-radius: 8px;
  background: var(--u-red); color: #fff; font: 700 17px/32px var(--u-mono); text-align: center; }
.ufx-steps b { color: var(--u-ink); font-size: 15.5px; }
.ufx-gallery { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.ufx-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ufx-shot { display: block; padding: 0; margin: 0; border: 1px solid var(--u-line); border-radius: var(--u-radius); overflow: hidden; background: var(--u-surface-3);
  cursor: zoom-in; box-shadow: var(--u-shadow-xs); transition: box-shadow 220ms var(--u-ease), transform 220ms var(--u-ease); }
.ufx-shot:hover { box-shadow: var(--u-shadow); transform: translateY(-2px); }
.ufx-shot img { display: block; width: 100%; height: auto; }
.ufx-dl { grid-column: 1 / -1; font-size: 14px; font-weight: 600; }
.ufx-dl a::after { content: " ↓"; }

/* ── emergency numbers */
.ufx-tel { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.ufx-tel .ufx-telc { display: grid; gap: 2px; background: var(--u-surface); border: 1px solid var(--u-line-soft); border-radius: var(--u-radius); padding: 14px 16px;
  color: var(--u-ink-2); text-decoration: none; font-size: 13.5px; box-shadow: var(--u-shadow-xs); min-height: 44px; }
.ufx-tel .ufx-telc b { user-select: all; }
.ufx-tel b { font: 600 26px/1.1 var(--u-mono); color: var(--u-red-deep); letter-spacing: -0.01em; }
.ufx-tel .hot .ufx-telc { border-left: 4px solid var(--u-red); }

/* ── CTA: ink block */
.ufx-cta-in { background: var(--u-inkbg); color: #fff; border-radius: var(--u-radius-lg); padding: clamp(22px, 4vw, 34px); }
.ufx-cta-in h2 { color: #fff !important; font-size: clamp(21px, 2.6vw, 26px); font-weight: 700; margin-bottom: 6px; }
.ufx-cta-in p { color: rgba(255,255,255,.68); max-width: 62ch; margin-bottom: 18px; font-size: 15px; }

/* ── lightbox */
.ufx-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(20,20,19,.86); display: grid; place-items: center; padding: 16px; }
.ufx-lightbox[hidden] { display: none !important; }
.ufx-lightbox img { max-width: min(100%, 720px); max-height: calc(100vh - 32px); width: auto; height: auto; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.ufx-lb-close { position: fixed; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: #1D1D1A;
  font: 400 28px/44px var(--u-sans); cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.3); }

/* ── map popup for a station (maplibre popup content) */
.ufx-pop { font-family: var(--u-sans); color: #1D1D1A; min-width: 200px; }
html[lang="th"] .ufx-pop { font-family: var(--u-thai); }
.ufx-pop h4 { margin: 0 0 6px; font-size: 14.5px; line-height: 1.3; padding-left: 8px; border-left: 3px solid var(--u-red); }
.ufx-pop p { margin: 4px 0; font-size: 13px; color: #3C3C3A; }
.ufx-pop .ufx-badges { margin: 6px 0; }
.ufx-pop a { color: #C7000B; font-weight: 700; }

.ufx-st .acc-note { font-size: 13px; color: var(--u-ink-3); padding-left: 10px; border-left: 2px solid var(--u-line); }

/* ── map popup for a ThaiWater reading */
.ufx-rg-pop .rg-kind { color: #666666; font-size: 12.5px; }
.ufx-rg-pop .rg-mean { display: flex; align-items: center; gap: 7px; margin-top: 6px; }
.ufx-rg-pop .rg-mean b { color: #1D1D1A; font-family: inherit; font-weight: 700; }
.ufx-rg-pop .rg-mean i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #7C93A3; }
.ufx-rg-pop .rg-mean.s4 i { background: #E0A800; }
.ufx-rg-pop .rg-mean.s5 i { background: #E9002F; }
.ufx-rg-pop .rg-mean.w5 i { background: #D9480F; }   /* gauge near/above bank: orange — red is kept for water on a road */
.ufx-rg-pop .rg-mean.rain i { background: #2F7FD8; }
.ufx-rg-pop .rg-val { font-size: 13px; font-weight: 600; color: #3C3C3A; padding-left: 16px; }
/* our popups open above the map's own overlays (time stamp, layer panel, timelapse bar), which otherwise cover their heading */
.maplibregl-popup:has(.ufx-pop) { z-index: 4; }
.ufx-rg-pop .rg-note { font-size: 12px; color: #666666; margin-top: 4px; }
.ufx-rg-pop .rg-time, .ufx-rg-pop .rg-src { color: #8A8A88; font-size: 12px; margin-top: 2px; }
.ufx-pop .prov { color: #666666; font-size: 12.5px; }

/* the flood page's footer credit */
.foot .credit { margin-top: 10px; font-size: 12.5px; }
.foot .credit a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule); }
.foot .credit a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ── responsive */
@media (max-width: 900px) {
  .ufx-owner-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) {
  section.ufx { padding-top: 30px; }
  .ufx-hero { padding-top: 14px !important; }
  .ufx-hero-in { grid-template-columns: minmax(0, 1fr) 84px; gap: 8px; padding: 22px 18px; align-items: start; }
  .ufx-hero-img img { max-height: 150px; }
  .ufx-btns .ufx-btn { flex: 1 1 auto; }
  .ufx-list { grid-template-columns: 1fr; }
  .ufx-gallery { grid-template-columns: 1fr; }
  .ufx-thumbs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ufx-tel { grid-template-columns: 1fr 1fr; }
  .ufx-tel .hot { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .ufx-hero-in { grid-template-columns: 1fr; }
  .ufx-hero-img { display: none; }
}
@media (max-width: 380px) {
  .ufx-seg button { padding: 7px 12px; }
}
