:root {
  color-scheme: light;
  --paper: #f8f7ef;
  --surface: #fcfcfa;
  --ink: #55585a;
  --ink-strong: #394b57;
  --muted: #687278;
  --line: #c9c9c4;
  --brand: #3d5666;
  --brand-dark: #2d4452;
  --brand-soft: #e7edef;
  --pin: #bd1833;
  --success: #536d7b;
  --danger: #a53c42;
  --focus: #758c9a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  width: 100%;
  max-width: 30rem;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 0.55rem) 1rem calc(var(--safe-bottom) + 1.25rem);
}

.page-header {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  margin-bottom: 0.55rem;
  background: var(--paper);
  text-align: center;
}

.back-button {
  position: absolute;
  left: 0;
  top: 1.1rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--ink-strong);
  border-radius: 50%;
  touch-action: manipulation;
}

.back-button svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.brand-logo {
  display: block;
  width: min(8.3rem, 38vw);
  height: auto;
  mix-blend-mode: multiply;
}

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

h1 {
  margin-bottom: 0;
  color: var(--ink-strong);
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: 0.015em;
}

.location-query {
  margin-bottom: 0.4rem;
}

.store-search {
  margin: 0.8rem 0;
}

.address-input-wrap.store-search-input-wrap {
  grid-template-columns: 1.75rem minmax(0, 1fr);
  min-height: 3.25rem;
  padding-right: 0.85rem;
}

#store-search-input {
  width: 100%;
  min-width: 0;
  height: 3rem;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
}

#store-search-input::placeholder {
  color: #70777b;
  opacity: 1;
}

.store-search-status {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
}

.store-search-status:empty {
  display: none;
}

.store-search-status[data-tone="error"] {
  color: var(--danger);
}

.store-search-results {
  display: grid;
  gap: 0.5rem;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
}

.store-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem 0.5rem;
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  color: var(--ink-strong);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.store-result strong {
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.store-result-number {
  font-size: 0.87rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.store-result-address {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.store-choice.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.location-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 3px 10px rgba(45, 68, 82, 0.16);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background-color 120ms ease;
}

.location-button svg,
.recenter-button svg {
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.location-button:disabled,
.search-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.location-status {
  min-height: 1.25rem;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.45;
  text-align: center;
}

.location-status[data-tone="error"],
.address-status[data-tone="error"] {
  color: var(--danger);
  font-weight: 750;
}

.location-status[data-tone="success"],
.address-status[data-tone="success"] {
  color: var(--success);
}

.map-shell {
  display: none;
  position: relative;
  height: clamp(27rem, 55svh, 31rem);
  margin: 0 -1rem;
  overflow: hidden;
  background: var(--paper);
}

.map-shell.is-unavailable {
  display: block;
  height: 7rem;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--paper);
}

#map:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.map-loading {
  position: absolute;
  z-index: 500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.76), transparent 13rem),
    var(--paper);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.recenter-button {
  position: absolute;
  z-index: 700;
  right: 0.75rem;
  bottom: 1.8rem;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid #a9adb0;
  border-radius: 50%;
  color: var(--ink-strong);
  background: rgba(252, 252, 250, 0.96);
  box-shadow: 0 3px 12px rgba(57, 75, 87, 0.2);
  cursor: pointer;
  transition: transform 120ms ease;
}

.leaflet-container {
  color: var(--ink);
  background: var(--paper);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-tile-pane {
  filter: grayscale(1) brightness(1.13) contrast(0.72);
  opacity: 0.58;
}

.leaflet-control-attribution {
  max-width: calc(100vw - 4.75rem);
  padding: 1px 4px !important;
  color: #656a6d;
  background: rgba(248, 247, 239, 0.84) !important;
  font-size: 0.58rem !important;
  line-height: 1.3 !important;
}

.leaflet-control-attribution a {
  color: var(--ink-strong);
}

.store-map-icon,
.anchor-map-icon {
  overflow: visible !important;
  border: 0;
  background: transparent;
}

.leaflet-marker-icon.store-map-icon,
.store-marker {
  pointer-events: none;
}

.store-marker {
  position: relative;
  display: block;
  width: 0;
  height: 0;
  min-height: 0;
  color: var(--ink);
}

.store-marker-glyph {
  position: absolute;
  top: -0.875rem;
  left: -0.875rem;
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  color: #56595b;
}

.store-marker-link {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

.store-marker-link line {
  stroke: #a9adb0;
  stroke-width: 1.5;
}

.store-marker.is-selected .store-marker-card {
  border-color: #82949e;
  box-shadow: 0 0 0 2px rgba(61, 86, 102, 0.14), 0 5px 12px rgba(55, 57, 58, 0.2);
}

html.map-view,
body.map-view {
  overflow: hidden;
  overscroll-behavior: none;
}

.map-view .app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: none;
  min-height: 0;
  padding: calc(var(--safe-top) + 0.55rem) 0 0;
}

.map-view .page-header {
  flex: none;
  margin-right: 1rem;
  margin-left: 1rem;
}

.map-view .store-search,
.map-view .location-query,
.map-view .address-query,
.map-view .fallback-results,
.map-view footer,
.map-view .toast {
  display: none !important;
}

.map-view .map-shell {
  display: block;
  flex: 1;
  min-height: 0;
  height: auto;
  margin: 0;
}

.map-view #map,
.map-view .store-marker-card {
  touch-action: none;
}

.map-view .store-choice:active {
  transform: none;
}

.anchor-marker {
  display: grid;
  place-items: center;
  width: 3.15rem;
  height: 3.15rem;
  border: 2px solid var(--pin);
  border-radius: 50%;
  color: var(--pin);
  background: var(--paper);
  box-shadow: 0 2px 7px rgba(98, 31, 42, 0.14);
}

.anchor-marker svg {
  width: 2rem;
  height: 2rem;
  overflow: visible;
  fill: currentColor;
}

.address-query {
  padding: 1.55rem 0 0.2rem;
}

.address-query h2 {
  margin: 0 0 0.85rem;
  color: var(--ink);
  font-size: clamp(1.23rem, 5.8vw, 1.5rem);
  line-height: 1.25;
  letter-spacing: 0.015em;
  text-align: center;
}

.address-input-wrap {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 2.8rem;
  gap: 0.45rem;
  align-items: center;
  min-height: 3.65rem;
  padding: 0 0.2rem 0 0.85rem;
  border: 2px solid #626365;
  border-radius: 0.72rem;
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.address-input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(61, 86, 102, 0.14);
}

.search-icon {
  width: 1.75rem;
  height: 1.75rem;
  stroke: #5c5f61;
  stroke-width: 1.9;
  stroke-linecap: round;
}

#address-input {
  width: 100%;
  height: 3.45rem;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
}

#address-input::placeholder {
  color: #70777b;
  opacity: 1;
}

#address-input::-webkit-search-cancel-button {
  display: none;
}

.clear-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: #eff0ed;
  cursor: pointer;
  transition: transform 120ms ease;
}

.clear-button svg {
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.address-status {
  min-height: 1.3rem;
  margin: 0.42rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 650;
  line-height: 1.45;
  text-align: center;
}

.address-privacy {
  margin: -0.18rem 0 0.55rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
}

.area-options {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
}

.area-option {
  display: grid;
  gap: 0.15rem;
  min-height: 2.85rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #aeb4b7;
  border-radius: 0.65rem;
  color: var(--ink-strong);
  background: #fff;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.area-option span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.area-option:disabled {
  opacity: 0.6;
  cursor: wait;
}

.search-button {
  display: block;
  min-width: 7.75rem;
  min-height: 3rem;
  margin: 0 auto;
  padding: 0.45rem 1.4rem;
  border: 1px solid #b5b6b4;
  border-radius: 1.5rem;
  color: var(--ink);
  background: linear-gradient(#fff, #e8e8e5);
  box-shadow: 0 3px 7px rgba(71, 72, 73, 0.25);
  font-size: 1.16rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.fallback-results {
  margin-top: 1rem;
}

.fallback-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.fallback-heading h2 {
  margin-bottom: 0;
  color: var(--ink-strong);
  font-size: 1rem;
}

#results-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.store-list {
  display: grid;
  gap: 0.55rem;
}

.store-card {
  display: block;
  width: 100%;
  padding: 0.85rem;
  border: 1px solid #d2d3cf;
  border-radius: 0.72rem;
  background: #fff;
  box-shadow: 0 3px 9px rgba(55, 57, 58, 0.09);
  text-align: left;
  cursor: pointer;
}

.store-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.store-name {
  margin: 0;
  color: var(--ink-strong);
  font-size: 0.98rem;
  line-height: 1.35;
}

.store-distance {
  flex: none;
  font-size: 0.82rem;
  font-weight: 750;
}

.store-number,
.store-address {
  display: block;
  margin: 0.3rem 0 0;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.45;
}

footer {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 1200;
  right: 1rem;
  bottom: calc(var(--safe-bottom) + 1rem);
  left: 1rem;
  max-width: 26rem;
  margin: auto;
  padding: 0.72rem 0.9rem;
  border-radius: 0.7rem;
  color: #fff;
  background: rgba(45, 68, 82, 0.96);
  box-shadow: 0 5px 18px rgba(26, 37, 43, 0.26);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.4;
  text-align: center;
}

.location-button:active,
.recenter-button:active,
.store-choice:active,
.clear-button:active,
.search-button:active,
.area-option:active {
  transform: scale(0.975);
}

.location-button:focus-visible,
.recenter-button:focus-visible,
.store-choice:focus-visible,
.clear-button:focus-visible,
.search-button:focus-visible,
.area-option:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 359px) {
  .app-shell {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .map-shell {
    margin-right: -0.75rem;
    margin-left: -0.75rem;
  }

  .store-marker-name {
    font-size: 0.84rem;
  }

  .store-marker-number,
  .store-marker-distance {
    font-size: 0.82rem;
  }

}

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