:root {
  --bg: #0f1115; --panel: #171a21; --panel-a: rgba(23,26,33,.93); --line: #272c36; --fg: #e6e9ef;
  --muted: #8d95a5; --accent: #ffcb05; --accent2: #3b6ef5;
  --ok: #38c172; --warn: #f0932b; --bad: #d64545;
  /* 판매처 색 — 세븐일레븐 주황, 롯데마트 빨강, GS25 하늘(예정) */
  --cu: #7b3fa0; --seven: #f37021; --emart: #ffb300; --gs25: #00b2e3; --emartmart: #ffd400; --lotte: #e4002b;
  --panel-w: 392px;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f6f7f9; --panel:#fff; --panel-a: rgba(255,255,255,.94); --line:#e3e6ec; --fg:#1a1d24; --muted:#6b7280; }
}
* { box-sizing: border-box; }
html, body { height:100%; }
body { margin:0; background:var(--bg); color:var(--fg); overflow:hidden;
  font:14px/1.5 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", sans-serif; }
h2 { font-size:13px; margin:0; color:var(--muted); font-weight:600; }
button { background:var(--accent2); color:#fff; border:0; border-radius:7px;
  padding:7px 13px; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; }
button:disabled { opacity:.5; cursor:default; }
.muted { color:var(--muted); } .small { font-size:12px; }
[hidden] { display:none !important; }

/* ===== 지도가 바닥 ===== */
.map { position:fixed; inset:0; background:var(--bg); z-index:0; }
.leaflet-container { background:var(--bg) !important; font:inherit !important; }
.leaflet-popup-content { margin:0 !important; }
.leaflet-bottom.leaflet-left { margin-bottom:104px; }

/* ===== 떠 있는 요소 공통 ===== */
.float, .panel, .mapctl, .notices {
  position:fixed; z-index:20; }
button.mini { background:transparent; border:1px solid var(--line); color:var(--muted);
  padding:4px 10px; font-size:11px; font-weight:600; border-radius:6px; white-space:nowrap; }
button.mini:hover { border-color:var(--accent2); color:var(--fg); }
button.mini.install { border-color:var(--accent2); color:var(--fg); }
.notices { top:12px; left:60px; display:flex; flex-direction:column; gap:8px; max-width:360px; }
.foot { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:12px 0 0; }
.notice { background:var(--panel-a); border:1px solid var(--line); border-radius:12px; padding:10px 12px;
  font-size:12px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; box-shadow:0 6px 24px rgba(0,0,0,.2); }
.notice.warn { border-color:var(--warn); color:var(--warn); }
.notice .mini { margin-left:auto; }
.kbd { display:inline-block; border:1px solid var(--line); border-radius:5px; padding:0 6px; font-size:12px; }

/* 지도 조작 버튼 — 왼쪽 아래 */
.mapctl { left:12px; bottom:12px; display:flex; flex-direction:column; gap:8px; align-items:flex-start; }
.ctl { background:var(--panel-a); color:var(--fg); border:1px solid var(--line); border-radius:10px;
  padding:0 12px; height:36px; font-size:12px; font-weight:700; box-shadow:0 4px 16px rgba(0,0,0,.25);
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px); }
#locBtn { width:36px; padding:0; font-size:18px; line-height:1; }
#locBtn.busy { opacity:.6; }
.seg { display:flex; }
.seg .ctl { border-radius:0; color:var(--muted); }
.seg .ctl:first-child { border-radius:10px 0 0 10px; }
.seg .ctl:last-child { border-radius:0 10px 10px 0; border-left:0; }
.seg .ctl.on { color:var(--fg); background:var(--line); }

/* ===== 오른쪽 플로팅 패널 ===== */
.panel { top:12px; right:12px; bottom:12px; width:var(--panel-w);
  background:var(--panel-a); backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
  border:1px solid var(--line); border-radius:16px; box-shadow:0 10px 36px rgba(0,0,0,.3);
  display:flex; flex-direction:column; overflow:hidden; }
/* 스크롤은 손잡이 아래 본문만. 손잡이가 스크롤 영역 안에 있으면 끌어내리기가 스크롤로 먹힌다. */
.panelbody { flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; padding:4px 14px 14px; }
.panelbody::-webkit-scrollbar { width:8px; }
.panelbody::-webkit-scrollbar-thumb { background:var(--line); border-radius:4px; }
.handle { display:none; }
.sec { padding:12px 0; border-bottom:1px solid var(--line); }
.sec:last-of-type { border-bottom:0; }
.sectop { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
details.sec summary { cursor:pointer; font-size:13px; color:var(--muted); font-weight:600; list-style:none;
  display:flex; align-items:center; gap:8px; }
details.sec summary::-webkit-details-marker { display:none; }
details.sec summary::before { content:'▸'; font-size:11px; }
details.sec[open] summary::before { content:'▾'; }
details.sec > :not(summary) { margin-top:10px; }
label.muted input { vertical-align:-1px; margin-right:4px; }
label.carry { display:block; margin-top:8px; }

/* 칩(상품·지역) */
.chips { display:flex; flex-wrap:wrap; gap:6px; }
/* 한 줄짜리 섹션 — 제목 + 드롭다운 */
.sec.row1 { display:flex; align-items:center; gap:10px; }
.sec.row1 h2 { flex:none; }
select#prodSel { flex:1; min-width:0; background:var(--panel); color:var(--fg); border:1px solid var(--line); border-radius:8px;
  padding:7px 10px; font:inherit; font-size:13px; font-weight:600; }
select#prodSel:focus { outline:none; border-color:var(--accent2); }
.prod { border:1px solid var(--line); border-radius:999px; padding:5px 11px; font-size:12px;
  cursor:pointer; display:flex; align-items:center; gap:6px; background:transparent; color:var(--fg);
  transition:border-color .15s; font-weight:500; }
.prod:hover { border-color:var(--accent2); }
.prod.on { border-color:var(--accent2); background:var(--line); font-weight:600; }
.prod .n { font-variant-numeric:tabular-nums; font-weight:700; color:var(--ok); }
.prod .n.zero { color:var(--muted); font-weight:400; }
.prod .rt { width:6px; height:6px; border-radius:50%; background:var(--ok); }
.prod.all { font-weight:600; }
.empty { color:var(--muted); font-size:13px; padding:16px 0; text-align:center; }
.chip { background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:4px 10px; font-size:11px; }
.chip b { color:var(--accent); }

/* 판매처 목록 — 도감처럼 세로 목록, 눌러서 켜고 끈다 */
.chainlist { display:flex; flex-direction:column; gap:6px; }
.chainrow { display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--line);
  border-radius:10px; cursor:pointer; position:relative; overflow:hidden; transition:opacity .15s, border-color .15s;
  user-select:none; -webkit-user-select:none; }
.chainrow.on { border-color:var(--c); }
.chainrow:not(.on) { opacity:.42; }
.chainrow:not(.on) .sw { filter:grayscale(.6); }
.chainrow.soon { opacity:.5; cursor:default; }
.chainrow .sw { flex:none; width:24px; height:15px; border-radius:8px; background:var(--c); border:1.5px solid #fff;
  box-shadow:0 1px 3px rgba(0,0,0,.3); }
.chainrow .sw.mart { border-radius:3px; }
.chainrow .cn { flex:1; min-width:0; line-height:1.25; }
.chainrow .cn b { font-size:13px; }
.chainrow .cn .meta { display:block; font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chainrow .cq { text-align:right; font-variant-numeric:tabular-nums; font-size:13px; font-weight:700; white-space:nowrap; }
.chainrow .cq.zero { color:var(--muted); font-weight:500; font-size:12px; }
.chainrow .cq .u { font-size:11px; color:var(--muted); font-weight:500; }
.chainrow .tog { flex:none; width:34px; height:20px; border-radius:10px; background:var(--line); position:relative; transition:background .15s; }
.chainrow .tog::after { content:''; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff; transition:left .15s; box-shadow:0 1px 2px rgba(0,0,0,.3); }
.chainrow.on .tog { background:var(--c); }
.chainrow.on .tog::after { left:16px; }
.chainrow .soonlbl { font-size:11px; color:var(--muted); }

.badge { display:inline-block; padding:2px 7px; border-radius:5px; font-size:11px; font-weight:700; color:#fff; white-space:nowrap; }
.badge.cu{background:var(--cu)} .badge.seven{background:var(--seven)} .badge.emart24{background:var(--emart);color:#2a2000}
.badge.emart{background:var(--emartmart);color:#2a2000} .badge.lottemart{background:var(--lotte)} .badge.gs25{background:var(--gs25)}
.badge.m { border-radius:2px; }

/* 탭 */
.tabs { display:flex; gap:6px; }
.tabs.sub { margin-bottom:8px; }
button.tab, button.ktab { background:transparent; color:var(--muted); border:1px solid var(--line);
  padding:5px 10px; font-size:12px; border-radius:7px; white-space:nowrap; }
button.tab.on, button.ktab.on { background:var(--line); color:var(--fg); }

/* 목록 — 패널이 좁으니 표 대신 카드 */
.rows { display:flex; flex-direction:column; gap:6px; }
.row { border:1px solid var(--line); border-radius:10px; padding:8px 10px; cursor:pointer; transition:border-color .15s; }
.row:hover { border-color:var(--accent2); }
.row .l1 { display:flex; align-items:center; gap:6px; }
.row .l1 .nm { flex:1; min-width:0; font-weight:700; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row .l1 .q { font-variant-numeric:tabular-nums; font-weight:800; font-size:16px; white-space:nowrap; }
.row .l1 .q.stale { color:var(--muted); font-weight:600; }
.row .l1 .q.hidden { color:var(--muted); font-weight:600; text-decoration:underline dashed; text-underline-offset:3px; }
.row .items .muted { color:var(--muted); }
.row .l2 { display:flex; justify-content:space-between; gap:8px; font-size:11px; color:var(--muted); margin-top:2px; }
.row .l2 .ad { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row .l2 .st { white-space:nowrap; }
.row .l2 .st.warn { color:var(--warn); }
.row .items { font-size:11px; color:var(--muted); margin-top:2px; }
.unit { font-size:11px; color:var(--muted); font-weight:500; margin-left:1px; }
.rowcount { font-size:11px; color:var(--muted); margin:6px 2px 0; }
.up { color:var(--ok); font-weight:700; } .down { color:var(--warn); }
.k { display:inline-block; padding:2px 7px; border-radius:5px; font-size:11px; font-weight:700; }
.k.restock { background:var(--ok); color:#fff; }
.k.sellout { background:var(--bad); color:#fff; }
.k.drop    { background:var(--warn); color:#2a2000; }
.k.up      { background:var(--accent2); color:#fff; }
.k.first   { background:var(--line); color:var(--muted); }

/* 운영 표(수집 루프) */
table { width:100%; border-collapse:collapse; font-size:12px; }
th, td { text-align:left; padding:6px 6px; border-bottom:1px solid var(--line); }
th { color:var(--muted); font-weight:600; font-size:10px; text-transform:uppercase; letter-spacing:.04em; }
td.n { text-align:right; font-variant-numeric:tabular-nums; font-weight:600; }
.tablewrap { overflow-x:auto; border:1px solid var(--line); border-radius:8px; }
.tablewrap table { margin:0; }
code { background:var(--line); padding:1px 5px; border-radius:4px; font-size:11px; }

/* ===== 핀 ===== */
/* 편의점은 타원(알약), 마트는 네모. 숫자는 재고 수량(마트는 상자 수). */
.pin { display:inline-flex; align-items:center; justify-content:center;
  min-width:26px; height:22px; padding:0 6px; border-radius:11px; color:#fff;
  font-size:12px; font-weight:700; white-space:nowrap; cursor:pointer;
  box-shadow:0 1px 4px rgba(0,0,0,.35); border:1.5px solid #fff; font-family:inherit; }
.pin.mart { border-radius:4px; min-width:28px; height:24px; font-size:13px; }
.pin.cu{background:#7b3fa0} .pin.seven{background:#f37021} .pin.emart24{background:#ffb300;color:#2a2000}
.pin.emart{background:#ffd400;color:#2a2000} .pin.lottemart{background:#e4002b} .pin.gs25{background:#00b2e3}
/* 미확인 — 속이 빈 점선 핀. 취급점(재고 0) — 속이 빈 실선 작은 핀. 수량 숨김(이마트24 9999) — 연회색 점선 핀, 숫자는 숨기기 전 수량. */
.pin.stale { background:#fff; border-style:dashed; }
.pin.hidden { background:#eef0f4; border-style:dashed; border-width:2px; }
.pin.zero { background:#fff; opacity:.85; font-size:11px; min-width:22px; height:19px; font-weight:600; }
.pin.cu.stale, .pin.cu.zero, .pin.cu.hidden { color:#7b3fa0; border-color:#7b3fa0; }
.pin.seven.stale, .pin.seven.zero, .pin.seven.hidden { color:#f37021; border-color:#f37021; }
.pin.emart24.stale, .pin.emart24.zero, .pin.emart24.hidden { color:#a87400; border-color:#ffb300; }
.pin.emart.stale, .pin.emart.zero, .pin.emart.hidden { color:#8a6800; border-color:#e0a800; }
.pin.lottemart.stale, .pin.lottemart.zero, .pin.lottemart.hidden { color:#e4002b; border-color:#e4002b; }
.pin.gs25.stale, .pin.gs25.zero, .pin.gs25.hidden { color:#0086b3; border-color:#00b2e3; }
.pin.hl { outline:3px solid var(--accent); outline-offset:1px; }
/* 재고 0 편의점 — 숫자 없는 작은 회색 점. 테두리만 체인 색. 확대했을 때만 그린다. */
.pin.dot { min-width:11px; width:11px; height:11px; padding:0; border-radius:50%; background:#b4bac6; border-width:2px;
  font-size:0; box-shadow:0 1px 2px rgba(0,0,0,.3); opacity:.9; }
.pin.dot.stale { background:#fff; border-style:dashed; }
/* 재고 0 점 캔버스 — 지도 위에 얹히되 이벤트는 받지 않는다(드래그·클릭은 지도가 처리) */
.dots { display:block; pointer-events:none; }
.pin.dot.cu{border-color:#7b3fa0} .pin.dot.seven{border-color:#f37021} .pin.dot.emart24{border-color:#d99a00} .pin.dot.gs25{border-color:#00b2e3}
.legendpin.dot { display:inline-block; vertical-align:middle; transform:none; }
.off { display:none !important; }
.legendpin { transform:scale(.85); vertical-align:middle; cursor:default; box-shadow:none; }
.legend { margin:10px 0 0; line-height:1.9; }
.me { width:16px; height:16px; border-radius:50%; background:#3b6ef5; border:3px solid #fff;
  box-shadow:0 0 0 6px rgba(59,110,245,.25), 0 1px 4px rgba(0,0,0,.3); }

/* 말풍선 — 타일 위에 얹히므로 테마와 무관하게 밝은 카드로 고정 */
.iw { position:relative; width:252px; padding:12px 14px; border-radius:12px;
  background:#fff; color:#1a1d24; border:1px solid #d8dce4;
  box-shadow:0 10px 28px rgba(15,17,21,.24); font-size:13px; line-height:1.5; }
.iw::after { content:''; position:absolute; left:50%; bottom:-7px; width:13px; height:13px;
  margin-left:-6.5px; background:#fff; border-right:1px solid #d8dce4;
  border-bottom:1px solid #d8dce4; transform:rotate(45deg); }
.iwx { position:absolute; top:7px; right:7px; width:24px; height:24px; padding:0;
  background:transparent; color:#9aa1ad; font-size:17px; font-weight:400; line-height:1; border-radius:6px; }
.iwx:hover { background:#f1f3f7; color:#1a1d24; }
.iwhead { display:flex; align-items:center; gap:6px; padding-right:24px; }
.iwhead b { font-size:14px; letter-spacing:-.01em; }
.iwaddr { color:#6b7280; font-size:12px; margin:5px 0 9px; }
.iwlist { list-style:none; margin:0; padding:9px 0 0; border-top:1px solid #eceff4; }
.iwlist li { display:flex; justify-content:space-between; gap:10px; padding:2px 0; }
.iwlist li span { color:#4b5563; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.iwlist li b { font-variant-numeric:tabular-nums; white-space:nowrap; }
.iwlist li b i { font-style:normal; font-weight:500; color:#6b7280; font-size:11px; }
.iwstale { margin-top:7px; font-size:11px; color:#b45309; }
.iwlist .hq { color:#6b7280; font-weight:600; text-decoration:underline dashed; text-underline-offset:3px; }
.iwzero { margin-top:7px; font-size:11px; color:#6b7280; }
.iwgo { display:inline-block; margin-top:10px; color:#3b6ef5; text-decoration:none; font-size:12px; font-weight:600; }
.leaflet-popup-content .iw { box-shadow:none; border:0; width:auto; min-width:224px; }
.leaflet-popup-content .iw::after { display:none; }

/* ===== 모바일: 패널이 아래 시트로 ===== */
@media (max-width: 900px) {
  :root { --sheet: 30vh; }
  body { font-size:15px; }
  .notices { top:8px; left:8px; right:8px; max-width:none; }
  .mapctl { left:auto; right:10px; bottom:calc(var(--sheet) + 12px); align-items:flex-end; transition:bottom .25s; }
  .leaflet-bottom.leaflet-left { margin-bottom:calc(var(--sheet) + 4px); }
  .panel { top:auto; left:0; right:0; bottom:0; width:auto; height:var(--sheet); border-radius:18px 18px 0 0;
    transition:height .25s; }
  .panel.dragging { transition:none; }
  .panelbody { padding:0 12px calc(12px + env(safe-area-inset-bottom)); }
  .handle { display:block; flex:none; width:100%; background:transparent; border:0; padding:10px 0 8px; margin:0;
    border-radius:0; touch-action:none; cursor:grab; }
  .handle span { display:block; width:44px; height:5px; border-radius:3px; background:var(--muted); margin:0 auto; opacity:.6; }
  .sec { padding:10px 0; }
  button, .prod { min-height:34px; }
  .prod { font-size:13px; }
  .chainrow { padding:9px 10px; }
  .chainrow .cn b { font-size:14px; }
  .row .l1 .q { font-size:18px; }
  button.tab, button.ktab { padding:7px 11px; font-size:13px; }
}
@media (display-mode: standalone) {
  .notices { top:calc(8px + env(safe-area-inset-top)); }
}
