/* Pomar — mobile-first styles.
   Touch targets ≥ 44px; inputs use 16px text so iOS doesn't zoom; icons are Lucide (static/icons/lucide.svg). */

@font-face {
  font-family: "Outfit";
  src: url("../vendor/fonts/outfit-latin-wght.fdf9c509a809.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Outfit";
  src: url("../vendor/fonts/outfit-latin-ext-wght.6a2414e384c3.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font-display: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;

  /* Brand: the logo's teal and ink */
  --brand: #6ecabb;
  --brand-light: #8ad8ca;
  --ink: #101820;

  --bg: #eef6f4;
  --bg-glow-1: rgb(110 202 187 / 40%);
  --bg-glow-2: rgb(244 162 97 / 14%);
  --surface: #ffffff;
  --surface-2: #e9f3f1;
  --field: #f7fbfa;
  --text: #101820;
  --muted: #5a6b6c;
  --border: #d3e4e0;
  --border-soft: rgb(16 24 32 / 7%);

  --primary: #0f766e;
  --primary-strong: #134e4a;
  --primary-soft: #d2f1eb;
  --primary-ring: rgb(15 118 110 / 28%);
  --on-primary: #ffffff;
  --accent: #e76f51;
  --accent-strong: #c8553d;
  --gold: #e9c46a;

  --grad-primary: linear-gradient(135deg, #10302f 0%, #135e57 45%, #1f8a7d 100%);
  --grad-bar: linear-gradient(120deg, #101820 0%, #12302f 35%, #1b6c63 75%, #2c9d8e 100%);
  --grad-brand: radial-gradient(ellipse at 50% 45%, #8ad8ca 0%, #7dd1c2 45%, #6ecabb 100%);
  --grad-accent: linear-gradient(135deg, #f4a261 0%, #e76f51 60%, #d64f3a 100%);
  --grad-gold: linear-gradient(135deg, #ffd97a 0%, #e9c46a 50%, #f4a261 100%);

  --ok-bg: #d7f2ea; --ok-text: #0f4d45;
  --err-bg: #fde4dd; --err-text: #8a2718;
  --warn-bg: #fff1cc; --warn-text: #6b4c00;

  --glass: rgb(255 255 255 / 78%);
  --glass-border: rgb(255 255 255 / 60%);
  --shadow-sm: 0 1px 2px rgb(16 24 32 / 6%), 0 2px 6px rgb(16 24 32 / 5%);
  --shadow: 0 1px 2px rgb(16 24 32 / 6%), 0 8px 24px -6px rgb(16 24 32 / 14%);
  --shadow-lg: 0 2px 6px rgb(16 24 32 / 8%), 0 18px 40px -12px rgb(16 24 32 / 28%);

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --appbar-h: 58px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-space: calc(var(--nav-h) + 22px + var(--safe-bottom));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1316;
    --bg-glow-1: rgb(110 202 187 / 14%);
    --bg-glow-2: rgb(231 111 81 / 8%);
    --surface: #121e21;
    --surface-2: #182a2c;
    --field: #0f191b;
    --text: #e4f2ef;
    --muted: #9ab3b0;
    --border: #23393a;
    --border-soft: rgb(255 255 255 / 6%);
    --primary: #6ecabb;
    --primary-strong: #8ad8ca;
    --primary-soft: #143836;
    --primary-ring: rgb(110 202 187 / 30%);
    --on-primary: #ffffff;
    --accent: #f08a6c;
    --ok-bg: #12332f; --ok-text: #b4e8de;
    --err-bg: #3a1a14; --err-text: #f7b5a6;
    --warn-bg: #3a2f0f; --warn-text: #f3d98a;
    --glass: rgb(18 30 33 / 78%);
    --glass-border: rgb(255 255 255 / 8%);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -6px rgb(0 0 0 / 50%);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 40%), 0 18px 40px -12px rgb(0 0 0 / 70%);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: var(--nav-space);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  background:
    radial-gradient(ellipse 80% 50% at 100% 0%, var(--bg-glow-1), transparent 60%),
    radial-gradient(ellipse 70% 40% at 0% 100%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; margin-top: 1.6em; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.icon {
  width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon.lg { width: 28px; height: 28px; }
.icon.xl { width: 40px; height: 40px; stroke-width: 1.6; }

/* Colour tones for kinds of records (TreeEvent.KIND_STYLE) and other accents */
.tone-amber { --tone: #d97706; } .tone-pink { --tone: #db2777; } .tone-purple { --tone: #7c3aed; }
.tone-red { --tone: #dc2626; } .tone-blue { --tone: #2563eb; } .tone-teal { --tone: #0d9488; }
.tone-green { --tone: #16a34a; } .tone-brown { --tone: #9a5b2e; } .tone-slate { --tone: #475569; }
.tone-indigo { --tone: #4f46e5; }
@media (prefers-color-scheme: dark) {
  .tone-amber { --tone: #fbbf24; } .tone-pink { --tone: #f472b6; } .tone-purple { --tone: #a78bfa; }
  .tone-red { --tone: #f87171; } .tone-blue { --tone: #60a5fa; } .tone-teal { --tone: #2dd4bf; }
  .tone-green { --tone: #4ade80; } .tone-brown { --tone: #d69e6c; } .tone-slate { --tone: #94a3b8; }
  .tone-indigo { --tone: #818cf8; }
}
.tone-chip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 14px;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, var(--surface));
}

/* ---------- App bar & bottom navigation ---------- */

.appbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 4px;
  height: calc(var(--appbar-h) + var(--safe-top)); padding: var(--safe-top) 8px 0;
  color: #fff;
  background:
    radial-gradient(circle at 88% -40%, rgb(255 255 255 / 22%), transparent 45%),
    radial-gradient(circle at 10% 140%, rgb(233 196 106 / 25%), transparent 40%),
    var(--grad-bar);
  box-shadow: 0 6px 20px -10px rgb(20 52 39 / 60%);
}
body:not(.map-page) .appbar { border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 4px; }
.appbar h1 {
  flex: 1; margin: 0 8px; font-size: 1.15rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.appbar a, .appbar button { color: inherit; }
.brand { flex: 1; display: flex; align-items: center; gap: 10px; margin-left: 8px; text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 8px; box-shadow: 0 2px 10px rgb(0 0 0 / 30%), 0 0 0 1px rgb(255 255 255 / 18%); }
.brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; letter-spacing: -.02em; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 14px;
  background: transparent; border: 0; text-decoration: none; cursor: pointer; font: inherit;
  transition: background .15s;
}
.icon-btn .icon { width: 22px; height: 22px; }
.appbar .icon-btn:hover, .appbar .icon-btn:active { background: rgb(255 255 255 / 16%); }

.bottomnav {
  position: fixed; z-index: 1000; left: 12px; right: 12px; bottom: calc(10px + var(--safe-bottom));
  max-width: 520px; margin: 0 auto; height: var(--nav-h); padding: 6px;
  display: flex; gap: 4px;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 24px;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 18px; color: var(--muted); text-decoration: none;
  font: 600 .72rem/1.1 var(--font-display); letter-spacing: .01em;
  transition: background .2s, color .2s;
}
.bottomnav a .icon { width: 23px; height: 23px; }
.bottomnav a[aria-current="page"] { color: var(--primary-strong); background: var(--primary-soft); }
.bottomnav a[aria-current="page"] .icon { stroke-width: 2.3; }

main.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- Messages ---------- */

.messages { list-style: none; margin: 0; padding: 0; }
.message {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 16px; margin-bottom: 10px;
  background: var(--ok-bg); color: var(--ok-text);
}
.message .icon { margin-top: 1px; }
.message.error { background: var(--err-bg); color: var(--err-text); }
.message.warning { background: var(--warn-bg); color: var(--warn-text); }
.toast-area { position: fixed; left: 12px; right: 12px; top: calc(var(--appbar-h) + var(--safe-top) + 8px); z-index: 1200; pointer-events: none; max-width: 560px; margin: 0 auto; }
.toast-area .message {
  pointer-events: auto; box-shadow: var(--shadow-lg); border: 1px solid var(--glass-border);
  animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.2), toast-out .4s ease 5s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); visibility: hidden; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 16px; border: 1px solid transparent;
  background: var(--grad-primary); color: var(--on-primary);
  font: 600 1rem/1.2 var(--font-display); letter-spacing: .01em; text-decoration: none; text-align: center;
  box-shadow: 0 8px 18px -8px rgb(16 48 47 / 60%), inset 0 1px 0 rgb(255 255 255 / 16%);
  cursor: pointer; transition: transform .12s ease, box-shadow .2s, filter .2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn .icon { width: 20px; height: 20px; }
.btn.secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn.secondary .icon { color: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); box-shadow: none; }
.btn.accent { background: var(--grad-accent); box-shadow: 0 8px 18px -8px rgb(214 79 58 / 60%), inset 0 1px 0 rgb(255 255 255 / 20%); }
.btn.danger { background: var(--grad-accent); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .9rem; border-radius: 13px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn, .btn-row > form { flex: 1 1 140px; }
.btn-row > form > .btn { width: 100%; }

.fab {
  position: fixed; z-index: 1001; right: 18px; bottom: calc(var(--nav-space) + 6px);
  width: 62px; height: 62px; border-radius: 22px; border: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none;
  background: var(--grad-accent);
  box-shadow: 0 12px 26px -8px rgb(214 79 58 / 70%), inset 0 1px 0 rgb(255 255 255 / 25%);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }
.fab .icon { width: 30px; height: 30px; stroke-width: 2.4; }

/* ---------- Cards & lists ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.list {
  list-style: none; margin: 0 0 16px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow);
}
.list > li + li { border-top: 1px solid var(--border-soft); }
.list a.row, .list .row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 60px;
  color: inherit; text-decoration: none; border-radius: 16px; transition: background .15s;
}
.list a.row:hover { background: var(--surface-2); }
.list a.row::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-left: auto;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); opacity: .6;
}
.row .grow { flex: 1; min-width: 0; }
.row .title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 15px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 1.45rem;
  background: color-mix(in srgb, var(--c, #6ecabb) 16%, var(--surface));
  color: var(--primary); font-family: var(--font-display); font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.orchard-card { display: block; color: inherit; text-decoration: none; transition: transform .15s, box-shadow .2s; }
.orchard-card:active { transform: scale(.99); }
.orchard-row { display: flex; align-items: center; gap: 14px; padding: 14px; }
.orchard-row .body { flex: 1; min-width: 0; }
.orchard-row .title { font-family: var(--font-display); font-size: 1.1rem; }
.outline-box {
  flex: none; width: 72px; height: 72px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgb(255 255 255 / 45%), transparent 50%),
    linear-gradient(135deg, #b9e8df, #8ad8ca 60%, #6ecabb);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 30%);
}
.outline-box svg { width: 54px; height: 54px; filter: drop-shadow(0 2px 3px rgb(16 48 47 / 35%)); }
.outline-box .icon { color: #fff; width: 34px; height: 34px; stroke-width: 1.8; }
.outline-box polygon { fill: rgb(255 255 255 / 70%); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; color: var(--muted); font-size: .85rem; }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.meta .icon { width: 15px; height: 15px; color: var(--primary); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); vertical-align: middle;
}
.badge.pending { background: var(--warn-bg); color: var(--warn-text); }
.badge.local { background: var(--ok-bg); color: var(--ok-text); }
.badge.dead, .badge.removed { background: var(--err-bg); color: var(--err-text); }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); }
.illustration { height: auto; }
.empty .illustration { width: 100%; max-width: 360px; margin: -8px auto 14px; border-radius: 18px; }
.empty .big { display: inline-flex; margin-bottom: 8px; }

dl.facts { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .88rem; display: flex; align-items: center; gap: 6px; }
dl.facts dd { margin: 0; font-weight: 500; }
dl.facts dt .icon { width: 16px; height: 16px; color: var(--primary); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.stats .stat {
  position: relative; overflow: hidden; padding: 16px; border-radius: var(--radius); color: #fff; text-decoration: none;
  background: var(--grad-primary); box-shadow: var(--shadow);
}
.stats .stat:nth-child(2) { background: var(--grad-accent); }
.stats .stat::after {
  content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%;
  background: rgb(255 255 255 / 14%);
}
.stats .num { display: block; font: 700 2rem/1 var(--font-display); margin-bottom: 4px; }

/* ---------- Forms ---------- */

form p { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url],
input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 50px; padding: 11px 14px;
  font: 16px/1.3 var(--font-body); color: var(--text);
  background: var(--field); border: 1.5px solid var(--border); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-ring); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); vertical-align: middle; }
input[type=color] { width: 64px; height: 46px; padding: 4px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--field); }
input[type=file] { font-size: 1rem; max-width: 100%; }
.helptext, .field .help { display: block; color: var(--muted); font-size: .84rem; margin-top: 6px; font-weight: 400; }
.errorlist { list-style: none; padding: 0; margin: 6px 0; color: var(--err-text); font-size: .9rem; font-weight: 600; }
.field { margin-bottom: 18px; }
.field.inline label { display: inline; margin-left: 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
details.more { margin: 8px 0 18px; border-top: 1px solid var(--border); }
details.more > summary {
  display: flex; align-items: center; gap: 8px; padding: 14px 0; cursor: pointer; list-style: none;
  font: 600 1rem var(--font-display); color: var(--primary);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: ""; width: 9px; height: 9px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s; margin: 0 4px 0 2px;
}
details.more[open] > summary::before { transform: rotate(45deg); }
.inline-details > summary { color: var(--primary); font-size: .9rem; padding: 8px 0; cursor: pointer; font-weight: 600; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; text-transform: uppercase; }
.input-row input::placeholder { text-transform: none; }
.search-field { position: relative; }
.search-field .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 46px; }
.compact-select { width: auto; min-height: 40px; padding: 4px 32px 4px 12px; font-size: .9rem; }

/* Checkbox/radio lists as tappable pills (months, uses, severity, stars, permissions) */
.pills, ul.pills, div.pills { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.pills > div, .pills > li { margin: 0; }
.pills label { margin: 0; font-weight: 500; }
.pills input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pills label, .pill {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.pills label:has(input:checked) { background: var(--grad-primary); color: #fff; border-color: transparent; box-shadow: 0 6px 14px -8px rgb(16 48 47 / 70%); }
.pills label:has(input:focus-visible) { outline: 3px solid var(--primary-ring); outline-offset: 2px; }
.stars label { font-size: 1.05rem; letter-spacing: -1px; color: #d9a400; }
.stars label:has(input:checked) { background: var(--grad-gold); color: #4a3200; }

/* Species picker: radio buttons as tiles tinted with the species colour */
.species-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; }
.species-picker > div { margin: 0; }
.species-picker label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; margin: 0;
  min-height: 92px; padding: 10px 6px; border-radius: 18px; border: 2px solid var(--border-soft);
  background: var(--surface); box-shadow: var(--shadow-sm);
  text-align: center; font-weight: 500; font-size: .85rem; line-height: 1.2; cursor: pointer;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.species-picker label:active { transform: scale(.97); }
.species-picker label .emoji {
  display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%;
  font-size: 1.6rem; line-height: 1; background: color-mix(in srgb, var(--c, #6ecabb) 18%, var(--surface));
}
.species-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.species-picker label:has(input:checked) {
  border-color: var(--c, var(--primary)); font-weight: 700;
  background: color-mix(in srgb, var(--c, #6ecabb) 10%, var(--surface));
  box-shadow: 0 8px 18px -10px var(--c, #1f8a7d);
}
.species-picker.collapsed > div:nth-child(n+7):not(:has(input:checked)) { display: none; }

/* ---------- Search & filters ---------- */

.searchbar {
  position: sticky; top: calc(var(--appbar-h) + var(--safe-top)); z-index: 5;
  margin: -8px -16px 8px; padding: 12px 16px 8px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters select { width: auto; min-height: 40px; padding: 6px 34px 6px 14px; border-radius: 999px; flex: none; font-size: .9rem; background-color: var(--surface); }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: 500 .9rem var(--font-body);
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm);
}
.chip[aria-pressed="false"] { opacity: .45; }
.chip .dot { width: 10px; height: 10px; border-radius: 5px; }

/* ---------- Photos ---------- */

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 16px; }
.photo-grid a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: var(--surface-2); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photo-grid a:hover img { transform: scale(1.05); }
.hero-photo {
  position: relative; display: block; margin: -20px -16px 18px; overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: var(--surface-2); box-shadow: var(--shadow);
}
.hero-photo img { width: 100%; max-height: 52vh; object-fit: cover; }
.hero-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 60%, rgb(0 0 0 / 25%)); pointer-events: none; }
.tree-hero {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 170px; margin: -20px -16px 18px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden;
  background: url("../img/orchard.dfb4e9668d89.svg") center 62% / cover no-repeat, var(--surface-2);
  box-shadow: var(--shadow);
}
.tree-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(rgb(0 0 0 / 0%), rgb(0 0 0 / 12%)); }
.tree-hero .emoji {
  position: relative; display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; border-radius: 50%;
  font-size: 3.2rem; background: color-mix(in srgb, var(--c, #6ecabb) 18%, rgb(255 255 255 / 75%));
  border: 3px solid rgb(255 255 255 / 85%); box-shadow: 0 14px 30px -10px rgb(0 0 0 / 50%);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.upload-preview { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.upload-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.camera-btn { position: relative; overflow: hidden; }
.camera-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-view { margin: -20px -16px 16px; background: #000; border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden; }
.photo-view img { width: 100%; max-height: 75vh; object-fit: contain; }
.uploading { opacity: .6; pointer-events: none; }

/* ---------- Timeline ---------- */

.timeline { position: relative; list-style: none; margin: 0; padding: 0; }
.timeline::before { content: ""; position: absolute; left: 19px; top: 18px; bottom: 18px; width: 2px; border-radius: 2px; background: var(--border); }
.timeline > li { position: relative; display: flex; gap: 14px; padding: 10px 0; }
.timeline .ico { position: relative; z-index: 1; box-shadow: 0 0 0 4px var(--bg); }
.timeline .ico .icon { width: 20px; height: 20px; }
.timeline .entry { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow-sm); }
.timeline .when { color: var(--muted); font-size: .82rem; }
.timeline .photo-grid { margin: 10px 0 4px; grid-template-columns: repeat(4, 1fr); }
.timeline.compact::before { display: none; }
.timeline.compact .ico { box-shadow: none; }
.timeline.compact > li { padding: 5px 0; align-items: center; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.quick-actions a, .quick-actions .quick-photo label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; margin: 0;
  min-height: 84px; padding: 8px 2px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border-soft); box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none; text-align: center; font: 500 .74rem/1.15 var(--font-body); cursor: pointer;
  transition: transform .12s;
}
.quick-actions a:active, .quick-actions .quick-photo label:active { transform: scale(.95); }
.quick-actions .tone-chip { width: 42px; height: 42px; }
.quick-actions .tone-chip .icon { width: 22px; height: 22px; }
.quick-actions .quick-photo label { background: var(--grad-accent); color: #fff; border: 0; box-shadow: 0 10px 20px -10px rgb(214 79 58 / 70%); }
.quick-actions .quick-photo .tone-chip { background: rgb(255 255 255 / 22%); color: #fff; }
.quick-actions .quick-photo .upload-preview { display: none; }

/* ---------- Maps ---------- */

.map-page { padding-bottom: 0; overflow: hidden; }
.map-page .map-wrap { position: fixed; left: 0; right: 0; top: calc(var(--appbar-h) + var(--safe-top)); bottom: 0; }
.map-page:not(.no-nav) .leaflet-bottom { bottom: calc(var(--nav-h) + 14px + var(--safe-bottom)); }
.map { width: 100%; height: 100%; background: #dfe7d9; }
.map-box { isolation: isolate; position: relative; height: 48vh; min-height: 280px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border-soft); }
.map-box .map { height: 100%; }
.mini-map-static { isolation: isolate; height: 210px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }

.crosshair { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; pointer-events: none; z-index: 900; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1.5px rgb(0 0 0 / 55%); }
.crosshair::before { left: 29px; top: 0; width: 2px; height: 60px; }
.crosshair::after { top: 29px; left: 0; height: 2px; width: 60px; }
.crosshair .ring { position: absolute; inset: 17px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px rgb(0 0 0 / 50%), inset 0 0 0 1.5px rgb(0 0 0 / 30%); }
.crosshair .ring::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #fff; }

.map-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 950;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -10px 30px -12px rgb(0 0 0 / 30%);
}
.map-panel .hint { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.status-line { font-size: .85rem; margin-bottom: 8px; min-height: 1.2em; }
.status-line.warn { color: var(--warn-text); background: var(--warn-bg); padding: 6px 10px; border-radius: 10px; }
.map-wrap.with-panel { display: flex; flex-direction: column; }
.map-wrap.with-panel .map-stage { position: relative; flex: 1; min-height: 0; }
.map-wrap.with-panel .map-panel { position: static; margin-top: -22px; }

.map-top-controls { position: absolute; top: 12px; left: 64px; right: 64px; z-index: 950; display: flex; gap: 8px; }
.map-top-controls .filters { flex: 1; }
.map-top-controls .chip { background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-color: var(--glass-border); }
.map-search { position: absolute; top: 12px; left: 60px; right: 60px; z-index: 950; }
.map-search input { min-height: 44px; border-radius: 14px; background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow); border-color: var(--glass-border); }
.map-search .results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.map-search .results:empty { display: none; }
.map-search .results button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; font-size: .9rem; }
.map-search .results button:hover { background: var(--surface-2); }

/* Bottom sheet (tree summary on the orchard map, tree form on the placement page) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(18px + var(--safe-bottom));
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -12px 40px -8px rgb(0 0 0 / 35%);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2, .9, .3, 1);
}
.sheet.open { transform: none; }
.sheet .grabber { display: block; width: 46px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; border: 0; padding: 0; cursor: pointer; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 1050; background: rgb(8 20 14 / 35%); display: none; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet-backdrop.open { display: block; }
.sheet .sheet-actions { position: sticky; bottom: calc(-18px - var(--safe-bottom)); background: var(--surface); padding: 12px 0 calc(8px + var(--safe-bottom)); margin-bottom: calc(-18px - var(--safe-bottom)); border-top: 1px solid var(--border-soft); }
.sheet-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.sheet-head .avatar { width: 64px; height: 64px; border-radius: 20px; font-size: 2rem; }
.sheet-head .title { font: 650 1.15rem/1.2 var(--font-display); }

/* Tree markers */
.tree-pin-icon { background: none; border: 0; }
.tree-pin {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; font-size: 15px; line-height: 1;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c, #1f8a7d) 45%, white), var(--c, #1f8a7d) 70%);
  border: 2.5px solid #fff; box-shadow: 0 4px 10px -2px rgb(0 0 0 / 50%), 0 0 0 1px rgb(0 0 0 / 10%);
}
.tree-pin.dead, .tree-pin.removed { filter: grayscale(1); opacity: .6; }
.tree-pin.planned { border-style: dashed; opacity: .85; }
.tree-pin.highlight { box-shadow: 0 0 0 4px rgb(255 214 102 / 90%), 0 4px 12px rgb(0 0 0 / 50%); }
.tree-pin .lbl {
  position: absolute; top: 31px; left: 50%; transform: translateX(-50%); display: none;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  background: rgb(15 30 20 / 72%); color: #fff; font: 600 11px/1.5 var(--font-display);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.show-labels .tree-pin .lbl { display: block; }
.vertex-icon { background: #fff; border: 3px solid var(--accent); border-radius: 50%; box-shadow: 0 2px 6px rgb(0 0 0 / 45%); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1e88e5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(30 136 229 / 25%), 0 1px 4px rgb(0 0 0 / 40%); }

/* Leaflet controls, restyled to match */
.leaflet-container { font: inherit; }
.leaflet-bar, .leaflet-control-layers {
  border: 1px solid var(--glass-border) !important; border-radius: 16px !important; overflow: hidden;
  box-shadow: var(--shadow) !important;
}
.leaflet-bar a {
  width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 20px !important;
  display: flex !important; align-items: center; justify-content: center;
  background: var(--glass) !important; color: var(--text) !important; border-bottom-color: var(--border-soft) !important;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.leaflet-bar a .icon { width: 22px; height: 22px; color: var(--primary); }
.leaflet-control-layers { background: var(--glass) !important; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--text); }
.leaflet-control-layers-toggle { width: 46px !important; height: 46px !important; }
.leaflet-control-layers-expanded { padding: 10px 14px !important; font-size: .95rem; }
.leaflet-control-attribution { border-radius: 10px 0 0 0; background: var(--glass) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--primary); }
.leaflet-control-scale-line { border-radius: 6px; background: var(--glass); }
@media (prefers-color-scheme: dark) { .leaflet-control-layers-toggle { filter: invert(1) hue-rotate(180deg); } }

/* ---------- Catalog ---------- */

.calendar { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin: 10px 0 6px; }
.calendar .m { text-align: center; font-size: .7rem; color: var(--muted); margin-top: 2px; }
.calendar .bar { height: 12px; border-radius: 6px; background: var(--surface-2); }
.calendar .bar.flowering { background: linear-gradient(135deg, #f9a8d4, #ec4899); }
.calendar .bar.ripening { background: linear-gradient(135deg, #fca5a5, #e76f51); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; }

/* ---------- Home ---------- */

.hero { text-align: center; padding: 6px 0 10px; }
.hero .illustration {
  width: 100%; border-radius: var(--radius-lg); margin-bottom: 18px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft);
}
.hero h1 { font-size: 2rem; }
.hero p { max-width: 36em; margin-left: auto; margin-right: auto; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: center; }
.steps .tone-chip { width: 42px; height: 42px; }

.lang-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lang-form button { font: inherit; }
.lang-form .chip[aria-pressed="false"] { opacity: 1; }
.lang-form button[aria-pressed="true"] { background: var(--grad-primary); color: #fff; border-color: transparent; }

table.simple { width: 100%; border-collapse: separate; border-spacing: 0; }
table.simple th, table.simple td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); }
table.simple th { font: 600 .85rem var(--font-display); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
table.simple tr:last-child td { border-bottom: 0; }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Misc ---------- */

.tree-list-overlay { position: absolute; inset: 0; z-index: 980; overflow-y: auto; background: var(--bg); }
.tree-list-overlay main.container { padding-bottom: calc(var(--nav-space) + 80px); }
.orchard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.catastro-box { padding: 14px; margin-bottom: 12px; }
#pick-parcel-btn[aria-pressed="true"] { background: var(--grad-primary); color: #fff; border-color: transparent; }
#pick-parcel-btn[aria-pressed="true"] .icon { color: #fff; }
.danger-text { color: var(--accent) !important; }
.section-title { display: flex; align-items: center; gap: 10px; }
.section-title .tone-chip { width: 34px; height: 34px; border-radius: 11px; }
.section-title .tone-chip .icon { width: 18px; height: 18px; }

.auth-page main.container { max-width: 460px; }
.auth-page main h1 { margin-top: 10px; }
.auth-page main form { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.auth-page main button[type=submit], .auth-page main button:not([type]) {
  width: 100%; min-height: 50px; margin-top: 8px; border: 0; border-radius: 16px;
  background: var(--grad-primary); color: #fff; font: 600 1rem var(--font-display);
  box-shadow: 0 8px 18px -8px rgb(16 48 47 / 60%); cursor: pointer;
}
.auth-page main form p { margin-bottom: 14px; }

@media (min-width: 900px) {
  .sheet { left: auto; right: 16px; width: 440px; bottom: 16px; border-radius: var(--radius-lg); max-height: calc(100dvh - var(--appbar-h) - 32px); }
  .sheet:not(.open) { transform: translateY(calc(100% + 40px)); }  /* lifted 16px, so 105% left a strip showing */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
#catastro-status:empty { display: none; }

/* ---------- One entry for several trees ---------- */

.kind-picker { margin-bottom: 18px; }
.kind-picker .pill { gap: 8px; padding-left: 6px; color: var(--text); text-decoration: none; font-weight: 500; }
.kind-picker .pill .tone-chip { width: 30px; height: 30px; border-radius: 999px; }
.kind-picker .pill .tone-chip .icon { width: 16px; height: 16px; }
.kind-picker .pill.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface)); font-weight: 700; }
.small-title { font-size: 1.05rem; margin: 22px 0 10px; }
.small-title > .icon { color: var(--primary); }
.select-map { height: 46vh; min-height: 260px; margin-bottom: 10px; }
.select-shortcuts { margin-bottom: 10px; }
.select-shortcuts .chip[aria-pressed="true"] { background: var(--grad-primary); color: #fff; border-color: transparent; }
.select-shortcuts .chip[aria-pressed="false"] { opacity: 1; }
.select-mode .tree-pin { transition: opacity .15s, filter .15s, transform .15s; }
.select-mode .tree-pin:not(.selected) { opacity: .55; filter: saturate(.4); }
.tree-pin.selected { box-shadow: 0 0 0 4px var(--accent), 0 4px 12px rgb(0 0 0 / 50%); transform: scale(1.12); }
.tree-pin.selected::after {
  content: "✓"; position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font: 700 11px/1 var(--font-body);
  background: var(--accent); color: #fff; border: 2px solid #fff;
}
.tree-checklist { margin-bottom: 10px; }
.tree-checklist > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px;
  font-weight: 600; cursor: pointer; list-style: none;
}
.tree-checklist > summary::-webkit-details-marker { display: none; }
.tree-checklist .check-list { margin: 0; border: 0; box-shadow: none; border-radius: 0; border-top: 1px solid var(--border-soft); max-height: 55vh; overflow-y: auto; }
.check-list label.row { cursor: pointer; margin: 0; font-weight: 400; min-height: 56px; }
.check-list label.row:has(input:checked) { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.check-list .avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 1.2rem; }
.sticky-submit {
  position: sticky; bottom: calc(var(--nav-space) - 8px); z-index: 5; margin: 18px -16px 0; padding: 12px 16px;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.fab-mini {
  position: fixed; z-index: 1001; right: 18px; bottom: calc(var(--nav-space) + 80px);
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px 0 12px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border); color: var(--text); text-decoration: none; font: 600 .9rem var(--font-display);
  box-shadow: var(--shadow);
}
.fab-mini .icon { color: var(--primary); }
.chip-label { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted); font-size: .85rem; font-weight: 600; padding-right: 2px; }
.chip-label .icon { width: 16px; height: 16px; }

/* Home page hero: the logo lockup on the brand teal */
.brand-hero {
  display: flex; align-items: center; justify-content: center; margin: -8px 0 18px; padding: 22px 18px 20px;
  border-radius: var(--radius-lg); background: var(--grad-brand); box-shadow: var(--shadow-lg);
}
.brand-hero img { width: min(60%, 280px); height: auto; }
/* "Align with the grid" suggestion while placing a tree */
.grid-btn {
  display: inline-flex; align-items: center; gap: 8px; margin: -2px 0 10px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1.5px dashed var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--surface));
  color: var(--text); font: 600 .9rem var(--font-display); cursor: pointer;
}
.grid-btn .icon { color: var(--primary); width: 18px; height: 18px; }

/* Aerial photo enhancement: level 1 (and above) is a colour/contrast filter on the photo tiles */
.map[data-enhance="1"] .pnoa-layer, .map[data-enhance="2"] .pnoa-layer {
  filter: contrast(1.12) saturate(1.22) brightness(1.03);
}
.enhance-control { position: relative; }
.enhance-control a { position: relative; }
.leaflet-container .enhance-control a.on { background: var(--grad-brand) !important; color: var(--ink) !important; }
.leaflet-container .enhance-control a.on .icon { color: var(--ink); }
.enhance-control .badge-level {
  position: absolute; right: 3px; bottom: 2px; font: 700 10px/1 var(--font-display); color: inherit;
}
.enhance-label {
  position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  width: max-content; max-width: min(230px, calc(100vw - 110px)); text-align: right;
  padding: 6px 11px; border-radius: 14px; background: rgb(16 24 32 / 82%); color: #fff; font: 600 12px/1.3 var(--font-display);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); pointer-events: none;
}
/* Upscaled tiles: on phones with fractional pixel ratios Chromium left a hairline at some tile edges, even
   with Leaflet's plus-lighter blending. These tiles are 257 px, with a real extra column and row from the
   neighbour (apps/orchards/tiles.py), drawn with normal blending, so neighbours simply overlap by 1px. */
.leaflet-container .pnoa-upscaled img.leaflet-tile { width: 257px !important; height: 257px !important; mix-blend-mode: normal !important; }
.enhance-menu {
  position: absolute; right: calc(100% + 8px); top: 0; width: min(290px, calc(100vw - 100px));
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border-soft); box-shadow: var(--shadow-lg);
}
.enhance-menu-title { padding: 6px 10px 4px; font: 700 .8rem var(--font-display); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.enhance-menu button {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px;
  background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer;
}
.enhance-menu button:hover { background: var(--surface-2); }
.enhance-menu button[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 22%, var(--surface)); }
.enhance-menu .n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); font: 700 12px var(--font-display); color: var(--muted); margin-top: 1px;
}
.enhance-menu button[aria-pressed="true"] .n { background: var(--brand); color: var(--ink); }
.enhance-menu strong { display: block; font: 600 .92rem var(--font-display); }
.enhance-menu small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.35; margin-top: 1px; }

/* ---------- Wide screens (desktop, 1024 px and up) ----------
   Same pages as on phones, arranged for a big screen: navigation in the top bar, wider pages, the
   orchard's tree list beside the map, a tree's details in a window in the middle, two-column tree page. */

.topnav { display: none; }

/* A tree's details in a window over the orchard map (opened from orchard-map.js on wide screens). */
.modal {
  width: min(1080px, calc(100vw - 48px)); max-height: calc(100dvh - 48px); padding: 0; border: 0;
  border-radius: var(--radius-lg); background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgb(8 20 14 / 45%); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#tree-dialog-body { display: contents; }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border-soft);
}
.modal-head .grow { flex: 1; min-width: 0; }
.modal-title { font: 700 1.15rem var(--font-display); }
.modal-head .icon-btn { color: var(--text); }
.modal-head .icon-btn:hover { background: var(--surface-2); }
.modal-content { overflow-y: auto; padding: 20px 24px 24px; }
.modal .hero-photo, .modal .tree-hero { margin: 0 0 18px; border-radius: var(--radius-lg); }

@media (min-width: 1024px) {
  :root { --nav-space: 24px; }
  .bottomnav { display: none; }
  .appbar { padding-left: 16px; padding-right: 16px; }
  .topnav { display: flex; gap: 4px; margin-left: auto; padding-left: 16px; }
  .topnav a {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 12px;
    color: rgb(255 255 255 / 82%); text-decoration: none; font: 600 .92rem var(--font-display);
  }
  .topnav a:hover { background: rgb(255 255 255 / 12%); color: #fff; }
  .topnav a[aria-current="page"] { background: rgb(255 255 255 / 20%); color: #fff; }
  .topnav .icon { width: 19px; height: 19px; }
  .map-page:not(.no-nav) .leaflet-bottom { bottom: 0; }

  body.wide main.container { max-width: 1180px; padding: 24px 32px; }

  /* Orchard: the tree list always beside the map */
  .orchard-map-wrap > .tree-list-overlay,
  .orchard-map-wrap > .tree-list-overlay[hidden] {
    display: block !important; position: absolute; left: 0; top: 0; bottom: 0; width: 400px; z-index: 5;
    border-right: 1px solid var(--border-soft); box-shadow: var(--shadow);
  }
  .orchard-map-wrap > .tree-list-overlay main.container { padding: 18px 18px 24px; }
  .orchard-map-wrap > #map { position: absolute; left: 400px; right: 0; top: 0; bottom: 0; width: auto; }
  .orchard-map-wrap .map-top-controls { left: 464px !important; }
  #view-toggle { display: none; }
  .orchard-map-wrap .list a.row[aria-current="true"] { background: var(--primary-soft); }

  /* Tree page (and the tree window): its data on the left, its records on the right */
  .tree-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .tree-side > .section-title:first-child { margin-top: 0; }
  body.wide .hero-photo, body.wide .tree-hero { margin: 0 0 18px; border-radius: var(--radius-lg); }

  /* Lists as grids of cards */
  .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 16px; }
  .card-grid > .card { margin: 0; }
  .card-grid + .btn.block { display: inline-flex; width: auto; padding: 0 28px; }
  body.wide #variety-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 6px; }
  body.wide #variety-rows > li + li { border-top: 0; }
  body.wide #variety-rows > li { border-bottom: 1px solid var(--border-soft); }

  /* Home: the logo beside the introduction */
  .home-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; margin-bottom: 12px; }
  .home-top .brand-hero { margin: 0; padding: 40px 24px; }
  .home-top .hero { text-align: left; }
  .home-top .hero p { margin-left: 0; }
}

/* Planting rows on the suggestions page */
.rows-tool { margin: 10px 0; padding: 12px 14px; }
.rows-head { display: flex; align-items: center; gap: 8px; }
.rows-head .icon { color: var(--primary); }
.rows-tool p { margin: 6px 0 10px; }
.rows-count { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rows-count label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.rows-count input { width: 80px; }
.map.picking { cursor: crosshair; }
.leaflet-interactive.row-hit { cursor: pointer; }
.map.picking .suggestion-crown, .map.picking .suggestion-dot { cursor: crosshair; }
/* The photo moved to match the LiDAR (tree-suggest.js sets the offset in pixels for the current zoom) */
.map .pnoa-layer { translate: var(--photo-shift-x, 0px) var(--photo-shift-y, 0px); }
.leaflet-tooltip.row-label {
  background: rgb(16 24 32 / 78%); color: #fff; border: 0; border-radius: 999px; box-shadow: none;
  font: 700 11px/1.4 var(--font-display); padding: 0 6px;
}
.leaflet-tooltip.row-label::before { display: none; }

/* The tree form now lives inside the panel: keep the panel (and the sheet sliding up from it) above the
   map's own controls. */
.workspace-place .map-panel { z-index: 1001; }

/* ---------- Desktop workspace: map pages ----------
   The map fills the screen to the right; a column on the left holds the page's title, status and tools,
   scrolling on its own, with the main action pinned to its bottom. Phones keep the stacked layout. */
@media (min-width: 1024px) {
  :root { --ws-panel: 420px; --ws-top: calc(var(--appbar-h) + var(--safe-top)); }
  body.workspace, body.workspace-place { overflow: hidden; }
  body.workspace .appbar, body.workspace-place .appbar { border-radius: 0; margin-bottom: 0; }

  body.workspace main.container {
    position: fixed; top: var(--ws-top); left: 0; bottom: 0; width: var(--ws-panel); max-width: none;
    margin: 0; padding: 20px 22px 0; overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg); border-right: 1px solid var(--border-soft); box-shadow: var(--shadow);
  }
  body.workspace .ws-map {
    position: fixed; top: var(--ws-top); left: var(--ws-panel); right: 0; bottom: 0;
    height: auto; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none;
  }
  body.workspace .sticky-submit { bottom: 0; margin: 18px -22px 0; padding: 14px 22px 18px; }
  body.workspace .select-shortcuts { flex-wrap: wrap; overflow: visible; }

  /* New tree / move tree: the buttons and the tree form in the left column */
  body.workspace-place .map-wrap.with-panel { left: var(--ws-panel); }
  body.workspace-place .map-wrap.with-panel .map-stage { height: 100%; }
  body.workspace-place .map-wrap.with-panel .map-panel {
    position: fixed; top: var(--ws-top); left: 0; bottom: 0; width: var(--ws-panel); margin: 0;
    padding: 20px 22px; overflow-y: auto; border-radius: 0; box-shadow: var(--shadow);
    border-right: 1px solid var(--border-soft);
  }
  body.workspace-place .map-panel .btn-row { flex-direction: column; }
  body.workspace-place .map-panel .btn-row > .btn { flex: none; width: 100%; }
  body.workspace-place .map-panel .sheet {
    position: static; transform: none !important; width: auto; max-height: none; overflow: visible;
    margin: 18px 0 0; padding: 18px 0 0; border-radius: 0; box-shadow: none; background: transparent;
    border-top: 1px solid var(--border-soft);
  }
  body.workspace-place .map-panel .sheet .grabber,
  body.workspace-place .sheet-backdrop { display: none !important; }
  body.workspace-place .map-panel .sheet .sheet-actions { bottom: -20px; margin: 0 -22px -20px; padding: 14px 22px 18px; }
  body.workspace-place .map-panel .sheet .sheet-actions.btn-row { flex-direction: row; }
}

/* Desktop: plain pages (forms, sharing, records) on a card instead of a bare column */
@media (min-width: 1024px) {
  body:not(.wide):not(.workspace):not(.map-page):not(.auth-page) main.container {
    max-width: 780px; margin: 28px auto 40px; padding: 28px 40px 32px;
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  }
  body:not(.wide):not(.workspace):not(.map-page):not(.auth-page) main.container .card { box-shadow: none; background: var(--surface-2); }
}

/* Navigation: phones get a back arrow and the page title; wide screens get breadcrumbs */
.crumbs { display: none; }
@media (min-width: 1024px) {
  .appbar .back-btn, .appbar .page-title { display: none; }
  .crumbs {
    display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0;
    color: rgb(255 255 255 / 72%); font: 600 .95rem var(--font-display);
  }
  .crumbs a { color: inherit; text-decoration: none; padding: 6px 8px; border-radius: 10px; white-space: nowrap; }
  .crumbs a:hover { background: rgb(255 255 255 / 12%); color: #fff; }
  .crumbs .crumb-brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding-left: 0; }
  .crumbs .crumb-brand img { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px rgb(255 255 255 / 18%); }
  .crumbs .sep { opacity: .5; }
  .crumbs .crumb-current { color: #fff; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Long press on the orchard map: a ring grows under the finger until it fires (orchard-map.js) */
.press-ring {
  position: absolute; z-index: 800; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  border: 3px solid var(--brand); background: rgb(110 202 187 / 18%); pointer-events: none;
  animation: press-grow linear forwards;
}
@keyframes press-grow { from { transform: scale(0.3); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .press-ring { animation: none; } }
.leaflet-container { -webkit-touch-callout: none; }
