:root {
  --ink: #14232b;
  --muted: #5b6b73;
  --line: #e3e0d8;
  --paper: #fbfaf7;
  --accent: #0d6e6e;
  --open: #17824f;
  --customers: #b86e00;
  --closed: #c0392b;
  --unknown: #667085;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 35, 43, 0.16);
  --top: max(10px, env(safe-area-inset-top));
  --sheet-h: 190px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }
/* The open sheet is as tall as what it holds; js/app.js measures that and sets --sheet-open-h. */
#app.sheet-open { --sheet-h: var(--sheet-open-h, 52dvh); }

/* ---------- map ---------- */
.mapwrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: #e8e6df; z-index: 0; }
.leaflet-container { font: inherit; }
.leaflet-bottom { bottom: var(--sheet-h); transition: bottom 0.28s ease; }
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution { font-size: 11px; }

.pin { background: none; border: 0; }
.pin svg { display: block; transform-origin: 50% 100%; transition: transform 0.15s ease; filter: drop-shadow(0 2px 3px rgba(20, 35, 43, 0.35)); }
.pin-selected svg { transform: scale(1.35); }
.pin-mine::after {
  content: ""; position: absolute; right: -3px; top: -3px; width: 11px; height: 11px;
  border-radius: 50%; background: #1d4ed8; border: 2px solid #fff;
}
/* One number for the toilets of an area, when the map is zoomed out. */
.areanum { background: none; border: 0; }
.areanum span {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(20, 35, 43, 0.35);
}
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1d6fe8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(29, 111, 232, 0.22); }

.crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 500; display: none; }
#app.placing .crosshair { display: block; }

.placebar {
  position: absolute; left: 10px; right: 10px; bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 1200; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; max-width: 460px; margin: 0 auto;
}
.placebar p { margin: 0 0 12px; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: var(--top); left: 10px; right: 10px; z-index: 1100;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px;
  min-height: 52px; padding: 8px 10px 10px 10px;
  background: rgba(255, 255, 255, 0.96); border-radius: var(--radius); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { flex: none; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.15; letter-spacing: -0.01em; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }
.tools { display: flex; align-items: center; gap: 8px; flex: none; }
.help { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--accent); font-weight: 700; font-size: 17px; }
.lang { display: flex; flex: none; background: #f1efe9; border-radius: 10px; padding: 3px; }
.lang button { border: 0; background: none; border-radius: 8px; padding: 6px 9px; font-size: 13px; font-weight: 600; color: var(--muted); min-height: 32px; }
.lang button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 35, 43, 0.18); }

/* ---------- address search ---------- */
.search { flex: 0 0 100%; display: flex; align-items: center; gap: 6px; background: #f1efe9; border-radius: 12px; padding: 0 4px 0 12px; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); background: #fff; }
.search input { flex: 1; min-width: 0; height: 42px; border: 0; background: none; font-size: 16px; outline: none; }
.search input:focus-visible { outline: none; }
.search input::placeholder { color: var(--muted); }
.search button { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); }
.search .q-go { background: var(--accent); color: #fff; }
.search.busy .q-go svg { animation: pulse 1s ease-in-out infinite; }
.results { flex: 0 0 100%; list-style: none; margin: 0; padding: 0; max-height: 46dvh; overflow-y: auto; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 10px 4px; }
.results b { display: block; font-weight: 600; }
.results span { display: block; font-size: 13.5px; color: var(--muted); }
.origin-dot { width: 22px; height: 22px; border-radius: 50%; background: #14232b; border: 4px solid #fff; box-shadow: 0 0 0 2px #14232b, 0 3px 8px rgba(20, 35, 43, 0.4); }

/* ---------- filters ---------- */
.filters {
  position: absolute; top: calc(var(--top) + 114px); left: 0; right: 0; z-index: 1090;
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 10px 10px; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px;
  border-radius: 18px; border: 1px solid var(--line); background: #fff; font-size: 14px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(20, 35, 43, 0.12);
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip .ico { display: inline-flex; flex: none; }
.chip.radius { padding: 0 4px 0 10px; gap: 4px; color: var(--accent); }
.chip.radius .rlabel { color: var(--ink); margin-right: 2px; }
.chip.radius button { border: 1px solid #cfcbc0; background: #fff; height: 28px; padding: 0 9px; border-radius: 14px; font-size: 14px; color: var(--ink); white-space: nowrap; }
.chip.radius button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
div.empty .btn { margin-top: 10px; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:disabled { opacity: 0.45; cursor: default; }
.chip[aria-pressed="true"] .n { color: rgba(255, 255, 255, 0.72); }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px #fff; }

/* ---------- sheet ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--sheet-h); z-index: 1100;
  display: flex; flex-direction: column; background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(20, 35, 43, 0.16); transition: height 0.28s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.handle { flex: none; display: block; width: 100%; height: 24px; border: 0; background: none; padding: 0; }
.handle span { display: block; width: 40px; height: 4px; border-radius: 2px; background: #cfcbc0; margin: 0 auto; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 14px 18px; }
#app:not(.sheet-open) .sheet-body { overflow: hidden; }

.list-head { display: flex; flex-direction: column; gap: 1px; padding: 0 2px 8px; }
.list-head strong { font-size: 17px; }
.list-head span { font-size: 13px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0;
  border-top: 1px solid var(--line); padding: 11px 2px; min-height: 62px;
}
.row .mini { flex: none; width: 30px; display: flex; justify-content: center; }
.row .txt { flex: 1; min-width: 0; }
.row .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; font-size: 13.500px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub b { font-weight: 600; }
.row .dist { flex: none; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.a-open { color: var(--open); }
.a-customers { color: var(--customers); }
.a-closed { color: var(--closed); }
.a-unknown { color: var(--unknown); }
.open-now { color: var(--open); font-weight: 600; }
.closed-now { color: var(--closed); font-weight: 600; }
.closed-note { margin-top: 3px; }
.linkbtn.inline { padding: 0; font-size: 13px; text-decoration: underline; }
.hline { display: block; }
.facts dd strong { display: block; margin-bottom: 2px; }
.hnote { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.pin-closed svg { opacity: 0.45; }
.empty, .foot { color: var(--muted); font-size: 13px; padding: 14px 2px 0; margin: 0; }
.foot { border-top: 1px solid var(--line); }
.foot a { color: inherit; }

/* ---------- detail ---------- */
.linkbtn { border: 0; background: none; padding: 6px 0 10px; color: var(--accent); font-weight: 600; font-size: 14px; }
.detail h2, .form h2 { margin: 0 0 2px; font-size: 21px; line-height: 1.2; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.detail .kind { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
/* The bubble that pops out above a tapped duck: a picture, who may use the toilet, the price. */
.duckpop .leaflet-popup-content-wrapper { padding: 0; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 26px rgba(20, 35, 43, 0.3); }
.duckpop .leaflet-popup-content { margin: 0; width: 236px !important; line-height: 1.2; font: inherit; }
.duckpop { margin-bottom: 0; animation: pop-in 0.22s cubic-bezier(0.2, 1.4, 0.4, 1); transform-origin: 50% 100%; }
@keyframes pop-in { from { opacity: 0; scale: 0.6; } to { opacity: 1; scale: 1; } }
@media (prefers-reduced-motion: reduce) { .duckpop { animation: none; } }
.pop { cursor: pointer; }
.pop-pic svg { display: block; width: 100%; height: auto; }
.pop-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 9px 9px; }
.sc-access, .sc-price { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; font-weight: 700; font-size: 14px; line-height: 1.2; }
.sc-access { padding: 5px 12px 5px 5px; color: #fff; }
.sc-access.b-open { background: var(--open); }
.sc-access.b-customers { background: var(--customers); }
.sc-access.b-closed { background: var(--closed); }
.sc-access.b-unknown { background: var(--unknown); }
.sc-sym { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.sc-access.b-open .sc-sym { color: var(--open); }
.sc-access.b-customers .sc-sym { color: var(--customers); }
.sc-access.b-closed .sc-sym { color: var(--closed); }
.sc-access.b-unknown .sc-sym { color: var(--unknown); }
.sc-price { padding: 6px 4px; color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; font-weight: 700; color: #fff; font-size: 16px; }
.badge.b-open { background: var(--open); }
.badge.b-customers { background: var(--customers); }
.badge.b-closed { background: var(--closed); }
.badge.b-unknown { background: var(--unknown); }
.facts { margin: 14px 0 0; padding: 0; }
.facts div { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.facts dt { flex: none; width: 108px; color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.source { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--closed); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-report { text-decoration: underline; text-underline-offset: 3px; }
.btn-report span { display: inline-flex; }
.btn-quiet { flex: 0 0 100%; border: 0; min-height: 36px; color: var(--muted); font-weight: 500; font-size: 14px; }

/* ---------- form ---------- */
.form .field { margin-top: 16px; }
.form label, .form .label { display: block; font-weight: 600; font-size: 14.500px; margin-bottom: 7px; }
.form input[type="text"], .form textarea {
  width: 100%; border: 1px solid #cfcbc0; border-radius: 12px; padding: 11px 12px; background: #fff; font-size: 16px;
}
.form textarea { min-height: 76px; resize: vertical; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1 1 auto; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid #cfcbc0; background: #fff;
  text-align: center; font-size: 15px;
}
.seg.col { flex-direction: column; }
.seg.col button { text-align: left; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.htable { margin-top: 10px; }
.hrow { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.hrow .hday { flex: none; width: 34px; font-weight: 600; font-size: 14.5px; }
.hrow input[type="time"] { flex: 1 1 0; min-width: 0; border: 1px solid #cfcbc0; border-radius: 10px; padding: 8px 6px; background: #fff; font-size: 16px; }
.hrow input[type="time"]:disabled { background: #f1efe9; color: #9aa3a8; }
.hrow .hclosed { flex: none; display: inline-flex; align-items: center; gap: 5px; margin: 0 0 0 4px; font-weight: 400; font-size: 14px; }
.hrow .hclosed input { width: 20px; height: 20px; }
.htable .linkbtn { margin-top: 6px; }
.thanks { margin: 14px 0 0; padding: 12px; border-radius: 14px; background: #fff8dc; border: 1px solid #f3dc8a; }
.thanks p { margin: 0 0 10px; font-size: 14px; color: #4d4a35; }
.ducks { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 8px; }
.ducks span { display: inline-flex; }
.ducks strong { margin-left: 8px; font-size: 15px; }
.ducks.pop span:last-of-type { animation: duckpop 0.6s ease; }
@keyframes duckpop { 0% { transform: scale(0) rotate(-30deg); } 60% { transform: scale(1.5) rotate(10deg); } 100% { transform: scale(1); } }
.btn-duck { width: 100%; background: #ffd84d; border-color: #e9bd1e; color: #3b2f00; }
/* the duck is as yellow as the button: a white disc behind it keeps it visible */
.btn-duck span { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #e9bd1e; }
.rowducks { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; font-weight: 600; font-size: 13px; color: #8a6a00; vertical-align: middle; }
.rowducks svg { width: 17px; height: 15px; }
/* The small icons for baby facilities and a shower, in the list and next to the badge. */
.extras { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.extras span { display: inline-flex; }
.badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badges .extras span { width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.warn { margin: 12px 0 0; padding: 12px; border-radius: 12px; background: #fdf1e3; border: 1px solid #f0cfa0; }
.warn p { margin: 0; font-weight: 600; }
.warn .actions { margin-top: 10px; }
.notice { margin: 16px 0 0; padding: 10px 12px; background: #f1efe9; border-radius: 12px; font-size: 13.500px; color: #3f4d54; }

/* ---------- floating buttons ---------- */
.fabs {
  position: absolute; right: 12px; bottom: calc(var(--sheet-h) + 14px); z-index: 1050;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; transition: bottom 0.28s ease, opacity 0.2s ease;
}
.fab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; min-width: 48px; padding: 0;
  border-radius: 24px; border: 0; background: #fff; color: var(--ink); box-shadow: var(--shadow);
}
.fab.busy svg { animation: pulse 1s ease-in-out infinite; }
.fab.on { color: #1d6fe8; }
.fab-primary { background: var(--accent); color: #fff; padding: 0 16px 0 13px; font-weight: 600; font-size: 15px; }
@keyframes pulse { 50% { opacity: 0.35; } }

.toast {
  position: absolute; left: 50%; top: calc(var(--top) + 168px); transform: translateX(-50%); z-index: 1300;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: min(88vw, 420px);
  box-shadow: var(--shadow); text-align: center;
}

/* ---------- welcome ---------- */
.intro { position: absolute; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 35, 43, 0.5); }
.intro-card { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; background: #fff; border-radius: 22px; padding: 20px 20px 18px; box-shadow: var(--shadow); }
.ihead { display: flex; align-items: center; gap: 14px; }
.ihead img { flex: none; border-radius: 14px; }
.ihead h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.ihead .lead { margin: 2px 0 0; font-size: 14.5px; color: var(--muted); }
.intro-card h3 { margin: 16px 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.irow { display: flex; align-items: center; gap: 10px; padding: 2px 0; font-size: 15px; }
.irow span:first-child { flex: none; display: inline-flex; }
.igrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.ilist { margin: 14px 0 16px; padding-left: 18px; font-size: 14.5px; color: #3f4d54; }
.ilist li { margin: 3px 0; }
.ilinks { margin: 12px 0 0; text-align: center; font-size: 13.5px; }
.ilinks a { color: var(--muted); }
.intro-card .btn { width: 100%; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #1d6fe8; outline-offset: 2px; }

/* On touch screens a drag should scroll or move the map, not mark text. */
@media (pointer: coarse) {
  #app { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  #app input, #app textarea { -webkit-user-select: text; user-select: text; }
}

/* ---------- phone only ---------- */
@media (max-width: 899px) {
  #app.sheet-open .fabs { opacity: 0; pointer-events: none; }
  #app.placing .sheet, #app.placing .filters { display: none; }
  #app.placing { --sheet-h: 0px; }
}
#app.placing .fabs { display: none; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 400px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); background: #fff; }
  .mapwrap { position: relative; inset: auto; grid-column: 2; grid-row: 1 / -1; border-left: 1px solid var(--line); }
  .topbar, .filters, .sheet { position: static; grid-column: 1; box-shadow: none; border-radius: 0; }
  .topbar { grid-row: 1; padding: 18px 20px 12px; background: #fff; }
  .brand h1 { font-size: 20px; }
  .filters { grid-row: 2; flex-wrap: wrap; overflow: visible; padding: 2px 20px 16px; border-bottom: 1px solid var(--line); }
  .chip { box-shadow: none; }
  .sheet { grid-row: 3; height: auto; min-height: 0; transition: none; padding-bottom: 0; }
  .handle { display: none; }
  .sheet-body, #app:not(.sheet-open) .sheet-body { overflow-y: auto; padding: 16px 20px 24px; }
  .row:hover { background: #f7f5f0; }
  .fabs { right: 16px; bottom: 30px; }
  .leaflet-bottom { bottom: 0; }
  .leaflet-control-zoom { display: block; }
  .toast { left: calc(400px + (100% - 400px) / 2); top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Start screen of the iPhone app (see index.html): the duck's head bobs in the water. The square
   drawing covers the screen the same way the app's launch picture does, so the two line up. */
.boot { position: fixed; inset: 0; z-index: 5000; overflow: hidden; background: #0d6e6e; transition: opacity 0.3s; }
.boot svg { position: absolute; left: 50%; top: 50%; width: max(100vw, 100vh); height: max(100vw, 100vh); transform: translate(-50%, -50%); }
.boot.out { opacity: 0; pointer-events: none; }
.boot .bob { transform-origin: 500px 560px; animation: boot-bob 2.4s ease-in-out infinite; }
.boot .wave-front { animation: boot-wave 2.6s linear infinite; }
.boot .wave-back { animation: boot-wave 4s linear infinite reverse; }
.boot .ripple { transform-origin: 500px 600px; animation: boot-ripple 2.4s ease-in-out infinite; }
@keyframes boot-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-22px) rotate(-3deg); }
  75% { transform: translateY(30px) rotate(3deg); }
}
@keyframes boot-wave { to { transform: translateX(-160px); } }
@keyframes boot-ripple {
  0%, 100% { opacity: 0.3; transform: scaleX(1); }
  25% { opacity: 0.12; transform: scaleX(0.8); }
  75% { opacity: 0.5; transform: scaleX(1.25); }
}
@media (prefers-reduced-motion: reduce) { .boot .bob, .boot .wave-front, .boot .wave-back, .boot .ripple { animation: none; } }
