/* StormAU app shell: quick-switch chips, phone tab bar + bottom sheet, preferences.
   Products declare themselves with data-product attributes (see docs/ADDING_A_PRODUCT.md);
   nothing here knows about any particular product. */

:root { --tabh: 58px; --shell-bg:#12172e; --shell-line:#2a3f5f; --shell-accent:#4a9eff; --shell-on:#3ddc97; }

/* Hidden by the user's preferences. */
.shellHidden { display:none !important; }
.shellFlex { display:flex; flex-direction:column; }

/* ---- Quick-switch chips (one-tap layers), all screen sizes ---------------------- */
#chips { position:fixed; z-index:15; display:flex; gap:7px; overflow-x:auto; white-space:nowrap; -webkit-overflow-scrolling:touch;
  scrollbar-width:none; padding:2px 2px 6px; pointer-events:none; }
#chips::-webkit-scrollbar { display:none; }
#chips .chip { pointer-events:auto; display:inline-flex; align-items:stretch; flex:0 0 auto; border-radius:22px; overflow:hidden;
  background:rgba(12,16,32,0.86); border:1px solid #33456b; box-shadow:0 2px 10px rgba(0,0,0,.45); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
#chips .chip.on { border-color:var(--shell-on); background:rgba(14,52,42,0.9); }
#chips .chip button { all:unset; cursor:pointer; box-sizing:border-box; min-height:40px; display:inline-flex; align-items:center; gap:6px; color:#dbe6ff; font-size:13px; font-weight:600; }
#chips .chipMain { padding:0 10px 0 12px; }
#chips .chip.on .chipMain { color:#c8ffe6; }
#chips .chipMore { padding:0 11px 0 6px; opacity:.7; font-size:16px; }
#chips .ci { font-size:16px; }
#chips .cb { background:#c2185b; color:#fff; border-radius:9px; padding:0 6px; font-size:11px; font-weight:800; line-height:17px; min-width:17px; text-align:center; }
#chips .cb:empty { display:none; }
#chips .cdot { width:8px; height:8px; border-radius:50%; background:#5b6a8c; flex:0 0 auto; }
#chips .chip.on .cdot { background:var(--shell-on); box-shadow:0 0 6px var(--shell-on); }
/* desktop: sit at the top of the map, clear of the zoom controls */
#chips { top:10px; left:316px; right:70px; }

/* ---- Preferences ------------------------------------------------------------------ */
.shellModal { position:fixed; inset:0; z-index:40; display:none; background:rgba(0,0,0,.6); align-items:flex-end; justify-content:center; }
.shellModal.show { display:flex; }
.shellModal .card { width:min(640px,100%); max-height:92dvh; max-height:92vh; overflow-y:auto; background:#161c38; color:#dbe6ff;
  border:1px solid var(--shell-line); border-radius:16px 16px 0 0; padding:0 14px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 821px) { .shellModal { align-items:center; } .shellModal .card { border-radius:14px; max-height:86vh; } }
.shellModal .head { position:sticky; top:0; z-index:2; display:flex; align-items:center; gap:8px; padding:14px 0 10px; background:#161c38; border-bottom:1px solid var(--shell-line); }
.shellModal .head h2 { margin:0; font-size:16px; flex:1; }
.shellModal .head button { all:unset; cursor:pointer; padding:9px 14px; border-radius:10px; background:#26305c; font-size:13px; font-weight:700; }
.shellModal h3 { margin:16px 0 6px; font-size:11px; letter-spacing:.7px; text-transform:uppercase; color:#8fa8c8; }
.prow { display:grid; grid-template-columns:1fr auto; gap:6px 10px; align-items:center; padding:10px 0; border-bottom:1px solid #222b4e; }
.prow.off .pmeta { opacity:.45; }
.prow .pmeta b { font-size:14px; display:block; }
.prow .pmeta span { font-size:11px; color:#8fa8c8; display:block; margin-top:1px; }
.prow .pctl { display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.prow .pctl button, .prow .pctl select { all:unset; cursor:pointer; box-sizing:border-box; min-width:40px; min-height:40px; padding:0 10px; text-align:center; line-height:40px;
  border-radius:10px; background:#232c55; color:#dbe6ff; font-size:14px; }
.prow .pctl select { background:#232c55; padding:0 6px; font-size:12px; }
.prow .pctl .pinb.on { background:#7a5a00; color:#ffd54f; }
.prow .sw { display:inline-flex; align-items:center; gap:6px; min-height:40px; font-size:12px; text-transform:none; margin:0; }
.prow .sw input { width:22px; height:22px; margin:0; }
.popt { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 0; font-size:13px; text-transform:none; }
.popt select { padding:8px; font-size:13px; }
.shellModal textarea { width:100%; box-sizing:border-box; min-height:74px; background:#0c1020; color:#9fb3d6; border:1px solid var(--shell-line); border-radius:8px; font-size:11px; padding:8px; }
.shellModal .row2 { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.shellModal .row2 button { all:unset; cursor:pointer; padding:10px 14px; border-radius:10px; background:#26305c; font-size:13px; font-weight:700; }
.shellModal .row2 button.danger { background:#4a1c1c; color:#ffb4a8; }
.prefsCard { display:none; margin:0 0 10px; padding:12px; border:1px solid var(--shell-line); border-radius:10px; background:#1a2246; }
.prefsCard b { font-size:14px; }
.prefsCard p { margin:4px 0 10px; font-size:11px; color:#8fa8c8; line-height:1.4; }
.prefsCard button, #shellManageDesktop { all:unset; cursor:pointer; padding:10px 14px; border-radius:10px; background:var(--shell-accent); color:#06122b; font-size:13px; font-weight:800; }
#shellManageDesktop { display:inline-block; margin:2px 0 10px; }

/* Before the shell script has run (it loads last), a phone or narrow window used to show the
   DESKTOP sidebar for several seconds, then snap to the phone layout. Keep the sidebar and the
   desktop menu button out of sight from the first paint on small screens; the rules below take
   over as soon as body.shell is set. visibility (not display) so the shell can still measure it. */
@media (max-width: 820px) {
  body:not(.shell) #sidebar { visibility:hidden; position:fixed; left:0; right:0; bottom:0; width:100%; max-width:none; height:58vh; }
  body:not(.shell) #mapwrap { width:100%; }
  body:not(.shell) #navToggle, body:not(.shell) #navScrim { display:none !important; }
}

/* ================= Phone / iPhone width ================= */
#tabbar, #sheetHead { display:none; }
@media (max-width: 820px) {
  body.shell #navToggle, body.shell #navScrim { display:none !important; }
  body.shell #shellManageDesktop { display:none; }

  /* Quick-switch chips run along the top, clear of the notch */
  body.shell #chips { top:calc(8px + env(safe-area-inset-top)); left:8px; right:8px; }

  /* Tab bar */
  body.shell #tabbar { display:flex; position:fixed; left:0; right:0; bottom:0; z-index:30; height:calc(var(--tabh) + env(safe-area-inset-bottom));
    padding-bottom:env(safe-area-inset-bottom); background:rgba(12,16,32,.96); border-top:1px solid var(--shell-line);
    backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px); }
  body.shell #tabbar button { all:unset; cursor:pointer; flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px;
    color:#8fa8c8; font-size:10.5px; font-weight:700; position:relative; -webkit-tap-highlight-color:transparent; }
  body.shell #tabbar button .ti { font-size:21px; line-height:1; filter:grayscale(.6); }
  body.shell #tabbar button.active { color:var(--shell-accent); }
  body.shell #tabbar button.active .ti { filter:none; }
  body.shell #tabbar button.active::before { content:""; position:absolute; top:0; left:26%; right:26%; height:3px; border-radius:0 0 3px 3px; background:var(--shell-accent); }
  body.shell #tabbar .tb { position:absolute; top:5px; left:calc(50% + 6px); background:#c2185b; color:#fff; border-radius:9px; padding:0 5px; font-size:10px; font-weight:800; line-height:16px; min-width:16px; text-align:center; }
  body.shell #tabbar .tb:empty { display:none; }

  /* The sidebar becomes a bottom sheet; the map stays visible above it */
  body.shell #sidebar { position:fixed; left:0; right:0; top:auto; width:100%; max-width:none; box-sizing:border-box;
    bottom:calc(var(--tabh) + env(safe-area-inset-bottom)); height:var(--sheet-h,58dvh); height:var(--sheet-h,58vh); height:var(--sheet-h,58dvh);
    transform:translateY(calc(100% + 80px)); transition:transform .26s cubic-bezier(.2,.8,.2,1), height .2s ease;
    border-radius:18px 18px 0 0; border-right:0; border-top:1px solid #35507f; padding:0 12px 24px; overflow-y:auto; -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain; z-index:20; box-shadow:0 -8px 28px rgba(0,0,0,.6); background:#161b34; }
  body.shell #sidebar.open { transform:translateY(0); }
  body.shell #sidebar > h1, body.shell #sidebar > .sub { display:none; }
  body.shell #mapwrap { width:100%; }
  body.shell .maplibregl-ctrl-top-right { top:calc(58px + env(safe-area-inset-top)); }     /* clear of the chip row */
  body.shell .maplibregl-ctrl-bottom-left, body.shell .maplibregl-ctrl-bottom-right { bottom:calc(var(--tabh) + env(safe-area-inset-bottom)); }

  body.shell #sheetHead { display:flex; align-items:center; gap:8px; position:sticky; top:0; z-index:5; margin:0 -12px 8px; padding:6px 12px 8px;
    background:#161b34; border-bottom:1px solid #26305c; }
  #sheetGrab { position:absolute; top:5px; left:50%; width:44px; height:5px; margin-left:-22px; border-radius:3px; background:#4a5b86; }
  body.shell #sheetHead .st { flex:1; margin-top:12px; font-size:15px; font-weight:800; color:#dbe6ff; }
  body.shell #sheetHead button { all:unset; cursor:pointer; margin-top:8px; min-width:48px; min-height:48px; text-align:center; line-height:48px; border-radius:12px; background:#2f3d78; color:#fff; font-size:22px; font-weight:700; border:1px solid #4a64a8; }
  body.shell #sheetHead button[data-a="close"] { background:#7a2740; border-color:#c2476b; }

  /* Products are docked into #pages (see shell.js): the group wrappers are empty shells */
  body.shell .navGroup { display:none; }
  body.shell #pages { display:flex; flex-direction:column; }
  /* A raw-controls product has no <summary>, so give it a heading on a phone */
  body.shell .productWrap[data-title]::before { content:attr(data-icon) " " attr(data-title); display:block; margin:6px 2px 10px; font-size:12px;
    font-weight:800; letter-spacing:.5px; text-transform:uppercase; color:#4a9eff; }
  body.shell [data-product], body.shell .prefsCard, body.shell [data-shell-page="map"] { display:none; }
  body.shell #sidebar[data-tab="map"] [data-shell-page="map"] { display:block; }
  body.shell #sidebar[data-tab="risk"]    [data-product][data-page="risk"],
  body.shell #sidebar[data-tab="nowcast"] [data-product][data-page="nowcast"],
  body.shell #sidebar[data-tab="live"]    [data-product][data-page="live"],
  body.shell #sidebar[data-tab="model"]   [data-product][data-page="model"],
  body.shell #sidebar[data-tab="more"]    [data-product][data-page="more"] { display:block; }
  body.shell #sidebar[data-tab="more"] .prefsCard { display:block; }
  body.shell [data-product].shellHidden { display:none !important; }
  body.shell .productWrap { margin-top:8px; }

  /* Bigger, thumb-friendly controls inside products */
  body.shell details.section summary { padding:14px 13px; font-size:13px; }
  body.shell details.section { margin-top:10px; }
  body.shell #sidebar input[type=checkbox] { width:22px; height:22px; }
  body.shell #sidebar select, body.shell #sidebar button, body.shell #sidebar input[type=number] { min-height:42px; font-size:14px; }
  body.shell #sidebar label { font-size:12px; }
}

/* Phone: a preference row is two lines - what it is, then its controls */
@media (max-width: 560px) {
  .prow { grid-template-columns:1fr; gap:8px; padding:12px 0; }
  .prow .pctl { justify-content:flex-start; gap:8px; }
  .prow .pctl select { min-width:96px; }
}


/* ======================= Accessibility =======================
   --ui-scale is set from the user's own settings (Aa button / Preferences). The page
   is full of fixed pixel sizes (9-11 px in places), so instead of a root font size the
   scale is applied with zoom to each region of the interface. Map label layers are
   scaled from JavaScript (shell.js: scaleMapText). */
:root { --ui-scale: 1; }
#sidebar > * { zoom: var(--ui-scale); }
#sidebar { width: calc(300px * var(--ui-scale)); max-width: 58vw; }
#chips { left: calc(min(300px * var(--ui-scale), 58vw) + 16px); }
#chips .chip { zoom: min(var(--ui-scale), 1.7); }
/* Scale what is INSIDE fixed-width boxes, never the box: zoom also multiplies the width, and a
   scaled 360 px panel is wider than a 390 px phone. */
.shellModal .card > * { zoom: var(--ui-scale); }
.maplibregl-popup-content { zoom: var(--ui-scale); }
.aaChip { pointer-events:auto; }
#chips .chip.aa { border-color:#8fb4ff; background:rgba(20,32,70,.92); }
#chips .chip.aa .chipMain { padding:0 14px; font-weight:800; }
#chips .chip.aa .cl { font-size:15px; }

#a11yPanel { position:fixed; z-index:45; display:none; width:min(calc(360px * var(--ui-scale)), calc(100vw - 16px)); box-sizing:border-box; color:#eaf1ff;
  background:#131a38; border:1px solid #4a6aa8; border-radius:14px; padding:12px 14px 14px; box-shadow:0 10px 34px rgba(0,0,0,.65); }
#a11yPanel > * { zoom: var(--ui-scale); }
#a11yPanel.show { display:block; }
#a11yPanel h4 { margin:0 0 8px; font-size:14px; display:flex; align-items:center; justify-content:space-between; }
.a11yBox .sizeRow { display:flex; align-items:center; gap:8px; margin:6px 0 10px; }
.a11yBox .sizeRow button, .a11yBox .presets button, .a11yBox .btnRow button { all:unset; cursor:pointer; box-sizing:border-box; min-height:44px; min-width:44px; text-align:center;
  line-height:44px; padding:0 12px; border-radius:10px; background:#26305c; color:#eaf1ff; font-weight:800; font-size:15px; }
.a11yBox .sizeRow .val { flex:1; text-align:center; font-size:15px; font-weight:800; }
.a11yBox .presets { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px; }
.a11yBox .presets button { min-width:56px; font-size:13px; }
.a11yBox .presets button.on { background:#4a9eff; color:#04122b; }
.a11yBox label.opt { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:44px; font-size:14px; text-transform:none; margin:0; border-top:1px solid #222b4e; }
.a11yBox label.opt input { width:24px; height:24px; margin:0; flex:0 0 auto; }
.a11yBox .hint { font-size:11px; color:#a9bce0; line-height:1.4; margin:2px 0 6px; }
.a11yBox .btnRow { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.a11yBox .preview { margin:4px 0 8px; padding:8px 10px; border:1px solid #2a3f5f; border-radius:8px; background:#0c1020; }
.a11yBox .preview b { color:#ffb74d; }

/* High contrast: lighter text, stronger edges, opaque overlays */
html.a11y-contrast { --shell-line:#8fb4ff; }
html.a11y-contrast body { color:#ffffff; }
html.a11y-contrast #sidebar, html.a11y-contrast .shellModal .card, html.a11y-contrast #a11yPanel { background:#000b24; }
html.a11y-contrast details.section, html.a11y-contrast .navGroup { border-color:#8fb4ff !important; }
html.a11y-contrast #chips .chip { background:#000b24; border-color:#cfe0ff; }
html.a11y-contrast #chips .chip.on { background:#003a24; border-color:#5dffb0; }
html.a11y-contrast #tabbar { background:#000b24; border-top-color:#cfe0ff; }
html.a11y-contrast #tabbar button { color:#dbe8ff; }
html.a11y-contrast [style*="color:#778"], html.a11y-contrast [style*="color:#889"], html.a11y-contrast [style*="color:#667"],
html.a11y-contrast [style*="color:#8fa8c8"], html.a11y-contrast [style*="color:#9fb3d6"], html.a11y-contrast [style*="color:#a9bce0"],
html.a11y-contrast [style*="color:#8899"], html.a11y-contrast .meta, html.a11y-contrast .sub { color:#e2ecff !important; }
html.a11y-contrast a { color:#9fd0ff !important; text-decoration:underline; }
html.a11y-contrast :focus-visible { outline:3px solid #ffd54f; outline-offset:2px; }

/* Bold text */
html.a11y-bold body, html.a11y-bold #sidebar, html.a11y-bold #a11yPanel, html.a11y-bold .shellModal .card { font-weight:650; }
html.a11y-bold label, html.a11y-bold .meta { font-weight:700 !important; }

/* Larger touch targets */
html.a11y-targets button, html.a11y-targets select, html.a11y-targets summary, html.a11y-targets input[type=number] { min-height:52px !important; }
html.a11y-targets input[type=checkbox], html.a11y-targets input[type=radio] { width:28px !important; height:28px !important; }
html.a11y-targets details.section summary { padding-top:16px !important; padding-bottom:16px !important; }

/* Reduce motion */
html.a11y-motion *, html.a11y-motion *::before, html.a11y-motion *::after { transition:none !important; animation:none !important; scroll-behavior:auto !important; }

/* Phone: tab bar grows with the text size (capped so it cannot swallow the screen) */
@media (max-width: 820px) {
  :root { --tabh: calc(58px * min(var(--ui-scale), 1.6)); }
  body.shell #tabbar button { font-size: calc(10.5px * min(var(--ui-scale), 1.6)); }
  body.shell #tabbar button .ti { font-size: calc(21px * min(var(--ui-scale), 1.6)); }
  body.shell #chips { top: calc(8px + env(safe-area-inset-top)); left: 8px; }
  body.shell .maplibregl-ctrl-top-right { top: calc((14px + 44px * min(var(--ui-scale), 1.7)) + env(safe-area-inset-top)); }
}

#chips .chip.st { border-color:#ef6c00; background:rgba(60,32,8,.92); }
#chips .chip.st.stale { border-color:#ff5252; background:rgba(64,14,14,.94); }
#chips .chip.st .cl { color:#ffe0b2; }
#chips .chip.st.stale .cl { color:#ffd0d0; }


/* ================= Desktop "Jump to" bar (ui/nav.js) ================= */
#navJump { display:none; }
@media (min-width: 821px) {
  #navJump { display:block; margin:8px 0 12px; padding:8px; border:1px solid #2a3b66; border-radius:10px; background:#10172d; }
  #navJump .njHead { display:flex; justify-content:space-between; align-items:center; font-size:10px; font-weight:700; letter-spacing:.06em;
    text-transform:uppercase; color:#8fa8c8; margin-bottom:6px; }
  #navJump .njHead label { text-transform:none; letter-spacing:0; font-weight:400; display:flex; gap:4px; align-items:center; cursor:pointer; }
  #navJump .njHead input { width:auto; margin:0; }
  #navJump .njGrid { display:grid; grid-template-columns:repeat(2,1fr); gap:4px; }
  #navJump button { all:unset; box-sizing:border-box; cursor:pointer; padding:6px 6px; border-radius:7px; background:#1a2444; color:#dbe6ff;
    font-size:11px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border:1px solid transparent; }
  #navJump button:hover { background:#24305a; }
  #navJump button:focus-visible { outline:2px solid var(--shell-accent,#4da3ff); outline-offset:1px; }
  #navJump button.on { background:#16407a; border-color:#4da3ff; color:#fff; }
}

/* "For you" buttons in the Jump bar (ui/modes.js) */
@media (min-width: 821px) { #navJump button.fy { background:#1d3a2a; border-color:#2f6b4a; } #navJump button.fy:hover { background:#25503a; } }

/* ================= Scenes and voice (ui/assist.js) ================= */
#assistFab { position:fixed; z-index:25; display:flex; flex-direction:row; align-items:center; gap:8px; left:50%; transform:translateX(-50%); bottom:8px; }
#assistFab button { all:unset; cursor:pointer; width:44px; height:44px; border-radius:50%; background:#16407a; color:#fff; font-size:20px; display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 10px rgba(0,0,0,.5); border:1px solid #4da3ff; -webkit-tap-highlight-color:transparent; }
#assistFab button:focus-visible { outline:2px solid #fff; outline-offset:2px; }
#assistPanel { display:none; position:fixed; z-index:26; left:12px; bottom:128px; width:min(360px, calc(100vw - 24px)); max-height:min(70vh,560px); overflow-y:auto; box-sizing:border-box;
  background:#0d1120; border:1px solid #2a4b80; border-radius:12px; padding:10px 12px; box-shadow:0 8px 28px rgba(0,0,0,.6); color:#dbe6ff; font-size:12px; }
#assistPanel.open { display:block; }
#assistPanel .asHead { display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; font-size:13px; }
#assistPanel .asHead button { all:unset; cursor:pointer; padding:4px 8px; color:#9fb3d8; }
#asScenes { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
#asScenes button { all:unset; box-sizing:border-box; cursor:pointer; padding:9px 8px; border-radius:9px; background:#1a2444; border:1px solid transparent; font-size:12px; font-weight:600; line-height:1.2; }
#asScenes button:hover { background:#24305a; } #asScenes button.learned { background:#1d3a2a; border-color:#2f6b4a; }
#asLearnNote { font-size:10px; color:#8fa8c8; margin:5px 0 8px; line-height:1.35; }
#assistPanel .asRow { display:flex; gap:6px; }
#assistPanel .asRow input { flex:1; min-width:0; margin:0; padding:8px; font-size:13px; }
#assistPanel .asRow button { all:unset; cursor:pointer; padding:8px 12px; border-radius:8px; background:#2a4b80; font-size:13px; }
#assistPanel .asRow button.on { background:#c62828; }
#asReply { min-height:18px; margin:7px 0 4px; font-size:12px; line-height:1.4; }
#assistPanel .asEx { font-size:11px; color:#9fb3d8; margin:4px 0; } #assistPanel .asEx div { margin-top:4px; line-height:1.5; }
#assistPanel .asSpeak { display:flex; gap:6px; align-items:center; font-size:11px; color:#9fb3d8; margin:4px 0; } #assistPanel .asSpeak input { width:auto; margin:0; }
#assistPanel .asPriv { font-size:9.5px; color:#778; line-height:1.4; margin-top:4px; }
@media (min-width: 821px) { #assistFab { left:calc(50% + 150px); bottom:8px; } #assistPanel { left:316px; bottom:58px; } }
@media (max-width: 820px) { #assistFab { bottom:calc(var(--tabh, 62px) + env(safe-area-inset-bottom) + 6px); } #assistPanel { bottom:calc(var(--tabh, 62px) + env(safe-area-inset-bottom) + 56px); } }

/* ================= Feedback and test banner (ui/feedback.js) ================= */
#fbModal { display:none; position:fixed; inset:0; z-index:40; background:rgba(0,0,0,.6); align-items:center; justify-content:center; padding:12px; }
#fbModal.open { display:flex; }
#fbModal .fbCard { width:min(420px,100%); max-height:92vh; overflow:auto; box-sizing:border-box; background:#0d1120; border:1px solid #2a4b80; border-radius:12px; padding:12px 14px; color:#dbe6ff; font-size:13px; }
#fbModal .fbHead { display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; }
#fbModal .fbHead button { all:unset; cursor:pointer; padding:4px 8px; color:#9fb3d8; }
#fbModal label { display:block; font-size:11px; color:#9fb3d8; margin:6px 0 2px; }
#fbModal select, #fbModal textarea, #fbModal input { width:100%; box-sizing:border-box; margin:0; padding:8px; font-size:13px; }
#fbModal #fbStatus { min-height:16px; margin-top:6px; font-size:12px; }
#fbModal .fbRow { margin-top:6px; } #fbModal #fbSend { all:unset; cursor:pointer; padding:8px 16px; border-radius:8px; background:#2a4b80; font-weight:700; } #fbModal #fbSend:disabled { opacity:.5; }
#fbModal .fbPriv { font-size:10px; color:#778; line-height:1.4; margin-top:8px; }
#testBanner { position:fixed; z-index:22; left:50%; transform:translateX(-50%); bottom:60px; max-width:calc(100vw - 24px); display:flex; gap:8px; align-items:center; background:rgba(120,70,0,.92); color:#ffe9c2;
  border:1px solid #b5731a; border-radius:18px; padding:4px 6px 4px 12px; font-size:11px; }
#testBanner button { all:unset; cursor:pointer; padding:2px 8px; }
@media (max-width: 820px) { #testBanner { bottom:calc(var(--tabh, 62px) + env(safe-area-inset-bottom) + 58px); } }

/* Collapsed tools handle: a small, faint pill at the bottom edge; the three buttons appear beside it when opened. */
#assistFab #assistTog { width:34px; height:22px; border-radius:11px; font-size:15px; line-height:1; background:rgba(22,64,122,.55); border:1px solid rgba(77,163,255,.5); box-shadow:none; opacity:.75; }
#assistFab #assistTog:hover, #assistFab.open #assistTog { opacity:1; }
#assistFab > button:not(#assistTog) { display:none; }
#assistFab.open > button:not(#assistTog) { display:flex; width:40px; height:40px; font-size:18px; opacity:.92; }

/* First-visit privacy notice */
#privNotice { position:fixed; z-index:40; left:50%; transform:translateX(-50%); bottom:64px; width:min(440px, calc(100vw - 24px)); box-sizing:border-box; padding:12px 14px; border-radius:12px;
  background:#101a38; color:#dbe6ff; border:1px solid #4da3ff; box-shadow:0 6px 28px rgba(0,0,0,.6); font-size:12.5px; line-height:1.5; max-height:70vh; overflow-y:auto; }
@media (min-width: 821px) { #privNotice { left:calc(50% + 150px); } }
@media (max-width: 820px) { #privNotice { bottom:calc(var(--tabh, 62px) + env(safe-area-inset-bottom) + 60px); } }
#privNotice p { margin:6px 0; }
#privNotice .pnRow { display:flex; gap:8px; margin-top:8px; }
#privNotice button { all:unset; cursor:pointer; padding:8px 14px; border-radius:8px; background:#26305c; color:#fff; font-size:13px; }
#privNotice #pnOk { background:#2a6fd6; font-weight:700; }
#privNotice button:focus-visible { outline:2px solid #fff; outline-offset:2px; }

/* ---- Top chips: unmistakably ON or OFF ---------------------------------------------------------------------------------------- */
/* OFF: dim, outlined, hollow circle. ON: solid green, white tick, bold. State is shown by shape and fill, not by colour alone. */
#chips .chip:not(.aa):not(.st) { border:2px solid #33456b; background:rgba(12,16,32,.82); }
#chips .chip:not(.aa):not(.st) .chipMain { color:#a9b6d6; font-weight:600; }
#chips .chip:not(.aa):not(.st) .ci { opacity:.6; }
#chips .cdot { width:16px; height:16px; border-radius:50%; border:2px solid #7283a9; background:transparent; box-shadow:none; position:relative; }
#chips .chip.on:not(.aa):not(.st) { border-color:#8dffcf; background:#15a56e; box-shadow:0 0 0 2px rgba(141,255,207,.28), 0 2px 10px rgba(0,0,0,.45); }
#chips .chip.on:not(.aa):not(.st) .chipMain { color:#fff; font-weight:800; }
#chips .chip.on:not(.aa):not(.st) .ci { opacity:1; }
#chips .chip.on .chipMore { opacity:1; color:#fff; }
#chips .chip.on .cdot { background:#fff; border-color:#fff; box-shadow:none; }
#chips .chip.on .cdot::after { content:"\2713"; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#0b6b46; font-size:12px; font-weight:900; line-height:1; }
#chips .chip.on .cb { background:#fff; color:#0b6b46; }
html.a11y-contrast #chips .chip:not(.aa):not(.st) { background:#000b24; border-color:#cfe0ff; }
html.a11y-contrast #chips .chip.on { background:#00a05c; border-color:#fff; }

/* ---- Layers button and its pop-up (closed unless asked for) ------------------------------------------------------------------ */
#assistFab #mapKeyBtn { position:relative; }
#assistFab #mapKeyBtn .mkCount { position:absolute; top:-3px; right:-3px; min-width:16px; height:16px; border-radius:8px; background:#15a56e; color:#fff; font-size:10px; font-weight:800; line-height:16px; text-align:center; padding:0 3px; box-sizing:border-box; }
#assistFab:not(.open) > #mapKeyBtn { display:none !important; }
#mapKey { position:fixed; z-index:30; left:calc(50% + 150px); transform:translateX(-50%); bottom:64px; width:min(400px, calc(100vw - 24px)); max-height:60vh; overflow-y:auto; box-sizing:border-box; padding:8px 10px; border-radius:12px; background:rgba(16,26,56,.97); color:#dbe6ff; border:1px solid #4da3ff; box-shadow:0 6px 24px rgba(0,0,0,.55); font-size:12px; }
#mapKey .mkHead { display:flex; justify-content:space-between; align-items:center; margin-bottom:4px; }
#mapKey .mkHead button { all:unset; cursor:pointer; padding:4px 8px; color:#9fb3d8; }
#mapKey .mkItem { display:flex; gap:8px; align-items:flex-start; padding:7px 0; border-top:1px solid rgba(120,150,200,.22); }
#mapKey .alDot { width:9px; height:9px; border-radius:50%; flex:0 0 auto; margin-top:5px; }
#mapKey .mkBody { flex:1; min-width:0; }
#mapKey .mkWhat { font-size:11px; color:#a9bddf; line-height:1.4; margin-top:1px; }
#mapKey .mkOp { display:flex; align-items:center; gap:8px; font-size:11px; color:#9fb3d8; margin-top:5px; }
#mapKey .mkOp input { flex:1; margin:0; }
#mapKey .mkOff { all:unset; cursor:pointer; padding:5px 10px; border-radius:8px; background:#26305c; font-size:11px; flex:0 0 auto; }
#mapKey button:focus-visible { outline:2px solid #fff; outline-offset:2px; }
@media (max-width: 820px) { #mapKey { left:50%; bottom:calc(var(--tabh, 62px) + env(safe-area-inset-bottom) + 60px); } }

/* Phone: while the bottom sheet is open the tools row would float over its text, so it steps aside (it returns when the sheet is closed). */
@media (max-width: 820px) { body.shell:has(#sidebar.open) #assistFab, body.shell:has(#sidebar.open) #mapKey { display:none !important; } }
/* 26 Nov 2026: the country buttons also stepped over the sheet header; they step aside with the sheet, like the tools row. */
@media (max-width: 820px) { body.shell:has(#sidebar.open) #regionJump { display:none !important; } }

/* ---- Top shortcut chips must always FIT the screen (iPhone, iPad, desktop) -------------------------------------------------------------------------
   They used to be one row with hidden sideways scrolling, so on a phone the last ones ran off the edge with no sign they existed. Now they wrap onto as
   many rows as needed and never scroll. On a phone (under 600 px) each chip is icon-only (a tick badge shows ON) so ten fit in two rows; the full
   label stays for wider screens and for the data-problem chip (it matters). Touch screens get 44 px targets (Apple's minimum). */
#chips { flex-wrap:wrap; overflow:visible; white-space:normal; row-gap:6px; align-content:flex-start; }
#chips .chip { position:relative; overflow:visible; }
@media (pointer:coarse) { #chips .chip button { min-height:44px; } #chips .chipMore { min-width:44px; justify-content:center; padding:0 6px; } }
@media (max-width: 820px) { body.shell #chips { right:56px; } }                /* keep clear of the map's zoom buttons */
@media (max-width: 599px) {
  body.shell #chips { gap:6px; }
  #chips .chip:not(.st) .cl, #chips .chip .cdot, #chips .chip:not(.aa):not(.st) .chipMore { display:none; }
  #chips .chip.aa .cl { display:inline; } #chips .chip.aa .pct { display:none; } #chips .chip.aa .chipMain { padding:0 12px; }
  #chips .chip:not(.aa):not(.st) .chipMain { min-width:44px; justify-content:center; padding:0 8px; gap:3px; }
  #chips .chip .ci { font-size:20px; }
  #chips .chip.on:not(.aa):not(.st)::after { content:"\2713"; position:absolute; top:-5px; right:-5px; width:17px; height:17px; border-radius:50%; background:#fff; color:#0b6b46;
    font-size:12px; font-weight:900; line-height:17px; text-align:center; box-shadow:0 1px 3px rgba(0,0,0,.5); z-index:2; }
  #chips .cb { position:absolute; bottom:-4px; right:-4px; z-index:2; }
}

/* ---- Tap targets (audit findings, 3 Oct): the chip arrow was 6 px wide, the tools handle 36x24 and the tool buttons 42 px. Apple asks for 44 px. ------- */
/* the selector must out-rank "#chips .chip button { all:unset }", or the arrow collapses to the width of its glyph (6 px) */
#chips .chip button.chipMore { min-width:34px; justify-content:center; padding:0 6px; }
@media (pointer:coarse), (max-width: 1100px) { #chips .chip button.chipMore { min-width:44px; } #chips .chip button { min-height:44px; } }
#assistFab.open > button:not(#assistTog), #assistFab #mapKeyBtn { width:44px; height:44px; }
/* the handle keeps its small, faint look but its tappable area is 44 x 40 */
#assistFab #assistTog { width:44px; height:40px; background:transparent; border:0; box-shadow:none; opacity:1; position:relative; isolation:isolate; color:#fff; }
#assistFab #assistTog::before { content:""; position:absolute; left:5px; right:5px; top:9px; bottom:9px; border-radius:11px; z-index:-1; background:rgba(22,64,122,.6); border:1px solid rgba(77,163,255,.55); }
#assistFab.open #assistTog::before { background:#16407a; }

/* Day look (bright sun): the dark interface is inverted (and its hues turned back) into a light one, with bold text and larger
   size (see applyA11y in shell.js). Maps, images and canvases are put back the right way round so colours that carry meaning stay true.
   Backgrounds are set darker than usual first, so after inversion they become near-white and text becomes near-black. */
html.look-day #sidebar, html.look-day #tabbar, html.look-day .shellModal .card, html.look-day #a11yPanel, html.look-day #validTimeBox,
html.look-day #chips .chip:not(.on) { filter: invert(1) hue-rotate(180deg); }
html.look-day #sidebar, html.look-day .shellModal .card, html.look-day #a11yPanel, html.look-day #tabbar { background:#000b24; color:#ffffff; }
html.look-day #sidebar img, html.look-day #sidebar canvas, html.look-day #sidebar video, html.look-day #sidebar svg,
html.look-day .shellModal .card img, html.look-day .shellModal .card canvas { filter: invert(1) hue-rotate(180deg); }
html.look-day #chips .chip:not(.on) { background:#000b24; color:#fff; border-color:#cfe0ff; }
html.look-day #chips .chip.on { background:#0b7a45; color:#fff; border-color:#064d2b; }
html.look-day #sidebar { border-right-color:#8fb4ff; }

/* ---- Learn section and service level (ui/learn.js, ui/levels.js): readable on a phone, 16 px inputs so iOS does not zoom ---- */
#learnBody { font-size: 14px; line-height: 1.5; }
#learnBody .lrnHead { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
#learnBody .lrnHead span { color: #c9d6ee; font-size: 13px; }
#learnBody .lrnGuide { border: 1px solid #2a4b80; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #101a30; }
#learnBody .lrnGuide label { display: block; margin: 6px 0 2px; font-size: 13px; }
#learnBody input { width: 100%; font-size: 16px; min-height: 44px; box-sizing: border-box; }
#learnBody .lrnBig { font-size: 16px; font-weight: 700; margin-top: 8px; }
#learnBody .lrnNote { color: #9fb3d8; font-size: 12px; margin-top: 4px; }
#learnBody .lrnTrack h4 { margin: 12px 0 6px; font-size: 13px; color: #9fc4ff; }
#learnBody .lrnLesson { border: 1px solid #22304d; border-radius: 10px; margin: 6px 0; background: #0f1830; }
#learnBody .lrnLesson > summary { cursor: pointer; padding: 12px; min-height: 44px; box-sizing: border-box; font-weight: 600; list-style: none; }
#learnBody .lrnLesson > summary::-webkit-details-marker { display: none; }
#learnBody .lrnText { padding: 0 12px 12px; }
#learnBody .lrnText p, #learnBody .lrnText ul, #learnBody .lrnText ol { margin: 6px 0; }
#learnBody .lrnText li { margin: 4px 0; }
#learnBody dt { font-weight: 700; margin-top: 8px; }
#learnBody dd { margin: 2px 0 0; color: #c9d6ee; }

/* ---- Home sheet (ui/home.js): answer first, big tap targets, 16 px inputs ---- */
#homeSheet { position: fixed; inset: 0; z-index: 3000; background: #0a1220; color: #e8eefb; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#homeSheet[hidden] { display: none; }
#homeSheet .hmInner { max-width: 640px; margin: 0 auto; padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); font-size: 16px; line-height: 1.45; }
#homeSheet h2 { margin: 18px 0 4px; font-size: 24px; }
#homeSheet h3 { margin: 18px 0 8px; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: #9fc4ff; }
#homeSheet button { font: inherit; cursor: pointer; }
#homeSheet .hmTop { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#homeSheet .hmTop b { font-size: 18px; color: #4a9eff; }
#homeSheet .hmSub { display: block; font-size: 13px; color: #9fb3d8; }
#homeSheet .hmClose { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid #2a4b80; background: #17243c; color: #e8eefb; }
#homeSheet .hmBand { margin: 12px 0; padding: 16px; border-radius: 16px; border: 2px solid; }
#homeSheet .hmBandTitle { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
#homeSheet .hmBand.red { background: #5c1414; border-color: #ff5a5a; }
#homeSheet .hmBand.amber { background: #5e3a00; border-color: #ffb02e; }
#homeSheet .hmBand.green { background: #0f3b26; border-color: #59d68b; }
#homeSheet .hmBand.grey { background: #1a2438; border-color: #44557a; }
#homeSheet .hmRow { display: flex; gap: 8px; flex-wrap: wrap; }
#homeSheet .hmRow button { flex: 1 1 30%; min-height: 48px; border-radius: 12px; border: 1px solid #2a4b80; background: #17243c; color: #e8eefb; }
#homeSheet .hmCard { background: #131f36; border: 1px solid #22304d; border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
#homeSheet .hmCardTop { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#homeSheet .hmTier { padding: 2px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; background: #33415f; }
#homeSheet .hmTier.t2 { background: #6b5a00; } #homeSheet .hmTier.t3 { background: #8a4a00; } #homeSheet .hmTier.t4, #homeSheet .hmTier.t5 { background: #8a1c1c; }
#homeSheet .hmMean, #homeSheet .hmDo { margin-top: 4px; color: #d3def2; }
#homeSheet .hmAsk { display: flex; gap: 8px; }
#homeSheet .hmAsk input { flex: 1; min-width: 0; min-height: 48px; font-size: 16px; padding: 0 14px; border-radius: 12px; border: 1px solid #2a4b80; background: #101a30; color: #e8eefb; }
#homeSheet .hmAsk button { min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0; background: #1f6fd1; color: #fff; font-weight: 700; }
#homeSheet .hmAnswer { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: #10261d; border: 1px solid #2c6b48; }
#homeSheet .hmAnswer .hmCard { background: #0f1830; }
#homeSheet .hmChips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#homeSheet .hmChips button { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid #2a4b80; background: #17243c; color: #cfe0ff; }
#homeSheet .hmNote { color: #9fb3d8; font-size: 13px; margin-top: 8px; }
#homeSheet .hmFoot { margin-top: 22px; color: #9fb3d8; font-size: 13px; }
#homeSheet .hmFoot a { color: #8fc0ff; }
#homeSheet .hmLink { background: none; border: 0; color: #8fc0ff; text-decoration: underline; padding: 8px 0; min-height: 44px; }
#homeSheet .hmWho { display: flex; gap: 14px; align-items: center; width: 100%; margin: 10px 0; padding: 16px; min-height: 76px; text-align: left; border-radius: 16px; border: 2px solid #2a4b80; background: #17243c; color: #e8eefb; font-size: 17px; }
#homeSheet .hmWho > span:first-child { font-size: 34px; }
#homeSheet .hmWho small { color: #b9c9e6; font-size: 14px; }
html.hmOpen { overflow: hidden; }
#homeSheet .hmBrand { flex: 1; min-width: 0; }
#homeSheet .hmClose { width: auto !important; flex: 0 0 auto; }
#homeSheet .hmAsk { margin-top: 4px; }
#homeSheet .hmAsk input { width: auto !important; flex: 1 1 auto !important; min-width: 0 !important; }
#homeSheet .hmAsk button { width: auto !important; flex: 0 0 auto; }
#homeSheet .hmRow { margin-top: 14px; }
#homeSheet .hmMore > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: #8fc0ff; }
#homeSheet .hmChips button { width: auto !important; flex: 0 1 auto; font-size: 15px; }
#homeSheet .hmRow button { width: auto !important; }
#homeSheet .hmChips button, #homeSheet .hmRow button, #homeSheet .hmAsk button { margin: 0 !important; }
#homeSheet .hmChips button { padding: 0 12px; font-size: 14px; }

/* Pressed highlight (28 Nov 2026, owner: show people what they pressed). Instant and still: a bright ring and a lighter fill while the finger is down.
   No movement, no animation, no size change (the earlier "pop" animation was removed because it went in and out in Safari). Toggle state after the press is
   shown by the existing colours: chips go green with a tick, country and tab buttons highlight, Events turns amber. */
#chips .chip:active, #chips .chip button:active, .cBtn:active, [data-region]:active, #tabbar button:active, #evBtn:active, .pinb:active, #cp-pop .row:active {
  outline:3px solid #ffe066 !important; outline-offset:-3px; filter:brightness(1.35); transition:none !important; }

/* Pressed label (28 Nov 2026): the name of the button just pressed, top centre, over everything. */
#pressLabel { position:fixed; left:50%; top:calc(env(safe-area-inset-top,0px) + 176px); transform:translateX(-50%); z-index:2147483000; display:none; pointer-events:none;
  max-width:88vw; padding:10px 18px; border-radius:12px; background:#0b1730; color:#fff; border:3px solid #ffe066; font:800 18px/1.2 -apple-system,Segoe UI,sans-serif; text-align:center; box-shadow:0 4px 18px rgba(0,0,0,.5); }
#pressLabel.on { border-color:#39d353; } #pressLabel.off { border-color:#ff6b6b; }
