:root{
  --bg: #ffffff;
  --ink: #0b0b0c;
  --ink-soft: #6b6b70;
  --accent: #0a84ff;
  --line: rgba(0,0,0,0.08);
  --radius-lg: 28px;
  --radius-md: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; margin: 0; }
body{
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

#map{
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ---------- topplinje ---------- */

#topBar{
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
#topBar > *{ pointer-events: auto; }

.iconBtn{
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s cubic-bezier(.2,.8,.2,1);
}
.iconBtn:active{ transform: scale(0.92); }

.pill{
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- FAB ---------- */

.fab{
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  transition: transform 0.18s cubic-bezier(.2,.8,.2,1);
}
.fab:active{ transform: translateX(-50%) scale(0.9); }

.fabSecondary{
  position: fixed;
  bottom: calc(40px + var(--safe-bottom));
  left: calc(50% + 72px);
  transform: translateX(-50%);
  z-index: 500;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s cubic-bezier(.2,.8,.2,1);
}
.fabSecondary:active{ transform: translateX(-50%) scale(0.9); }

/* ---------- leaflet control tweaks ---------- */

.locateBtn{
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: #fff;
  cursor: pointer;
}

/* ---------- bottom sheets ---------- */

.sheet{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 900;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 24px calc(24px + var(--safe-bottom));
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
  animation: sheetUp 0.28s cubic-bezier(.2,.8,.2,1);
}
.sheet[hidden]{ display: none; }
@keyframes sheetUp{
  from{ transform: translateY(24px); opacity: 0; }
  to{ transform: translateY(0); opacity: 1; }
}

.sheetHandle{
  width: 36px; height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 6px auto 14px;
  cursor: pointer;
}

.sheet h2{ margin: 0 0 8px; font-size: 20px; letter-spacing: -0.01em; }
.hint{ color: var(--ink-soft); font-size: 14px; margin: 4px 0 12px; }
.note{ color: var(--ink-soft); font-size: 13px; min-height: 18px; }

.sheet label{ display:block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.sheet input[type="text"], .sheet input[type="password"]{
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #f5f5f7;
  font-size: 16px;
}

.sheetActions{ display: flex; gap: 10px; margin-top: 16px; }
.primaryBtn, .secondaryBtn{
  flex: 1;
  min-height: 48px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 16px; font-weight: 600;
  transition: transform 0.15s cubic-bezier(.2,.8,.2,1);
}
.primaryBtn{ background: var(--ink); color: #fff; }
.primaryBtn:disabled{ background: #d1d1d6; color: #8e8e93; }
.secondaryBtn{ background: #f0f0f2; color: var(--ink); }
.primaryBtn:active, .secondaryBtn:active{ transform: scale(0.97); }

/* ---------- filter chips ---------- */

.filterRow{ display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.filterChip{
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f5f5f7;
  font-size: 14px; text-transform: capitalize;
}
.filterChip.active{ background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- funnliste ---------- */

.findRow{
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 4px;
  border: none; border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-size: 15px;
}

/* ---------- registrering ---------- */

.previewImg, .scanImg{
  width: 100%; max-height: 260px; object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.scanWrap{ position: relative; overflow: hidden; border-radius: var(--radius-md); }
.detailImgLoading{
  display: flex; align-items: center; justify-content: center;
  height: 160px; background: #f5f5f7; color: var(--ink-soft); font-size: 14px;
}
.rodlisteBadge{
  display: inline-block;
  background: #fff3e0; color: #b06a00;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  margin: 0 0 12px;
}

.posStatus{
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
  font-size: 14px;
  margin-bottom: 4px;
}
.linkBtn{
  border: none; background: transparent;
  color: var(--accent); font-size: 14px; font-weight: 600;
  padding: 4px 8px;
}
.scanLine{
  position: absolute; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanPulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 16px 2px var(--accent);
}
@keyframes scanPulse{
  0%{ top: 0; opacity: 0.4; }
  50%{ opacity: 1; }
  100%{ top: 100%; opacity: 0.4; }
}

.kiCard{ padding: 14px; border-radius: var(--radius-md); background: #f5f5f7; margin-bottom: 10px; }
.kiCardAuto{ border: 2px solid var(--accent); }
.konfidensBadge{
  display: inline-block; margin-left: 8px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
}

.candidateCards{ display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.candidateCard{
  flex: 0 0 auto; min-width: 140px;
  padding: 14px; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: #fff;
  text-align: left;
}

.speciesResults{ display: flex; flex-direction: column; }
.speciesResult{
  min-height: 48px; text-align: left; padding: 0 12px;
  border: none; border-bottom: 1px solid var(--line); background: transparent;
  font-size: 16px; line-height: 1.3;
}
.speciesResult em{ font-size: 14px; color: var(--ink-soft); margin-left: 4px; }
.speciesResultFritekst{ color: var(--accent); font-weight: 600; }
.selectedSpecies{ margin: 10px 0; font-size: 15px; }

/* ---------- toast ---------- */

.toast{
  position: fixed;
  bottom: calc(120px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 1000;
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}

@media (min-width: 760px){
  .sheet{ max-width: 480px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg); bottom: 24px; }
}
