/* LichenMeter — mobile-first field app. Navy app bar, white cards, one accent blue. */

/* vendored map styles (Leaflet + marker clustering) */
@import url('../vendor/leaflet.css');
@import url('../vendor/leaflet-markercluster.css');

/* ===================================================================
   Design tokens
   =================================================================== */
:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --text: #0d1b2a;
  --muted: #52637a;
  --border: #d6dee9;
  --border-strong: #aebcce;

  --appbar: #0b2a4a;
  --appbar-2: #14467a;
  --appbar-text: #ffffff;
  --appbar-muted: #b9cbe2;

  --primary: #0b63c5;
  --primary-hover: #0951a3;
  --primary-soft: #e2edfb;
  --primary-text: #ffffff;
  --accent: #8fd694;
  --accent-text: #06301a;
  --focus: #2b7cff;

  --ok-bg: #e2f6e7;
  --ok-text: #155c2b;
  --warn-bg: #fff3d6;
  --warn-text: #6b4500;
  --error-bg: #fde4e4;
  --error-text: #8a1111;

  --foliose: #22c55e;
  --crustose: #f97316;
  --bark: #7c5a3a;
  --stage-bg: #12202f;

  --aq-veryPoor: #c62828;
  --aq-poor: #ef6c00;
  --aq-moderate: #d4a106;
  --aq-good: #5f9e2f;
  --aq-veryGood: #1f7a3a;

  --shadow-sm: 0 1px 2px rgb(13 27 42 / 0.06);
  --shadow: 0 1px 2px rgb(13 27 42 / 0.06), 0 6px 18px rgb(13 27 42 / 0.07);
  --shadow-lg: 0 10px 30px rgb(11 42 74 / 0.18);

  --radius: 16px;
  --radius-sm: 12px;
  --tap: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #08121f;
    --surface: #101d30;
    --surface-2: #15253c;
    --text: #e8eef7;
    --muted: #9fb1c9;
    --border: #22354f;
    --border-strong: #375073;
    --appbar: #061223;
    --appbar-2: #0d2a4c;
    --appbar-text: #ffffff;
    --appbar-muted: #93a9c6;
    --primary: #5aa9ff;
    --primary-hover: #82bfff;
    --primary-soft: #132e4f;
    --primary-text: #04182e;
    --accent: #8fd694;
    --accent-text: #06301a;
    --focus: #8cc2ff;
    --ok-bg: #0f3320;
    --ok-text: #aef0c3;
    --warn-bg: #3a2c05;
    --warn-text: #ffe08a;
    --error-bg: #3d1212;
    --error-text: #ffc4c4;
    --stage-bg: #02070e;
    --aq-veryPoor: #ff6b6b;
    --aq-poor: #ffa04d;
    --aq-moderate: #f5cf4a;
    --aq-good: #a3d977;
    --aq-veryGood: #5fd38a;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #08121f;
  --surface: #101d30;
  --surface-2: #15253c;
  --text: #e8eef7;
  --muted: #9fb1c9;
  --border: #22354f;
  --border-strong: #375073;
  --appbar: #061223;
  --appbar-2: #0d2a4c;
  --appbar-text: #ffffff;
  --appbar-muted: #93a9c6;
  --primary: #5aa9ff;
  --primary-hover: #82bfff;
  --primary-soft: #132e4f;
  --primary-text: #04182e;
  --accent: #8fd694;
  --accent-text: #06301a;
  --focus: #8cc2ff;
  --ok-bg: #0f3320;
  --ok-text: #aef0c3;
  --warn-bg: #3a2c05;
  --warn-text: #ffe08a;
  --error-bg: #3d1212;
  --error-text: #ffc4c4;
  --stage-bg: #02070e;
    --aq-veryPoor: #ff6b6b;
    --aq-poor: #ffa04d;
    --aq-moderate: #f5cf4a;
    --aq-good: #a3d977;
    --aq-veryGood: #5fd38a;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

/* ===================================================================
   Base
   =================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

lm-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg);
}
@media (min-width: 761px) {
  lm-app {
    box-shadow: 0 0 0 1px var(--border);
  }
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 1.25rem;
}
h2 {
  font-size: 1.125rem;
  width: 100%;
}
p {
  margin: 0;
}
textarea {
  resize: vertical;
}
a {
  color: var(--primary);
}

.ico {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}

[hidden] {
  display: none !important;
}

/* ===================================================================
   App bar, tabs, wizard header, bottom bar
   =================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--appbar), var(--appbar-2));
  color: var(--appbar-text);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.brand img {
  border-radius: 9px;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.18);
}
.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .icon-btn {
  border-color: rgb(255 255 255 / 0.22);
  background: rgb(255 255 255 / 0.08);
  color: var(--appbar-text);
}
.topbar .icon-btn:hover {
  background: rgb(255 255 255 / 0.16);
}

.tabbar {
  position: sticky;
  top: calc(56px + max(8px, env(safe-area-inset-top)));
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 4px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.tab .ico {
  width: 22px;
  height: 22px;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.wizard-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.wizard-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wizard-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}
.wizard-icon .ico {
  width: 22px;
  height: 22px;
}
.wizard-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.wizard-head h2 {
  font-size: 1.35rem;
}
.progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress li {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.2s;
}
.progress li.done {
  background: var(--primary);
}
.progress li.current {
  background: linear-gradient(90deg, var(--primary) 50%, var(--border) 50%);
}

main {
  flex: 1;
  padding: 16px 16px 112px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
main:focus {
  outline: none;
}
main > * {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.bottombar .btn {
  flex: 1;
}
.bottombar .btn-primary {
  flex: 1.6;
}

/* ===================================================================
   Cards & layout helpers
   =================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel > h2 {
  font-size: 1.05rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===================================================================
   Controls
   =================================================================== */
.btn,
.icon-btn {
  min-height: var(--tap);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  touch-action: manipulation;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn:active,
.icon-btn:active {
  transform: translateY(1px);
}
.icon-btn {
  min-width: var(--tap);
  padding: 0;
  border-radius: 50%;
}
.icon-btn .ico {
  width: 22px;
  height: 22px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-text);
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-accent:hover {
  background: color-mix(in srgb, var(--accent) 85%, #fff);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-on-dark {
  background: rgb(255 255 255 / 0.1);
  border-color: rgb(255 255 255 / 0.4);
  color: #fff;
}
.btn-on-dark:hover {
  background: rgb(255 255 255 / 0.18);
  border-color: #fff;
  color: #fff;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover {
  background: var(--primary-soft);
  border-color: transparent;
}
.btn-lg {
  min-height: 54px;
  font-size: 1.02rem;
}
.btn-block {
  width: 100%;
}
label.btn {
  flex-direction: row;
  font-size: 1rem;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-row > .btn {
  flex: 1 1 auto;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
}
label.check input {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--primary);
}

input,
textarea,
select {
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  width: 100%;
  outline-offset: 2px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
  outline: none;
}
input[type='range'] {
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--primary);
}
label output {
  font-weight: 700;
  color: var(--primary);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
legend {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
  padding: 0;
}

/* segmented control: pill track with a raised selected item */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: calc(var(--radius-sm) + 4px);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
/* a visible legend sits above the track, not inside it */
.segmented:has(> legend:not(.sr-only)) {
  position: relative;
  margin-top: 28px;
}
.segmented > legend:not(.sr-only) {
  position: absolute;
  top: -28px;
  left: 0;
}
.segmented label {
  flex: 1;
  font-size: 0.95rem;
}
.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.segmented span:hover {
  color: var(--text);
}
.segmented input:checked + span {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  box-shadow: var(--shadow);
}
.segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
/* a segmented control used as a top-level step chooser */
main > * > .segmented {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
main > * > .segmented input:checked + span {
  background: var(--primary);
  color: var(--primary-text);
}

/* ===================================================================
   Feedback
   =================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
}
.alert .ico {
  margin-top: 1px;
}
.alert-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}
.alert-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}
.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}
.status:empty {
  display: none;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.4;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.chip .ico {
  width: 14px;
  height: 14px;
}
.chip-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: transparent;
}

dialog {
  width: min(92vw, 480px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: rgb(4 12 24 / 0.6);
  backdrop-filter: blur(2px);
}
dialog h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
dialog ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===================================================================
   Step guide
   =================================================================== */
.step-help {
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.step-help-intro {
  display: flex;
  gap: 10px;
  font-weight: 600;
}
.step-help-intro .ico {
  color: var(--primary);
  margin-top: 2px;
}
.step-help summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.92rem;
  list-style: none;
}
.step-help summary::-webkit-details-marker {
  display: none;
}
.step-help summary::before {
  content: '';
  width: 8px;
  height: 8px;
  margin: 0 6px 0 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.step-help details[open] > summary::before {
  transform: rotate(45deg);
}
.step-help details > :not(summary) {
  margin-left: 4px;
}
.step-help h3 {
  margin: 10px 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.step-help ol {
  margin: 0;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.step-help dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step-help dt {
  font-weight: 700;
}
.step-help dd {
  margin: 2px 0 0;
  color: var(--muted);
}

/* ===================================================================
   Home
   =================================================================== */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 24px 20px;
  border-radius: calc(var(--radius) + 4px);
  background:
    radial-gradient(120% 90% at 100% 0%, rgb(143 214 148 / 0.25), transparent 60%),
    linear-gradient(135deg, var(--appbar), var(--appbar-2));
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.hero-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero-title {
  font-size: 1.65rem;
  line-height: 1.15;
}
.hero-sub {
  color: var(--appbar-muted);
  max-width: 34ch;
}
.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.hero-art {
  flex: none;
  width: 128px;
  height: 128px;
  border-radius: 24px;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.12);
}
@media (max-width: 440px) {
  .hero-art {
    position: absolute;
    right: 14px;
    top: 16px;
    width: 64px;
    height: 64px;
    border-radius: 14px;
  }
  .hero-kicker,
  .hero-title {
    padding-right: 72px;
  }
  .hero-title {
    font-size: 1.45rem;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat strong {
  font-size: 1.6rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.stat span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.tiles {
  display: grid;
  gap: 10px;
}
@media (min-width: 560px) {
  .tiles {
    grid-template-columns: 1fr 1fr;
  }
}
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    transform 0.1s;
}
.tile:hover {
  border-color: var(--primary);
}
.tile:active {
  transform: scale(0.99);
}
.tile-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 14px;
}
.tile-icon .ico {
  width: 24px;
  height: 24px;
}
.tile-icon-blue {
  background: var(--primary-soft);
  color: var(--primary);
}
.tile-icon-green {
  background: var(--ok-bg);
  color: var(--ok-text);
}
.tile-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.tile-text strong {
  font-size: 1.02rem;
}
.tile-text small {
  color: var(--muted);
  font-size: 0.85rem;
}
.tile-arrow {
  color: var(--muted);
}

.how-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.how-steps li {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 8px 0;
}
.how-steps li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 21px;
  top: 52px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}
.how-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}
.how-icon b {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 0.7rem;
  box-shadow: 0 0 0 2px var(--surface);
}
.how-steps li > span:last-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.how-steps small {
  color: var(--muted);
  font-size: 0.86rem;
}
.home-note {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  padding: 0 4px;
}
.home-note .ico {
  color: var(--ok-text);
  margin-top: 2px;
}

/* ===================================================================
   Air quality card (Save step)
   =================================================================== */
.aq {
  border-top: 4px solid var(--aq-color, var(--primary));
}
.aq:has(.aq-main[data-level='veryPoor']) {
  --aq-color: var(--aq-veryPoor);
}
.aq:has(.aq-main[data-level='poor']) {
  --aq-color: var(--aq-poor);
}
.aq:has(.aq-main[data-level='moderate']) {
  --aq-color: var(--aq-moderate);
}
.aq:has(.aq-main[data-level='good']) {
  --aq-color: var(--aq-good);
}
.aq:has(.aq-main[data-level='veryGood']) {
  --aq-color: var(--aq-veryGood);
}
.aq-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.aq-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--aq-color, var(--primary)) 16%, var(--surface));
  color: var(--aq-color, var(--primary));
}
.aq-badge .ico {
  width: 22px;
  height: 22px;
}
.aq-main {
  display: flex;
  align-items: center;
  gap: 16px;
}
.aq-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: none;
  color: var(--aq-color);
}
.aq-score strong {
  font-size: 3rem;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.aq-score span {
  color: var(--muted);
  font-weight: 700;
}
.aq-verdict strong {
  font-size: 1.2rem;
  color: var(--aq-color);
}
.aq-verdict p {
  color: var(--muted);
  font-size: 0.9rem;
}
.aq-scale {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  margin-top: 14px;
}
.aq-scale span {
  height: 10px;
}
.aq-scale span:first-child {
  border-radius: 5px 0 0 5px;
}
.aq-scale span:nth-child(5) {
  border-radius: 0 5px 5px 0;
}
.aq-scale [data-level='veryPoor'] {
  background: var(--aq-veryPoor);
}
.aq-scale [data-level='poor'] {
  background: var(--aq-poor);
}
.aq-scale [data-level='moderate'] {
  background: var(--aq-moderate);
}
.aq-scale [data-level='good'] {
  background: var(--aq-good);
}
.aq-scale [data-level='veryGood'] {
  background: var(--aq-veryGood);
}
.aq-scale i {
  position: absolute;
  top: -5px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--aq-color);
  box-shadow: var(--shadow);
}
.aq-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.aq-breakdown {
  display: grid;
  grid-template-columns: max-content 1fr;
  margin: 14px 0 0;
  font-size: 0.92rem;
}
.aq-breakdown dt,
.aq-breakdown dd {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.aq-breakdown dt {
  color: var(--muted);
}
.aq-breakdown dd {
  margin: 0;
  padding-left: 16px;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.aq-breakdown > :nth-last-child(-n + 2) {
  border-bottom: 0;
}
[data-result] > .alert {
  margin-top: 10px;
}
.aq-more {
  border-top: 1px solid var(--border);
  padding-top: 4px;
}
.aq-more summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.92rem;
  list-style: none;
}
.aq-more summary::-webkit-details-marker {
  display: none;
}
.aq-more summary::before {
  content: '';
  width: 8px;
  height: 8px;
  margin: 0 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.aq-more[open] > summary::before {
  transform: rotate(45deg);
}
.aq-more > :not(summary) {
  margin-bottom: 10px;
}
.aq-how {
  margin: 0;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}
.aq-disclaimer {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.84rem;
}
.aq-disclaimer .ico {
  flex: none;
  margin-top: 1px;
}

/* ===================================================================
   Images & canvas stage
   =================================================================== */
.preview img {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--stage-bg);
}
.dropzone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  min-height: 140px;
  padding: 6px;
  justify-content: center;
  background: var(--surface-2);
}
.dropzone:has(img) {
  border-style: solid;
  border-color: transparent;
  background: transparent;
  padding: 0;
}
.dropzone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.empty-icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
  color: var(--primary);
  opacity: 0.8;
}

.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--stage-bg);
  box-shadow: var(--shadow);
}
.stage-canvas {
  display: block;
  width: 100%;
  height: min(62vh, 640px);
  touch-action: none;
}
.stage-tools {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stage-tools .icon-btn {
  background: rgb(6 18 35 / 0.7);
  color: #fff;
  border-color: rgb(255 255 255 / 0.35);
  backdrop-filter: blur(4px);
  font-size: 1.2rem;
}

/* ===================================================================
   Analysis
   =================================================================== */
.legend {
  display: flex;
  gap: 16px;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0 4px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 1px solid rgb(0 0 0 / 0.25);
}
.swatch-foliose {
  background: var(--foliose);
}
.swatch-crustose {
  background: var(--crustose);
}
.swatch-bark {
  background: var(--bark);
}
.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.totals div {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.totals strong {
  font-size: 1.7rem;
  line-height: 1.15;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.totals span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.table-wrap {
  overflow-x: auto;
}
table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
table.results th,
table.results td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
table.results thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
table.results th:first-child {
  text-align: left;
}

/* review tools */
.tool-row span {
  flex-direction: column;
  gap: 2px;
  padding: 6px 2px;
  min-height: 60px;
}
.tool-row .ico {
  width: 22px;
  height: 22px;
}
.tool-row small {
  font-size: 0.72rem;
  font-weight: 700;
}
.segmented .swatch {
  margin-right: 0;
}

/* ===================================================================
   Sync badge, save, records
   =================================================================== */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.25);
  background: rgb(255 255 255 / 0.08);
  color: var(--appbar-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.sync-badge .ico {
  width: 18px;
  height: 18px;
}
.sync-badge[data-state='synced'] {
  background: rgb(143 214 148 / 0.18);
  border-color: rgb(143 214 148 / 0.6);
}
.sync-badge[data-state='pending'],
.sync-badge[data-state='offline'],
.sync-badge[data-state='signed-out'] {
  background: #ffe8a8;
  border-color: #ffe8a8;
  color: #5a3a00;
}
.sync-badge[data-state='error'] {
  background: #ffc9c9;
  border-color: #ffc9c9;
  color: #7a0c0c;
}
@media (max-width: 400px) {
  .sync-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .sync-badge {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
}

dl.summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  margin: 0;
}
dl.summary dt,
dl.summary dd {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
dl.summary dt {
  color: var(--muted);
  padding-right: 16px;
}
dl.summary dd {
  margin: 0;
  font-weight: 650;
  text-align: right;
}
dl.summary > :nth-last-child(-n + 2) {
  border-bottom: 0;
}

.saved {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 6px;
  text-align: center;
}
.saved-icon {
  width: 64px;
  height: 64px;
  padding: 14px;
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok-text);
  stroke-width: 2.5;
}

ul.records {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.record {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.record-cover {
  display: flex;
  gap: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ===================================================================
   Maps
   =================================================================== */
.map-canvas {
  height: min(62vh, 620px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--stage-bg);
  box-shadow: var(--shadow);
}
.map-canvas.map-small {
  height: min(40vh, 360px);
}
.map-filters,
.map-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.map-tools {
  flex-direction: row;
  align-items: end;
  gap: 8px;
}
.map-tools label {
  flex: 1;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.map-legend span:first-child {
  font-weight: 600;
}
.legend-ramp {
  flex: 1;
  max-width: 200px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #e6f4d7, #4caf50, #14532d);
}
.tree-pin {
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.5);
  display: grid;
  place-items: center;
  font: 700 12px/1 system-ui, sans-serif;
}
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 0.3);
}
.coords {
  font-variant-numeric: tabular-nums;
}
.icon-btn[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.topbar .icon-btn[aria-pressed] {
  border-color: rgb(255 255 255 / 0.22);
  background: rgb(255 255 255 / 0.08);
}

/* ===================================================================
   Shown when index.html is opened from disk
   =================================================================== */
.file-warning {
  max-width: 560px;
  margin: 10vh auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.file-warning pre {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 1rem;
}
.file-warning a {
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 360px) {
  .brand-name {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ===================================================================
   Map engine (Leaflet / Google) extras
   =================================================================== */
.map-tabs {
  margin-bottom: 4px;
}
.map-tab-body {
  display: flex;
  flex-direction: column;
  gap: inherit;
}
.alert-info {
  background: var(--primary-soft);
  color: var(--text);
}
.map-editing {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* Leaflet divIcons: a zero-size anchor; the pin is centred on it */
.lm-divicon {
  background: none;
  border: 0;
}
.lm-divicon > * {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.lm-divicon > .edit-pin {
  transform: translate(-50%, -100%);
}
.edit-pin {
  width: 40px;
  height: 40px;
  color: #d93025;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.5));
}
.edit-pin svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: #fff;
  stroke-width: 1.5;
}
.map-cluster {
  min-width: 38px;
  height: 38px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--appbar);
  color: #fff;
  border: 3px solid rgb(255 255 255 / 0.85);
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.45);
  font: 700 13px/1 system-ui, sans-serif;
}
.tree-pin.mine {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}
.legend-mine {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.legend-mine .tree-pin {
  min-width: 14px;
  width: 14px;
  height: 14px;
  padding: 0;
  background: #9ca3af;
}
.lm-heat {
  position: absolute;
  pointer-events: none;
}
/* keep Leaflet's controls readable in both themes and above app content */
.map-canvas .leaflet-container,
.map-canvas.leaflet-container {
  font: inherit;
  background: var(--stage-bg);
}
.map-canvas .leaflet-control-layers label {
  flex-direction: row;
  font-weight: 500;
}
.map-canvas .leaflet-control-layers,
.map-canvas .leaflet-bar a {
  color: #0d1b2a;
}
.map-canvas .leaflet-bar a {
  width: 36px;
  height: 36px;
  line-height: 36px;
}
.map-canvas {
  position: relative;
  z-index: 0;
}
