:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #667085;
  --line: #dfe5ee;
  --primary: #0f172a;
  --accent: #22c55e;
  --accent-dark: #15803d;
  --bus: #2563eb;
  --bus-dark: #1d4ed8;
  --soft: #eef2f7;
  --warning: #fff7db;
  --shadow: 0 16px 50px rgba(15, 23, 42, .08);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 24px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.eyebrow, .result-kicker { color: var(--muted); font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 4px 0 0; font-size: clamp(28px, 4vw, 44px); line-height: 1; }
h2, h3 { margin: 0; }
.subtitle { max-width: 680px; margin: 10px 0 0; color: var(--muted); line-height: 1.5; }
.top-actions { display: grid; grid-template-columns: auto auto; gap: 7px 9px; align-items: center; min-width: 270px; }
.language-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.language-select { border: 1px solid var(--line); background: white; min-height: 42px; border-radius: 12px; padding: 0 12px; font-weight: 700; }
.top-actions .btn { grid-column: 1 / -1; }
.search-card, .controls-card, .map-card, .result-card, .routes-card, .how-card { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.search-card { padding: 20px; margin-bottom: 16px; display: grid; grid-template-columns: minmax(230px, .9fr) minmax(320px, 1.6fr); gap: 18px 24px; align-items: end; }
.search-copy h2 { margin-top: 5px; font-size: 24px; }
.search-copy p { color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.address-form { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.address-input { min-width: 0; min-height: 51px; border: 1px solid var(--line); border-radius: 14px; padding: 0 15px; background: #fbfcfe; outline: none; }
.address-input:focus { border-color: #94a3b8; box-shadow: 0 0 0 3px rgba(148, 163, 184, .15); }
.search-results { grid-column: 1 / -1; display: grid; gap: 7px; padding-top: 3px; }
.search-result { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 11px 13px; cursor: pointer; color: var(--text); }
.search-result:hover { background: #f8fafc; border-color: #cbd5e1; }
.search-result strong { display: block; font-size: 14px; }
.search-result span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.search-message { padding: 10px 12px; background: #f8fafc; border-radius: 12px; color: var(--muted); font-size: 13px; }
.controls-card { padding: 18px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; margin-bottom: 16px; }
.field-group label { display: block; font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; margin: 0 0 6px 4px; }
.location-field { min-height: 50px; display: flex; align-items: center; padding: 11px 14px; border-radius: 15px; border: 1px solid var(--line); background: #fbfcfd; font-size: 14px; line-height: 1.35; }
.location-field.destination { background: #f4fff7; border-color: #c6f6d5; }
.control-row { display: flex; gap: 8px; align-items: center; }
.btn { appearance: none; border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 850; cursor: pointer; transition: transform .15s ease, opacity .15s ease, background .15s ease; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--soft); color: var(--text); }
.btn-accent { background: var(--accent); color: #052e16; }
.btn-accent:hover { background: #4ade80; }
.btn-bus { background: var(--bus); color: white; }
.btn-bus:hover { background: var(--bus-dark); }
.full { width: 100%; margin-top: 10px; }
.button-stack { margin-top: 12px; }
.map-card { position: relative; overflow: hidden; margin-bottom: 16px; }
#map { height: min(58vh, 560px); min-height: 390px; z-index: 1; }
.map-hint { position: absolute; left: 14px; bottom: 14px; z-index: 500; background: rgba(15,23,42,.9); color: #fff; padding: 9px 12px; border-radius: 12px; font-size: 12px; backdrop-filter: blur(8px); max-width: calc(100% - 28px); }
.live-badge { position: absolute; right: 14px; top: 14px; z-index: 500; background: var(--warning); color: #6b4f00; border: 1px solid #efd57c; padding: 8px 11px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.results-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.result-card { padding: 18px; }
.result-card.best { grid-row: span 2; padding: 22px; background: linear-gradient(155deg, #ffffff 0%, #f1fff5 100%); border-color: #bdeacb; }
.result-card.transit-card { background: linear-gradient(155deg, #ffffff, #f5f9ff); border-color: #cfe0ff; }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.result-head.compact { align-items: center; }
.result-head h2 { font-size: 28px; margin-top: 5px; }
.result-head h3 { font-size: 17px; }
.eta { font-size: 42px; line-height: 1; font-weight: 900; letter-spacing: -0.04em; }
.eta.small { font-size: 24px; }
.details, .result-card p { color: var(--muted); line-height: 1.55; }
.verification-note { margin-top: 10px; padding: 10px 11px; border-radius: 12px; background: #eff6ff; color: #475569; font-size: 11px; line-height: 1.45; }
.routes-card, .how-card { padding: 20px; margin-bottom: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 16px; }
.section-title h2 { margin-top: 5px; font-size: 22px; }
.status-pill { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-radius: 999px; background: #e8fff0; color: var(--accent-dark); }
.arrival-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: 12px; }
.arrival-stop { padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: #fbfcfe; }
.arrival-stop.primary-stop { background: #f3fff6; border-color: #bdeacb; }
.stop-title { display: flex; align-items: center; gap: 10px; }
.stop-icon { width: 42px; height: 42px; border-radius: 13px; background: white; display: grid; place-items: center; border: 1px solid var(--line); font-size: 19px; flex: 0 0 auto; }
.stop-name { font-weight: 850; }
.stop-walk { color: var(--muted); font-size: 12px; margin-top: 3px; }
.route-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.route-number { min-width: 39px; height: 34px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--primary); color: white; font-weight: 900; font-size: 13px; }
.smallprint { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.how-card .result-kicker { display: block; margin-bottom: 12px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.step { border: 1px solid var(--line); border-radius: 15px; padding: 14px; background: #fbfcfe; color: var(--muted); line-height: 1.45; font-size: 13px; }
.step b { display: block; color: var(--text); margin-bottom: 4px; }
footer { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; padding: 6px 4px 18px; }
.agu-icon { width: 42px; height: 42px; border-radius: 14px; background: #22c55e; border: 4px solid white; box-shadow: 0 8px 22px rgba(0,0,0,.2); display: grid; place-items: center; font-size: 20px; }
.origin-icon { width: 36px; height: 36px; border-radius: 50%; background: #3b82f6; border: 4px solid white; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
@media (max-width: 900px) {
  .app-shell { padding: 14px; }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; min-width: 0; }
  .search-card { grid-template-columns: 1fr; }
  .address-form, .search-results { grid-column: 1; }
  .controls-card { grid-template-columns: 1fr; }
  .control-row { display: grid; grid-template-columns: 1fr 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .result-card.best { grid-column: 1 / -1; grid-row: auto; }
  .arrival-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  .address-form { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .result-card.best { grid-column: auto; }
  .control-row { grid-template-columns: 1fr; }
  .section-title { flex-direction: column; }
  #map { min-height: 410px; }
  .eta { font-size: 34px; }
  .map-hint { right: 14px; }
  .live-badge { max-width: calc(100% - 28px); white-space: normal; text-align: center; }
}

/* PWA / install UI */
body { padding-bottom: env(safe-area-inset-bottom); }
.app-shell { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.install-card { margin-bottom: 16px; padding: 17px 18px; border: 1px solid #cfe0ff; border-radius: var(--radius); background: linear-gradient(135deg, #f8fbff, #eef6ff); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.install-copy h2 { margin: 4px 0 0; font-size: 20px; }
.install-copy p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; max-width: 650px; }
.install-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.modal-backdrop { position: fixed; inset: 0; z-index: 5000; background: rgba(15,23,42,.55); backdrop-filter: blur(8px); padding: 18px; display: grid; place-items: center; }
.modal-backdrop[hidden] { display: none; }
.install-modal { width: min(430px, 100%); background: white; border-radius: 24px; padding: 24px; box-shadow: 0 28px 80px rgba(15,23,42,.28); position: relative; }
.modal-close { position: absolute; top: 12px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--soft); font-size: 25px; cursor: pointer; }
.install-icon-wrap { width: 84px; height: 84px; padding: 4px; border-radius: 22px; background: #eef2f7; margin-bottom: 14px; }
.install-icon-wrap img { width: 76px; height: 76px; border-radius: 18px; display: block; }
.install-modal h2 { font-size: 24px; margin: 0 40px 12px 0; }
.modal-body { color: var(--muted); line-height: 1.55; }
.modal-body ol { margin: 10px 0 0; padding-left: 23px; }
.modal-body li { margin: 7px 0; }
.install-card.is-installed { display: none; }
@media (max-width: 700px) {
  .app-shell { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .install-card { align-items: stretch; flex-direction: column; }
  .install-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .install-actions .btn { white-space: normal; }
}
@media (max-width: 420px) {
  .install-actions { grid-template-columns: 1fr; }
}
