/* ---------- design tokens ---------- */
:root {
  --bg:#f3f1ec;
  --card:#ffffff;
  --ink:#17242d;
  --muted:#4b5c68;
  --accent:#0b6bcb;
  --accent-dark:#084f96;
  --warn:#b42318;
  --ok:#137a43;
  --line:#d6dde2;
  --shadow:0 1px 2px rgba(16,42,58,.06), 0 10px 28px rgba(16,42,58,.07);
  --radius:14px;
}

/* ---------- base ---------- */
* { box-sizing:border-box; }
body { margin:0; font:17px/1.55 "Atkinson Hyperlegible", "Trebuchet MS", sans-serif; background:var(--bg); color:var(--ink); }
h1, h2, h3, h4, .stat .num { font-family:"Sora", sans-serif; letter-spacing:-.02em; }
h2 { line-height:1.25; }
h3 { line-height:1.3; }
a { color:var(--accent-dark); }
main { max-width:1040px; margin:0 auto; padding:18px 20px 32px; }

/* ---------- header ---------- */
header { display:flex; justify-content:space-between; align-items:center; padding:14px 20px; background:#102a3a; color:#fff; flex-wrap:wrap; gap:12px; }
header h1 { font-size:20px; margin:0; }
.brand { color:#fff; text-decoration:none; display:flex; align-items:center; gap:10px; font-weight:700; }
.brand:hover { color:#fff; text-decoration:underline; }
#who { font-size:15px; display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
#who a.hdr-link { color:#fff; font-weight:600; }

/* ---------- navigation and buttons ---------- */
nav { display:flex; gap:8px; margin:12px 0 16px; flex-wrap:wrap; }
nav button, button {
  font:inherit;
  font-size:16px;
  font-weight:600;
  min-height:42px;
  padding:9px 15px;
  border:1px solid #94a3b8;
  background:#fff;
  color:var(--ink);
  border-radius:9px;
  cursor:pointer;
}
nav button { min-height:44px; font-weight:700; }
button:hover { background:#f1f5f9; border-color:#64748b; }
nav button.on, button.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
nav button.on:hover, button.primary:hover { background:var(--accent-dark); border-color:var(--accent-dark); color:#fff; }
button.danger { color:var(--warn); border-color:var(--warn); background:#fef2f2; }
button.danger:hover { background:#fee2e2; border-color:var(--warn); color:var(--warn); }
button:disabled { opacity:.5; cursor:not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline:3px solid #f59e0b;
  outline-offset:2px;
}

/* ---------- cards and shared type ---------- */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; margin:14px 0; box-shadow:var(--shadow); }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.grow { flex:1; }
.route { font-size:18px; line-height:1.35; font-weight:700; }
.muted { color:var(--muted); font-size:15px; }
.err { color:var(--warn); margin:8px 0; font-weight:600; }
.ok { color:var(--ok); margin:8px 0; font-weight:600; }
.hidden { display:none; }

/* ---------- badges ---------- */
.badge { display:inline-block; padding:3px 10px; border-radius:99px; font-size:14px; line-height:1.4; background:#e2e8f0; color:var(--ink); font-weight:600; }
.badge.now { background:#fee2e2; color:var(--warn); font-weight:700; }
.badge.offer { background:#dcfce7; color:var(--ok); }
.badge.request { background:#e0f2fe; color:var(--accent); }

/* ---------- forms ---------- */
label { display:block; margin:12px 0 4px; font-size:15px; font-weight:600; color:var(--muted); }
input, select, textarea {
  font:inherit;
  font-size:16px;
  width:100%;
  padding:10px 12px;
  border:1px solid #94a3b8;
  border-radius:8px;
  background:#fff;
  color:var(--ink);
}
input:not([type="radio"]):not([type="checkbox"]), select, textarea { min-height:46px; }
textarea { resize:vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color:var(--accent); outline-offset:1px; }
.seg { display:flex; gap:8px; flex-wrap:wrap; }
.seg label { margin:0; min-height:46px; display:flex; align-items:center; gap:8px; padding:10px 14px; border:1px solid #94a3b8; border-radius:8px; background:#fff; color:var(--ink); font-size:16px; font-weight:400; cursor:pointer; }
.seg label:hover { border-color:#64748b; background:#f8fafc; }
.seg input { width:auto; min-height:0; margin:0; padding:0; }

/* ---------- stats ---------- */
.stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:12px; margin:14px 0; }
.stat { background:#eef3f6; border-radius:10px; padding:14px; text-align:center; }
.stat .num { font-size:28px; font-weight:700; line-height:1.2; }

/* ---------- hero ---------- */
.hero { background:linear-gradient(135deg, #102a3a 0%, #0d3850 55%, #0b4a4b 100%); color:#fff; padding:24px; border:0; animation:hero-rise .5s ease-out both; }
.hero h2 { margin:0 0 6px; font-size:28px; }
.hero .muted { color:#c3def2; }
.hero .stat { background:rgba(255,255,255,.12); color:#fff; }
.hero .stat .muted { color:#cfe3f5; }
.hero button.primary { background:#fff; color:#102a3a; border-color:#fff; }
.hero button.primary:hover { background:#eef3f6; border-color:#fff; color:#102a3a; }
.hero button:not(.primary) { background:transparent; color:#fff; border-color:rgba(255,255,255,.8); }
.hero button:not(.primary):hover { background:rgba(255,255,255,.14); border-color:#fff; color:#fff; }
.cta { gap:10px; }
.cta .big { flex:1; padding:12px 16px; font-size:17px; min-height:50px; }
@keyframes hero-rise { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@media (prefers-reduced-motion:reduce) { .hero { animation:none; } }

/* ---------- map ---------- */
#map { height:360px; border-radius:var(--radius); overflow:hidden; margin:0; border:1px solid var(--line); background:#e2e8f0; }
.pin { width:18px; height:18px; border-radius:50%; border:2px solid #fff; box-shadow:0 1px 4px rgba(0,0,0,.5); cursor:pointer; }
.pin.place { width:10px; height:10px; background:#6a737d; }
.pin.offer { background:var(--ok); }
.pin.request { background:var(--accent); }

/* ---------- layout grids ---------- */
.find-grid { display:grid; grid-template-columns:1.15fr .85fr; gap:14px; align-items:start; margin:14px 0; }
.find-grid > .card { margin:0; }
.ride-list { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:14px; margin:14px 0; }
.ride-list > .card { margin:0; }
.match { display:flex; flex-direction:column; gap:6px; }
.match > .card { margin:0; }

/* ---------- ride cards ---------- */
.ride { border-left:5px solid var(--line); }
.ride.offer { border-left-color:var(--ok); }
.ride.request { border-left-color:var(--accent); }
.ride > * + * { margin-top:8px; }
.ride .route { margin:2px 0; }
.ride .row { row-gap:8px; }
.similar { margin-top:10px; }
.similar-item { border-top:1px solid var(--line); padding-top:10px; margin-top:10px; }
.similar-item > .ride { margin:0; }

/* ---------- place search ---------- */
.placefield { position:relative; }
.suggest { position:absolute; left:0; right:0; z-index:10; background:#fff; border:1px solid #94a3b8; border-radius:10px; margin-top:4px; max-height:320px; overflow:auto; box-shadow:0 12px 32px rgba(16,42,58,.18); }
.suggest .opt { display:block; width:100%; text-align:left; border:0; border-bottom:1px solid var(--line); border-radius:0; padding:12px 14px; background:#fff; font-size:16px; font-weight:400; min-height:46px; }
.suggest .opt:hover { background:#eef3f6; }
.suggest .opt.common::before { content:"★ "; color:#b45309; }
.suggest .opt .muted { font-size:14px; }
button.result { display:block; width:100%; text-align:left; margin-top:6px; font-size:15px; }

/* ---------- toasts ---------- */
#toasts { position:fixed; top:12px; left:50%; transform:translateX(-50%); z-index:1000; width:min(92vw, 460px); display:flex; flex-direction:column; gap:10px; }
.toast { background:#102a3a; color:#fff; padding:14px 16px; border-radius:12px; box-shadow:0 12px 32px rgba(0,0,0,.32); cursor:pointer; font-size:17px; line-height:1.45; border:1px solid rgba(255,255,255,.18); }
.toast .muted { color:#cfe3f5; margin-top:4px; }

/* ---------- users, sign-in, footer ---------- */
.user-row { border-top:1px solid var(--line); padding:12px 0; }
.user-row:first-child { border-top:0; }
.signin button { display:block; width:100%; margin-top:10px; min-height:46px; }
button.social { background:#fff; font-weight:600; }
button.social.SignInWithApple { background:#000; color:#fff; border-color:#000; }
button.social.LoginWithAmazon { background:#ffd814; border-color:#fcd200; }
footer { text-align:center; padding:24px 16px 32px; font-size:16px; color:var(--muted); }
footer a { color:var(--accent-dark); font-weight:600; }

/* ---------- skip link ---------- */
.skip { position:absolute; left:-9999px; top:0; width:1px; height:1px; overflow:hidden; }
.skip:focus { position:fixed; left:12px; top:12px; width:auto; height:auto; overflow:visible; z-index:2000; background:#fff; color:#102a3a; padding:10px 16px; border-radius:8px; font-weight:700; text-decoration:none; box-shadow:var(--shadow); outline:3px solid #f59e0b; outline-offset:2px; }

/* ---------- responsive ---------- */
@media (max-width:800px) {
  .find-grid { grid-template-columns:1fr; }
}
@media (max-width:520px) {
  body { font-size:16px; }
  main { padding:14px; }
  .card { padding:16px; }
  .stats { grid-template-columns:repeat(2, 1fr); }
  .ride-list { grid-template-columns:1fr; }
}