: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%; overflow: hidden; overscroll-behavior: none; 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; }
@media (max-width: 760px) { html, body { 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-family: "Noto Serif KR", serif; font-size: 23px; letter-spacing: -0.04em; font-weight: 900; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.dnav { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; }
.dnav button { border: 0; background: none; height: 30px; border-radius: 7px; white-space: nowrap; }
.dnav [data-step] { width: 30px; font-size: 19px; line-height: 1; color: var(--ink); }
.dnav [data-step]:hover:not(:disabled) { background: var(--paper); }
.dnav [data-step]:disabled { opacity: .25; cursor: default; }
#pick { min-width: 74px; padding: 0 14px; background: var(--paper); font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; 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; }
.cats { cursor: grab; user-select: none; }
.cats.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); }
.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 li:last-child { border-bottom: 0; }
.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: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(100% - var(--peek, 132px))); }
  #grip { display: block; border: 0; background: none; padding: 10px 0 6px; width: 100%; touch-action: none; }
  .top { touch-action: none; }
  #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); }


/* 날짜 고르기 달력 */
#cal { position: absolute; z-index: 20; top: 62px; right: 14px; width: 288px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 12px 10px; box-shadow: 0 18px 40px -16px rgba(30,25,15,.35); animation: calIn .14s ease-out; }
#cal[hidden] { display: none; }
@keyframes calIn { from { opacity: 0; transform: translateY(-4px); } }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 15px; letter-spacing: -0.02em; }
.cal-nav { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; font-size: 20px; line-height: 1; color: var(--ink); }
.cal-nav:hover:not(:disabled) { background: var(--bg); }
.cal-nav:disabled { opacity: .25; cursor: default; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week span { text-align: center; font-size: 11px; color: var(--mute); padding: 2px 0 6px; }
.cal-week span:first-child { color: var(--crime); }
.cal-grid button { position: relative; height: 36px; border: 0; background: none; font-size: 13.5px; font-variant-numeric: tabular-nums; border-radius: 0; }
.cal-grid button:disabled { color: #c9c3b8; cursor: default; }
.cal-grid button:not(:disabled):not(.start):not(.end):hover { background: var(--bg); border-radius: 9px; }
.cal-grid button.today { font-weight: 800; }
.cal-grid button.in { background: var(--bg); }
.cal-grid button.start { border-radius: 9px 0 0 9px; }
.cal-grid button.end { border-radius: 0 9px 9px 0; }
.cal-grid button.start.end { border-radius: 9px; }
.cal-grid button.start, .cal-grid button.end { background: var(--ink); color: var(--paper); font-weight: 700; }
.cal-grid button.anchor { box-shadow: inset 0 0 0 2px var(--ink); border-radius: 9px; }
.cal-grid i { position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--crime); }
.cal-grid .start i, .cal-grid .end i { background: var(--paper); }
.cal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.cal-foot button { border: 0; background: var(--bg); border-radius: 7px; padding: 5px 10px; font-size: 12px; font-weight: 600; flex: none; }
.cal-hint { margin: 0 2px; font-size: 11.5px; color: var(--mute); }
@media (max-width: 760px) { #cal { right: 10px; left: 10px; width: auto; top: 70px; } .cal-grid button { height: 40px; } }

/* 사건 상세: 공유·신고 */
.d-acts { display: flex; gap: 6px; margin: -4px 0 16px; }
.d-acts button { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; }
.d-acts #report { color: var(--mute); font-weight: 500; margin-left: auto; border-color: transparent; }
.d-acts button:hover { background: var(--bg); }

/* 사건 경과 */
.arts li { position: relative; }
.t-day { font-size: 11.5px; font-weight: 700; color: var(--ink); padding: 12px 0 0; font-variant-numeric: tabular-nums; }
.t-st { display: inline-block; font-style: normal; font-size: 11px; font-weight: 700; color: var(--paper); background: var(--ink); border-radius: 5px; padding: 1px 6px; margin-bottom: 4px; }

/* 검색·내 위치 */
#searchBox { position: fixed; z-index: 9; top: 12px; right: 12px; width: 300px; }
.sb-row { display: flex; gap: 6px; }
#q { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 4px 14px -6px rgba(30,25,15,.3); outline: none; }
#q:focus { border-color: var(--ink); }
#me { width: 40px; height: 40px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); display: grid; place-items: center; box-shadow: 0 4px 14px -6px rgba(30,25,15,.3); }
#me.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#qres { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 30px -14px rgba(30,25,15,.35); max-height: 320px; overflow-y: auto; }
#qres[hidden] { display: none; }
#qres button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 7px; }
#qres button:hover { background: var(--bg); }
#qres b { display: block; font-size: 13.5px; font-weight: 600; }
#qres span { font-size: 11.5px; color: var(--mute); }
#qres .none { padding: 10px; font-size: 13px; color: var(--mute); }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2f6db5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47,109,181,.2); transform: translate(-50%, -50%); }

/* 알림 토스트 */
#toast { position: fixed; z-index: 40; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); white-space: nowrap; }
#toast[hidden] { display: none; }

/* 신고 창 */
#rp { position: fixed; inset: 0; z-index: 30; background: rgba(27,26,23,.35); display: grid; place-items: center; padding: 16px; }
#rp[hidden] { display: none; }
#rpForm { width: 100%; max-width: 360px; background: var(--paper); border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.5); }
#rpForm h3 { margin: 0 0 10px; font-size: 16px; }
#rpForm label { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 14px; cursor: pointer; }
#rpForm input[type=radio] { accent-color: var(--ink); width: 16px; height: 16px; }
#rpNote { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical; background: var(--paper); color: var(--ink); }
.rp-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.rp-btns button { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 14px; font-size: 13px; }
.rp-btns button[type=submit] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }

@media (max-width: 760px) {
  #searchBox { left: 10px; right: 10px; top: 10px; width: auto; }
  #toast { bottom: auto; top: 62px; }
}

.cal-quick { display: flex; gap: 4px; flex: none; }

/* 지역 필터 */
.region { position: relative; padding: 0 18px 10px; }
#rgBtn { width: 100%; height: 38px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); padding: 0 12px; font-size: 14px; font-weight: 700; }
#rgBtn::before { content: "지역"; font-size: 12px; font-weight: 500; color: var(--mute); margin-right: 10px; }
#rgLabel { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rgBtn i { width: 10px; height: 6px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236f6b63' stroke-width='1.5'/%3E%3C/svg%3E"); }
#rgBtn.on { border-color: var(--ink); }
#rgPop { position: absolute; z-index: 20; left: 18px; right: 18px; top: 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; box-shadow: 0 18px 40px -16px rgba(30,25,15,.35); max-height: min(60vh, 460px); overflow-y: auto; animation: calIn .14s ease-out; }
#rgPop[hidden], .rg-sec[hidden] { display: none; }
.rg-sec + .rg-sec { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.rg-h { font-size: 11.5px; font-weight: 700; color: var(--mute); margin: 0 2px 8px; }
.rg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
#rgSgg { grid-template-columns: repeat(3, 1fr); }
.rg-grid button { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-size: 13px; padding: 0 6px; white-space: nowrap; overflow: hidden; }
.rg-grid button b { font-size: 11px; font-weight: 600; color: var(--mute); font-variant-numeric: tabular-nums; }
.rg-grid button:hover { background: var(--bg); }
.rg-grid button.on { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 700; }
.rg-grid button.on b { color: rgba(255,253,249,.7); }

/* 핀 묶음 */
.cluster { width: var(--s); height: var(--s); transform: translate(-50%, -50%); border-radius: 50%; padding: 3px; background: var(--ring); cursor: pointer;
  box-shadow: 0 3px 10px -3px rgba(30,25,15,.45); transition: transform .12s; }
.cluster:hover { transform: translate(-50%, -50%) scale(1.08); }
.cluster span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--paper); color: var(--ink);
  font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* 목록 머리: 요약 + 정렬 */
.lhead { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 7px 18px; border-bottom: 1px solid var(--line); }
.lhead[hidden] { display: none; }
#sum { margin: 0; font-size: 12px; color: var(--mute); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sum b { color: var(--ink); font-weight: 700; }
.sort { display: flex; flex: none; gap: 2px; }
.sort button { border: 0; background: none; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; color: var(--mute); }
.sort button.on { color: var(--ink); font-weight: 700; background: var(--bg); }

/* 이 동네 다른 사건 */
.near { margin: 0 0 18px; padding: 10px 12px 4px; background: var(--bg); border-radius: 10px; }
.arts-h { margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.near[hidden] { display: none; }
.near h3 { margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.near ol { list-style: none; margin: 0; padding: 0; }
.near button { display: grid; grid-template-columns: 4px 1fr; gap: 1px 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 0; border-radius: 0; }
.near button i { grid-row: span 2; background: var(--c); border-radius: 2px; }
.near button .t { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.near button .m { font-size: 11.5px; color: var(--mute); }
.near button:hover .t { text-decoration: underline; }

/* 휴대폰: 아래 목록창의 머리 부분 줄이기 */
@media (max-width: 760px) {
  .top { padding: 2px 14px 8px; align-items: center; }
  .brand h1 { font-size: 19px; }
  #stamp { display: none; }
  .dnav { padding: 2px; }
  .dnav button { height: 28px; }
  #pick { min-width: 64px; font-size: 13px; }
  .region { padding: 0 14px 7px; }
  #rgBtn { height: 34px; font-size: 13.5px; }
  #rgPop { left: 14px; right: 14px; top: 40px; }
  .kinds { padding: 0 14px 7px; gap: 5px; }
  .kind { flex-direction: row; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border-radius: 9px; }
  .kind .n { order: 2; font-size: 15px; }
  .kind .l { order: 1; font-size: 12.5px; color: var(--ink); }
  .cats { padding: 0 14px 8px; }
  .cats .cat { padding-top: 4px; padding-bottom: 4px; }
  .lhead { padding: 3px 14px; }
  #panel { transition: transform .32s cubic-bezier(.2,.8,.2,1); will-change: transform; }
  #panel.collapsed #list, #panel.collapsed .lhead { pointer-events: none; }
}

/* 진행 중 */
em.live { display: inline-flex; align-items: center; gap: 4px; font-style: normal; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--crime);
  border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 2px; }
em.live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }
.pin.live::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--c); animation: ripple 1.6s ease-out infinite; pointer-events: none; }
@keyframes ripple { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

/* 핀/밀도 전환 */
.cal-note { margin: 6px 0 0; font-size: 11px; color: var(--muted, #8a8f98); text-align: center; }
