:root {
  --mint: #34a87a;
  --mint-dark: #2a8a64;
  --mint-soft: #e6f5ee;
  --bg: #f5faf7;
  --surface: #ffffff;
  --text: #16241d;
  --text-muted: #5a6b63;
  --border: #d8e6df;
  --danger: #c0392b;
  --danger-soft: #fde8e6;
  --warn: #8a6d1a;
  --warn-soft: #fbf3da;
  --shadow: 0 2px 12px rgba(20, 60, 45, 0.08);
  --radius: 14px;
  --focus: #1463c4;
}

[data-theme="dark"] {
  --mint: #4cc593;
  --mint-dark: #3aa97a;
  --mint-soft: #16312699;
  --bg: #0e1813;
  --surface: #16241d;
  --text: #e8f2ec;
  --text-muted: #9fb3aa;
  --border: #294037;
  --danger: #ff7a6c;
  --danger-soft: #3a201d;
  --warn: #e8c869;
  --warn-soft: #332c12;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
  --focus: #7fb4ff;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-wrap: break-word;
  word-break: break-word;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--mint);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 50;
}
.skip-link:focus {
  left: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: var(--mint);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 700;
}
.brand-mark {
  display: inline-flex;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.field {
  margin-bottom: 14px;
}
.field:last-child {
  margin-bottom: 0;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

input,
select {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input-row {
  display: flex;
  gap: 8px;
}
.input-row input {
  flex: 1;
  min-width: 0;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 6px 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.btn-primary {
  background: var(--mint);
  color: #fff;
}
.btn-primary:hover {
  background: var(--mint-dark);
}
.btn-secondary {
  background: var(--mint-soft);
  color: var(--mint-dark);
  border-color: var(--border);
}
[data-theme="dark"] .btn-secondary {
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--border);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-row .btn {
  flex: 1;
  min-width: 140px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.status-bar {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
}
.status-bar.is-loading {
  background: var(--mint-soft);
  border-color: var(--mint);
  color: var(--mint-dark);
}
[data-theme="dark"] .status-bar.is-loading {
  color: var(--text);
}
.status-bar.is-offline {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}
.status-bar.is-error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.results-head h2 {
  margin: 0;
}
.badge {
  background: var(--mint-soft);
  color: var(--mint-dark);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
[data-theme="dark"] .badge {
  color: var(--text);
}

.center-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

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

.result-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg);
}
.result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.result-name {
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
}
.result-dist {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mint-dark);
  white-space: nowrap;
}
[data-theme="dark"] .result-dist {
  color: var(--mint);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.tag {
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.tag.free {
  background: var(--mint-soft);
  border-color: var(--mint);
  color: var(--mint-dark);
}
[data-theme="dark"] .tag.free {
  color: var(--text);
}
.tag.paid {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}
.tag.wheelchair {
  background: #e7f0fb;
  border-color: #9cc2ef;
  color: #1463c4;
}
[data-theme="dark"] .tag.wheelchair {
  background: #16263a;
  border-color: #2f4a6e;
  color: #7fb4ff;
}

.result-meta {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 4px 0;
}

.result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.result-links a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mint-dark);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
[data-theme="dark"] .result-links a {
  color: var(--mint);
}
.result-links a:hover {
  background: var(--mint-soft);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 18px 4px;
  margin: 0;
}

.source-card p {
  font-size: 0.88rem;
  margin: 0 0 8px;
}
.source-card p:last-child {
  margin-bottom: 0;
}
.muted {
  color: var(--text-muted);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toast.toast-error {
  background: var(--danger);
  color: #fff;
}
.toast.toast-ok {
  background: var(--mint-dark);
  color: #fff;
}

.install-btn {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 55;
  background: var(--mint);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.app-footer {
  text-align: center;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.app-footer p {
  margin: 0;
}

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

@media (max-width: 400px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
  .input-row {
    flex-wrap: wrap;
  }
  .input-row .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
