/* ===== BearAware — cartoon-forest mobile theme ===== */
:root {
  --forest:   #5a8f4e;
  --forest-d: #46703d;
  --leaf:     #8bc26f;
  --honey:    #f5b53d;
  --honey-d:  #e09a1f;
  --cream:    #fdf7ec;
  --cream-2:  #f6ecd8;
  --bark:     #8a5a34;
  --ink:      #33291f;
  --ink-soft: #7d6f5c;
  --danger:   #e2674a;
  --white:    #ffffff;
  --shadow:   0 10px 30px rgba(60, 45, 20, .18);
  --shadow-sm:0 4px 14px rgba(60, 45, 20, .14);
  --radius:   22px;
  --ff-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --ff-body: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ff-body);
  color: var(--ink);
  /* Playful backdrop for the desktop "device" view */
  background:
    radial-gradient(1200px 600px at 20% -10%, #cfe6bf 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #ffe6b0 0%, transparent 55%),
    #e9f0e0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* ---- Device frame ---- */
.device {
  position: relative;
  width: 100%; height: 100%;
  max-width: 440px; max-height: 940px;
}
@media (min-width: 480px) {
  .device {
    margin: 22px; border-radius: 42px;
    box-shadow: var(--shadow), 0 0 0 10px #2c2620, 0 0 0 12px #494139;
    overflow: hidden; height: calc(100% - 44px);
  }
}
.app {
  position: relative; height: 100%; width: 100%;
  background: var(--cream);
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* ---- Top bar ---- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(180deg, var(--cream) 55%, rgba(253,247,236,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { filter: drop-shadow(0 3px 4px rgba(60,45,20,.2)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: var(--ff-display); font-weight: 700; font-size: 22px;
  color: var(--forest-d); letter-spacing: .2px;
}
.brand-accent { color: var(--honey-d); }
.brand-tag { font-size: 11px; color: var(--ink-soft); font-weight: 600; margin-top: 3px; }
.icon-btn {
  width: 42px; height: 42px; border: none; border-radius: 14px;
  background: var(--white); color: var(--forest-d);
  box-shadow: var(--shadow-sm); cursor: pointer;
  display: grid; place-items: center; transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.92); }

/* ---- Map ---- */
#map { position: absolute; inset: 0; z-index: 1; background: #dce6d2; }
.leaflet-container { font-family: var(--ff-body); background: #dce7d0; }
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution {
  font-size: 9px !important; background: rgba(253,247,236,.75) !important;
  border-radius: 8px 0 0 0 !important;
}

/* ---- Custom bear pin marker ---- */
.bear-pin {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  filter: drop-shadow(0 4px 5px rgba(40,30,10,.35));
  transition: transform .15s ease;
}
.bear-pin .pin-body {
  width: 40px; height: 40px; border-radius: 50% 50% 50% 8px;
  transform: rotate(45deg);
  background: var(--honey); border: 3px solid var(--white);
  display: grid; place-items: center;
}
.bear-pin .pin-face { transform: rotate(-45deg); font-size: 19px; line-height: 1; }
.bear-pin.cubs::after {
  content: "👶"; position: absolute; top: -4px; right: -4px;
  font-size: 13px; background: var(--white); border-radius: 50%;
  width: 19px; height: 19px; display: grid; place-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.bear-pin.pending { animation: bob 1s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-6px);} }

/* Leaflet popup restyle */
.leaflet-popup-content-wrapper {
  border-radius: 18px; box-shadow: var(--shadow); background: var(--white);
}
.leaflet-popup-content { margin: 14px 16px; font-family: var(--ff-body); }
.leaflet-popup-tip { background: var(--white); }
.pop { min-width: 168px; }
.pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pop-emoji { font-size: 26px; }
.pop-type { font-family: var(--ff-display); font-weight: 600; font-size: 16px; color: var(--ink); }
.pop-row { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; margin: 3px 0; }
.pop-row b { color: var(--ink); font-weight: 700; }
.pop-notes { font-style: italic; }
.pop-edit {
  margin-top: 10px; width: 100%; border: none; cursor: pointer;
  background: var(--cream-2); color: var(--forest-d); font-weight: 800;
  font-family: var(--ff-body); padding: 8px; border-radius: 12px; font-size: 13px;
}
.pop-edit:active { transform: scale(.97); }

/* ---- Count chip ---- */
.count-chip {
  position: absolute; z-index: 400; left: 50%; transform: translateX(-50%);
  top: calc(70px + env(safe-area-inset-top));
  background: var(--white); color: var(--forest-d); font-weight: 800; font-size: 12.5px;
  padding: 7px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.count-chip #countNum { color: var(--honey-d); }

/* ---- Placement hint ---- */
.place-hint {
  position: absolute; z-index: 600; left: 16px; right: 16px;
  top: calc(70px + env(safe-area-inset-top));
  background: var(--forest); color: var(--white); font-weight: 700; font-size: 14px;
  padding: 12px 14px; border-radius: 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  animation: dropIn .25s ease;
}
@keyframes dropIn { from{ opacity:0; transform: translateY(-10px);} to{opacity:1; transform:none;} }
.hint-cancel {
  border: none; background: rgba(255,255,255,.22); color: var(--white);
  font-weight: 800; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
}
/* crosshair over the map while placing */
.app.placing #map { cursor: crosshair; }

/* ---- Report FAB ---- */
.fab {
  position: absolute; z-index: 450; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 9px;
  padding: 15px 24px; border: none; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, var(--honey) 0%, var(--honey-d) 100%);
  color: #4a3410; font-family: var(--ff-display); font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 20px rgba(224,154,31,.5), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .12s ease;
}
.fab:active { transform: translateX(-50%) scale(.95); }
.fab-paw { font-size: 19px; }
.fab.hidden { transform: translateX(-50%) translateY(120px); opacity: 0; pointer-events: none; }

/* ---- Bottom sheet ---- */
.scrim {
  position: absolute; inset: 0; z-index: 700; background: rgba(40,30,15,.4);
  animation: fade .2s ease; backdrop-filter: blur(2px);
}
@keyframes fade { from{opacity:0;} to{opacity:1;} }
.sheet {
  position: absolute; z-index: 800; left: 0; right: 0; bottom: 0;
  background: var(--cream);
  border-radius: 28px 28px 0 0; box-shadow: 0 -12px 40px rgba(40,30,15,.28);
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88%; overflow-y: auto;
  animation: slideUp .28s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes slideUp { from{ transform: translateY(100%);} to{ transform: none;} }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #d9cbb2; margin: 8px auto 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-family: var(--ff-display); font-weight: 700; font-size: 21px; color: var(--forest-d); margin: 4px 0 2px; }
.sheet-close { border: none; background: none; font-size: 30px; line-height: 1; color: var(--ink-soft); cursor: pointer; padding: 0 4px; }
.sheet-loc {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700;
  color: var(--ink-soft); background: var(--cream-2); padding: 9px 12px; border-radius: 12px; margin: 8px 0 4px;
}

/* ---- Form ---- */
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-family: var(--ff-display); font-weight: 600; font-size: 15px; color: var(--ink); }
.muted { color: var(--ink-soft); font-weight: 600; font-size: 12px; }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.type-btn {
  border: 2px solid transparent; background: var(--white); border-radius: 16px;
  padding: 11px 6px 9px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow-sm); transition: transform .1s ease, border-color .1s ease;
}
.type-btn:active { transform: scale(.95); }
.type-btn .emoji { font-size: 26px; display: block; }
.type-btn .name { font-size: 11.5px; font-weight: 800; color: var(--ink-soft); margin-top: 4px; display: block; }
.type-btn.active { border-color: var(--forest); background: #eef6e6; }
.type-btn.active .name { color: var(--forest-d); }

.toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.seg {
  border: 2px solid transparent; background: var(--white); border-radius: 14px;
  padding: 12px; cursor: pointer; font-family: var(--ff-body); font-weight: 800; font-size: 14px;
  color: var(--ink-soft); box-shadow: var(--shadow-sm); transition: transform .1s ease;
}
.seg:active { transform: scale(.96); }
.seg.active { border-color: var(--honey-d); background: #fff4de; color: var(--honey-d); }

.text-input {
  font-family: var(--ff-body); font-size: 15px; color: var(--ink);
  background: var(--white); border: 2px solid #eadfca; border-radius: 14px;
  padding: 12px 14px; width: 100%; resize: none;
}
.text-input:focus { outline: none; border-color: var(--leaf); }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn { flex: 1; border: none; border-radius: 16px; padding: 15px; cursor: pointer;
  font-family: var(--ff-display); font-weight: 600; font-size: 16px; transition: transform .1s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, var(--leaf), var(--forest)); color: var(--white); box-shadow: 0 6px 16px rgba(90,143,78,.45); }
.btn-danger { flex: 0 0 auto; background: #fbe4dd; color: var(--danger); }

/* ---- Toast ---- */
.toast {
  position: absolute; z-index: 900; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--white); font-weight: 700; font-size: 13.5px;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow);
  animation: toastIn .25s ease;
}
@keyframes toastIn { from{ opacity:0; transform: translate(-50%, 10px);} to{ opacity:1; transform: translate(-50%,0);} }
