:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  font-family: "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 env(safe-area-inset-bottom);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.header {
  padding: 1.25rem 1.25rem 0.5rem;
  text-align: center;
}
.header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.main { padding: 0.75rem 1rem 2rem; }

.controls {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.btn-row {
  display: flex;
  gap: 0.6rem;
}
.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #0f172a;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); color: #fff; }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}
.btn-sm { flex: 0 0 auto; padding: 0.65rem 1rem; }

.search-panel {
  margin-top: 0.75rem;
}
.search-panel.hidden { display: none; }
.search-row {
  display: flex;
  gap: 0.5rem;
}
#place-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}
#place-input:focus { border-color: var(--accent); }
#place-input::placeholder { color: var(--muted); }

.radius-field {
  margin: 0.9rem 0 0;
  padding: 0;
  border: none;
}
.radius-field legend {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  padding: 0;
}
.pills {
  display: flex;
  gap: 0.45rem;
}
.pill {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.5rem 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f172a;
}

.status {
  margin: 0.85rem 0;
  min-height: 1.4rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}
.status.error { color: var(--err); }
.status.ok { color: var(--ok); }
.status.loading::before {
  content: "";
  display: inline-block;
  width: 0.7rem; height: 0.7rem;
  margin-right: 0.45rem;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.map {
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.map .leaflet-container { background: #1e293b; }

.results-section { margin-top: 0.25rem; }
.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}
.results-header h2 {
  margin: 0;
  font-size: 1.05rem;
}
.result-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.card:hover, .card:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}
.card-name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.3;
  margin: 0;
}
.card-stars {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--warn);
  white-space: nowrap;
}
.card-stars.none {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}
.card-meta {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.card-meta span + span::before {
  content: " · ";
  color: var(--surface2);
}
.card-links {
  margin-top: 0.45rem;
  font-size: 0.78rem;
}
.card-links a {
  color: var(--accent);
  text-decoration: none;
}
.card-links a:hover { text-decoration: underline; }

.footer {
  padding: 0.5rem 1.25rem 1.5rem;
  text-align: center;
}
.footer p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Leaflet dark-ish tweaks */
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  color: #94a3b8 !important;
}
.leaflet-control-attribution a { color: #38bdf8 !important; }

@media (min-width: 640px) {
  .map { height: 280px; }
}
