/* Spots: a field tool. Readable in bright sun, big tap targets, blaze orange for "you are here". */

@font-face { font-family: 'Atkinson'; src: url(/fonts/atkinson-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(/fonts/atkinson-400-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(/fonts/atkinson-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(/fonts/barlow-condensed-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(/fonts/barlow-condensed-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --paper: #edf0ea;
  --surface: #f8faf6;
  --ink: #18231e;
  --spruce: #1d2a23;
  --moss: #3f5e48;
  --stone: #5d6862;
  --line: #cbd3cc;
  --blaze: #f25c05;
  --blaze-soft: #fde3d2;
  --danger: #b3261e;
  --focus: #2b6cb0;
  --body: 'Atkinson', system-ui, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --top: calc(52px + env(safe-area-inset-top));
  --tabs: calc(62px + env(safe-area-inset-bottom));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121815;
    --surface: #1a221e;
    --ink: #e4eae3;
    --moss: #8fb59a;
    --stone: #98a59d;
    --line: #2d3933;
    --blaze-soft: #3a2415;
    --danger: #ff8a80;
    --focus: #8ab4f8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--body);
  padding-top: var(--top);
  padding-bottom: calc(var(--tabs) + 24px);
  min-height: 100dvh;
}
a { color: var(--moss); text-underline-offset: 2px; }
h1, h2 { font-family: var(--cond); font-weight: 600; line-height: 1.1; margin: 0 0 .4em; letter-spacing: .005em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--stone); }
.small { font-size: .88rem; }
.hint { display: block; color: var(--stone); font-size: .88rem; font-weight: 400; margin-top: .3rem; }
.empty { color: var(--stone); }
.error-text { color: var(--danger); }
.danger-text { color: var(--danger) !important; }

/* ---- top bar and tabs ---- */
.top {
  position: fixed; inset: 0 0 auto; z-index: 1000;
  height: var(--top); padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--spruce); color: #edf0ea;
}
.title { flex: 1; font: 600 1.35rem/1 var(--cond); padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: inherit; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.sync { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); color: #d5ddd6; border: 0; border-radius: 99px; padding: 6px 12px; font: 500 .95rem var(--cond); cursor: pointer; }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: #79c28f; }
.sync[data-state=pending] i { background: var(--blaze); }
.sync[data-state=offline] i { background: #8b958f; }
.sync[data-state=busy] i { background: #f0c75e; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
@media (max-width: 380px) { .sync span { display: none; } }

.tabs {
  position: fixed; inset: auto 0 0; z-index: 1000;
  height: var(--tabs); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--stone); font: 500 .95rem var(--cond); }
.tabs svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.8; fill: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg [fill=none] { fill: none; }
.tabs svg path:not([fill]) { fill: none; }
.tabs a.on { color: var(--ink); }
.tabs a.on svg { color: var(--blaze); }

main { max-width: 680px; margin: 0 auto; padding: 16px; }
body[data-wide=yes] main { max-width: none; padding: 0; }

/* ---- buttons and forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 1rem var(--body); text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blaze); border-color: var(--blaze); color: #1a0e05; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .92rem; }
.btn.big { min-height: 52px; font-size: 1.1rem; width: 100%; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.linklike { background: none; border: 0; padding: 0; color: var(--moss); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: 46px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--moss); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--moss) 25%, transparent); }
label, .field { display: block; font-weight: 700; margin-bottom: 14px; }
label > input, label > textarea, label > select, label > .input-row { margin-top: 5px; font-weight: 400; }
.label { display: block; font-weight: 700; margin-bottom: 5px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.input-row.between { justify-content: space-between; margin-top: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; gap: 0; } }
.seg { border: 0; padding: 0; margin: 0 0 14px; display: flex; gap: 0; }
.seg legend { font-weight: 700; margin-bottom: 5px; }
.seg label { margin: 0; flex: 1; font-weight: 700; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { text-align: center; padding: 10px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; }
.seg label:first-of-type { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.seg label:last-of-type { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }
.seg label:has(input:checked) { background: var(--spruce); color: #edf0ea; border-color: var(--spruce); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); }
.group { border-left: 3px solid var(--blaze); padding-left: 12px; margin-bottom: 6px; }
.row-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.row-buttons.wrap { flex-wrap: wrap; justify-content: flex-start; }
.row-buttons.sticky { position: sticky; bottom: calc(var(--tabs) + 8px); background: var(--paper); padding: 10px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
details > summary { cursor: pointer; font-weight: 700; color: var(--moss); padding: 6px 0; }

/* ---- nearby ---- */
.here {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  background: var(--blaze); color: #1a0e05; margin: -16px -16px 16px; padding: 16px;
}
.here-label { margin: 0; font-weight: 700; font-size: .95rem; }
.here-name { display: block; font: 600 1.8rem/1.05 var(--cond); color: inherit; text-decoration: none; }
.here-btn { background: var(--spruce); color: #fff; border-color: var(--spruce); min-height: 52px; padding: 0 22px; font-size: 1.1rem; flex-shrink: 0; }
.search { margin-bottom: 10px; }
.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 10px; }
.notice p { margin: 0; font-size: .92rem; }
.loc-list { list-style: none; margin: 0; padding: 0; }
.loc-row {
  display: grid; grid-template-columns: 4.6rem 1fr auto; gap: 12px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.dist { font: 600 1.45rem/1 var(--cond); color: var(--ink); }
.loc-main { min-width: 0; }
.loc-name { display: block; font-weight: 700; }
.loc-sub { display: block; color: var(--stone); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-last { color: var(--stone); font-size: .82rem; text-align: right; max-width: 6.5rem; }
.tag { display: inline-block; font: 600 .82rem/1 var(--cond); padding: 3px 7px 2px; border-radius: 4px; background: var(--line); color: var(--ink); vertical-align: 2px; letter-spacing: .02em; }
.tag.private { background: var(--blaze-soft); color: color-mix(in srgb, var(--blaze) 70%, var(--ink)); }
.tag.public { background: color-mix(in srgb, var(--moss) 18%, transparent); color: var(--moss); }
.tag.ebird { background: color-mix(in srgb, var(--moss) 15%, transparent); color: var(--moss); }
.empty-state { text-align: center; padding: 48px 16px; color: var(--stone); list-style: none; }

/* ---- location ---- */
.cover { margin: -16px -16px 0; position: relative; background: var(--spruce); aspect-ratio: 16 / 9; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.none { aspect-ratio: auto; min-height: 0; background: none; margin: 0; }
.cover.none .cover-pick { position: static; padding: 0; margin-top: 16px; }
.cover-pick { position: absolute; right: 12px; bottom: 12px; }
.cover:not(.none) .cover-pick .btn { background: rgba(24,35,30,.75); color: #fff; border-color: transparent; min-height: 36px; font-size: .88rem; }
.loc-head { padding-top: 16px; }
.loc-head h1 { margin-bottom: .15em; }
.loc-place { color: var(--stone); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 16px 0; }
.facts dt { color: var(--stone); font-size: .92rem; padding-top: 1px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.block { border-top: 2px solid var(--line); padding-top: 14px; margin-top: 18px; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.block-head h2 { margin: 0; }
.count { font: 500 1.1rem var(--cond); color: var(--stone); margin-left: 4px; }
.notes { white-space: normal; overflow-wrap: anywhere; }
.owner-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 0; }
.species { list-style: none; padding: 0; margin: 8px 0 0; }
.species li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.species li > span:last-child { text-align: right; font-size: .9rem; }
.species.ebird li { display: block; }
.species.ebird li > span { display: block; text-align: left; }
.visit-list { list-style: none; padding: 0; margin: 0; }
.visit-list a { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.v-date { display: block; font: 600 1.2rem var(--cond); }
.v-sub { display: block; font-size: .9rem; color: var(--stone); }
.v-notes { display: block; font-size: .92rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.log-add { display: grid; gap: 8px; margin-bottom: 12px; }
.log-add input[type=date] { max-width: 12rem; }
.log-add .btn { justify-self: start; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.log-date { font: 600 1.05rem var(--cond); }
.danger-zone { margin-top: 36px; text-align: center; }

/* photos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: var(--line); cursor: pointer; overflow: hidden; border-radius: 3px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending-dot { position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--blaze); box-shadow: 0 0 0 2px #fff; }

/* ---- visit ---- */
.visit-head { margin-bottom: 12px; }
.visit-loc { font: 600 1.15rem var(--cond); text-decoration: none; }
.visit-head h1 { font-size: 1.8rem; margin: 2px 0 0; }
.weather { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin: 12px 0; }
.weather p { margin: 0; }
.wx-main { display: flex; align-items: center; gap: 14px; line-height: 1.25; }
.wx-temp { font: 600 2.8rem/1 var(--cond); }
.wx-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 8px 14px; margin: 12px 0 0; }
.wx-facts dt { font-size: .8rem; color: var(--stone); }
.wx-facts dd { margin: 0; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; gap: 8px; align-items: center; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 6px 12px; font: inherit; cursor: pointer; min-height: 38px; }
.chip span { color: var(--stone); font-size: .85rem; }
.add-sighting { display: grid; grid-template-columns: 1fr 6.5rem auto; gap: 8px; }
.add-sighting .btn { min-height: 46px; }

/* ---- more / admin ---- */
.menu { list-style: none; padding: 0; margin: 0; }
.menu a { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 700; text-decoration: none; color: var(--ink); }
.people { list-style: none; padding: 0; margin: 0; }
details.block { border-top: 0; }
.people li { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.people li.off { opacity: .6; }
.person .muted { display: block; }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.person-actions select { width: auto; min-height: 38px; padding: 6px 10px; }
.roles dt { font-weight: 700; margin-top: 8px; }
.roles dd { margin: 0; color: var(--stone); }

/* ---- sign in ---- */
.auth { max-width: 380px; margin: 24px auto; }
.brand-block { text-align: center; margin-bottom: 24px; }
.brand-block img { border-radius: 16px; }
.brand-block h1 { font-size: 2.6rem; margin: 8px 0 0; }
.brand-block p { color: var(--stone); }
.auth .hint { text-align: center; margin-top: 16px; }

/* ---- map ---- */
.bigmap { height: calc(100dvh - var(--top) - var(--tabs)); width: 100%; }
body[data-wide=yes] { padding-bottom: var(--tabs); }
.pinmap { height: 260px; border-radius: var(--r-md); overflow: hidden; border: 1.5px solid var(--line); }
.pin span { display: block; width: 22px; height: 22px; margin: 0 auto; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin-public span { background: #3f7d52; }
.pin-private span { background: var(--blaze); }
.pin-edit span { background: var(--blaze); width: 26px; height: 26px; }
.leaflet-container { font: 15px var(--body); }
.pop-name { font: 600 1.2rem var(--cond); color: var(--spruce) !important; }
.pop-sub { color: #5d6862; }

/* ---- sheets and toast ---- */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 14px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); }
dialog.sheet::backdrop { background: rgba(10, 16, 13, .55); }
.sheet-body { padding: 20px; }
.sheet-body p { margin-bottom: 14px; }
dialog.sheet.full { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; background: #0c110e; color: #e4eae3; }
.viewer { position: relative; height: 100%; display: flex; flex-direction: column; }
.viewer-img { flex: 1; min-height: 0; display: grid; place-items: center; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-bar { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.4); }
.viewer-bar .meta { color: #a9b5ad; font-size: .9rem; margin: 0 0 8px; }
.viewer-bar .caption { margin: 0 0 4px; }
.viewer-bar .btn { background: transparent; color: #e4eae3; border-color: #3a4740; }
.viewer-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 1.2rem; cursor: pointer; }
.viewer-nav { position: absolute; top: 40%; width: 44px; height: 64px; border: 0; background: rgba(0,0,0,.35); color: #fff; font-size: 2rem; cursor: pointer; }
.viewer-nav.prev { left: 0; border-radius: 0 8px 8px 0; }
.viewer-nav.next { right: 0; border-radius: 8px 0 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 14px); z-index: 3000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--spruce); color: #edf0ea; padding: 12px 18px; border-radius: var(--r-md);
  max-width: calc(100vw - 32px); width: max-content; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast { background: #2d3933; } .toast.error { background: #8c1d18; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
