:root {
  --blue: #3569EB;
  --blue-d: #2453CC;
  --blue-soft: #E8EFFE;
  --coral: #E97967;
  --coral-soft: #FCEBE8;
  --green: #3F8C69;
  --yellow: #F2C75C;
  --cream: #FAF9F6;
  --navy: #14203A;
  --ink-2: #5E6779;
  --line: #E6E4DF;
  --card: #FFFFFF;
  --field: #FFFFFF;
  --danger: #C8432F;
  --shadow: 0 24px 60px -24px rgb(20 32 58 / .35), 0 2px 8px rgb(20 32 58 / .06);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font: 15px/1.45 "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--navy);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- map ---------- */
.map-wrap { position: fixed; inset: 0; }
.map { width: 100%; height: 100%; }
.map-placeholder {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px;
  background: radial-gradient(circle at 70% 30%, #e7eefc, var(--cream) 65%); color: var(--ink-2);
}
.bob { width: 56px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- panel ---------- */
.sheet {
  position: fixed; top: 16px; left: 16px; bottom: 16px; width: 420px; z-index: 5;
  background: var(--cream); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; overflow: clip;
}
.sheet-scroll { overflow-y: auto; overflow-x: hidden; padding: 20px 22px 28px; flex: 1; overscroll-behavior: contain; }
.grabber { display: none; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.logo { width: 44px; height: 44px; }
.wordmark { font-weight: 800; font-size: 26px; letter-spacing: -0.03em; flex: 1; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--navy);
  transition: background .15s;
}
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }
.icon-btn.busy .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px;
}
.menu-who { padding: 8px 10px 10px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--line); margin-bottom: 6px; word-break: break-all; }
.menu-who strong { color: var(--navy); }
.menu-item { width: 100%; text-align: left; padding: 9px 10px; border-radius: 10px; font-weight: 600; }
.menu-item:hover { background: var(--blue-soft); color: var(--blue); }

.banner {
  background: #FFF7E0; color: #6A5414; border: 1px solid #F6E3A8;
  border-radius: 12px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- inputs ---------- */
.field { position: relative; }
.input-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--field); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 4px 5px 4px 14px; transition: border-color .15s, box-shadow .15s;
}
.input-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgb(53 105 235 / .14); }
.input-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0; font-size: 16px; }
.input-box input::placeholder { color: #9AA1AE; }
.input-box .lead { color: var(--ink-2); }
.input-box.small { border-radius: 12px; padding-left: 12px; }
.input-box.small input { padding: 8px 0; font-size: 15px; }
.add-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--blue); color: #fff; transition: transform .15s, background .15s;
}
.add-btn:hover { background: var(--blue-d); transform: scale(1.05); }
.add-btn .i { stroke-width: 2.5; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.chips:empty { margin: 0 0 16px; }
.chip {
  --c: var(--coral);
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 10px;
  font-weight: 600; font-size: 14px; color: color-mix(in srgb, var(--c) 75%, var(--navy));
  background: color-mix(in srgb, var(--c) 16%, #fff);
  animation: pop .2s ease-out;
}
.chip button { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.chip button .i { width: 14px; height: 14px; stroke-width: 2.5; }
.chip button:hover { background: color-mix(in srgb, var(--c) 25%, #fff); }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

/* tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #EFEEEA; border-radius: 16px; padding: 5px; margin-bottom: 14px; }
.tab {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 8px; border-radius: 12px;
  font-weight: 600; font-size: 14px; color: var(--navy); border: 1.5px solid transparent; transition: background .15s, color .15s;
}
.tab[aria-selected="true"] { background: var(--blue-soft); border-color: #B7CBF8; color: var(--blue); }

.group { display: grid; gap: 10px; margin-bottom: 14px; }
.group[hidden] { display: none; }

/* route card */
.route-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 12px 12px 10px; display: grid; gap: 6px; }
.route-rows { position: relative; display: grid; gap: 10px; padding-right: 46px; }
.route-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 4px; }
.row-label { font-weight: 600; font-size: 14px; }
.route-rows::before {
  content: ""; position: absolute; left: 68px; top: 34px; bottom: 34px; width: 0;
  border-left: 2.5px dotted var(--navy); opacity: .55;
}
.swap { position: absolute; right: 0; top: 50%; transform: translateY(-50%); border: 1.5px solid var(--line); border-radius: 50%; background: var(--card); }
.dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.dot.start { background: var(--green); }
.dot.end { background: var(--yellow); }
.dot.mid { background: #fff; border: 3px solid var(--ink-2); }
.stop-row .icon-btn { width: 30px; height: 30px; color: var(--ink-2); }
.text-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 600; font-size: 14px; justify-self: start; padding: 4px 2px; }
.text-btn .i { width: 16px; height: 16px; }

/* autocomplete dropdown */
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; list-style: none;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 6px; max-height: 280px; overflow-y: auto; animation: pop .14s ease-out;
}
.route-row .suggest { left: 48px; }
.suggest li { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--blue-soft); }
.suggest .i { color: var(--ink-2); width: 18px; height: 18px; }
.suggest .main { font-weight: 600; }
.suggest .sec { color: var(--ink-2); font-size: 12px; display: block; }
.suggest .powered { justify-content: flex-end; font-size: 11px; color: var(--ink-2); cursor: default; padding: 4px 8px 2px; }
.suggest .powered:hover { background: none; }

/* sliders */
.slider-head { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.slider-head span { flex: 1; }
.slider-head output { font-weight: 800; font-size: 16px; }
.unit-toggle, .sort-toggle { display: inline-flex; background: #EFEEEA; border-radius: 10px; padding: 3px; }
.unit-toggle button, .sort-toggle button { white-space: nowrap; padding: 4px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.unit-toggle button[aria-pressed="true"], .sort-toggle button[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; outline: 0; margin: 6px 0;
  background: linear-gradient(var(--blue), var(--blue)) 0 / var(--fill, 20%) 100% no-repeat, #E3E2DD;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue);
  border: 3px solid #fff; box-shadow: 0 2px 8px rgb(20 32 58 / .3); cursor: grab;
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; cursor: grab; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgb(53 105 235 / .2); }

/* filters */
.filters { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; margin-bottom: 14px; }
.filters summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filters .chev { margin-left: auto; transition: transform .2s; }
.filters[open] .chev { transform: rotate(180deg); }
.filters-body { padding: 0 14px 14px; display: grid; gap: 6px; }
.route-only[hidden] { display: none; }

/* CTA */
.cta {
  position: relative; overflow: hidden; width: 100%; padding: 15px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 10px 24px -10px rgb(53 105 235 / .8); transition: background .15s, transform .15s;
}
.cta:hover { background: var(--blue-d); }
.cta:active { transform: scale(.985); }
.cta > * { position: relative; z-index: 1; }
.cta-fill { position: absolute !important; inset: 0; width: 0; z-index: 0 !important; background: rgb(255 255 255 / .18); transition: width .3s ease; }
.cta.loading { pointer-events: none; }
.cta.loading .i { animation: nudge .6s ease-in-out infinite alternate; }
@keyframes nudge { to { transform: translateX(4px); } }
.fineprint { text-align: center; color: var(--ink-2); font-size: 12px; margin-top: 8px; }

/* ---------- results ---------- */
#results { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.results-head[hidden] { display: none; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.results-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.summary { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.status { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.status.error { color: var(--danger); font-weight: 600; }
.status.empty { text-align: center; padding: 16px 8px; font-size: 14px; }

.list { list-style: none; display: grid; gap: 10px; margin-top: 12px; }
.card {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 12px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s; animation: rise .3s ease-out both; animation-delay: calc(var(--i, 0) * 30ms);
}
.card:hover { box-shadow: 0 8px 20px -14px rgb(20 32 58 / .5); }
.card.active { border-color: var(--blue); }
.card.in-trip { border-color: var(--green); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.thumb {
  width: 64px; height: 76px; border-radius: 12px; background: #F4F2EE; display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.bottle-art { width: 30px; height: 60px; }
.card h3 { font-size: 16px; font-weight: 800; line-height: 1.25; }
.card .meta { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.offers { list-style: none; margin-top: 8px; display: grid; gap: 4px; }
.offers li { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.offers .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.offers .wine { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offers .price { font-weight: 700; font-variant-numeric: tabular-nums; }
.offers a { color: inherit; text-decoration-color: #B7CBF8; text-underline-offset: 3px; }
.pick {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--line); color: var(--ink-2); transition: all .15s;
}
.pick .i { width: 14px; height: 14px; stroke-width: 2.6; }
.pick:hover { border-color: var(--green); color: var(--green); }
.pick[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pill-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); font-weight: 600; font-size: 13px; text-decoration: none;
}
.pill-link .i { width: 15px; height: 15px; }

/* trip tray */
.trip {
  border-top: 1px solid var(--line); background: var(--card); padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px;
  animation: rise .25s ease-out;
}
.trip[hidden] { display: none; }
.trip-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trip-info strong { font-size: 14px; width: 100%; }
.text-btn.muted { color: var(--ink-2); }
.trip-open {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px;
  background: var(--green); color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.trip-open .i { width: 16px; height: 16px; }
.trip-note { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }

/* ---------- map markers ---------- */
.shop-pin { position: relative; display: grid; justify-items: center; transform-origin: 50% 100%; transition: transform .15s; animation: drop .35s cubic-bezier(.3,1.6,.5,1) both; }
.shop-pin svg.drop { width: 34px; height: 42px; filter: drop-shadow(0 4px 6px rgb(20 32 58 / .35)); }
.shop-pin .tag {
  position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--navy); font: 700 12px/1 "Plus Jakarta Sans", system-ui, sans-serif;
  padding: 4px 7px; border-radius: 8px; white-space: nowrap; box-shadow: 0 2px 6px rgb(20 32 58 / .25);
}
.shop-pin:hover, .shop-pin.active { transform: scale(1.15); z-index: 2; }
/* lots of shops: only show the price on hover / when selected */
.crowded .shop-pin .tag { display: none; }
.crowded .shop-pin:hover .tag, .crowded .shop-pin.active .tag { display: block; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.6); } }
.end-pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgb(20 32 58 / .4); }
.end-pin.start { background: var(--green); }
.end-pin.end { background: var(--yellow); }

/* trip stop marker: a little card of the bottles bought there */
.trip-pin {
  display: grid; justify-items: center; animation: drop .35s cubic-bezier(.3,1.6,.5,1) both;
}
.trip-bubble {
  display: flex; align-items: flex-end; gap: 2px; padding: 6px 8px 4px; background: #fff; border-radius: 14px;
  border: 2px solid var(--green); box-shadow: 0 6px 14px -4px rgb(20 32 58 / .45); position: relative;
}
.trip-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: #fff;
  border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: translateX(-50%) rotate(45deg);
}
.trip-bubble img { width: 22px; height: 46px; object-fit: contain; }
.trip-bubble .bottle-art { width: 18px; height: 40px; }
.trip-bubble b { font: 800 12px/1 "Plus Jakarta Sans", system-ui, sans-serif; color: var(--green); align-self: center; padding-left: 2px; }
.trip-bubble .num {
  position: absolute; top: -10px; left: -10px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff;
  font: 800 12px/22px "Plus Jakarta Sans", system-ui, sans-serif; text-align: center; border: 2px solid #fff;
}

/* info window */
.iw { font: 13px/1.45 "Plus Jakarta Sans", system-ui, sans-serif; color: var(--navy); max-width: 270px; }
.iw h3 { font-size: 15px; font-weight: 800; }
.iw .meta { color: var(--ink-2); font-size: 12px; margin-bottom: 6px; }
.iw .offers li { font-size: 13px; }
.iw .pill-link { margin-top: 8px; }

/* ---------- sign-in gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgb(250 249 246 / .72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.gate[hidden] { display: none; }
.gate-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow);
  padding: 32px 26px 26px; display: grid; gap: 14px; text-align: center; animation: pop .25s ease-out;
}
.gate-logo { width: 84px; justify-self: center; }
.gate-word { font-weight: 800; font-size: 30px; letter-spacing: -0.03em; margin-top: -6px; }
.gate-card h2 { font-size: 19px; }
.gate-sub { color: var(--ink-2); font-size: 14px; margin-top: -4px; }
.gate-card .input-box input { text-align: center; }

/* ---------- phone: bottom sheet ---------- */
@media (max-width: 760px) {
  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 55dvh);
    border-radius: 26px 26px 0 0; border-bottom: 0;
    transition: height .35s cubic-bezier(.2,.9,.3,1);
  }
  .sheet.dragging { transition: none; }
  .sheet[data-snap="peek"] { --sheet-h: 180px; }
  .sheet[data-snap="mid"] { --sheet-h: 55dvh; }
  .sheet[data-snap="full"] { --sheet-h: 92dvh; }
  .grabber { display: grid; place-items: center; padding: 10px 0 2px; cursor: grab; touch-action: none; }
  .grabber span { width: 44px; height: 5px; border-radius: 999px; background: #C9C6BF; }
  .sheet-scroll { padding: 6px 18px 24px; }
  .brand { margin-bottom: 10px; }
  .logo { width: 38px; height: 38px; }
  .wordmark { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
