:root {
  --bg: #f6f4ef;
  --ink: #23211f;
  --muted: #726d66;
  --line: #ddd5c8;
  --panel: #fffdf8;
  --accent: #27736c;
  --accent-dark: #174f4a;
  --diaper: #a7681f;
  --unknown: #6d7280;
  --soft: #e6f1ee;
  --shadow: 0 18px 44px rgba(42, 36, 28, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(39, 115, 108, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(167, 104, 31, 0.05) 1px, transparent 1px),
    linear-gradient(145deg, #fbfaf6 0%, #f3efe7 52%, #edf4f1 100%);
  background-size: 40px 40px, 40px 40px, auto;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
  padding: 12px 0 36px;
}

h1,
h2,
p {
  margin-top: 0;
}

.app-header {
  margin-bottom: 8px;
}

h1 {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 900;
}

.lead {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(42, 36, 28, 0.08);
}

.location-search {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
}

.filter-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.filter-row input {
  accent-color: var(--accent);
}

select,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

select {
  padding: 0 12px;
}

#areaSelect {
  min-width: 0;
  width: 100%;
}

button {
  padding: 0 14px;
  font-weight: 800;
}

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

.location-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-color: rgba(39, 115, 108, 0.28);
  background: var(--soft);
  color: var(--accent-dark);
  white-space: nowrap;
  min-width: 84px;
}

.location-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.location-icon::before,
.location-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
  opacity: 0.85;
}

.location-icon::before {
  left: 50%;
  top: -5px;
  width: 2px;
  height: 22px;
  transform: translateX(-50%);
}

.location-icon::after {
  left: -5px;
  top: 50%;
  width: 22px;
  height: 2px;
  transform: translateY(-50%);
}

.location-button.is-active {
  border-color: rgba(39, 115, 108, 0.6);
  background: var(--accent);
  color: #fff;
}

.map-style-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 82px;
  min-width: 82px;
  min-height: 40px;
  padding: 4px 7px;
  border-color: rgba(39, 115, 108, 0.22);
  border-radius: 999px;
  background: #eef5f2;
  color: var(--accent-dark);
  box-shadow: inset 0 1px 4px rgba(35, 33, 31, 0.12);
}

.map-style-toggle[aria-pressed="true"] {
  background: #f8f1df;
  border-color: rgba(167, 104, 31, 0.28);
  color: #785016;
}

.toggle-option {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 24px;
  opacity: 0.62;
}

.toggle-option-soft {
  border: 1px solid rgba(39, 115, 108, 0.28);
  border-radius: 5px;
  background:
    linear-gradient(90deg, #d8e7e2 0 33%, #e8efe7 33% 66%, #d5e0ea 66% 100%);
}

.toggle-option-color {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid rgba(35, 33, 31, 0.18);
  border-radius: 5px;
}

.toggle-option-color span:nth-child(1) {
  background: #8ccbb0;
}

.toggle-option-color span:nth-child(2) {
  background: #f3d279;
}

.toggle-option-color span:nth-child(3) {
  background: #7fb0d6;
}

.toggle-thumb {
  position: absolute;
  left: 4px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  border: 1px solid rgba(39, 115, 108, 0.18);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(35, 33, 31, 0.18);
  transform: translateY(-50%);
  transition: left 160ms ease, border-color 160ms ease;
}

.map-style-toggle[aria-pressed="true"] .toggle-thumb {
  left: 40px;
  border-color: rgba(167, 104, 31, 0.22);
}

.map-icon {
  display: grid;
  grid-template-columns: repeat(3, 7px);
  width: 23px;
  height: 17px;
  overflow: hidden;
  border: 1px solid rgba(35, 33, 31, 0.22);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.38);
}

.map-icon span:nth-child(1) {
  background: #cfded9;
}

.map-icon span:nth-child(2) {
  background: #e3e7dd;
  transform: skewY(-10deg);
}

.map-icon span:nth-child(3) {
  background: #c8d5df;
}

.map-style-toggle[aria-pressed="true"] .map-icon span:nth-child(1) {
  background: #8ccbb0;
}

.map-style-toggle[aria-pressed="true"] .map-icon span:nth-child(2) {
  background: #f3d279;
}

.map-style-toggle[aria-pressed="true"] .map-icon span:nth-child(3) {
  background: #7fb0d6;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.map-panel,
.list-panel,
.source-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.map-panel {
  overflow: hidden;
}

#map {
  width: 100%;
  height: 680px;
  background: #e9ece8;
}

.map-note {
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.cluster-marker {
  background: transparent;
  border: 0;
}

.cluster-marker-inner {
  display: grid;
  place-items: center;
  align-content: center;
  border: 4px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #55a99e, #27736c 68%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(35, 33, 31, 0.32);
  font-weight: 900;
  line-height: 1;
}

.cluster-marker-inner span {
  font-size: 0.72rem;
}

.cluster-marker-inner strong {
  margin-top: 2px;
  font-size: 1.08rem;
}

.list-panel {
  max-height: 760px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.list-header h2 {
  margin-bottom: 3px;
  font-size: 1.15rem;
}

.list-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.facility-list {
  overflow: auto;
  padding: 10px;
}

.facility-card {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ad-card {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 12px 13px;
  border: 1px dashed rgba(39, 115, 108, 0.28);
  border-radius: 8px;
  background: rgba(230, 241, 238, 0.56);
  color: var(--muted);
}

.ad-label {
  width: max-content;
  padding: 2px 7px;
  border: 1px solid rgba(39, 115, 108, 0.22);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 0.66rem;
  font-weight: 900;
}

.ad-card strong {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
}

.ad-card p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
}

.ad-card a {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.ad-card-adsense {
  min-height: 118px;
}

.ad-card-adsense .adsbygoogle {
  min-width: 250px;
  min-height: 90px;
}

.facility-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 115, 108, 0.16);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.facility-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 30px;
  padding: 0 9px;
  border-color: rgba(167, 104, 31, 0.28);
  background: #fff9f0;
  color: #8a5316;
  line-height: 1;
}

.like-button span {
  font-size: 1rem;
}

.like-button strong {
  font-size: 0.78rem;
}

.like-button[aria-pressed="true"] {
  border-color: rgba(168, 61, 73, 0.32);
  background: #fff0f1;
  color: #9a3340;
}

.area-badge,
.distance-badge,
.status-badge,
.confidence-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.area-badge {
  background: #f7ead5;
  color: #785016;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.distance-badge {
  background: var(--soft);
  color: var(--accent-dark);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-badge {
  background: #eef0f3;
  color: var(--unknown);
}

.status-badge.yes {
  background: var(--soft);
  color: var(--accent-dark);
}

.status-badge.no {
  background: #f8eadc;
  color: var(--diaper);
}

.location-text,
.note-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.source-row a {
  color: var(--accent-dark);
  font-weight: 900;
  text-decoration: none;
}

.confidence-badge {
  background: #eef0f3;
  color: var(--muted);
}

.confidence-badge.high {
  background: var(--soft);
  color: var(--accent-dark);
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 900;
}

.popup-location {
  margin: 0 0 8px;
  color: #555;
  line-height: 1.45;
}

.popup-like {
  margin-top: 8px;
  color: #8a5316;
  font-weight: 900;
}

.source-panel {
  margin-top: 16px;
  padding: 16px;
}

.source-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.source-panel a {
  color: var(--accent-dark);
  font-weight: 900;
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  h1 {
    font-size: 1rem;
  }

  .app-header,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .filter-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  #map {
    height: 460px;
  }

  .list-panel {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 100%;
    padding: 6px 8px 24px;
  }

  h1 {
    padding-inline: 2px;
    font-size: 0.92rem;
  }

  .controls {
    position: sticky;
    top: 0;
    z-index: 600;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 8px;
  }

  .location-search {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-box {
    min-height: 40px;
  }

  .filter-row {
    grid-column: 1 / -1;
    margin-inline: -2px;
    padding-inline: 2px;
  }

  .filter-row label {
    min-height: 36px;
    padding-inline: 9px;
    font-size: 0.78rem;
  }

  select,
  button {
    min-height: 40px;
  }

  #areaSelect {
    grid-column: 1 / 2;
    width: 100%;
  }

  .map-style-toggle {
    width: 82px;
    padding-inline: 7px;
  }

  .location-button {
    width: auto;
    min-width: 78px;
    padding-inline: 10px;
  }

  .content-grid {
    gap: 8px;
  }

  #map {
    height: min(54vh, 420px);
    min-height: 320px;
  }

  .map-note {
    padding: 9px 10px;
    font-size: 0.76rem;
  }

  .list-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.96);
  }

  .list-header h2 {
    font-size: 1rem;
  }

  .facility-list {
    padding: 8px;
  }

  .facility-card {
    gap: 8px;
    margin-bottom: 8px;
    padding: 11px;
  }

  .card-top {
    display: grid;
    gap: 8px;
  }

  .card-heading {
    justify-content: space-between;
  }

  .like-button {
    width: auto;
  }

  .card-badges {
    justify-content: flex-start;
  }

  .facility-card h3 {
    font-size: 0.96rem;
  }

  .status-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .status-badge {
    justify-content: center;
    min-width: 0;
    padding-inline: 6px;
    font-size: 0.68rem;
  }

  .location-text,
  .note-text {
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .source-row {
    display: grid;
    justify-items: start;
  }

  .source-panel {
    margin-top: 8px;
    padding: 12px;
  }

  .source-panel h2 {
    font-size: 1rem;
  }

  .source-panel p {
    font-size: 0.84rem;
  }

  .leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
  }
}

@media (max-width: 390px) {
  .status-row {
    grid-template-columns: 1fr;
  }
}
