:root {
  --bg: #f4f2ee;
  --paper: #fffdf9;
  --ink: #1b1a17;
  --mute: #6f6b63;
  --line: #e2ddd3;
  --disaster: #2f6db5;
  --accident: #d9822b;
  --crime: #b8322a;
  --sel: #1b1a17;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; }

/* 패널: PC는 왼쪽 고정, 휴대폰은 아래에서 올라오는 시트 */
#panel { position: fixed; z-index: 10; top: 12px; left: 12px; bottom: 12px; width: 392px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px -12px rgba(30,25,15,.25); display: flex; flex-direction: column; overflow: hidden; }
#grip { display: none; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; font-weight: 800; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--bg); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; font-size: 13px; color: var(--mute); }
.seg button.on { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 18px 10px; }
.kind { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 9px 10px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; transition: opacity .15s, border-color .15s; }
.kind .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kind .l { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.kind .l i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.kind.off { opacity: .4; }
.kind:not(.off) { border-color: var(--c); }

.cats { display: flex; gap: 5px; overflow-x: auto; padding: 0 18px 12px; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; border: 1px solid var(--line); background: none; border-radius: 99px; padding: 4px 10px; font-size: 12.5px; color: var(--mute); white-space: nowrap; }
.cat.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cat b { font-weight: 600; margin-left: 3px; font-variant-numeric: tabular-nums; }

#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.item { display: grid; grid-template-columns: 4px 1fr auto; gap: 0 12px; padding: 12px 18px 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:hover, .item.sel { background: #f7f4ee; }
.item .bar { background: var(--c); border-radius: 0 3px 3px 0; }
.item h3 { margin: 0 0 3px; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.item .meta { font-size: 12px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 0 8px; }
.item .meta .c { color: var(--c); font-weight: 600; }
.item .side { text-align: right; font-size: 11.5px; color: var(--mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .side .hurt { display: block; margin-top: 3px; color: var(--crime); font-weight: 600; }
.empty { padding: 40px 18px; color: var(--mute); font-size: 14px; text-align: center; }

#detail { flex: 1; overflow-y: auto; padding: 14px 18px 18px; }
#back { border: 0; background: none; padding: 0; font-size: 13px; color: var(--mute); margin-bottom: 12px; }
#back::before { content: "‹ "; }
.d-kind { font-size: 12px; font-weight: 700; color: var(--c); }
.d-title { margin: 4px 0 6px; font-size: 20px; letter-spacing: -0.02em; line-height: 1.3; }
.d-where { font-size: 13px; color: var(--mute); margin-bottom: 4px; }
.d-note { font-size: 12px; color: var(--mute); background: var(--bg); border-radius: 8px; padding: 7px 10px; margin: 10px 0 4px; }
.d-stats { display: flex; gap: 14px; margin: 12px 0 16px; font-size: 13px; }
.d-stats b { font-size: 18px; margin-right: 3px; font-variant-numeric: tabular-nums; }
.arts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.arts li { border-bottom: 1px solid var(--line); }
.arts a { display: block; padding: 11px 0; text-decoration: none; color: inherit; }
.arts a:hover h4 { text-decoration: underline; }
.arts h4 { margin: 0 0 3px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.arts p { margin: 0 0 4px; font-size: 12.5px; color: var(--mute); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.arts span { font-size: 11.5px; color: var(--mute); }

.foot { padding: 10px 18px 12px; font-size: 11px; line-height: 1.5; color: var(--mute); border-top: 1px solid var(--line); }

/* 지도 표식 */
.pin { position: relative; transform: translate(-50%, -50%); width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer;
  display: grid; place-items: center; color: #fff; font: 700 11px Pretendard, sans-serif; transition: transform .15s; }
.pin.area { background: color-mix(in srgb, var(--c) 35%, transparent); border: 2px dashed var(--c); color: var(--c); box-shadow: none; }
.pin:hover { transform: translate(-50%, -50%) scale(1.15); }
.pin.sel { outline: 3px solid var(--sel); outline-offset: 2px; z-index: 5; }
.nokey { position: fixed; inset: 0; display: grid; place-items: center; color: var(--mute); font-size: 14px; padding: 24px 24px 24px 420px; text-align: center; }

@media (max-width: 760px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 78dvh; border-radius: 16px 16px 0 0;
    transition: transform .25s ease; padding-bottom: env(safe-area-inset-bottom); }
  #panel.collapsed { transform: translateY(calc(78dvh - 196px)); }
  #grip { display: block; border: 0; background: none; padding: 8px 0 0; width: 100%; }
  #grip span { display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto; }
  .top { padding-top: 8px; }
  .foot { display: none; }
  .nokey { padding: 24px 24px 220px; }
}

/* 바탕 지도는 회색으로 눌러 핀만 보이게 */
#map img { filter: grayscale(1) contrast(.92) brightness(1.04); }
