:root {
  --ink: #1d2a20;
  --ink-soft: #4f5d52;
  --paper: #fbfaf6;
  --card: #ffffff;
  --line: #e2e0d7;
  --brand: #1f4d2b;
  --brand-soft: #e6efe7;
  --brand-ink: #ffffff;
  --accent: #e8b931;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 8px 28px rgb(20 30 20 / 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.optional { font-weight: 400; color: var(--ink-soft); }

/* ---- Top bar and toolbar ---- */
.topbar {
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--brand); color: var(--brand-ink);
  z-index: 1000;
}
.brand { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; }
.brand > :not(.brand-mark) { grid-column: 2; }
.brand-mark { grid-column: 1; grid-row: 1 / span 3; width: 34px; height: 34px; display: block; }
.brand h1 { font-size: 1.05rem; font-weight: 700; }
.brand-sub { margin: 0; font-size: 0.78rem; opacity: 0.85; }
.brand-notice { margin: 2px 0 0; font-size: 0.72rem; font-weight: 600; color: #ffe08a; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 1000;
}
.search-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.search-row .search-wrap { flex: 1; min-width: 0; }
/* While filtering: a soft yellow strip with «Filtrando · 5 de 38», the chips and «Quitar filtros». */
.active-filters:not([hidden]) { background: #fff7d6; border-radius: 12px; padding: 6px 8px; align-items: center; flex-wrap: wrap; }
.filtering { font-size: 0.85rem; color: var(--ink); white-space: nowrap; margin-right: 2px; }
.chip-clear { background: #fff; border: 1px solid var(--ink-soft); font-weight: 600; }
.layers, .active-filters { grid-column: 1 / -1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
/* Layers: on = filled in brand colour with a ✓; off = white with a grey border and an empty box. Readable without colour. */
.layer {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none; min-height: 36px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 999px; padding: 4px 12px 4px 8px;
  cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.layer-check { width: 18px; height: 18px; flex: none; border-radius: 5px; border: 1.5px solid #9aa39b; background: #fff;
  display: grid; place-items: center; font-size: 0.75rem; line-height: 1; color: transparent; }
.layer-check::before { content: '✓'; }
.layer .swatch { --c: #9aa39b; }
.layer[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.layer[aria-pressed="true"] .layer-check { background: #fff; border-color: #fff; color: var(--brand); font-weight: 900; }
.layer[aria-pressed="true"] .swatch { --c: #fff; }
.layer[aria-pressed="false"] .layer-icon { filter: grayscale(1); opacity: 0.6; }
.layer:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.search-wrap { position: relative; }
#search, .tags-input input {
  width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234f5d52' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center;
}
.tags-input input { border-radius: 10px; padding-left: 12px; background-image: none; background-color: #fff; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1200; list-style: none; margin: 0; padding: 4px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 50vh; overflow-y: auto;
}
.suggest li { display: flex; gap: 10px; align-items: baseline; padding: 8px 14px; cursor: pointer; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--brand-soft); }
.suggest-icon { width: 1em; color: var(--ink-soft); }
.suggest-hint { margin-left: auto; font-size: 0.8rem; color: var(--ink-soft); white-space: nowrap; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--paper); }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.segmented button[aria-selected="true"] { background: var(--brand); color: #fff; }

.btn {
  border: 1px solid transparent; border-radius: 999px; padding: 8px 14px; min-height: 40px;
  cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn-primary { background: var(--accent); color: #2a2200; }
.btn-ghost { background: transparent; border-color: currentColor; color: inherit; }
.btn-help { width: 38px; padding: 0; justify-content: center; font-weight: 700; text-decoration: none; }
.btn-icon-text .btn-icon { font-weight: 800; }
#open-mine .btn-icon { display: none; }
.welcome { position: fixed; left: 50%; bottom: max(140px, calc(env(safe-area-inset-bottom) + 128px)); transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 40px 12px 14px; z-index: 1500; }
.welcome p { margin: 0; flex: 1 1 180px; }
.welcome .btn { min-height: 36px; padding: 6px 14px; text-decoration: none; }
.welcome-close { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.btn-outline { background: var(--card); border-color: var(--line); color: var(--brand); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #2a2200; font-size: 0.8rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.2rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--line); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; text-align: left; }

/* ---- Layout and views ---- */
.layout { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; }
.view-scroll { overflow-y: auto; padding: 12px 16px 24px; }
.map { position: absolute; inset: 0; background: #e9efe6; }
.floating-btn {
  position: absolute; z-index: 800; left: 50%; transform: translateX(-50%); bottom: 18px;
  border: 0; border-radius: 999px; padding: 10px 16px; background: var(--brand); color: #fff; font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
}
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 auto 12px; max-width: 1100px; flex-wrap: wrap; }
.inline-select { font-size: 0.9rem; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; }
.inline-select select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; }
.empty { text-align: center; color: var(--ink-soft); padding: 32px 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto; }
.card, .agenda-item {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line)); border-radius: 12px;
  padding: 12px; cursor: pointer;
}
.card:hover, .agenda-item:hover { border-color: var(--brand); border-left-color: var(--c); }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-title { font-weight: 700; }
.card-meta { font-size: 0.85rem; color: var(--ink-soft); }
.card-when { font-size: 0.88rem; font-weight: 600; }
.card-cat { display: inline-flex; gap: 6px; align-items: center; font-size: 0.82rem; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-mini { font-size: 0.75rem; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 1px 7px; }

#agenda { max-width: 760px; margin: 0 auto; }
.agenda-day { margin-bottom: 16px; }
.agenda-date { position: sticky; top: -12px; background: var(--paper); padding: 8px 0; font-size: 0.95rem; color: var(--ink-soft); z-index: 1; }
.agenda-item { margin-top: 8px; align-items: center; }
.date-badge { flex: none; width: 48px; text-align: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); padding: 4px 0; font-size: 0.75rem; line-height: 1.1; text-transform: uppercase; }
.date-badge strong { display: block; font-size: 1.3rem; }
.subscribe { position: relative; font-size: 0.9rem; }
.subscribe summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; padding: 6px 0; }
.subscribe summary::-webkit-details-marker { display: none; }
.subscribe-menu { position: absolute; right: 0; top: 100%; z-index: 5; display: grid; gap: 2px; width: min(320px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; }
.subscribe-menu a, .subscribe-menu .link-btn { display: block; padding: 10px 8px; border-radius: 8px; text-align: left; color: var(--ink); text-decoration: none; }
.subscribe-menu a:hover, .subscribe-menu .link-btn:hover { background: var(--brand-soft); }
.subscribe-menu .small { margin: 4px 8px 2px; font-size: 0.8rem; }

/* ---- Logos ---- */
.logo { position: relative; flex: none; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo-fallback { position: absolute; inset: 0; display: grid; place-items: center; background: var(--c, var(--brand)); color: #fff; font-weight: 700; font-size: 0.9rem; letter-spacing: 0.02em; }
.logo-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.logo-preview { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* ---- Panels ---- */
.panel { position: absolute; z-index: 1100; background: var(--card); box-shadow: var(--shadow); overflow-y: auto; padding: 8px 16px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: -8px; background: inherit; padding: 4px 0; z-index: 2; }
.panel h2 { font-size: 1.1rem; }
.panel-filters { top: 12px; left: 12px; width: 340px; max-height: calc(100% - 24px); border-radius: var(--radius); }
.list-people { max-width: 1100px; margin: 24px auto 0; }
.list-people-head { margin-bottom: 10px; }
.list-people-head h2 { font-size: 1.1rem; }
.list-people-head p { margin: 4px 0 0; }

/* The card (ficha): a window over everything, the rest dimmed. Centred on a computer, almost full screen on a phone. */
.sheet { border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: min(86dvh, 900px); border-radius: var(--radius);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: rgb(15 25 15 / 0.55); }
.sheet-inner { overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 20px; max-height: inherit; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 2;
  background: var(--card); padding: 12px 0 8px; margin-bottom: 4px; }
.sheet-head .tags { flex: 1; min-width: 0; }
.sheet-back { flex: none; padding-left: 8px; padding-right: 10px; }
.sheet-close { background: var(--paper); border: 1px solid var(--line); width: 44px; height: 44px; font-size: 1.25rem; }
.sheet .person { border: 0; padding: 0; }
.legal-links { font-size: 0.82rem; color: var(--ink-soft); margin: 14px 0 0; }
#town-filter { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

fieldset { border: 0; padding: 0; margin: 14px 0 0; }
legend { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; user-select: none; font-size: 0.9rem; background: var(--paper); white-space: nowrap; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked), .chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip-tag { color: var(--brand); }

/* ---- Markers: colour = category, shape = kind (readable without colour) ---- */
.pin { width: 26px; height: 26px; display: grid; place-items: center; position: relative; }
/* A municipality where initiatives act without a seat: its area is drawn soft and dashed, with this label in the centre */
.town-label-icon { background: none; border: 0; }
/* «Collado Villalba (5) 🤝 2»: the name of the municipality first; the number, what acts in all of it. */
.town-label { display: inline-flex; align-items: center; gap: 5px; transform: translate(-50%, -50%); padding: 3px 4px 3px 9px; white-space: nowrap;
  background: rgb(255 255 255 / 0.94); border: 1.5px dashed var(--brand); border-radius: 999px; box-shadow: var(--shadow);
  color: var(--brand); font-size: 0.74rem; line-height: 1.2; cursor: pointer; }
.town-label b { font-size: 0.78rem; }
.town-count { min-width: 19px; padding: 1px 6px; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 700; text-align: center; }
.town-people { padding-right: 5px; }
.towns-compact .town-label { padding: 1px 3px 1px 7px; gap: 4px; }
.towns-compact .town-label b { font-size: 0.66rem; font-weight: 600; }
.towns-compact .town-count { min-width: 16px; padding: 0 5px; font-size: 0.66rem; }
.towns-compact .town-people { font-size: 0.66rem; }
.town-label.is-short { padding: 1px; gap: 2px; }
.town-label.is-short b { display: none; }
.town-label.is-short .town-people { padding-right: 3px; }
.leaflet-marker-icon:focus-visible .town-label { outline: 2px solid var(--brand); outline-offset: 2px; }
.related .small { font-size: 0.82rem; margin: -2px 0 4px; }
.town-list { display: grid; gap: 8px; margin: 8px 0; }
/* An initiative without a seat, highlighted when its card is open: a dashed halo says «an area, not a point» */
.pin.is-area::before { content: ''; position: absolute; inset: -7px; border: 2px dashed var(--c); border-radius: 50%; background: color-mix(in srgb, var(--c) 15%, transparent); }
.scope-choice { display: grid; gap: 2px; margin: 6px 0; }
.scope-choice .check { margin: 6px 0; }
.pin span { display: block; width: 20px; height: 20px; background: var(--c); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.45); }
.pin.shape-circle span { border-radius: 50%; }
.pin.shape-square span { border-radius: 4px; }
.pin.shape-diamond span { width: 17px; height: 17px; transform: rotate(45deg); border-radius: 3px; }
.pin.is-selected span { outline: 3px solid var(--ink); outline-offset: 1px; }
/* The bubble over what is chosen on the map: kind, name, when and where, «Abrir ficha»; ✕ lets go of it. */
.bubble-popup .leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: var(--shadow); }
.bubble-popup .leaflet-popup-content { margin: 12px 40px 12px 14px; font: inherit; line-height: 1.3; }
.bubble-popup a.leaflet-popup-close-button { width: 36px; height: 36px; font-size: 24px; line-height: 34px; color: var(--ink-soft); top: 2px; right: 2px; }
.bubble { display: grid; gap: 4px; justify-items: start; }
.bubble-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-soft); }
.bubble-name { font-size: 0.98rem; color: var(--ink); }
.bubble-where { font-size: 0.82rem; color: var(--ink-soft); }
.bubble .btn { margin-top: 4px; }
/* What is chosen stands out: bigger, and a ring that pulses (still for those who prefer less motion). */
.pin.is-selected { transform: scale(1.3); }
.pin.is-selected::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid var(--ink);
  pointer-events: none; animation: pin-pulse 1.6s ease-out infinite; }
@keyframes pin-pulse { from { transform: scale(0.7); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin.is-selected::after { animation: none; opacity: 0.6; } }
/* A space: a triangle (white edge, then its colour), drawn with clip-path; the shadow goes on the pin. */
.pin.shape-triangle { filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.5)); }
.pin.shape-triangle span { position: relative; width: 26px; height: 23px; border: 0; box-shadow: none; background: #fff; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pin.shape-triangle span::after { content: ''; position: absolute; inset: 5px 4px 2.5px; background: var(--c); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pin.shape-triangle.is-selected span { outline: 0; background: var(--ink); }
.swatch { width: 12px; height: 12px; display: inline-block; flex: none; background: var(--c, var(--ink-soft)); border-radius: 50%; }
.swatch.shape-square { border-radius: 3px; }
.swatch.shape-diamond { transform: rotate(45deg) scale(0.85); border-radius: 2px; }
.swatch.shape-triangle { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background-color: rgb(31 77 43 / 0.28); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background-color: var(--brand); color: #fff; font-weight: 700; }

/* ---- Card (ficha) ---- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.card-head { display: flex; gap: 12px; align-items: center; margin: 6px 0 10px; }
#sheet-body h2 { font-size: 1.3rem; }
.organizer { margin: 4px 0 0; font-size: 0.9rem; color: var(--ink-soft); }
#sheet-body .desc { white-space: pre-line; margin: 0 0 12px; }
.facts { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.facts li { display: flex; gap: 8px; align-items: baseline; overflow-wrap: anywhere; }
.facts .k { flex: 0 0 auto; color: var(--ink-soft); font-size: 0.85rem; min-width: 64px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.card-actions .btn { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.related { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.related h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 6px; }
.related ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.features { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.feature { background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 3px 10px; font-size: 0.85rem; font-weight: 600; }
.card-features { display: flex; flex-wrap: wrap; gap: 4px; }
.feature-mini { font-size: 0.75rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 1px 7px; font-weight: 600; }
.how-to-join { background: #fff7d6; border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
.how-to-join h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 4px; }
.how-to-join p { margin: 0; white-space: pre-line; }
.feature-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.feature-choices label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 0.92rem; }
.feature-choices input { width: 16px; height: 16px; }
.feature-choices label.is-disabled { opacity: 0.45; }
.feature-choices .zone-choice { border-style: dashed; border-color: var(--brand); flex-basis: 100%; }
.feature-choices label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.updated { font-size: 0.8rem; color: var(--ink-soft); margin: 10px 0 4px; }
.contacts { display: grid; gap: 2px; }
.source { font-size: 0.8rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 8px; overflow-wrap: anywhere; }

/* ---- Dialog (login, form, mine) ---- */
.dialog { border: 0; border-radius: var(--radius); padding: 8px 20px 20px; width: min(600px, 100vw - 24px); max-height: calc(100dvh - 24px); box-shadow: var(--shadow); background: var(--card); }
.dialog::backdrop { background: rgb(15 25 15 / 0.45); }
.field { display: grid; gap: 4px; margin: 12px 0; min-width: 0; }
.field > span:first-child { font-weight: 600; font-size: 0.92rem; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.field textarea { min-height: 110px; resize: vertical; }
.field textarea.short { min-height: 70px; }
.hint { font-size: 0.8rem; color: var(--ink-soft); }
.error, .form-error { color: var(--danger); font-size: 0.85rem; display: block; }
.error:empty, .form-error:empty { display: none; }
.invalid input, .invalid select, .invalid textarea, .invalid .picker { border-color: var(--danger) !important; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.group { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 2px; margin: 14px 0; min-width: 0; }
.group legend { font-weight: 700; padding: 0 6px; }
.inline-input { display: flex; gap: 8px; }
.inline-input input { flex: 1; min-width: 0; }
.inline-input .btn { flex: none; }
.address-results { list-style: none; margin: -4px 0 8px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 2px; }
.address-results button { width: 100%; text-align: left; background: none; border: 0; padding: 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.address-results button:hover, .address-results button:focus-visible { background: var(--brand-soft); }
.picker-wrap { position: relative; }
.picker { height: 300px; border-radius: 10px; border: 1px solid var(--line); cursor: crosshair; }
.picker-done { display: none; }
.picker-wrap.is-expanded { position: fixed; inset: 0; z-index: 1000; background: var(--card); }
.picker-wrap.is-expanded .picker { height: 100%; border-radius: 0; border: 0; }
.picker-wrap.is-expanded .picker-done { display: block; position: absolute; z-index: 1000; left: 50%; transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); min-width: 140px; }
.picker-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: 0.88rem; }
/* Pins for the picker and for an address found from the main search */
.spot-pin { width: 22px; height: 30px; background: var(--accent, #c2410c); border-radius: 50% 50% 50% 0; transform: rotate(-45deg) scale(0.9);
  transform-origin: 50% 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 0.35); margin: 0 auto; }
.spot-pin.is-pick { width: 28px; height: 28px; background: var(--brand, #1f4d2b); margin-top: 2px; }
.spot-label { font-weight: 600; }
.map-button { width: 34px; height: 34px; background: #fff; border: 2px solid rgb(0 0 0 / 0.2); border-radius: 4px; font-size: 18px; line-height: 1; cursor: pointer; background-clip: padding-box; }
.map-button:hover { background: #f4f4f4; }
.tags-input { display: grid; gap: 6px; }
.suggest-inline { top: calc(100% + 2px); }
.code-input { font-size: 1.6rem !important; letter-spacing: 0.4em; text-align: center; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.demo-code { background: #fff7d6; border: 1px dashed var(--accent); padding: 8px 10px; border-radius: 10px; font-size: 0.9rem; }
.form-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }

/* Add flow: steps, kind choice, kind switch, contacts */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 4px 0 12px; counter-reset: step; font-size: 0.82rem; color: var(--ink-soft); }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 6px; }
.steps li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-weight: 700; }
.steps li + li::before { margin-left: 2px; }
.steps li + li { padding-left: 10px; border-left: 1px solid var(--line); }
.steps li.is-current { color: var(--ink); font-weight: 700; }
.steps li.is-current::before { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps li.is-done::before { content: '✓'; background: var(--brand-soft); }
.kind-choices { display: grid; gap: 10px; margin: 8px 0 14px; }
.kind-choice { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; text-align: left; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.kind-choice:hover, .kind-choice:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.kind-choice .swatch { grid-row: span 2; width: 18px; height: 18px; }
.kind-choice .kind-icon { grid-row: span 2; font-size: 1.2rem; width: 18px; text-align: center; }
.kind-choice strong { font-size: 1.05rem; }
.kind-choice span:last-child { color: var(--ink-soft); font-size: 0.88rem; }
.kind-switch { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kind-switch label { flex: 1; }
.kind-switch input { position: absolute; opacity: 0; pointer-events: none; }
.kind-switch label > span { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 9px 6px; cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.kind-switch label + label > span { border-left: 1px solid var(--line); }
.kind-switch input:checked + span { background: var(--brand); color: #fff; }
.kind-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.contact-rows { display: grid; gap: 8px; }
.contact-rows:empty { display: none; }
.contact-row { display: grid; grid-template-columns: 110px 1.4fr 1fr auto; gap: 6px; align-items: center; }
.contact-row select, .contact-row input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 0; }
.link-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 6px; align-items: center; }
.link-row input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 0; }
.field .btn-small { justify-self: start; }

/* Mis iniciativas */
.mine-group { margin: 14px 0; }
.mine-group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.mine-group h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 0; }
.mine-group .count { color: var(--ink-soft); font-weight: 400; }
.mine-main { min-width: 0; }
.mine-note { margin-top: 6px; font-size: 0.85rem; background: #fff7d6; border-radius: 8px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mine-list li.is-new { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.mine-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.mine-list li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mine-list .status { font-size: 0.78rem; color: var(--ink-soft); }
.mine-list li { flex-wrap: wrap; }
.mine-list .small { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
/* «Pasar a otra persona»: the email field opens under the card, the whole width. */
.hand-over { flex: 1 0 100%; border-top: 1px dashed var(--line); padding-top: 8px; }
.hand-over p { margin: 0 0 6px; font-size: 0.85rem; }
.hand-over-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hand-over-row input { flex: 1 1 200px; min-width: 0; }
.mine-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; z-index: 2000; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* ---- Mobile: one column toolbar, panels as bottom sheets, dialog full screen ---- */
@media (max-width: 720px) {
  .topbar { padding-bottom: 8px; }
  .brand { min-width: 0; }
  .brand h1 { font-size: 0.95rem; line-height: 1.15; }
  .brand-sub { display: none; }
  .brand-notice { font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .actions { gap: 6px; }
  .actions .btn { padding: 6px 10px; min-height: 36px; font-size: 0.85rem; }
  .actions .btn-help { width: 36px; padding: 0; }
  .toolbar { grid-template-columns: 1fr; padding: 8px 12px; gap: 8px; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding: 7px 10px; }
  .sheet { width: 100vw; max-width: 100vw; max-height: calc(100dvh - max(56px, env(safe-area-inset-top) + 40px)); margin: auto 0 0;
    border-radius: var(--radius) var(--radius) 0 0; }
  .sheet-inner { padding: 0 16px max(20px, env(safe-area-inset-bottom)); }
  .panel-filters {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 75%;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .picker { height: 260px; }
  .group { padding: 2px 10px 0; }
  .contact-row { grid-template-columns: 110px 1fr auto; }
  .contact-row input:nth-of-type(2) { grid-column: 1 / 3; }
  .contact-row .icon-btn { grid-row: 1; grid-column: 3; }
  .link-row { grid-template-columns: 1fr auto; }
  .link-row input:nth-of-type(2) { grid-column: 1 / 2; }
  .link-row .icon-btn { grid-row: 1; grid-column: 2; }
  .kind-choice { padding: 12px 14px; }
  .row { grid-template-columns: 1fr; }
  .mine-list li { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .hand-over { flex: none; }
  .mine-actions { justify-content: flex-start; }
  .view-scroll { padding: 10px 12px 24px; }
}

/* Phones: one row of header (the title can take two lines; the buttons become icons) to leave the screen to the map.
   The prototype notice moves to the welcome card and the guide. */
@media (max-width: 520px) {
  .topbar { padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); gap: 8px; }
  .brand h1 { font-size: 0.92rem; }
  .brand { column-gap: 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-notice { display: none !important; }
  .actions .btn-text { display: none; }
  .actions .btn, .actions .btn-help { width: 38px; height: 38px; min-height: 38px; padding: 0; font-size: 1rem; }
  #open-mine .btn-icon { display: inline; }
  #open-add .btn-icon { font-size: 1.4rem; line-height: 1; }
  #open-filters { padding: 6px 12px; min-height: 40px; }
  .layer { min-height: 34px; font-size: 0.85rem; padding: 3px 10px 3px 6px; }
  .toolbar { padding: 6px 12px; gap: 6px; }
  #search { padding-top: 8px; padding-bottom: 8px; }
  .segmented button { padding: 5px 10px; }
  .layer { min-height: 32px; }
  /* The five layers always in sight (they do not fit in one row): they wrap and share each row's width. */
  .layers { flex-wrap: wrap; gap: 6px; overflow: visible; }
  .layers .layer { flex: 1 1 auto; justify-content: center; gap: 5px; padding: 3px 8px 3px 5px; font-size: 0.82rem; }
  .layer { justify-content: flex-start; min-width: 0; }
  .long-only { display: none; }
  .floating-btn { bottom: max(14px, env(safe-area-inset-bottom)); padding: 9px 16px; }
  .town-label { padding: 2px 3px 2px 7px; font-size: 0.66rem; border-width: 1px; }
  .town-label b { font-size: 0.7rem; }
}

/* ---- Talents ---- */
.people-intro { max-width: 1100px; margin: 0 auto 10px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.people-intro p { margin: 0; flex: 1 1 320px; color: var(--ink-soft); }
.people-filters { max-width: 1100px; margin: 0 auto 12px; display: grid; gap: 6px; }
.people-filters .check { font-size: 0.88rem; }
.person { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 8px; align-content: start; }
.person.is-new { outline: 3px solid var(--brand); }
.person-head { display: flex; gap: 10px; align-items: center; }
.person-head h3 { margin: 0; font-size: 1.05rem; }
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; }
.person-about { margin: 0; }
.talents { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.talents li { display: flex; gap: 8px; align-items: flex-start; }
.talent-icon { width: 1.4em; text-align: center; flex: none; }
.talent-detail { display: block; font-size: 0.88rem; color: var(--ink-soft); }
.person-collab { margin: 0; font-size: 0.9rem; }
.person-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.9rem; }
.person-invite { border: 2px dashed var(--brand); background: transparent; }
.person-invite h3, .person-invite p { margin: 0; }
.talent-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 6px; align-items: start; }
.talent-row .talent-detail-input { grid-column: 1 / 3; }
.mine-person { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.more-details { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.more-details > summary { cursor: pointer; font-weight: 700; color: var(--brand); padding: 6px 0; }
.more-details > summary .muted { font-weight: 400; }

.report { margin: 4px 0 0; font-size: 0.82rem; }
.report .link-btn { color: var(--ink-soft); }

.availability { margin: 0; font-size: 0.88rem; }
.availability .now { color: var(--ink-soft); }
.availability .now.is-on { color: var(--brand); font-weight: 700; }
.verified { color: var(--brand); font-weight: 700; }
.unverified { color: var(--ink-soft); font-size: 0.85em; }
.mine-requests { background: var(--brand-soft); }
.mine-requests h3 { margin: 0 0 6px; }
