:root {
  --bg: #F7F9FC;          /* lime-washed wall */
  --surface: #FFFFFF;
  --ink: #14214D;         /* azulejo ink */
  --muted: #56628C;
  --cobalt: #2340B0;
  --cobalt-ink: #FFFFFF;
  --wash: #DCE4F7;        /* faded tile glaze */
  --line: #C3CDEA;
  --yellow: #FFC21A;      /* tram 28 */
  --yellow-ink: #14214D;
  --danger: #B3261E;
  --radius-tile: 6px;
  --radius-btn: 999px;
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Figtree', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1230;
    --surface: #131D45;
    --ink: #E6ECFB;
    --muted: #A3AFD6;
    --cobalt: #8AA2FF;
    --cobalt-ink: #0B1230;
    --wash: #1A2656;
    --line: #2B3A78;
    --danger: #FF8A80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1230; --surface: #131D45; --ink: #E6ECFB; --muted: #A3AFD6;
  --cobalt: #8AA2FF; --cobalt-ink: #0B1230; --wash: #1A2656; --line: #2B3A78; --danger: #FF8A80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 8rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}
a { color: var(--cobalt); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.wrap {
  max-width: 36rem;
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 16px 3rem;
}

/* ---------- Hero ---------- */
.hero h1 {
  font: 800 clamp(3.4rem, 17vw, 5.6rem)/0.86 var(--display);
  letter-spacing: -0.01em;
  margin: 0.5rem 0 1rem;
  color: var(--cobalt);
  text-wrap: balance;
}
.lede { margin: 0 0 2rem; color: var(--muted); max-width: 30rem; font-size: 1.05rem; }

/* ---------- Steps ---------- */
.step { margin: 0 0 2.25rem; }
.step h2 {
  font: 700 1.6rem/1.1 var(--display);
  margin: 0 0 0.85rem;
  letter-spacing: 0.01em;
}
.status { min-height: 1.4em; margin: 0.6rem 0 0; color: var(--muted); font-size: 0.95rem; }
.status.ok { color: var(--ink); font-weight: 600; }
.status.err { color: var(--danger); font-weight: 600; }

/* ---------- Buttons & inputs ---------- */
.btn {
  font: 600 1rem/1 var(--body);
  border-radius: var(--radius-btn);
  padding: 0.8rem 1.15rem;
  cursor: pointer;
  border: 2px solid transparent;
  min-height: 44px;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-block { width: 100%; }
.pin { width: 1.15em; height: 1.15em; fill: currentColor; flex-shrink: 0; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-outline { background: transparent; color: var(--cobalt); border-color: var(--cobalt); }
.btn-solid { background: var(--cobalt); color: var(--cobalt-ink); }
.btn-pick {
  width: 100%;
  background: var(--yellow);
  color: var(--yellow-ink);
  font: 800 1.9rem/1 var(--display);
  letter-spacing: 0.02em;
  padding: 1.05rem 1rem;
  border-radius: var(--radius-tile);
  box-shadow: 0 4px 0 #14214D;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-pick { box-shadow: 0 4px 0 #000; } }
.btn-pick:active { transform: translateY(3px); box-shadow: 0 1px 0 #14214D; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn-pick:focus-visible { outline-color: var(--cobalt); }

input[type="search"], input[type="time"] {
  font: 500 1rem var(--body);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  width: 100%;
}
input[type="search"]:focus, input[type="time"]:focus { border-color: var(--cobalt); outline: none; }

.where { display: grid; gap: 0.6rem; }
.area-search { display: flex; gap: 0.5rem; }
.area-search input { flex: 1; min-width: 0; }
.area-results { list-style: none; margin: 0.5rem 0 0; padding: 0; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.area-results li + li { border-top: 1px solid var(--line); }
.area-results button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--ink);
  font: 500 0.95rem var(--body); padding: 0.75rem 0.9rem; cursor: pointer; min-height: 44px;
}
.area-results button:hover { background: var(--wash); }

/* ---------- Where: chosen location pill ---------- */
.where-set {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.6rem 0.7rem 0.9rem;
  background: var(--wash);
  border-radius: 12px;
  min-height: 52px;
}
.where-set .pin { color: var(--cobalt); }
.where-set > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.link-btn {
  background: none;
  border: 0;
  color: var(--cobalt);
  font: 700 0.95rem var(--body);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.5rem 0.6rem;
  min-height: 44px;
  cursor: pointer;
  border-radius: 8px;
}

/* ---------- Mood tiles (azulejos) ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
@media (min-width: 30rem) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile::before { aspect-ratio: 1; }
}

.tile {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: var(--radius-tile);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  box-shadow: inset 0 0 0 2px var(--line);
  font-family: var(--body);
}
.tile::before {
  content: '';
  display: block;
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 2 / 1;
  background: var(--cobalt);
  opacity: 0.32;
  -webkit-mask: var(--pattern) center / 100% 100% no-repeat;
  mask: var(--pattern) center / 100% 100% no-repeat;
  transition: opacity 0.15s ease;
}
.tile:hover::before { opacity: 0.55; }
.tile .tile-text {
  position: relative;
  width: 100%;
  padding: 0.55rem 0.65rem 0.6rem;
  flex: 1;
  background: var(--surface);
  border-top: 2px solid var(--line);
}
.tile strong { display: block; font: 700 1.05rem/1.15 var(--body); }
.tile small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.25; margin-top: 0.15rem; }

.tile[aria-checked="true"] { background: var(--wash); box-shadow: inset 0 0 0 3px var(--cobalt); }
.tile[aria-checked="true"]::before { opacity: 1; }
.tile[aria-checked="true"] .tile-text { background: var(--cobalt); color: var(--cobalt-ink); border-top-color: var(--cobalt); }
.tile[aria-checked="true"] small { color: inherit; opacity: 0.85; }

/* ---------- When ---------- */
.when-row { display: grid; gap: 0.7rem; }
.when-row .chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
.when-row .chips span { text-align: center; padding: 0.6rem 0.2rem; font-variant-numeric: tabular-nums; }
.time-other { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.time-other input[type="time"] { font: 600 1rem var(--body); width: auto; padding: 0.5rem 0.7rem; }

.more {
  margin-top: 1.25rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.more summary {
  list-style: none;
  cursor: pointer;
  padding: 0.8rem 2.6rem 0.8rem 1rem;
  position: relative;
  min-height: 44px;
  border-radius: 10px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after {
  content: '';
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2.5px solid var(--cobalt);
  border-bottom: 2.5px solid var(--cobalt);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.15s ease;
}
.more[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.more-title { display: block; font-weight: 700; }
.more-summary { display: block; color: var(--muted); font-size: 0.9rem; }
.more-body { display: grid; gap: 1.25rem; padding: 0.4rem 1rem 1.1rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.when-grid { display: grid; gap: 1.25rem; }
.field { display: grid; gap: 0.45rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-weight: 600; font-size: 0.95rem; padding: 0; margin-bottom: 0.45rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span {
  display: block;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-btn);
  border: 2px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  min-height: 44px;
  line-height: 1.3;
}
.chips input:checked + span { background: var(--cobalt); border-color: var(--cobalt); color: var(--cobalt-ink); }
.chips input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.chips-stack { flex-direction: column; }
.chips-stack span { border-radius: 12px; }
.chips-stack small { display: block; font-weight: 400; font-size: 0.85rem; opacity: 0.8; }

.check { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; cursor: pointer; min-height: 44px; }
.check input { width: 1.3rem; height: 1.3rem; accent-color: var(--cobalt); }

/* ---------- Pick bar (sticky on phones) ---------- */
.pick-bar {
  position: sticky;
  bottom: 0;
  z-index: 500;
  margin: 0 -16px;
  padding: 0.6rem 16px max(0.9rem, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 1.2rem);
}
.pick-bar .status { margin: 0 0 0.5rem; min-height: 0; }
.pick-bar .status:empty { display: none; }
.pick-bar .status.err, .pick-bar .status:not(:empty) {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.pick-bar .status.err { border-color: var(--danger); }

.spinner {
  display: none;
  width: 1.3rem;
  height: 1.3rem;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn-pick.loading .spinner { display: inline-block; }
.btn-pick.loading { opacity: 1; cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result ---------- */
.result, .shared {
  margin-top: 2.5rem;
  background: var(--surface);
  border-radius: 10px;
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--cobalt);
  overflow: hidden;
}
.shared { margin: 0 0 2.5rem; }
.result:focus { outline: none; }

.ticket-head { padding: 1.2rem 1.2rem 1rem; border-bottom: 2px dashed var(--line); }
.ticket-head .kicker { margin: 0 0 0.3rem; color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.place-name {
  font: 800 clamp(2.2rem, 10vw, 3rem)/0.95 var(--display);
  margin: 0;
  overflow-wrap: anywhere;
}
.place-name.rolling { color: var(--muted); }
.place-meta { margin: 0.5rem 0 0; color: var(--muted); }
.badge {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--wash);
  color: var(--ink);
}
.badge.open { background: var(--cobalt); color: var(--cobalt-ink); }

.board { list-style: none; margin: 0; padding: 0.4rem 1.2rem; }
.board li {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.7rem 0;
}
.board li + li { border-top: 1px solid var(--line); }
.board time {
  font: 800 2.2rem/1 var(--display);
  color: var(--cobalt);
  font-variant-numeric: tabular-nums;
}
.board .what { font-weight: 600; }
.board .what small { display: block; font-weight: 400; color: var(--muted); font-size: 0.9rem; }

.note { margin: 0 1.2rem 0.8rem; padding: 0.7rem 0.85rem; background: var(--wash); border-radius: 8px; font-size: 0.92rem; }

.map { height: 220px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: var(--wash); }

.actions { display: grid; gap: 0.55rem; padding: 1.1rem 1.2rem 1.25rem; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.actions .btn { width: 100%; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-send { background: var(--yellow); color: var(--yellow-ink); font-size: 1.05rem; }

.shortlist { padding: 0 1.2rem 1.2rem; }
.shortlist h3 { font: 700 1.4rem/1.1 var(--display); margin: 0.2rem 0 0.7rem; }
.shortlist ol { margin: 0 0 0.8rem; padding: 0; list-style: none; display: grid; gap: 0.45rem; }
.shortlist li button {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.6rem;
  align-items: center;
  text-align: left;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font: 500 0.95rem var(--body);
  min-height: 44px;
}
.shortlist li button:hover { border-color: var(--cobalt); }
.shortlist .num { font: 800 1.8rem/1 var(--display); color: var(--cobalt); }
.shortlist small { display: block; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 1000;
}

.foot { margin-top: 3rem; color: var(--muted); font-size: 0.85rem; }

/* Leaflet sits on our palette */
.leaflet-container { font-family: var(--body); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(0.75) contrast(1.1) saturate(0.7); }
}

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