:root {
  --blue: #0b5cab;
  --blue-dark: #08427c;
  --ink: #1b2530;
  --muted: #5d6b78;
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #e2e8f0;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(16, 42, 80, .16);
  --font: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- উপরের বার ---------- */
.topbar {
  background: linear-gradient(135deg, var(--blue) 0%, #1677d2 100%);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-drop { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.2)); }
.brand h1 { margin: 0; font-size: 22px; line-height: 1.1; font-weight: 700; }
.brand p { margin: 0; font-size: 13px; opacity: .9; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.6); background: rgba(255,255,255,.12);
  color: #fff; font-weight: 700; font-size: 16px;
}
.search { display: flex; gap: 6px; margin-top: 10px; }
.search input {
  flex: 1; min-width: 0; border: 0; border-radius: 10px; padding: 9px 12px;
  background: #fff; color: var(--ink); font-size: 15px; outline: none;
}
.search button {
  border: 0; border-radius: 10px; padding: 0 14px; background: var(--blue-dark); color: #fff; font-weight: 600;
}
.filters { display: flex; gap: 6px; margin-top: 8px; }
.filters button {
  border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff;
  border-radius: 999px; padding: 3px 12px; font-size: 13px;
}
.filters button.active { background: #fff; color: var(--blue); border-color: #fff; font-weight: 600; }

.demo-banner {
  background: #fff4d6; color: #6b4e00; font-size: 13px; text-align: center; padding: 6px 12px;
  border-bottom: 1px solid #f1dfa6; z-index: 999;
}

/* ---------- ম্যাপ ---------- */
.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe8f1; }
.leaflet-container { font-family: var(--font); }

.pin-wrap { background: none; border: 0; }
.pin {
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  position: relative; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
.pin.fresh::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 3px solid var(--c); animation: ripple 1.8s ease-out infinite;
}
.pin.dry { border-style: dashed; }
@keyframes ripple {
  from { transform: scale(1); opacity: .9; }
  to { transform: scale(2.6); opacity: 0; }
}

.crosshair {
  position: absolute; left: 50%; top: 50%; z-index: 700;
  transform: translate(-50%, -100%); pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.3));
  animation: bob 1.2s ease-in-out infinite alternate;
}
@keyframes bob { to { transform: translate(-50%, calc(-100% - 6px)); } }

.pick-bar {
  position: absolute; left: 12px; right: 12px; top: 12px; z-index: 800;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 12px; text-align: center;
}
.pick-bar p { margin: 0 0 8px; font-weight: 600; }
.pick-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pick-actions button, .actions button {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 600;
}
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:disabled { opacity: .6; cursor: wait; }

.map-btn {
  position: absolute; right: 12px; bottom: 150px; z-index: 600;
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff;
  box-shadow: var(--shadow); font-size: 20px;
}
.fab {
  position: absolute; right: 12px; bottom: 86px; z-index: 600;
  border: 0; border-radius: 999px; padding: 12px 20px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 22px rgba(11, 92, 171, .45);
}
.fab:active { transform: scale(.97); }
body.picking .fab, body.picking .map-btn, body.picking .sheet { display: none; }

/* ---------- নিচের তালিকা ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
  background: var(--card); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(16,42,80,.14);
  max-height: 72px; transition: max-height .3s ease; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
body.sheet-open .sheet { max-height: 70vh; }
.sheet-head {
  width: 100%; border: 0; background: none; padding: 10px 16px 14px; text-align: left;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; position: relative;
}
.grip { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; background: var(--line); border-radius: 4px; }
.sheet-head strong { flex: 1; font-size: 15px; margin-top: 6px; }
.sheet-toggle { color: var(--blue); font-size: 13px; font-weight: 600; margin-top: 6px; }
body.sheet-open .sheet-toggle { transform: rotate(0); }
.sheet-body { overflow-y: auto; max-height: calc(70vh - 64px); padding: 0 12px 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 4px 10px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list .empty { padding: 18px 8px; color: var(--muted); text-align: center; }
.item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 0; border-top: 1px solid var(--line); background: none; padding: 10px 4px;
}
.item.is-dry { opacity: .55; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- পপআপ ---------- */
.leaflet-popup-content-wrapper { border-radius: var(--radius); }
.leaflet-popup-content { margin: 12px 14px; }
.pop { font-size: 14px; line-height: 1.45; }
.pop-level { display: inline-block; background: var(--c); color: #fff; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.pop-area { font-weight: 700; font-size: 16px; margin-top: 6px; }
.pop-time { color: var(--muted); font-size: 12.5px; }
.pop-dry { margin-top: 6px; background: #f1f3f5; border-radius: 8px; padding: 4px 8px; font-size: 13px; }
.pop-note { margin: 8px 0 0; font-style: italic; }
.pop-photo { margin-top: 8px; color: var(--muted); font-size: 12px; }
.pop-photo img { width: 100%; border-radius: 10px; display: block; }
.pop-q { margin-top: 10px; font-weight: 600; font-size: 13px; }
.pop-votes { display: flex; gap: 6px; margin-top: 4px; }
.vote {
  flex: 1; border: 1px solid var(--line); background: #f8fafc; border-radius: 10px;
  padding: 6px 4px; font-size: 13px; font-weight: 600;
}
.vote:hover:not(:disabled) { border-color: var(--blue); }
.vote:disabled { opacity: .6; cursor: default; }
.pop-thanks { margin-top: 6px; color: #2e7d32; font-size: 12.5px; }

/* ---------- ডায়ালগ ---------- */
.dlg {
  border: 0; border-radius: 18px; padding: 18px; width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 40px); box-shadow: var(--shadow); color: var(--ink);
}
.dlg::backdrop { background: rgba(10, 25, 45, .45); }
.dlg h2 { margin: 0 0 6px; font-size: 20px; }
.form-area { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.levels { border: 0; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.levels legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.level-opt {
  display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 12px;
  padding: 8px 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.level-opt input { position: absolute; opacity: 0; pointer-events: none; }
.level-opt b { display: block; font-size: 14px; }
.level-opt small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.level-emoji { font-size: 22px; }
.level-opt:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.level-opt:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.field { display: block; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.field textarea {
  display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-weight: 400; resize: none;
}
.photo-btn {
  display: block; text-align: center; border: 1.5px dashed #b6c4d4; border-radius: 10px; padding: 9px;
  color: var(--blue); font-weight: 600; cursor: pointer;
}
.photo-preview { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; margin-top: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.how { padding-left: 20px; margin: 8px 0 12px; }
.how li { margin-bottom: 8px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 13px; margin: 6px 0; }

/* ---------- টোস্ট ---------- */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px);
  background: #17212b; color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100vw - 32px); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; }
  .topbar-row { order: 0; }
  .search { margin-top: 0; max-width: 460px; justify-self: center; width: 100%; }
  .filters { margin-top: 0; }
  #infoBtn { margin-left: 8px; }
  .sheet { left: 16px; right: auto; bottom: 16px; width: 380px; border-radius: 18px; }
  .fab { bottom: 24px; }
  .map-btn { bottom: 88px; }
  .toast { bottom: 40px; }
}
