/* ==========================================================================
   找廁所 / Taiwan Toilet Finder
   Design system: "wayfinding signage" — deep teal-navy chrome, one amber
   signal colour, condensed display type, mono numerals on signage plaques.
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */
:root {
  /* ink ramp */
  --ink-900: #06232A;
  --ink-800: #0A3038;
  --ink-700: #0E3B43;
  --ink-600: #1A5661;
  --ink-500: #38707A;
  --ink-400: #6C9098;
  --ink-300: #9DB3B8;
  --ink-200: #C8D5D7;
  --ink-100: #E3EAEA;

  /* surfaces */
  --paper: #EDF1F0;
  --surface: #FFFFFF;
  --surface-2: #F6F8F7;

  /* signal */
  --signal: #F2A03D;
  --signal-soft: #FDF0DC;
  --signal-deep: #92590C;

  /* semantic */
  --go: #147A50;
  --go-soft: #E2F2EA;
  --stop: #B33124;
  --stop-soft: #FBE9E6;
  --info: #1A5F92;
  --info-soft: #E5EFF7;

  /* type */
  --font-display: "Barlow Semi Condensed", "Noto Sans TC", system-ui, sans-serif;
  --font-body: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* space scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 44px;

  /* radii */
  --r-sm: 4px;
  --r-md: 10px;
  --r-lg: 18px;
  --r-pill: 999px;

  /* elevation — only two */
  --shadow-card: 0 1px 2px rgba(6, 35, 42, .06), 0 2px 8px rgba(6, 35, 42, .05);
  --shadow-float: 0 8px 28px rgba(6, 35, 42, .22);

  /* z-index scale. Leaflet uses 400 (panes), 700 (popups), 1000 (controls)
     internally, so every app overlay has to clear 1000. */
  --z-appbar: 1100;
  --z-scrim: 1200;
  --z-sheet: 1300;
  --z-toast: 1400;
  --z-skip: 1500;

  --tap: 44px;
  --appbar-h: auto;
  --ease: cubic-bezier(.2, .7, .3, 1);

  color-scheme: light;
}

/* Language-aware body stacks: keep CJK glyphs native to the reader. */
html[lang="ja"] { --font-body: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif; }
html[lang="ko"] { --font-body: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif; }
html[lang="zh-Hans"] { --font-body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; }
html[lang="en"] { --font-body: "Barlow Semi Condensed", system-ui, -apple-system, "Segoe UI", sans-serif; }

/* --- 2. Base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must beat any component `display` rule below. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic--sm { width: 17px; height: 17px; stroke-width: 1.9; }

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.appbar :focus-visible, .fab:focus-visible, .map__badge :focus-visible {
  outline-color: #FFC372;
}

.skip-link {
  position: fixed; top: -100px; left: var(--s3); z-index: var(--z-skip);
  background: var(--signal); color: var(--ink-900);
  padding: 10px 16px; border-radius: var(--r-md); font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: var(--s3); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- 3. Layout shell ----------------------------------------------------- */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.layout { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* --- 4. App bar ---------------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: var(--z-appbar);
  background: var(--ink-700);
  color: #fff;
  padding: max(var(--s3), env(safe-area-inset-top)) var(--s4) var(--s3);
  display: flex; flex-direction: column; gap: var(--s3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), var(--shadow-card);
}

.appbar__top { display: flex; align-items: center; gap: var(--s3); }

.brand { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.brand__mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-sm);
  background: var(--signal);
  color: var(--ink-900);
  box-shadow: inset 0 0 0 2px rgba(6, 35, 42, .18);
}
.brand__mark .ic { width: 24px; height: 24px; stroke-width: 1.9; }
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name {
  font-family: var(--font-display); font-weight: 700; font-size: 21px;
  line-height: 1.1; letter-spacing: .02em;
}
.brand__sub {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255, 255, 255, .62);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.appbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s1); }

.iconbtn {
  position: relative;
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--r-md);
  color: #fff;
  transition: background .16s var(--ease);
}
.iconbtn:hover { background: rgba(255, 255, 255, .16); }
.iconbtn:active { background: rgba(255, 255, 255, .24); }
.iconbtn--dark { background: var(--ink-100); border-color: var(--ink-200); color: var(--ink-700); }
.iconbtn--dark:hover { background: var(--ink-200); }
.iconbtn__tag {
  position: absolute; right: 3px; bottom: 2px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: .02em; color: var(--signal);
}

/* language menu */
.langmenu { position: relative; }
.langmenu__list {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 80;
  margin: 0; padding: var(--s1); list-style: none;
  min-width: 176px;
  background: var(--surface); color: var(--ink-900);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
}
.langmenu__list li { display: block; }
.langmenu__item {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3);
  background: none; border: 0; border-radius: var(--r-sm);
  text-align: start; font-size: 15px;
}
.langmenu__item:hover { background: var(--surface-2); }
.langmenu__item[aria-selected="true"] { color: var(--ink-700); font-weight: 700; }
.langmenu__item[aria-selected="true"]::after {
  content: ""; margin-inline-start: auto;
  width: 8px; height: 8px; border-radius: 50%; background: var(--signal);
}
.langmenu__native { color: var(--ink-400); font-size: 13px; font-family: var(--font-mono); }

/* search */
.search {
  position: relative;
  display: flex; align-items: center;
  background: rgba(255, 255, 255, .96);
  border-radius: var(--r-md);
  height: var(--tap);
  padding: 0 var(--s2) 0 var(--s3);
  box-shadow: inset 0 0 0 1px rgba(6, 35, 42, .08);
}
.search__icon { color: var(--ink-500); }
.search__input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: none; padding: 0 var(--s2);
  color: var(--ink-900); font-size: 15px;
}
.search__input::placeholder { color: var(--ink-400); }
.search__input:focus { outline: none; }
.search:focus-within { box-shadow: inset 0 0 0 2px var(--signal); }
.search__clear {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill);
  background: var(--ink-100); color: var(--ink-600);
}

/* segmented control */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1);
  padding: var(--s1);
  background: rgba(6, 35, 42, .38);
  border-radius: var(--r-md);
}
.segmented__btn {
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  border: 0; border-radius: 7px;
  background: none; color: rgba(255, 255, 255, .72);
  font-weight: 500; font-size: 14px;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.segmented__btn .ic { width: 19px; height: 19px; }
.segmented__btn.is-active {
  background: var(--surface); color: var(--ink-700); font-weight: 700;
  box-shadow: 0 1px 3px rgba(6, 35, 42, .3);
}
.segmented__count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .14);
}
.segmented__btn.is-active .segmented__count { background: var(--signal-soft); color: var(--signal-deep); }
.segmented__count:empty { display: none; }

/* development-mode warning: community endpoints are not licensed for commercial use */
.devbanner {
  display: flex; align-items: center; gap: var(--s2);
  margin: 0; padding: 9px var(--s4);
  background: #43290A; color: #FFDCA8;
  font-size: 12.5px; line-height: 1.45;
}
.devbanner .ic { color: var(--signal); flex: none; }

/* --- 5. Map -------------------------------------------------------------- */
.mapzone {
  position: relative;
  /* Contain Leaflet's panes so they can never paint over sheets or the app bar. */
  isolation: isolate;
  z-index: 0;
  height: clamp(200px, 34vh, 320px);
  background: var(--ink-100);
  flex: none;
}
#map { position: absolute; inset: 0; }
#map.is-unconfigured {
  background: repeating-linear-gradient(45deg, var(--ink-100) 0 10px, #E7EDED 10px 20px);
}

.map__badge {
  position: absolute; z-index: 500; left: var(--s3); top: var(--s3);
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 6px 10px;
  background: rgba(14, 59, 67, .92); color: #fff;
  border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
  box-shadow: var(--shadow-card);
  max-width: calc(100% - 90px);
}
.map__badge:empty { display: none; }
.map__badge b { color: var(--signal); font-weight: 600; }

.fab {
  position: absolute; z-index: 500; right: var(--s3); bottom: var(--s3);
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink-700);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-float);
}
.fab:hover { background: var(--surface-2); }
.fab.is-busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* leaflet look */
.leaflet-container { font-family: var(--font-body); background: var(--ink-100); }
.leaflet-control-attribution {
  font-size: 10.5px !important;
  background: rgba(255, 255, 255, .88) !important;
  color: var(--ink-600) !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: var(--ink-600) !important; }
.leaflet-control-zoom a {
  color: var(--ink-700) !important;
  border-radius: var(--r-sm) !important;
}
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow-card) !important; }
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md); box-shadow: var(--shadow-float);
  padding: 2px;
}
.leaflet-popup-content { margin: 10px 12px; font-size: 14px; line-height: 1.45; }
.leaflet-popup-content b { font-family: var(--font-display); font-size: 16px; }
.leaflet-popup-content .pop__meta { color: var(--ink-500); font-size: 12.5px; }

.pin {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  border: 2px solid var(--ink-900);
  box-shadow: 0 3px 8px rgba(6, 35, 42, .35);
  font-size: 13px; font-weight: 700;
}
.pin > * { transform: rotate(45deg); }
.pin__wc {
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px;
  letter-spacing: .02em; line-height: 1;
}
.pin--toilet { background: var(--signal); color: var(--ink-900); }
.pin--store { background: var(--surface); color: var(--ink-700); }
.pin--active { background: var(--ink-700); color: #fff; border-color: var(--signal); }
.pin .ic { width: 17px; height: 17px; stroke-width: 2; }

.mepin {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--info); border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(26, 95, 146, .28), var(--shadow-card);
}

/* --- 6. Results ---------------------------------------------------------- */
.results {
  flex: 1; min-height: 0;
  padding: var(--s4) var(--s4) calc(var(--s7) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s3);
}
.results:focus { outline: none; }

.results__bar { display: flex; align-items: center; gap: var(--s3); }
.results__meta {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-500);
}

.btn {
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .1s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--signal); color: var(--ink-900); box-shadow: inset 0 -2px 0 rgba(6, 35, 42, .14); }
.btn--primary:hover { background: #E5942F; }
.btn--ghost { background: var(--surface); color: var(--ink-700); border-color: var(--ink-200); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--ink-300); }
.btn--dark { background: var(--ink-700); color: #fff; }
.btn--dark:hover { background: var(--ink-600); }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: 0 var(--s3); font-size: 13.5px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn--filter { padding-inline: var(--s3); }

.pillcount {
  min-width: 20px; height: 20px; padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--ink-700); color: #fff;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}

/* active filter chips */
.activefilters { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tagchip {
  min-height: 34px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 6px 0 12px;
  border-radius: var(--r-pill);
  background: var(--ink-700); color: #fff;
  border: 0; font-size: 13.5px; font-weight: 500;
}
.tagchip .ic { width: 15px; height: 15px; opacity: .8; }
.tagchip:hover { background: var(--ink-600); }

/* filter chips inside sheets / store categories */
.chiprow { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s1); scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  min-height: 38px; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-600);
  border: 1px solid var(--ink-200);
  font-size: 13.5px; font-weight: 500;
}
.chip[aria-pressed="true"] {
  background: var(--ink-700); color: #fff; border-color: var(--ink-700);
}
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--go); flex: none; }
.chip[aria-pressed="true"] .chip__dot { background: var(--signal); }

/* --- 7. Cards ------------------------------------------------------------ */
.cardlist { display: flex; flex-direction: column; gap: var(--s3); }

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: var(--s3) var(--s4) var(--s3) var(--s3);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s3);
  border: 1px solid transparent;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.card.is-active { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft), var(--shadow-card); }
.card__body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.card__title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600; line-height: 1.25;
  color: var(--ink-900);
  display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap;
}
.card__title button {
  background: none; border: 0; padding: 0; text-align: start;
  font: inherit; color: inherit;
}
.card__title button::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-md); }
.card__addr { font-size: 13px; color: var(--ink-500); line-height: 1.4; }

/* signage plaque — the distance motif */
.plaque {
  align-self: start;
  min-width: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 6px 5px;
  border-radius: var(--r-sm);
  background: var(--signal-soft);
  border: 2px solid var(--signal);
  color: var(--ink-900);
}
.plaque__num { font-family: var(--font-mono); font-weight: 600; font-size: 17px; line-height: 1; letter-spacing: -.02em; }
.plaque__unit { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--signal-deep); margin-top: 3px; }
.plaque--muted { background: var(--ink-100); border-color: var(--ink-200); }
.plaque--muted .plaque__unit { color: var(--ink-400); }

/* badges: one loud, the rest quiet */
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 12px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: .02em;
}
.badge .ic { width: 14px; height: 14px; stroke-width: 2; }
.badge--go { background: var(--go-soft); color: var(--go); }
.badge--signal { background: var(--signal-soft); color: var(--signal-deep); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--quiet { background: var(--surface-2); color: var(--ink-600); box-shadow: inset 0 0 0 1px var(--ink-100); }

/* Trust levels. Only official data gets a solid fill and a tick; anything
   inferred or unverified is outlined so it can never read as confirmed. */
.badge--official { background: var(--ink-700); color: #fff; }
.badge--maybe {
  background: transparent; color: var(--signal-deep);
  box-shadow: inset 0 0 0 1.5px var(--signal);
}
.badge--unknown {
  background: transparent; color: var(--ink-500);
  box-shadow: inset 0 0 0 1.5px var(--ink-200);
  border-style: dashed;
  background-image: repeating-linear-gradient(45deg, rgba(108,144,152,.10) 0 4px, transparent 4px 8px);
}
.badge--rating { font-family: var(--font-mono); font-weight: 600; }

.card__foot {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--s2);
  padding-top: var(--s3);
  margin-top: var(--s1);
  border-top: 1px solid var(--ink-100);
}
.card__foot .btn { position: relative; z-index: 1; }
.card__srcnote { font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); margin-inline-end: auto; }

/* store report block */
.report { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--ink-100); }
.report__note {
  font-size: 12.5px; line-height: 1.5; color: var(--ink-500);
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border-inline-start: 3px solid var(--ink-200);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.report__tally { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--ink-600); flex-wrap: wrap; }
.report__links { display: inline-flex; align-items: center; gap: var(--s2); margin-inline-start: auto; flex-wrap: wrap; }
.report__tally b { font-family: var(--font-mono); }
.report__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.report__btn {
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--ink-200);
  background: var(--surface); color: var(--ink-700);
  font-size: 14px; font-weight: 600;
  position: relative; z-index: 1;
}
.report__btn:hover { background: var(--surface-2); }
.report__btn.is-yes[aria-pressed="true"] { background: var(--go-soft); border-color: var(--go); color: var(--go); }
.report__btn.is-no[aria-pressed="true"] { background: var(--stop-soft); border-color: var(--stop); color: var(--stop); }
.report__btn .ic { width: 18px; height: 18px; }

/* source credits — required by the data providers' terms, so they stay visible */
.credits {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--ink-200);
}
.credits__title {
  margin: 0 0 var(--s2);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400);
}
.credits__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.credits__list a { color: var(--ink-500); font-size: 12px; text-decoration: none; }
.credits__list a:hover { color: var(--ink-700); text-decoration: underline; }

/* 群眾回報：永遠虛線外框，永遠不用官方那種實心標章。
   一眼要能看出「這是別人說的」而不是「政府登記的」。 */
.badge--crowd {
  background: transparent; color: var(--ink-600);
  box-shadow: inset 0 0 0 1.5px var(--ink-300);
  border-style: dashed;
  background-image: repeating-linear-gradient(45deg, rgba(108,144,152,.10) 0 4px, transparent 4px 8px);
}
.badge--crowd-split { color: var(--signal-deep); box-shadow: inset 0 0 0 1.5px var(--signal); }

.crowdbox {
  padding: var(--s2) var(--s3);
  border: 1px dashed var(--ink-300);
  border-radius: var(--r-sm);
  background: repeating-linear-gradient(45deg, rgba(108,144,152,.05) 0 6px, transparent 6px 12px);
}
.crowdbox__head { display: flex; align-items: center; gap: var(--s2); margin-bottom: 4px; }
.crowdbox__counts { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-700); }
.crowdbox__meta { font-size: 11.5px; color: var(--ink-400); margin-top: 2px; }

.report__privacy {
  font-size: 11.5px; line-height: 1.5; color: var(--ink-400);
  margin-top: var(--s1);
}

/* --- 8. States ----------------------------------------------------------- */
.state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s3);
  padding: var(--s7) var(--s5);
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.state__icon {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border-radius: var(--r-md);
  background: var(--ink-100); color: var(--ink-600);
}
.state__icon .ic { width: 26px; height: 26px; }
.state--warn .state__icon { background: var(--signal-soft); color: var(--signal-deep); }
.state--error .state__icon { background: var(--stop-soft); color: var(--stop); }
.state__title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.state__body { font-size: 14px; color: var(--ink-500); max-width: 34ch; }
.state__actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }

.notice {
  display: flex; gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--info-soft);
  color: #14415F;
  font-size: 13px; line-height: 1.5;
}
.notice .ic { color: var(--info); width: 19px; height: 19px; }
.notice--warn { background: var(--signal-soft); color: #6B4109; align-items: center; }
.notice--warn .ic { color: var(--signal-deep); }
.notice--warn > div { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; flex: 1; }
.notice--warn p { font-weight: 600; }
.notice--warn .btn { margin-inline-start: auto; }

/* skeletons */
.skeleton {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: var(--s3);
  display: grid; grid-template-columns: 58px 1fr; gap: var(--s3);
}
.sk { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--ink-100) 25%, #EFF3F3 37%, var(--ink-100) 63%); background-size: 400% 100%; animation: sheen 1.3s ease infinite; }
.sk--plaque { height: 48px; }
.sk--line { height: 13px; }
.sk--line + .sk--line { margin-top: 9px; }
.sk--w60 { width: 60%; } .sk--w80 { width: 80%; } .sk--w40 { width: 40%; }
@keyframes sheen { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --- 9. Sheets / scrim / toasts ------------------------------------------ */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: rgba(6, 35, 42, .5);
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed; z-index: var(--z-sheet);
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--paper);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-float);
  animation: rise .24s var(--ease);
}
@keyframes rise { from { translate: 0 14px; opacity: .5; } }

.sheet__grab { width: 40px; height: 4px; border-radius: var(--r-pill); background: var(--ink-200); margin: var(--s2) auto 0; }
.sheet__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
}
.sheet__head h2 { font-size: 20px; flex: 1; }
.sheet__body { padding: 0 var(--s4) var(--s5); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--s2);
  padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ink-200);
  background: var(--surface-2);
}

.tabbar { display: flex; gap: var(--s5); padding: 0 var(--s4); border-bottom: 1px solid var(--ink-200); }
.tabbar__btn {
  min-height: var(--tap);
  padding: 0 2px;
  background: none; border: 0;
  border-bottom: 3px solid transparent;
  color: var(--ink-500); font-weight: 600; font-size: 15px;
  margin-bottom: -1px;
}
.tabbar__btn.is-active { color: var(--ink-900); border-bottom-color: var(--signal); }

.fieldlabel {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-500);
  margin: var(--s5) 0 var(--s2);
  display: flex; align-items: center; gap: var(--s2);
}
.fieldlabel::after { content: ""; flex: 1; height: 1px; background: var(--ink-200); }
.sheet__body > *:first-child.fieldlabel { margin-top: var(--s3); }

.togglegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.toggle {
  min-height: var(--tap);
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3);
  background: var(--surface); border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  font-size: 14px; text-align: start;
  color: var(--ink-700);
}
.toggle .ic { color: var(--ink-500); }
.toggle__box {
  width: 20px; height: 20px; flex: none; margin-inline-start: auto;
  border-radius: var(--r-sm);
  border: 2px solid var(--ink-300);
  display: grid; place-items: center;
  color: transparent;
}
.toggle[aria-pressed="true"] { border-color: var(--ink-700); background: var(--surface); box-shadow: inset 0 0 0 1px var(--ink-700); }
.toggle[aria-pressed="true"] .toggle__box { background: var(--ink-700); border-color: var(--ink-700); color: #fff; }
.toggle[aria-pressed="true"] .ic { color: var(--ink-700); }
.toggle__box .ic { width: 13px; height: 13px; stroke-width: 3; }

.select, .input {
  width: 100%; min-height: var(--tap);
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  color: var(--ink-900);
}
.select:focus, .input:focus { outline: none; border-color: var(--ink-700); box-shadow: 0 0 0 3px var(--signal-soft); }
.field { display: block; margin-bottom: var(--s3); }
.field__label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-700); }

.hint { font-size: 13px; color: var(--ink-500); line-height: 1.55; margin-top: var(--s2); }
.hint code { font-family: var(--font-mono); font-size: 12px; background: var(--ink-100); padding: 1px 5px; border-radius: var(--r-sm); }
.hint--ok { color: var(--go); font-weight: 600; }
.hint--err { color: var(--stop); font-weight: 600; }

.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

.langgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.langopt {
  min-height: var(--tap);
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--ink-200);
  background: var(--surface); color: var(--ink-700);
  font-size: 14.5px;
}
.langopt[aria-pressed="true"] { border-color: var(--ink-700); box-shadow: inset 0 0 0 1px var(--ink-700); font-weight: 700; }
.langopt__code { font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); margin-inline-start: auto; }

.sourcecard {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-top: var(--s3);
  padding: var(--s3);
  background: var(--ink-700); color: #fff;
  border-radius: var(--r-md);
}
.sourcecard__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .6); width: 100%; }
.sourcecard__value { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.sourcecard__count { font-family: var(--font-mono); font-size: 12px; color: var(--signal); margin-inline-start: auto; }

.disclosure {
  margin-top: var(--s3);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  overflow: hidden;
}
.disclosure > summary {
  min-height: var(--tap);
  display: flex; align-items: center;
  padding: var(--s2) var(--s3);
  font-weight: 600; font-size: 14px;
  cursor: pointer; list-style: none;
  color: var(--ink-700);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: ""; margin-inline-start: auto;
  width: 9px; height: 9px;
  border-right: 2px solid var(--ink-400); border-bottom: 2px solid var(--ink-400);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s var(--ease);
}
.disclosure[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.disclosure__body { padding: 0 var(--s3) var(--s3); font-size: 13px; color: var(--ink-600); line-height: 1.6; }
.disclosure__body h4 { margin: var(--s3) 0 var(--s1); font-size: 13px; color: var(--ink-900); font-family: var(--font-body); }
.disclosure__body ul { margin: var(--s1) 0; padding-inline-start: 18px; }
.disclosure__body li { margin-bottom: 4px; }
.disclosure__body pre {
  margin: var(--s2) 0 0; padding: var(--s3);
  background: var(--ink-900); color: #DDE9EA;
  border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5;
  overflow-x: auto;
}

/* toasts */
.toasts {
  position: fixed; z-index: var(--z-toast);
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s2);
  width: min(440px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--ink-900); color: #fff;
  box-shadow: var(--shadow-float);
  font-size: 14px;
  animation: toastin .22s var(--ease);
}
.toast .ic { flex: none; }
.toast--ok .ic { color: #6FD3A4; }
.toast--err .ic { color: #FF9E90; }
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } }

/* --- 10. Responsive ------------------------------------------------------ */
@media (min-width: 640px) {
  body { font-size: 15.5px; }
  .mapzone { height: clamp(260px, 38vh, 380px); }
  .cardlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
  .results { padding-inline: var(--s5); }
  .appbar { padding-inline: var(--s5); }
  .sheet {
    left: 50%; right: auto; transform: translateX(-50%);
    width: min(560px, 100%);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
}

@media (min-width: 1024px) {
  html, body { height: 100%; overflow: hidden; }
  .app { height: 100%; }
  .appbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 420px) auto;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s6);
  }
  .appbar__top { order: 1; }
  .search { order: 2; }
  .segmented { order: 3; width: 340px; }
  .appbar__actions { margin-left: 0; }

  .layout { flex-direction: row-reverse; overflow: hidden; }
  .mapzone { height: auto; flex: 1 1 auto; min-width: 0; }
  .results {
    flex: none;
    width: min(46vw, 480px);
    overflow-y: auto;
    border-inline-end: 1px solid var(--ink-200);
    background: var(--paper);
    padding-bottom: var(--s6);
  }
  .cardlist { grid-template-columns: 1fr; }
  .fab { bottom: var(--s5); right: var(--s5); }
  .map__badge { left: var(--s5); top: var(--s5); }

  .sheet {
    top: 50%; bottom: auto;
    transform: translate(-50%, -50%);
    border-radius: var(--r-lg);
    max-height: 84vh;
    width: min(600px, 92vw);
  }
  .sheet__grab { display: none; }
  .sheet__foot { border-radius: 0 0 var(--r-lg) var(--r-lg); padding-bottom: var(--s4); }
}

@media (min-width: 1440px) {
  .results { width: 520px; }
}

/* Touch devices get full 44px targets; pointer devices keep the compact size. */
@media (pointer: coarse) {
  .btn--sm, .chip, .tagchip, .search__clear, .langmenu__item { min-height: 44px; }
  .search__clear { width: 44px; }
  .tagchip { padding-inline: 14px 8px; }
}

/* --- 11. Motion / contrast preferences ----------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  .card { border-color: var(--ink-300); }
  .card__addr, .hint, .state__body { color: var(--ink-700); }
  .badge--quiet { box-shadow: inset 0 0 0 1px var(--ink-300); }
}

@media print {
  .appbar, .mapzone, .fab, .sheet, .scrim, .toasts { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #999; }
}
