/* Layout: Vollbild-Karte, oben schmale Statusleiste, unten Navigationsleiste, Details als Bottom-Sheet */
:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #e9eee6;
  --fg: #1c2720;
  --muted: #5d6b61;
  --line: #d3dbd0;
  --brand: #24402f;
  --brand-fg: #f1f6ef;
  --accent: #b8612f;
  --ok: #2f7d4a;
  --warn: #b7821c;
  --bad: #b23b32;
  --shadow: 0 6px 24px rgba(20, 35, 25, .18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111713;
    --surface: #18211b;
    --surface-2: #213028;
    --fg: #e4ebe5;
    --muted: #9aaa9f;
    --line: #2d3b32;
    --brand: #1a2e22;
    --brand-fg: #e4efe6;
    --accent: #e08452;
    --ok: #5cb67a;
    --warn: #e0b04a;
    --bad: #e46a5f;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: var(--brand); color: var(--brand-fg);
  z-index: 500;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; min-width: 0; }
.brand svg { width: 22px; height: 22px; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; gap: 6px; flex: none; }
.chip {
  font: 600 12px/1 var(--mono); padding: 6px 8px; border-radius: 999px;
  background: rgba(255,255,255,.12); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip.ok { background: rgba(92,182,122,.28); }
.chip.warn { background: rgba(224,176,74,.32); }
.chip.bad { background: rgba(228,106,95,.32); }

#map { flex: 1; min-height: 0; background: var(--surface-2); position: relative; z-index: 0; }
.leaflet-container { font: inherit; }

.mapbtns {
  position: absolute; right: max(12px, env(safe-area-inset-right, 0px));
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  display: flex; flex-direction: column; gap: 8px; z-index: 450;
}
.fab {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow);
  display: grid; place-items: center; padding: 0;
}
.fab svg { width: 22px; height: 22px; }
.fab.active { color: var(--accent); }

.bottombar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 6px) max(8px, env(safe-area-inset-left, 0px));
  z-index: 500;
}
.navbtn {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; font-size: 12px; color: var(--muted); border-radius: 10px;
}
.navbtn svg { width: 24px; height: 24px; }
.navbtn:active { background: var(--surface-2); }
.navbtn.shutter { color: var(--accent); font-weight: 600; }

.drawbar {
  position: absolute; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  z-index: 480; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.drawbar > * { pointer-events: auto; }
.drawhint {
  align-self: center; background: var(--brand); color: var(--brand-fg);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow);
  text-align: center;
}
.drawactions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.btn {
  border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px; box-shadow: none;
}
.btn.primary { background: var(--brand); color: var(--brand-fg); border-color: transparent; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--ok); color: #0d1a12; } }
.btn.accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: var(--bad); border-color: currentColor; background: transparent; }
.btn.ghost { box-shadow: var(--shadow); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }

.backdrop { position: fixed; inset: 0; background: rgba(10,20,14,.35); z-index: 900; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 901;
  max-height: 82%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-width: 720px; margin: 0 auto;
}
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 2px; flex: none; }
.sheetbody {
  overflow-y: auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h2 { margin: 4px 0 0; font-size: 19px; text-wrap: balance; }
.sheet h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 72px; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); font-size: 13px;
}
.cat i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cat[aria-pressed=true] { border-color: var(--fg); font-weight: 650; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab[aria-selected=true] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.list { display: flex; flex-direction: column; }
.item {
  display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%;
}
.item:last-child { border-bottom: 0; }
.item .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tx span { font-size: 13px; color: var(--muted); }
.item img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); }
.badge { font: 600 12px/1 var(--mono); padding: 4px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.badge.open { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.tasks { display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; align-items: center; gap: 10px; }
.task input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ok); flex: none; }
.task span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task.done span { text-decoration: line-through; color: var(--muted); }
.task .tstart, .row .tstart { flex: none; width: 128px; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line, #d6dccf); border-radius: 8px; background: var(--surface, #fff); color: var(--muted); }
.badge.later { background: color-mix(in srgb, #7a5fb0 20%, transparent); color: #7a5fb0; }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; }
.segbtn { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); }
.segbtn[aria-pressed=true] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent, #b8612e); font: inherit; font-weight: 600; text-decoration: underline; }
.task button { border: 0; background: none; color: var(--muted); padding: 4px 6px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.photo-full { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 10px; background: #000; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.confirm { border: 1px solid var(--bad); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }

.layer-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.layer-opt:last-child { border-bottom: 0; }
.layer-opt input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 2000;
  max-width: calc(100% - 32px); font-size: 14px; box-shadow: var(--shadow);
}

/* Fotomarker auf der Karte */
.photo-pin { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.photo-pin.manual { background: #7a5fb0; }
.vtx { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.vtx.mid { width: 12px; height: 12px; border-width: 2px; opacity: .8; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(42,125,225,.35); }
.feature-label {
  background: rgba(255,255,255,.85); border: 0; box-shadow: none; padding: 1px 6px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: #1c2720;
}
.feature-label::before { display: none; }

/* Kamera */
.camera { position: fixed; inset: 0; background: #000; z-index: 1500; color: #fff; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0)); display: flex; flex-direction: column; gap: 8px;
}
.tape { position: relative; height: 34px; overflow: hidden; border-radius: 8px; background: rgba(0,0,0,.35); }
.tape-inner { position: absolute; top: 0; bottom: 0; left: 50%; display: flex; will-change: transform; }
.tape-inner span { width: 30px; flex: none; text-align: center; font: 600 11px/34px var(--mono); color: rgba(255,255,255,.75); }
.tape-inner span.card { color: #ffd27a; font-size: 13px; }
.tape-needle { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff8a4c; }
.cam-readout { display: flex; justify-content: space-between; gap: 8px; font: 600 14px/1.2 var(--mono); font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000; flex-wrap: wrap; }
.cam-warn { background: rgba(178,59,50,.85); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.cam-ask { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 130px); z-index: 2; background: rgba(20,24,20,.92); border: 1px solid #e0a93b; border-radius: 12px; padding: 12px; font-size: 14px; display: flex; flex-direction: column; gap: 10px; }
.cam-ask[hidden] { display: none; }
.cam-ask .btn:not(.primary) { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); }
.cam-ask .btn.primary { background: #e0a93b; color: #1b1b1b; border-color: #e0a93b; }
.poscheck { border: 1px solid var(--warn, #c98a1b); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.horizon { position: absolute; left: 15%; right: 15%; top: 50%; height: 0; pointer-events: none; }
.hline { height: 2px; background: rgba(255,255,255,.7); box-shadow: 0 0 3px #000; transform-origin: center; }
.cam-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 22px) max(20px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6));
}
.cam-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; }
.cam-btn svg { width: 24px; height: 24px; }
.cam-shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; }
.cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.cam-shutter:active span { transform: scale(.88); }
.cam-shutter:disabled { opacity: .5; }
.cam-last { width: 52px; height: 52px; border-radius: 10px; background: rgba(255,255,255,.18) center/cover no-repeat; border: 2px solid rgba(255,255,255,.6); position: relative; }
.cam-last b { position: absolute; top: -8px; right: -8px; background: #ff8a4c; color: #000; border-radius: 999px; font: 700 11px/1 var(--mono); padding: 4px 6px; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.cam-flash.on { opacity: .8; transition: none; }

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

/* KI */
.badge.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.low { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.ai-plant .tx span, .proposal .tx span { display: block; margin-top: 2px; }
.ai-plant .tx span.row, .proposal .tx span.row { display: flex; }
.pick { position: relative; display: block; }
.pick input { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; accent-color: var(--accent); z-index: 1; }
.pick img { display: block; }
.pick input:not(:checked) + img { opacity: .55; }
.done-mark { position: absolute; right: 5px; bottom: 5px; background: var(--ok); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 5px; }
.proposal.focus { background: color-mix(in srgb, #7a5fb0 12%, transparent); border-radius: 8px; }
details summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.ai-plant .tx span.badge, .proposal .tx span.badge { display: inline-block; margin: 0 0 0 6px; vertical-align: 1px; }

/* Gärten */
.brand { background: none; border: 0; color: inherit; padding: 4px 6px 4px 0; border-radius: 8px; font: inherit; font-weight: 650; }
.brand .caret { width: 16px; height: 16px; opacity: .8; }
