:root {
  color-scheme: light;
  --ink: #15343a;
  --muted: #60767a;
  --muted-strong: #456064;
  --surface: #fffdf8;
  --surface-soft: #f5f5ed;
  --surface-strong: #eef6f1;
  --line: #dbe7df;
  --brand: #0f766e;
  --brand-dark: #0b5e58;
  --brand-soft: #d9f0e8;
  --accent: #e9794f;
  --accent-soft: #fff0e9;
  --shadow: 0 12px 28px rgba(27, 70, 68, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: #f8f8f2;
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button, a, select, input { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; }

.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;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 248, 242, 0.94);
  border-bottom: 1px solid rgba(219, 231, 223, 0.8);
  backdrop-filter: blur(16px);
}

.header-inner,
.page-shell,
.app-footer { width: min(100% - 32px, 1080px); margin: 0 auto; }

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.brand-mark svg { width: 24px; height: 24px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: 0.01em; }
.brand small { color: var(--muted); font-size: 12px; }

.header-action,
.text-button,
.primary-button,
.secondary-button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.header-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 14px;
}

.header-action svg,
.primary-button svg,
.search-field svg,
.install-icon svg { width: 20px; height: 20px; flex: 0 0 auto; }

.header-action:hover,
.primary-button:hover,
.secondary-button:hover { transform: translateY(-1px); }

.page-shell { padding: 38px 0 48px; }

.intro-block {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1, h2 { line-height: 1.2; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 7vw, 48px); letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -0.02em; }
.intro-copy { max-width: 560px; margin-bottom: 0; color: var(--muted-strong); }

.data-pill {
  flex: 0 0 auto;
  min-width: 94px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: right;
  box-shadow: var(--shadow);
}

.data-pill span, .data-pill small { display: block; }
.data-pill span { color: var(--brand-dark); font-size: 24px; font-weight: 800; line-height: 1.1; }
.data-pill small { color: var(--muted); font-size: 12px; }

.location-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
  padding: 16px;
  border: 1px solid #cfe9dd;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #e7f7ef, #f6faf1);
  box-shadow: var(--shadow);
}

.location-copy { display: flex; align-items: flex-start; gap: 10px; }
.status-dot { width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(233, 121, 79, 0.12); }
.location-card h2 { font-size: 16px; }
.location-card p { margin: 4px 0 0; color: var(--muted-strong); font-size: 13px; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.18);
}

.primary-button:hover { background: var(--brand-dark); }
.primary-button:disabled { cursor: wait; opacity: 0.66; transform: none; }

.map-section, .list-section { margin-top: 32px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.text-button { min-height: 40px; padding: 8px 10px; background: transparent; color: var(--brand-dark); font-size: 14px; }
.text-button:hover { background: var(--brand-soft); }

.map-frame {
  min-height: 340px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #dcebe6;
  box-shadow: var(--shadow);
}

.map-note { margin: 8px 2px 0; color: var(--muted); font-size: 12px; }
.map-note a { color: var(--brand-dark); }

.result-count { color: var(--muted); font-size: 14px; white-space: nowrap; }

.filter-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.search-field, .select-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search-field input, .select-field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(27, 70, 68, 0.04);
}
.search-field input { padding: 10px 14px 10px 44px; }
.select-field select { padding: 10px 36px 10px 14px; }
.search-field input:focus, .select-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15); }

.toilet-list { display: grid; gap: 10px; }
.toilet-card {
  position: relative;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(27, 70, 68, 0.045);
  animation: card-in 220ms ease both;
}

@keyframes card-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin: 0; font-size: 17px; line-height: 1.35; }
.distance { flex: 0 0 auto; color: var(--brand-dark); font-size: 13px; font-weight: 800; }
.card-address { margin: 7px 0 11px; color: var(--muted-strong); font-size: 14px; line-height: 1.5; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.tag { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 999px; background: var(--surface-strong); color: var(--brand-dark); font-size: 12px; font-weight: 700; }
.tag.accent { background: var(--accent-soft); color: #a5482d; }
.card-actions { display: flex; gap: 8px; }
.card-actions a, .card-actions button { min-height: 42px; border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 700; text-decoration: none; }
.nav-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; }
.nav-button:hover { background: var(--brand-dark); }
.map-button { border: 1px solid var(--line); background: transparent; color: var(--brand-dark); }
.map-button:hover { background: var(--surface-soft); }
.card-actions svg { width: 17px; height: 17px; }

.loading-state, .empty-state, .error-state {
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted-strong);
  text-align: center;
}
.spinner { display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -4px; border: 2px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { width: 100%; margin-top: 12px; }
.secondary-button { padding: 10px 16px; border: 1px solid var(--line); background: var(--surface); color: var(--brand-dark); }
.secondary-button:hover { background: var(--surface-soft); }

.install-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 34px;
  padding: 16px;
  border: 1px solid #f2d4c8;
  border-radius: var(--radius-md);
  background: #fff8f4;
}
.install-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px; background: var(--accent-soft); color: #a5482d; }
.install-card h2 { font-size: 16px; }
.install-card p { margin: 4px 0 0; color: var(--muted-strong); font-size: 13px; }

.app-footer { padding: 4px 0 36px; color: var(--muted); font-size: 12px; }
.app-footer p { margin: 4px 0; }
.app-footer a { color: var(--brand-dark); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 500; max-width: min(360px, calc(100% - 32px)); padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 12px 30px rgba(21, 52, 58, 0.24); font-size: 14px; }
.noscript { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 24px; background: var(--surface); color: var(--ink); text-align: center; }

.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 14px 16px; color: var(--ink); }
.popup-title { margin: 0 0 4px; font-weight: 800; }
.popup-meta { margin: 0 0 10px; color: var(--muted-strong); font-size: 12px; }
.popup-link { color: var(--brand-dark); font-size: 13px; font-weight: 700; }
.toilet-marker { display: grid; place-items: center; width: 32px; height: 32px; border: 3px solid #fff; border-radius: 50% 50% 50% 0; background: var(--brand); color: #fff; box-shadow: 0 4px 10px rgba(21, 52, 58, 0.28); transform: rotate(-45deg); }
.toilet-marker svg { width: 16px; height: 16px; transform: rotate(45deg); }
.toilet-marker.user { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); transform: none; }
.toilet-marker.user svg { transform: none; }

@media (min-width: 640px) {
  .page-shell { padding-top: 54px; }
  .filter-panel { grid-template-columns: minmax(0, 1.6fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr); }
  .toilet-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-frame { min-height: 430px; }
}

@media (min-width: 900px) {
  .header-inner, .page-shell, .app-footer { width: min(100% - 64px, 1080px); }
  .page-shell { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr); column-gap: 28px; align-items: start; }
  .intro-block, .location-card { grid-column: 1 / -1; }
  .map-section { grid-column: 1; grid-row: 3 / span 2; margin-top: 0; position: sticky; top: 94px; }
  .list-section { grid-column: 2; grid-row: 3; margin-top: 0; }
  .install-card { grid-column: 2; grid-row: 4; }
  .toilet-list { grid-template-columns: 1fr; max-height: 620px; overflow: auto; padding-right: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
