/* App surface. Keep the shared help/document styles independent. */
.map-page {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --muted: #61796f;
  --line: #e0e9e2;
  background: #f5f8f4;
  line-height: 1.5;
}
.ui-icon { width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* Safe-area padding is additional space, never subtracted from the content row. */
.map-page header {
  height: auto;
  min-height: calc(84px + var(--safe-top));
  padding: calc(14px + var(--safe-top)) calc(28px + var(--safe-right)) 14px calc(28px + var(--safe-left));
  gap: 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.map-page .brand { gap: 11px; min-height: 44px; font-size: 22px; letter-spacing: -.8px; line-height: 1.25; white-space: nowrap; }
.brand-icon { display: block; flex: 0 0 40px; border-radius: 13px; }
.brand-copy { display: flex; flex-direction: column; gap: 4px; }
.map-page .brand small { display: block; margin: 0; font-size: 8px; letter-spacing: 2.4px; color: #6a8376; line-height: 1; }
.map-page .header-right { flex-shrink: 0; gap: 18px; }
.map-page #language { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 14px; border-radius: 14px; background: #f5f8f4; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
#language .ui-icon { width: 16px; height: 16px; color: #638274; }
.map-page main { height: calc(100dvh - 84px - var(--safe-top)); grid-template-columns: 420px minmax(0, 1fr); }
.map-page .sidebar { background: #f9fbf7; }
.map-page .intro { padding: 28px 26px 22px; }
.map-page .eyebrow { color: #527968; font-size: 9px!important; letter-spacing: 1.8px; margin-bottom: 12px!important; }
.map-page h1 { font-size: 30px; line-height: 1.4; font-weight: 800; letter-spacing: -1.4px; margin-bottom: 10px; }
.map-page .intro > p:last-child { line-height: 1.7; }
.map-page .category-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.map-page .map-filters { position: absolute; inset: 0 0 auto; z-index: 3; width: min(100%, 760px); margin: 0 auto; padding: 12px 12px 0; pointer-events: none; }
.map-page #categories { display: flex; flex: 1; flex-wrap: nowrap; gap: 8px; min-width: 0; margin: 0; padding: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; pointer-events: auto; touch-action: pan-x; }
.map-page #categories::-webkit-scrollbar { display: none; }
.map-page #categories button { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; min-height: 44px; padding: 8px 14px; border: 1px solid #dbe5de; border-radius: 24px; background: #fff; color: #365448; font-size: 13px; font-weight: 600; line-height: 1.4; box-shadow: 0 2px 5px #173e3710; white-space: nowrap; }
.map-page #categories .filter-label { white-space: nowrap; }
.filter-icon { display: grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; border-radius: 9px; background: #edf2e9; color: #52734b; }
.filter-icon .ui-icon { width: 19px; height: 19px; }
.category-filter.toilet .filter-icon,.map-page .category-icon.toilet { background: #eaf0fc; color: #5978b2; }
.category-filter.smoking .filter-icon,.map-page .category-icon.smoking { background: #fbefdf; color: #a6773f; }
.category-filter.wifi .filter-icon,.map-page .category-icon.wifi { background: #e4f3ef; color: #3f8878; }
.category-filter.charge .filter-icon,.map-page .category-icon.charge { background: #eff3d9; color: #76883a; }
.map-page #categories .active { background: #245b43; border-color: #245b43; color: #fff; font-weight: 700; }
.map-page #categories .active .filter-icon { background: #245b43; color: #fff; }
.map-page .tabs { margin: 0 24px; padding: 4px; gap: 4px; background: #eaf0e9; border: 0; border-radius: 14px; }
.map-page .tabs button { min-height: 42px; padding: 10px 8px; background: transparent; border: 0; border-radius: 10px; line-height: 1.5; }
.map-page .tabs .active { background: #fff; box-shadow: 0 2px 7px #173e3709; }
.map-page .results-heading { align-items: center; gap: 12px; padding: 22px 26px 13px; }
.results-heading strong { font-size: 14px; }
.results-heading span { text-align: right; }
.map-page #list { padding: 0 20px; }
.map-page .card { padding: 17px 14px; margin-bottom: 10px; gap: 11px; background: #fff; border: 1px solid #e5ece4; border-radius: 18px; }
.map-page .card.is-focused { background: #fff9e9; border-color: #e7cc88; }
.map-page .category-icon { width: 40px; height: 42px; background: #edf2e9; color: #52734b; }
.map-page .place h2 { font-size: 14px; line-height: 1.6; }
.map-page .place p { font-size: 12px; line-height: 1.7; }
.map-page .pill { display: inline-block; margin: 3px 4px 0 0; font-size: 10px; line-height: 1.5; vertical-align: top; }
.map-page .card-actions { gap: 2px; }
.map-page .save { border-radius: 12px; background: #f6f8f3; }
.map-page .save.on { color: #245b43; background: #e6f0e7; }
.map-page .details-link { min-height: 44px; }
.map-page .unlocated-note { margin: 14px 24px; border: 1px solid #eee4cb; background: #faf5e8; font-size: 11px; }
.map-page .unlocated-note button { min-height: 36px; }
.map-page .map-title,.map-page #locate { border: 1px solid #dfe8de; box-shadow: 0 4px 18px #173e3710; }
.map-page #locate { min-height: 44px; border-radius: 14px; font-weight: 600; }
.map-page #search-area { top: calc(var(--filters-height, 142px) + 12px); left: 50%; transform: translateX(-50%); min-height: 44px; max-width: calc(100% - 24px); width: max-content; }
.map-page .map-top { top: auto; bottom: 24px; }
.map-page dialog { padding: 28px; border: 1px solid #e0e9e2; border-radius: 26px; max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom)); overflow-y: auto; }
.map-page #close-details { min-width: 44px; min-height: 44px; background: #f2f6ee; border-radius: 50%; }
.map-page #detail-content h2 { word-break: keep-all; overflow-wrap: anywhere; }
.map-page .detail-address { margin: 10px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.map-page .detail-location-note { margin: 10px 0 0; color: #784500; font-size: 12px; }
.map-page #details .walking-directions { margin: 20px 0 0; padding: 0; border: 0; background: transparent; }
.map-page .detail-more { margin-top: 14px; font-size: 12px; }
.map-page .detail-more > summary { padding: 8px 0; color: var(--muted); cursor: pointer; }
.map-page .detail-more > summary:focus-visible { outline: 3px solid #abc35c; outline-offset: 3px; border-radius: 4px; }
.map-page footer { line-height: 1.8; }
@media (hover: hover) {
  .map-page .card.has-location:hover { border-color: #bfd0c1; box-shadow: 0 4px 14px #173e3707; }
}
@media (min-width: 1500px) { .map-page main { grid-template-columns: 450px minmax(0, 1fr); } }
@media (max-width: 760px) {
  .map-page { padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left); }
  .map-page header { min-height: calc(76px + var(--safe-top)); padding: calc(14px + var(--safe-top)) 20px 14px; gap: 10px; }
  .map-page .brand { font-size: 20px; gap: 10px; }
  .map-page #language { padding: 10px 12px; }
  .map-page main { height: auto; min-height: 0; }
  .map-page .intro { padding: 24px 22px 20px; }
  .map-page h1 { font-size: 27px; line-height: 1.4; }
  .map-page .battery-note { margin: 0 20px 18px; }
  .map-page .map-panel { margin: 0 16px 20px; border: 1px solid #dbe5da; border-radius: 22px; height: clamp(340px, 48svh, 460px); }
  .map-page .tabs { margin: 0 20px; }
  .map-page .results-heading { padding: 20px 22px 12px; }
  .map-page .unlocated-note { order: 3; margin: 0 20px 14px; }
  .map-page #list { padding: 0 16px; }
  .map-page .card { padding: 16px 12px; gap: 10px; }
  .map-page footer { padding: 20px 22px; }
}
@media (max-width: 360px) {
  .map-page header { padding-left: 16px; padding-right: 16px; }
  .map-page .brand { font-size: 19px; }
  .map-page #language { gap: 5px; padding: 10px; }
  .map-page #categories button { gap: 6px; padding: 8px 12px; }
  .map-page #categories .filter-icon { width: 22px; height: 22px; }
  .map-page #categories .filter-icon .ui-icon { width: 17px; height: 17px; }
  .map-page .card { gap: 8px; }
  .map-page .category-icon { width: 34px; height: 38px; }
}

.category-filter.shelter .filter-icon,.map-page .category-icon.shelter { background: #e8eef7; color: #476185; }
.shelter-notice { padding: 12px; border-radius: 10px; background: #eef3fa; color: #3e5474; font-size: 12px; line-height: 1.7; }
.category-filter.cold .filter-icon,.map-page .category-icon.cold { background: #fff0dc; color: #8c451c; }
.cold-notice { padding: 12px; border-radius: 10px; background: #fff4e5; color: #7b461d; font-size: 12px; line-height: 1.7; }
.cold-shelter-details { margin: 16px 0; }
.cold-shelter-details summary { padding: 10px 0; cursor: pointer; font-size: 13px; font-weight: 600; }
.cold-shelter-details dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.cold-source { font-size: 11px; color: #536b61; overflow-wrap: anywhere; }

.places-sheet, .sheet-content { display: contents; }
.sheet-handle { display: none; }
.map-page #map { isolation: isolate; }
@media (max-width: 760px) {
  .map-page { height: 100dvh; overflow: hidden; padding: 0 var(--safe-right) 0 var(--safe-left); display: flex; flex-direction: column; }
  .map-page header { flex: 0 0 auto; min-height: calc(64px + var(--safe-top)); padding-top: calc(8px + var(--safe-top)); padding-bottom: 8px; }
  .map-page main { position: relative; display: block; flex: 1; min-height: 0; margin-bottom: var(--safe-bottom); overflow: hidden; isolation: isolate; }
  .map-page .sidebar { display: contents; }
  .map-page .intro { display: none; }
  .map-page .map-panel { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; z-index: 0; }
  .map-page .map-top { top: auto; bottom: calc(var(--sheet-height, 92px) + 12px); left: 12px; right: 12px; }
  .map-page .places-sheet { position: absolute; inset: auto 0 0; display: flex; flex-direction: column; height: 92px; max-height: 100%; z-index: 4; overflow: hidden; border: 1px solid #dbe5da; border-bottom: 0; border-radius: 24px 24px 0 0; background: #f9fbf7; box-shadow: 0 -5px 28px #173e3720; transition: height 240ms cubic-bezier(.2,.7,.2,1); }
  .map-page .places-sheet.is-dragging { transition: none; user-select: none; }
  .map-page .sheet-handle { display: flex; flex: 0 0 32px; justify-content: center; align-items: center; width: 100%; min-height: 32px; padding: 0; border: 0; border-radius: 24px 24px 0 0; background: transparent; cursor: grab; touch-action: none; }
  .map-page .sheet-handle > span:first-child { display: block; width: 44px; height: 5px; border-radius: 4px; background: #9baea2; }
  .map-page .sheet-handle:active { cursor: grabbing; }
  .map-page .sheet-handle:focus-visible { outline-offset: -4px; }
  .map-page .places-sheet .tabs { order: 0; flex: 0 0 auto; margin: 0 16px 6px; }
  .map-page .sheet-content { display: block; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
  .map-page .places-sheet[data-position="0"] .sheet-content { overflow: hidden; visibility: hidden; }
  .map-page .results-heading { padding: 10px 20px 12px; }
  .map-page .battery-note { margin: 10px 20px; }
  .map-page footer { flex-wrap: wrap; gap: 10px 14px; padding-bottom: 24px; }
  .map-page #toast { bottom: calc(var(--sheet-height, 92px) + 12px); left: 12px; transform: none; max-width: calc(100% - 124px); }
}
@media (prefers-reduced-motion: reduce) {
  .map-page .places-sheet { transition: none; }
}
