:root {
  --bark: #3e2723;
  --bark2: #5d4037;
  --cap: #c8a165;
  --cream: #faf6ef;
  --ink: #2a211c;
  --muted: #7a6b60;
  --fire: #d32f2f;
  --rx: #f57c00;
  --log: #7b5ea7;
  --ok: #2e7d32;
  --sheet-h: 46vh;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bark); }

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

#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  background: linear-gradient(var(--bark), rgba(62, 39, 35, 0.85));
  color: var(--cream);
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: 0.3px; }
.brand img { width: 24px; height: 24px; }
.brand small { font-weight: 500; font-size: 11px; opacity: 0.75; margin-left: 2px; }
.pill { background: var(--cap); color: var(--bark); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.status { margin-left: auto; font-size: 12px; opacity: 0.9; text-align: right; max-width: 45vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaflet-top { top: calc(env(safe-area-inset-top, 0px) + 48px); }
.leaflet-bottom { bottom: calc(96px + var(--safe-b)); }
@media (min-width: 900px) { .leaflet-bottom { bottom: 0; } }

#fabs {
  position: absolute; right: 12px; z-index: 1000;
  bottom: calc(var(--sheet-peek, 108px) + 16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px; transition: bottom 0.25s;
}
.fab {
  width: 52px; height: 52px; border-radius: 50%; border: 0; font-size: 20px;
  background: var(--cream); color: var(--bark); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.fab.primary { background: var(--bark2); color: var(--cream); font-size: 13px; font-weight: 700; line-height: 1.1; }
.fab.on { background: #1565c0; color: #fff; }

#crosshair { position: absolute; inset: 0; pointer-events: none; z-index: 900; display: grid; place-items: center; }
#crosshair div { width: 44px; height: 44px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000; position: relative; }
#crosshair div::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #ff1744; border-radius: 50%; }
#crossbar {
  position: absolute; left: 8px; right: 8px; top: calc(env(safe-area-inset-top, 0px) + 56px); z-index: 1100;
  background: var(--cream); border-radius: 12px; padding: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.35); font-size: 14px;
}

/* bottom sheet */
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1001;
  height: var(--sheet-h); background: var(--cream); border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column;
  transition: transform 0.25s; padding-bottom: var(--safe-b);
}
#sheet.collapsed { transform: translateY(calc(var(--sheet-h) - 96px - var(--safe-b))); }
#sheet.full { --sheet-h: 88vh; }
.grab { padding: 8px 0 4px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.grab span { width: 44px; height: 5px; border-radius: 3px; background: #c9bdb1; }
.tabs { display: flex; border-bottom: 1px solid #e6ddd2; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--bark); box-shadow: inset 0 -3px 0 var(--cap); }
.panel { overflow-y: auto; padding: 8px 14px 24px; flex: 1; -webkit-overflow-scrolling: touch; }
.panel h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; }
.row input { width: 20px; height: 20px; }
.sw { width: 16px; height: 12px; border-radius: 2px; display: inline-block; }
.sw.fire { background: var(--fire); }
.sw.rx { background: var(--rx); }
.sw.log { background: var(--log); }
.ages, .aspects { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; padding: 4px 0 4px 28px; }
.aspects { padding-left: 0; }
.aspects label { display: flex; gap: 4px; align-items: center; min-width: 52px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid #d8ccbf; background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.seg button.active { background: var(--bark2); color: #fff; border-color: var(--bark2); }

.btn { display: inline-flex; justify-content: center; align-items: center; border: 1px solid #d0c3b5; background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 14px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--bark2); border-color: var(--bark2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow.col { flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label { font-size: 14px; }
input[type='number'], select, textarea { width: 100%; padding: 9px; border: 1px solid #d0c3b5; border-radius: 8px; font-size: 16px; margin-top: 3px; background: #fff; font-family: inherit; }

/* score card */
.card { background: #fff; border: 1px solid #ebe2d7; border-radius: 12px; padding: 12px; margin: 10px 0; }
.score { display: flex; align-items: center; gap: 12px; }
.score .big { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 800; flex: none; }
.score .meta { font-size: 13px; color: var(--muted); }
.score .outlook { font-weight: 600; font-size: 15px; color: var(--ink); margin-top: 2px; }
.bk { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.bk td { padding: 4px 0; border-top: 1px solid #f1ebe3; vertical-align: top; }
.bk td:last-child { text-align: right; white-space: nowrap; color: var(--muted); }
.bar { height: 6px; background: #eee5da; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--cap); }
.chart { width: 100%; height: 90px; margin-top: 8px; }
.chart text { font-size: 9px; fill: var(--muted); }

.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid #efe7dd; }
.list-item .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.list-item .txt { flex: 1; min-width: 0; font-size: 14px; }
.list-item .txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .txt small { color: var(--muted); }

dialog { border: 0; border-radius: 16px; padding: 16px; width: min(420px, 92vw); background: var(--cream); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form > label { display: block; margin: 10px 0; }
dialog h3 { margin: 0 0 4px; }

#nav {
  position: absolute; left: 8px; right: 8px; top: calc(env(safe-area-inset-top, 0px) + 56px); z-index: 1050;
  background: #1565c0; color: #fff; border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
#nav > div { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
#nav .btn { color: #fff; border-color: rgba(255,255,255,.5); padding: 6px 10px; }

.leaflet-popup-content { font-size: 13px; margin: 10px 12px; }
.leaflet-popup-content b { font-size: 14px; }
.score-label { background: #fff; border: 2px solid; border-radius: 12px; padding: 1px 6px; font-weight: 700; font-size: 12px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.3); }

@media (min-width: 900px) {
  #sheet { left: 12px; right: auto; width: 400px; bottom: 12px; top: 64px; height: auto; border-radius: 16px; }
  #sheet.collapsed { transform: none; }
  .grab { display: none; }
  #fabs { bottom: 24px; }
}

#crossThumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
#crossbar span { flex: 1 1 60%; }
.tabs button { font-size: 14px; }
.popthumb { width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; margin: 4px 0; display: block; }
.recnum { background: #ffd54f; color: #3e2723; border: 2px solid #3e2723; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.reasons { margin: 4px 0 0; padding-left: 16px; font-size: 13px; color: var(--muted); }
label.btn { cursor: pointer; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; padding: 2px 0 4px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 18px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.legend i.hatch-go { border: 2px solid #00c853; background: repeating-linear-gradient(45deg, #00e676 0 2px, transparent 2px 6px), repeating-linear-gradient(-45deg, #00e676 0 2px, #e8f5e9 2px 6px); }
.legend i.hatch-soon { border: 2px solid #fdd835; background: repeating-linear-gradient(-45deg, #fdd835 0 2px, #fffde7 2px 7px); }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; margin-bottom: 8px; }
.trio .big { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 20px; font-weight: 800; margin: 0 auto 4px; }
.trio .big.today { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--bark2); }
.trio b { display: block; font-size: 14px; }
.trio small { color: var(--muted); font-size: 11px; }
.card > .meta { font-size: 13px; color: var(--muted); }
.card > .outlook { font-weight: 600; margin-top: 4px; }
.bk th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding-top: 10px; }
