:root {
  --ink: #1B1F24;
  --muted: #56616C;
  --line: #E3E7EB;
  --soft: #F4F6F8;
  --ember: #C2410C;
  --ember-bg: #FFF1EA;
  --high: #C7261A;
  --mid: #F07C3E;
  --low: #F9C784;
  --panel-w: 380px;
  --topbar-h: 58px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #FFFFFF; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
a { color: var(--ember); font-weight: 600; }
button { font-family: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #2563EB; outline-offset: 2px; }

.topbar {
  flex: 0 0 auto; min-height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: #FFFFFF; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.updated { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.35; }
.updated strong { color: var(--ink); font-weight: 600; }
@media (max-width: 599px) { .updated .latest { display: none; } .brand p { display: none; } }

.banner { flex: 0 0 auto; padding: 8px 16px; background: #FFF6DB; border-bottom: 1px solid #F2DE9C; color: #6B4E00; font-size: 13px; z-index: 3; }

.layout { position: relative; flex: 1 1 auto; min-height: 0; }
.map { position: absolute; inset: 0; }

.controls { position: absolute; top: 12px; left: 12px; right: 56px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 2; pointer-events: none; }
.controls > * { pointer-events: auto; }
.seg { display: flex; gap: 2px; padding: 3px; background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10); }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; font-weight: 600; }
.chip { min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #FFFFFF; font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10); }
.chip[aria-pressed="true"] { border-color: var(--high); background: #FDECEA; color: #8F1B12; font-weight: 600; }

.locate {
  position: absolute; right: 12px; bottom: 96px; z-index: 2; display: flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--ember); color: #FFFFFF;
  font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(194, 65, 12, 0.35);
}
.locate[disabled] { opacity: 0.7; cursor: progress; }

/* Panel: bottom sheet di ponsel, panel samping di layar lebar */
.panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; background: #FFFFFF;
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(16, 24, 40, 0.14);
  max-height: 72%; display: flex; flex-direction: column; transition: max-height .25s ease;
}
.panel:not(.open) { max-height: 76px; }
.handle { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; min-height: 64px; padding: 10px 16px 12px; border: 0; background: transparent; cursor: pointer; }
.grip { width: 40px; height: 4px; border-radius: 2px; background: #C9D0D6; }
.handle-text { font-size: 14px; font-weight: 600; }
.panel-body { overflow-y: auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 20px; }
.panel:not(.open) .panel-body { visibility: hidden; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--soft); }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .value.hot { color: var(--high); }
.stat .sub { font-size: 11px; color: var(--muted); }

.block h2, .card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank button { width: 100%; min-height: 48px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; text-align: left; cursor: pointer; }
.rank button:hover { border-color: #C9D0D6; background: var(--soft); }
.rank .name { font-size: 14px; font-weight: 600; }
.rank .meta { font-size: 12px; color: var(--muted); grid-column: 1 / 2; }
.rank .count { grid-row: 1 / 3; grid-column: 2; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank .bar { grid-column: 1 / 3; height: 5px; border-radius: 3px; background: #EEF1F4; overflow: hidden; }
.rank .bar span { display: block; height: 100%; background: var(--mid); border-radius: 3px; }
.empty { font-size: 13px; color: var(--muted); }

.legend ul { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend p { margin: 0; font-size: 12px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #FFFFFF; box-shadow: 0 0 0 1px #C9D0D6; }
.dot.h { background: var(--high); } .dot.n { background: var(--mid); } .dot.l { background: var(--low); }

.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.55; color: #33393F; }
.card { padding: 14px; border-radius: 14px; }
.safety { background: #EEF6FF; border: 1px solid #CFE3FA; }
.nearby { background: var(--ember-bg); border: 1px solid #F6C9B0; font-size: 14px; line-height: 1.55; }
.nearby.calm { background: #ECF8F1; border-color: #BFE5CF; }
.nearby p { margin: 0 0 6px; }
.nearby small { color: var(--muted); font-size: 12px; }
.credits { font-size: 11px; color: var(--muted); line-height: 1.5; }
.credits p { margin: 0 0 6px; }

/* Popup */
.maplibregl-popup-content { font-family: inherit; padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(16, 24, 40, 0.18); }
.pop h3 { margin: 0 0 2px; font-size: 15px; }
.pop .where { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.pop dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; font-weight: 600; }
.pop .note { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.h { background: #FDECEA; color: #8F1B12; } .badge.n { background: #FFF1E6; color: #8A3A08; } .badge.l { background: #FFF8E6; color: #6B4E00; }

.me { width: 18px; height: 18px; border-radius: 50%; background: #2563EB; border: 3px solid #FFFFFF; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.25); }

@media (min-width: 900px) {
  .panel { top: 0; bottom: 0; right: auto; width: var(--panel-w); max-height: none; border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); }
  .panel:not(.open) { max-height: none; }
  .panel:not(.open) .panel-body { visibility: visible; }
  .handle { display: none; }
  .panel-body { padding-top: 16px; }
  .map { left: var(--panel-w); }
  .controls { left: calc(var(--panel-w) + 12px); }
  .locate { bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
