  :root {
    color-scheme: light;
    --paper: #f7f5ef;        /* fons cru */
    --surface: #fbfaf6;
    --ink: #2b2a24;          /* tinta càlida */
    --ink-2: #6b675c;
    --muted: #97927f;
    --hairline: #e4e0d2;
    --border: rgba(43,42,36,0.12);
    --green-deep: #2e4b1f;   /* verd fosc d'acció */
    --green: #5c8a3a;
    --buit: #a86a2c;         /* ocre-terra: contorn de l'escocell buit */
    --decau: #d19b3f;        /* ocre ple */
    --decau-ink: #8a6215;
    --mort: #7c3122;         /* rovell */
    --serif: "New Spirit", "Fraunces", Georgia, "Times New Roman", serif;
    --sans: "Founders Grotesk", "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* ---------- capçalera ---------- */
  header {
    padding: 14px 18px 10px;
    background: var(--paper);
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
  }
  header h1 {
    font-family: var(--serif);
    font-size: 27px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--green-deep);
  }
  header p {
    font-size: 12.5px;
    color: var(--ink-2);
    margin-top: 2px;
    letter-spacing: 0.01em;
  }
  .head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .info-btn {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--hairline);
    background: var(--surface);
    color: var(--green-deep);
    font-family: var(--serif);
    font-style: italic;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 2px;
  }
  .about-text { font-size: 14px; line-height: 1.55; color: var(--ink); }
  .about-text p { margin-bottom: 12px; }
  .about-text .obert {
    font-family: var(--serif);
    font-style: italic;
    color: var(--green-deep);
  }
  .about-text .nota {
    font-size: 12.5px;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 10px 12px;
  }
  .about-text a { color: var(--green-deep); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--hairline); }

  /* ---------- comptadors ---------- */
  .stats {
    background: var(--paper);
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
  }
  .stats-caption {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 11px;
    color: var(--ink-2);
    padding: 10px 16px 4px;
    letter-spacing: 0.02em;
  }
  .stats-caption strong { font-weight: 600; color: var(--green-deep); }
  .stats-row {
    display: flex;
    gap: 0;
    padding: 0 8px;
    overflow-x: auto;
  }
  .tile {
    flex: 1;
    min-width: 72px;
    padding: 7px 10px 11px;
    background: none;
    border: none;
    border-left: 1px solid var(--hairline);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    font-family: inherit;
  }
  .tile:first-child { border-left: none; }
  .tile.off { opacity: .35; }
  .tile .num {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.05;
    color: var(--ink);
  }
  .tile .lbl {
    font-size: 11px;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }
  .glif { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
  .glif.g-buit  { background: #8c8c8c; }
  .glif.g-plantat { background: var(--green); }
  .glif.g-decau { background: var(--decau); }
  .glif.g-mort  { background: var(--mort); }

  /* ---------- mapa ---------- */
  #map { flex: 1; min-height: 0; z-index: 0; background: var(--paper); }
  .leaflet-container { font: inherit; }
  .leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--hairline) !important;
  }
  .leaflet-control-attribution { background: rgba(247,245,239,.8) !important; font-size: 9px !important; }

  /* ---------- barra d'acció ---------- */
  .fab-row {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
    padding: 0 16px;
  }
  .fab-row > * { pointer-events: auto; }
  .fab {
    border: none;
    border-radius: 999px;
    padding: 15px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--sans);
    letter-spacing: 0.01em;
    background: var(--green-deep);
    color: #f7f5ef;
    box-shadow: 0 4px 18px rgba(46,75,31,.28);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .fab.small {
    padding: 15px 17px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(43,42,36,.10);
  }

  /* ---------- full modal ---------- */
  .sheet-back {
    position: fixed; inset: 0;
    background: rgba(43,42,36,.32);
    z-index: 1100;
    display: none;
    align-items: flex-end;
    justify-content: center;
  }
  .sheet-back.open { display: flex; }
  .sheet {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--hairline);
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    max-height: 88vh;
    overflow-y: auto;
  }
  .sheet h2 {
    font-family: var(--serif);
    font-size: 19px;
    font-weight: 600;
    color: var(--green-deep);
    margin-bottom: 4px;
  }
  .sheet .sub { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
  .photo-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--hairline);
    margin-bottom: 12px;
    background: var(--paper);
    display: none;
  }
  .geo-note {
    font-size: 12.5px;
    border-radius: 10px;
    padding: 9px 11px;
    margin-bottom: 12px;
    background: var(--paper);
    border: 1px solid var(--hairline);
    color: var(--ink-2);
    display: none;
    font-style: italic;
    font-family: var(--serif);
  }
  .geo-note.ok { display: block; }
  .type-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .type-btn {
    border: 1.5px solid var(--hairline);
    background: var(--surface);
    border-radius: 14px;
    padding: 12px 6px 10px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.01em;
  }
  .type-btn .ic {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
  }
  .type-btn[data-type="buit"] .ic  { background: #8c8c8c; }
  .type-btn[data-type="plantat"] .ic { background: var(--green); }
  .type-btn[data-type="decau"] .ic { background: var(--decau); color: #4a3000; }
  .type-btn[data-type="mort"] .ic  { background: var(--mort); color: #f7f5ef; }
  .type-btn.sel { border-color: var(--green-deep); box-shadow: 0 0 0 1.5px var(--green-deep); }
  .planta-row { display: flex; gap: 8px; margin-bottom: 10px; }
  .planta-btn {
    flex: 1;
    border: 1.5px solid var(--hairline);
    background: var(--surface);
    border-radius: 999px;
    padding: 9px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .planta-btn.sel { border-color: var(--green-deep); box-shadow: 0 0 0 1.5px var(--green-deep); font-weight: 600; }
  textarea, input[type="text"] {
    width: 100%;
    font-family: var(--sans);
    font-size: 16px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--ink);
    margin-bottom: 10px;
    resize: none;
  }
  textarea:focus, input:focus { outline: 2px solid var(--green); outline-offset: -1px; }
  .sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
  .btn {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 13px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    letter-spacing: 0.01em;
  }
  .btn.primary { background: var(--green-deep); color: #f7f5ef; }
  .btn.primary:disabled { opacity: .35; cursor: default; }
  .btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--hairline); }

  /* ---------- marcadors: punts, no agulles ---------- */
  .dotpin {
    width: 20px; height: 20px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(251,250,246,.9), 0 1px 5px rgba(43,42,36,.35);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--sans);
    font-size: 11px; font-weight: 800; line-height: 1;
  }
  .dotpin.d-buit  { background: #8c8c8c; }
  .dotpin.d-plantat { background: var(--green); }
  .dotpin.d-decau { background: var(--decau); color: #4a3000; }
  .dotpin.d-mort  { background: var(--mort); color: #f7f5ef; }

  /* ---------- popup ---------- */
  .leaflet-popup-content-wrapper {
    background: var(--surface) !important;
    border-radius: 12px !important;
    border: 1px solid var(--hairline);
    box-shadow: 0 4px 18px rgba(43,42,36,.18) !important;
  }
  .leaflet-popup-tip { background: var(--surface) !important; }
  .leaflet-popup-content { margin: 11px 13px; font: 13px/1.45 var(--sans); width: 210px !important; color: var(--ink); }
  .pop img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
  .pop .tag {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--serif);
    font-size: 14px; font-weight: 600; margin-bottom: 3px;
    color: var(--green-deep);
  }
  .pop .meta { color: var(--muted); font-size: 11.5px; margin-top: 4px; font-style: italic; font-family: var(--serif); }
  .pop .del {
    margin-top: 9px; font-size: 12px; color: var(--mort);
    background: none; border: none; padding: 0; cursor: pointer; font-family: var(--sans); font-weight: 600;
  }

  /* ---------- toast ---------- */
  #toast {
    position: fixed;
    top: 14px; left: 50%;
    transform: translateX(-50%);
    background: var(--green-deep); color: #f7f5ef;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 999px;
    z-index: 2000;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
    max-width: 86vw;
    text-align: center;
    letter-spacing: 0.01em;
  }
  #toast.show { opacity: 1; }

  /* mode "toca el mapa" */
  body.picking #map { cursor: crosshair; }
  #pickBanner {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1500;
    background: var(--green-deep);
    color: #f7f5ef;
    text-align: center;
    font-size: 13.5px;
    padding: 12px;
    font-family: var(--serif);
    font-style: italic;
  }
  body.picking #pickBanner { display: block; }

  /* ---------- botó de menú (⋯) a la capçalera ---------- */
  .menu-btn {
    font-family: var(--sans);
    font-style: normal;
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ---------- botons de foto (barra inferior) ---------- */
  .fab.photo {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 15px 10px;
    font-size: 14.5px;
    white-space: nowrap;
  }
  .fab.photo.ghost-fab {
    background: var(--surface);
    color: var(--green-deep);
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(43,42,36,.10);
  }

  /* ---------- interruptor Totes / Les meves (radio discret) ---------- */
  .scope-toggle {
    display: flex;
    gap: 18px;
    padding: 7px 16px 9px;
    border-bottom: 1px solid var(--hairline);
  }
  .scope-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink-2);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .scope-radio input {
    accent-color: var(--green-deep);
    width: 15px; height: 15px;
    margin: 0;
    cursor: pointer;
  }
  .scope-radio:has(input:checked) {
    color: var(--green-deep);
    font-weight: 600;
  }

  /* ---------- anell als pins propis ---------- */
  .dotpin.mine {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green-deep), 0 1px 5px rgba(43,42,36,.4);
  }
