:root {
  --bg: oklch(0.98 0.006 75);
  --bg-blur: oklch(0.98 0.006 75 / 0.92);
  --ink: oklch(0.22 0.02 60);
  --ink-soft: oklch(0.32 0.02 60);
  --muted: oklch(0.5 0.02 60);
  --card: oklch(1 0 0);
  --border: oklch(0.88 0.01 75);
  --border-soft: oklch(0.93 0.008 75);
  --line: oklch(0.9 0.01 75);
  --blue: oklch(0.58 0.13 240);
  --blue-strong: oklch(0.5 0.13 240);
  --blue-hover: oklch(0.42 0.14 240);
  --blue-soft: oklch(0.94 0.03 240);
  --blue-tint: oklch(0.97 0.02 240);
  --blue-pale: oklch(0.9 0.02 240);
  --blue-underline: oklch(0.9 0.06 240);
  --red: oklch(0.6 0.14 30);
  --red-soft: oklch(0.95 0.03 30);
  --cost-ink: oklch(0.5 0.15 30);
  --cost-bg: oklch(0.96 0.03 60);
  --avatar-bg: oklch(0.92 0.008 75);
  --avatar-ink: oklch(0.55 0.02 60);
  --serif: "Lora", Georgia, serif;
  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue-strong);
}
a:hover {
  color: var(--blue-hover);
}
::selection {
  background: oklch(0.85 0.08 240);
}

.hidden {
  display: none !important;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
  flex-shrink: 0;
}
.lang-toggle button {
  border: none;
  background: none;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.lang-toggle button.active {
  background: var(--blue);
  color: #fff;
}
.lang-toggle--corner {
  position: absolute;
  top: 20px;
  right: 20px;
}

/* ---------- Name picker ---------- */
.welcome {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.welcome-inner {
  max-width: 520px;
  width: 100%;
  text-align: center;
  color: var(--ink);
}
.picker-title {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.15;
}
.picker-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 32px;
}
.family-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.family-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}
.family-btn:hover {
  border-color: var(--blue);
  background: var(--blue-tint);
}
.family-btn .family-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue-pale);
  color: var(--blue-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-blur);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
}
.header-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}
.voting-as {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--muted);
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--ink);
}
.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.switch-link {
  font-size: 13px;
  text-decoration: none;
  font-weight: 600;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-dark {
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-dark:hover {
  background: var(--ink-soft);
}

/* ---------- Add form ---------- */
.add-form-outer {
  padding: 20px 32px 0;
}
.add-form {
  max-width: 920px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.add-form-heading {
  font-weight: 700;
  font-size: 16px;
}
.add-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.7fr;
  gap: 12px;
}
.add-form input,
.add-form select,
.add-form textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid oklch(0.85 0.01 75);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
}
.add-form textarea {
  resize: vertical;
}
.add-form input:focus,
.add-form select:focus,
.add-form textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.add-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-ghost {
  background: none;
  border: 1px solid oklch(0.85 0.01 75);
  padding: 9px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn-primary:hover {
  background: var(--blue-strong);
}

/* ---------- Two-column layout (content + map) ---------- */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 0 32px;
  box-sizing: border-box;
}
.content-col {
  flex: 1 1 auto;
  min-width: 0;
}
.map-col {
  flex: 0 0 360px;
  width: 360px;
  position: sticky;
  top: 80px;
  align-self: flex-start;
}
#map {
  width: 100%;
  height: calc(100vh - 112px);
  min-height: 420px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px oklch(0.2 0.02 60 / 0.08);
  background: var(--card);
  z-index: 0;
}
.map-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}
.btn-map {
  font-size: 14px;
}
body.map-hidden .map-col {
  display: none;
}
.leaflet-marker-icon.marker-active {
  filter: drop-shadow(0 0 5px var(--blue)) drop-shadow(0 0 9px var(--blue));
}
.leaflet-popup-content {
  font-family: var(--sans);
  font-size: 13px;
  margin: 8px 12px;
}
.leaflet-popup-content .pin-name {
  font-weight: 700;
}
.leaflet-popup-content .pin-area {
  color: var(--muted);
  font-size: 12px;
}
.card.locating {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.card-time {
  margin-left: auto;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Top picks ---------- */
.top-picks-section {
  padding: 28px 0 24px;
}
.section-eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue-strong);
  margin-bottom: 10px;
}
.top-picks-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.top-pick {
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  flex: 0 0 auto;
}
.top-pick-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.top-pick-area {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.top-pick-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.top-pick-count .num {
  font-size: 20px;
  font-weight: 800;
  color: var(--blue-strong);
}
.top-pick-count .lbl {
  font-size: 12px;
  color: var(--muted);
}
.top-picks-empty {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Areas & cards ---------- */
.areas {
  padding: 0 0 64px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.area-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-underline);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.area-title:hover .area-label {
  color: var(--blue-strong);
}
.area-caret {
  font-size: 0.7em;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.area-count {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.area-section.collapsed .area-caret {
  transform: rotate(-90deg);
}
.area-section.collapsed .area-title {
  margin-bottom: 0;
}
.area-section.collapsed .card-grid {
  display: none;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.card-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}
.card-cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--cost-ink);
  background: var(--cost-bg);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-desc {
  font-size: 13.5px;
  color: oklch(0.48 0.02 60);
  line-height: 1.5;
  flex: 1;
}
.vote-row {
  display: flex;
  gap: 8px;
}
.vote-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  background: #fff;
  transition: background 0.12s;
}
.vote-btn.yes {
  border: 1.5px solid var(--blue);
  color: var(--blue-strong);
}
.vote-btn.yes:hover {
  background: var(--blue-soft);
}
.vote-btn.yes.active {
  background: var(--blue-soft);
}
.vote-btn.no {
  border: 1.5px solid var(--red);
  color: var(--red);
}
.vote-btn.no:hover {
  background: var(--red-soft);
}
.vote-btn.no.active {
  background: var(--red-soft);
}
.voters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.voter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--avatar-bg);
  color: var(--avatar-ink);
}
.voter.yes {
  background: var(--blue);
  color: #fff;
}
.voter.no {
  background: var(--red);
  color: #fff;
}
.voter.me {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor;
}

/* ---------- Footer ---------- */
.app-footer {
  margin-top: auto;
  text-align: center;
  color: oklch(0.65 0.01 75);
  font-size: 12px;
  padding: 24px 0 28px;
}

/* ---------- Responsive ---------- */
/* Stack the map above the list on narrower screens. */
@media (max-width: 900px) {
  .layout {
    flex-direction: column;
    padding: 0 18px;
  }
  .map-col {
    order: -1;
    width: 100%;
    flex: 0 0 auto;
    position: sticky;
    top: 64px;
    z-index: 5;
    margin-bottom: 8px;
  }
  #map {
    height: 42vh;
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .header {
    padding-left: 18px;
    padding-right: 18px;
  }
  .add-form-outer {
    padding-left: 18px;
    padding-right: 18px;
  }
  .add-form-grid {
    grid-template-columns: 1fr;
  }
  .picker-title {
    font-size: 28px;
  }
  .family-grid {
    grid-template-columns: 1fr;
  }
}
