/* ===== Kaaru Web — style.css ===== */

:root {
  --primary:    #2D6A4F;
  --secondary:  #40916C;
  --accent:     #95D5B2;
  --bg:         #F0F7F4;
  --text:       #1B4332;
  --text-light: #52796F;
  --white:      #FFFFFF;
  --shadow:     0 4px 24px rgba(27, 67, 50, .12);
  --radius:     12px;
  --error-bg:   #FFF0F0;
  --error-border: #FECACA;
  --error-text: #991B1B;
}

[data-theme="dark"] {
  --primary:    #52B788;
  --secondary:  #74C69D;
  --accent:     #2D6A4F;
  --bg:         #1A1A2E;
  --text:       #E0E0E0;
  --text-light: #A0A0B0;
  --white:      #252540;
  --shadow:     0 4px 24px rgba(0, 0, 0, .35);
  --error-bg:   #3A1A1A;
  --error-border: #7F1D1D;
  --error-text: #FCA5A5;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- Header ---------- */

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1000;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header .brand {
  display: flex;
  flex-direction: column;
}

header .brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .5px;
}

header .brand span {
  font-size: .78rem;
  opacity: .85;
  font-weight: 400;
}

/* Auth buttons in header */
.header-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-login {
  background: rgba(255,255,255,.2);
  color: var(--white);
  border: 1.5px solid rgba(255,255,255,.4);
  border-radius: 8px;
  padding: 0.45rem 1.1rem;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  white-space: nowrap;
}

.btn-login:hover {
  background: rgba(255,255,255,.3);
  border-color: rgba(255,255,255,.6);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-email {
  font-size: .78rem;
  opacity: .9;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,.4);
  padding-bottom: 1px;
  transition: border-color .2s;
}

.user-email:hover {
  border-color: rgba(255,255,255,.8);
}

.btn-logout {
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: .75rem;
  cursor: pointer;
  transition: background .2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,.25);
}

/* ---------- Theme Toggle ---------- */

.btn-theme {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background .2s;
  flex-shrink: 0;
}

.btn-theme:hover {
  background: rgba(255,255,255,.25);
}

/* Dark mode overrides for elements with hardcoded colors */
[data-theme="dark"] .trip-delete:hover {
  background: var(--error-bg);
  color: #F87171;
}

[data-theme="dark"] header {
  background: linear-gradient(135deg, #1B4332 0%, #2D6A4F 100%);
}

[data-theme="dark"] .stat-offset {
  background: linear-gradient(135deg, #1B4332, #2D6A4F);
}

[data-theme="dark"] .btn-calc {
  background: linear-gradient(135deg, #1B4332, #2D6A4F);
}

[data-theme="dark"] .btn-send-link {
  background: linear-gradient(135deg, #1B4332, #2D6A4F);
}

[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(.8) contrast(1.1) saturate(.8);
}

/* ---------- Login Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s;
}

.modal-close:hover { background: var(--bg); }

.login-step h2 {
  font-size: 1.2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.login-step p {
  font-size: .88rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.login-step input[type="email"] {
  width: 100%;
  font-size: 16px;
  padding: 0.7rem 0.75rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
  margin-bottom: 0.75rem;
  transition: border-color .2s;
}

.login-step input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.btn-send-link {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.btn-send-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(45,106,79,.25);
}

.btn-send-link:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  border-radius: 6px;
  font-size: .82rem;
}

.check-email-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-hint {
  font-size: .78rem !important;
  opacity: .7;
}

.btn-back-email {
  background: none;
  border: 1.5px solid var(--accent);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.btn-back-email:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Trip Saved Notification ---------- */

.trip-saved {
  max-width: 800px;
  width: 100%;
  margin: 0.5rem auto 0;
  padding: 0 0.75rem;
}

.trip-saved span {
  display: block;
  background: linear-gradient(135deg, rgba(45,106,79,.1), rgba(149,213,178,.2));
  border: 1px solid var(--accent);
  color: var(--primary);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: .85rem;
  font-weight: 500;
  text-align: center;
}

/* ---------- Trip History ---------- */

.history-section {
  max-width: 800px;
  width: 100%;
  margin: 1rem auto 1.5rem;
  padding: 0 0.75rem;
}

.history-inner {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.history-inner h2 {
  font-size: 1.05rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.summary-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem;
  text-align: center;
}

.summary-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.summary-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-light);
  margin-top: 0.15rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-empty {
  text-align: center;
  color: var(--text-light);
  font-size: .85rem;
  padding: 1.5rem 0.5rem;
}

.trip-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  transition: box-shadow .15s;
}

.trip-item:hover {
  box-shadow: 0 2px 8px rgba(27,67,50,.1);
}

.trip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.trip-date {
  font-size: .72rem;
  color: var(--text-light);
}

.trip-delete {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-light);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background .15s, color .15s;
  line-height: 1;
}

.trip-delete:hover {
  background: #FFF0F0;
  color: #D62828;
}

.trip-route {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.trip-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: .75rem;
  color: var(--text-light);
}

.trip-details span {
  background: var(--white);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.trip-carbon { font-weight: 600; color: var(--primary); }

.btn-load-more {
  width: 100%;
  margin-top: 0.75rem;
  background: var(--bg);
  border: 1.5px solid var(--accent);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.btn-load-more:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Trip Detail Modal ---------- */

.trip-detail-card {
  max-width: 560px;
}

.trip-detail-map {
  width: 100%;
  height: 280px;
  border-radius: 8px;
  margin-bottom: 1rem;
  z-index: 0;
}

.trip-detail-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.trip-detail-info .detail-row {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.trip-detail-info .detail-row.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-light);
  margin-bottom: 0.15rem;
}

.detail-value {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.detail-value.highlight {
  color: var(--primary);
}

@media (max-width: 600px) {
  .trip-detail-card { max-width: 100%; }
  .trip-detail-map { height: 220px; }
}

/* ---------- Controls ---------- */

.controls {
  max-width: 800px;
  width: 100%;
  margin: 0.75rem auto 0;
  padding: 0 0.75rem;
  position: relative;
  z-index: 500;
}

.controls-inner {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Address row */
.address-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.address-field {
  flex: 1 1 280px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .dot {
  position: absolute;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  z-index: 2;
}

.input-wrapper .dot.origin { background: var(--primary); }
.input-wrapper .dot.dest   { background: #D62828; }

/* Geolocation button inside origin input */
.btn-geoloc {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: var(--white);
  cursor: pointer;
  transition: background .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

.btn-geoloc:hover { background: var(--secondary); }
.btn-geoloc:active { transform: translateY(-50%) scale(.92); }

.btn-geoloc:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-geoloc.loading svg { display: none; }
.btn-geoloc.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.input-wrapper input {
  width: 100%;
  /* 16px font-size prevents iOS auto-zoom on focus */
  font-size: 16px;
  padding: 0.65rem 2.5rem 0.65rem 30px;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
  transition: border-color .2s;
  -webkit-appearance: none;
  appearance: none;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.input-wrapper input::placeholder {
  color: var(--text-light);
  opacity: .6;
}

/* Autocomplete suggestions */
.suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(27,67,50,.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 600;
  -webkit-overflow-scrolling: touch;
}

.suggestions.visible { display: block; }

.suggestions .suggestion-item {
  /* Min 44px touch target (Apple HIG) */
  min-height: 44px;
  padding: 0.6rem 0.75rem 0.6rem 30px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid rgba(149,213,178,.2);
  transition: background .15s;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.suggestions .suggestion-item:last-child { border-bottom: none; }

.suggestions .suggestion-item:hover,
.suggestions .suggestion-item:active,
.suggestions .suggestion-item.active {
  background: rgba(149,213,178,.25);
}

.suggestions .suggestion-item .suggestion-main {
  font-weight: 500;
  line-height: 1.3;
}

.suggestions .suggestion-item .suggestion-detail {
  font-size: .75rem;
  color: var(--text-light);
  margin-top: 1px;
  line-height: 1.3;
}

/* Options row */
.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 140px;
}

.field label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-light);
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352796F' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  /* 16px prevents iOS auto-zoom */
  font-size: 16px;
  padding: 0.65rem 2rem 0.65rem 0.75rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s;
  min-height: 44px;
}

.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.btn-calc {
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  white-space: nowrap;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-calc:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(45,106,79,.25);
}

.btn-calc:active { transform: translateY(0); }

.btn-calc:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- Map ---------- */

#map {
  width: 100%;
  height: 50vh;
  min-height: 280px;
  z-index: 1;
  margin-top: 0.75rem;
  touch-action: pan-x pan-y;
}

/* Fix Leaflet custom markers */
.custom-marker {
  background: none !important;
  border: none !important;
}

/* ---------- Results ---------- */

.results-wrapper {
  max-width: 800px;
  width: 100%;
  margin: 0.75rem auto 1.5rem;
  padding: 0 0.75rem;
}

.results {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: none;
}

.results.visible { display: block; }

.results h2 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.stat .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat .label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-light);
  margin-top: 0.2rem;
}

/* Offset highlight card */
.stat-offset {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  grid-column: 1 / -1;
}

.stat-offset .value {
  color: var(--white);
  font-size: 1.6rem;
}

.stat-offset .label {
  color: rgba(255,255,255,.85);
}

.comparison {
  margin-top: 1rem;
  padding: 0.85rem;
  background: linear-gradient(135deg, rgba(45,106,79,.06), rgba(149,213,178,.12));
  border-radius: 8px;
  font-size: .85rem;
  color: var(--text);
  line-height: 1.6;
}

.comparison strong { color: var(--primary); }

.btn-share {
  width: 100%;
  margin-top: 0.75rem;
  background: var(--bg);
  border: 1.5px solid var(--accent);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0.65rem;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.btn-share:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-share.copied {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ---------- Error ---------- */

.error-msg {
  display: none;
  max-width: 800px;
  width: 100%;
  margin: 0.75rem auto 0;
  padding: 0 0.75rem;
}

.error-msg.visible { display: block; }

.error-inner {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: .85rem;
}

/* ---------- Footer ---------- */

footer {
  margin-top: auto;
  text-align: center;
  padding: 0.75rem;
  font-size: .72rem;
  color: var(--text-light);
}

.footer-links {
  display: inline-flex;
  gap: 0.9rem;
  margin-left: 0.75rem;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

.legal-page {
  min-height: 100vh;
  padding: 2rem 1rem 3rem;
  background:
    radial-gradient(circle at top left, rgba(45, 106, 79, 0.10), transparent 32%),
    radial-gradient(circle at bottom right, rgba(82, 183, 136, 0.10), transparent 28%),
    var(--bg);
}

.legal-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(18, 38, 31, 0.08);
}

.legal-card h1 {
  margin-bottom: 0.4rem;
}

.legal-card h2 {
  margin-top: 1.4rem;
  margin-bottom: 0.45rem;
  color: var(--text);
}

.legal-card p {
  color: var(--text-soft);
  line-height: 1.7;
}

.legal-back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

/* ---------- Loading spinner ---------- */

.btn-calc.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn-calc.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile (< 600px) ---------- */

@media (max-width: 600px) {
  header { padding: 0.6rem 0.75rem; }
  header .brand h1 { font-size: 1.25rem; }
  header .brand span { font-size: .7rem; }

  .btn-login { padding: 0.4rem 0.8rem; font-size: .78rem; }
  .user-email { max-width: 120px; font-size: .7rem; }

  .controls { padding: 0 0.5rem; margin-top: 0.5rem; }
  .controls-inner { padding: 0.75rem; gap: 0.6rem; }

  .address-row { flex-direction: column; gap: 0.5rem; }
  .options-row { flex-direction: column; gap: 0.5rem; }

  .btn-calc { width: 100%; padding: 0.85rem; font-size: 1rem; }

  #map { height: 35vh; min-height: 220px; margin-top: 0.5rem; }

  .results-wrapper { padding: 0 0.5rem; }
  .results { padding: 1rem; }
  .results-grid { gap: 0.5rem; }
  .stat { padding: 0.6rem; }
  .stat .value { font-size: 1.2rem; }

  .comparison { font-size: .8rem; padding: 0.75rem; }

  .modal-card { padding: 1.5rem; }
  .history-section { padding: 0 0.5rem; }
  .history-summary { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
  .summary-value { font-size: .95rem; }
  .summary-label { font-size: .58rem; }
  .trip-details { gap: 0.35rem; font-size: .7rem; }
  .footer-links {
    display: flex;
    justify-content: center;
    margin: 0.6rem 0 0;
  }
  .legal-card { padding: 1.1rem; border-radius: 18px; }
}

/* Very small screens (iPhone SE etc) */
@media (max-width: 380px) {
  .controls-inner { padding: 0.6rem; }
  .stat .value { font-size: 1.1rem; }
  .stat .label { font-size: .62rem; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  #map { height: 40vh; min-height: 180px; }
  header { padding: 0.4rem 0.75rem; }
  header .brand h1 { font-size: 1.1rem; }
}

/* Desktop large */
@media (min-width: 900px) {
  .controls { max-width: 860px; }
  .results-wrapper { max-width: 860px; }
  .results-grid { grid-template-columns: repeat(4, 1fr); }
}
