:root {
  --bg: #16130e; --panel: #1f1a13; --panel2: #292219; --gold: #c8a45d;
  --gold-dim: #8a7440; --text: #e8ddc6; --text-dim: #9b8f76; --accent: #d9b96c;
  --danger: #b0563c; --ok: #7fa051;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
#app { display: flex; height: 100vh; }

#sidebar { width: 320px; min-width: 320px; background: var(--panel); display: flex;
  flex-direction: column; border-right: 1px solid #3a3020; z-index: 1000; overflow: hidden; }
#sidebar.hidden { display: none; }
#sidebar header { padding: 10px 12px 6px; }
#sidebar h1 { margin: 0 0 8px; font-size: 19px; color: var(--gold); letter-spacing: 1px;
  font-variant: small-caps; }
#mapswitch { display: flex; gap: 6px; margin-bottom: 8px; }
#mapswitch button { flex: 1; padding: 6px 4px; background: var(--panel2); color: var(--text-dim);
  border: 1px solid #3a3020; border-radius: 4px; cursor: pointer; font-size: 12px; }
#mapswitch button.active { color: var(--gold); border-color: var(--gold-dim); background: #322a1c; }

#progressbar { position: relative; height: 18px; background: var(--panel2); border-radius: 9px;
  overflow: hidden; border: 1px solid #3a3020; }
#progressfill { position: absolute; inset: 0; width: 0%; background: linear-gradient(90deg, #6d5a2e, var(--gold)); transition: width .3s; }
#progresstext { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 18px; color: #fff; text-shadow: 0 1px 2px #000; }

#searchwrap { display: flex; padding: 8px 12px 4px; gap: 4px; }
#search { flex: 1; padding: 7px 10px; background: var(--panel2); border: 1px solid #3a3020;
  border-radius: 4px; color: var(--text); font-size: 13px; }
#search:focus { outline: none; border-color: var(--gold-dim); }
#clearsearch { width: 32px; background: var(--panel2); border: 1px solid #3a3020; color: var(--text-dim);
  border-radius: 4px; cursor: pointer; font-size: 16px; }

#layers { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; }
#layers label { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-dim);
  background: var(--panel2); padding: 3px 8px; border-radius: 10px; cursor: pointer; border: 1px solid #3a3020; }
#layers label.on { color: var(--accent); border-color: var(--gold-dim); }
#layers input { display: none; }

#cats { flex: 1; overflow-y: auto; padding: 4px 6px 10px; }
.cat { margin: 2px 4px; border-radius: 5px; background: var(--panel2); border: 1px solid #322a1c; }
.cat-head { display: flex; align-items: center; padding: 5px 8px; cursor: pointer; gap: 6px; }
.cat-head input[type=checkbox] { accent-color: var(--gold); }
.cat-name { flex: 1; font-size: 13px; }
.cat-count { font-size: 11px; color: var(--text-dim); }
.cat-vis { background: none; border: 1px solid #3a3020; color: var(--text-dim); border-radius: 4px;
  font-size: 10px; padding: 2px 5px; cursor: pointer; min-width: 44px; }
.cat-vis.dim { color: var(--accent); } .cat-vis.hide { color: var(--danger); }
.cat-children { padding: 0 8px 6px 26px; display: none; }
.cat.open .cat-children { display: block; }
.cat-child { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); padding: 2px 0; }
.cat-child input { accent-color: var(--gold); }
.cat-child .cc-count { margin-left: auto; font-size: 10.5px; }
.cat-toggle { border: none; background: none; color: var(--text-dim); cursor: pointer; font-size: 10px; width: 16px; }

#quickcheck { border-top: 1px solid #3a3020; padding: 8px 12px; }
#quickcheck label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex-wrap: wrap; }
#quickcheck input { width: 18px; height: 18px; accent-color: var(--gold); }
#quickcheck .qc-title { font-size: 13px; color: var(--text-dim); font-weight: 600; }
#quickcheck.on .qc-title { color: var(--gold); }
#quickcheck.on { background: #292219; }

/* toast */
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(20,16,10,.96); color: var(--text); border: 1px solid var(--gold-dim);
  border-radius: 8px; padding: 10px 18px; font-size: 13px; z-index: 3000;
  box-shadow: 0 4px 16px rgba(0,0,0,.7); pointer-events: none;
  opacity: 0; transition: opacity .25s; max-width: 86vw; text-align: center; }
#toast.show { opacity: 1; }
#toast b { color: var(--gold); }

#sidebar footer { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-top: 1px solid #3a3020; }
#sidebar footer button { flex: 1 1 auto; min-width: 0; padding: 7px 2px; background: var(--panel2);
  color: var(--text-dim); border: 1px solid #3a3020; border-radius: 4px; cursor: pointer;
  font-size: 11.5px; white-space: nowrap; }
#sidebar footer button:hover { color: var(--gold); }

#sidebar-toggle { position: absolute; top: 10px; left: 330px; z-index: 1001; width: 38px; height: 38px;
  background: var(--panel); color: var(--gold); border: 1px solid #3a3020; border-radius: 6px;
  cursor: pointer; font-size: 17px; transition: left .15s; }
#app.nosb #sidebar-toggle { left: 10px; }
#btn-undo { position: absolute; top: 56px; left: 330px; z-index: 1001; width: 38px; height: 38px;
  background: var(--panel); color: var(--gold); border: 1px solid #3a3020; border-radius: 6px;
  cursor: pointer; font-size: 17px; transition: left .15s, opacity .15s; }
#app.nosb #btn-undo { left: 10px; }
#btn-undo:disabled { cursor: default; }

#map { flex: 1; background: #0d0b08; }
.leaflet-container { background: #0d0b08; font: inherit; }

/* markers */
.mk { display: flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.75); color: #fff; font-weight: 700;
  text-shadow: 0 1px 1px #000; box-shadow: 0 1px 4px rgba(0,0,0,.7); cursor: pointer; }
.mk.done { opacity: .35; filter: saturate(.4); }
.mk .badge, .mki .badge { position: absolute; top: -7px; right: -8px; background: #111; color: var(--gold);
  border: 1px solid var(--gold-dim); border-radius: 8px; font-size: 9.5px; font-weight: 700;
  padding: 0 4px; line-height: 13px; min-width: 14px; text-align: center; z-index: 2; }
.mk.grp { border-style: double; border-width: 3px; }
.mk.hl, .mki.hl img { box-shadow: 0 0 0 2px #ffd97a, 0 1px 5px #000; border-radius: 50%; }

/* fextralife image markers */
.mki { position: relative; cursor: pointer; }
.mki img { width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.9)); }
.mki.done { opacity: .35; filter: saturate(.35); }
.mki.grp img { filter: drop-shadow(0 0 3px #c8a45d) drop-shadow(0 1px 2px #000); }
.mki.noimg img { display: none; }
.mki.noimg { background: #6d5a2e; border-radius: 50%; border: 1.5px solid #000; }

/* tooltips */
.ttip { background: rgba(20,16,10,.94); color: var(--text); border: 1px solid var(--gold-dim);
  border-radius: 5px; font-size: 12px; padding: 4px 8px; box-shadow: 0 2px 8px rgba(0,0,0,.7); }
.ttip::before { display: none; }

/* popup */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border: 1px solid var(--gold-dim);
  border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.7); }
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--gold-dim); }
.leaflet-popup-content { margin: 10px 12px; min-width: 230px; max-width: 300px; }
.pp-title { font-size: 15px; color: var(--gold); font-weight: 600; margin-bottom: 2px; padding-right: 14px; }
.pp-type { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.pp-desc { font-size: 12px; max-height: 130px; overflow-y: auto; margin-bottom: 6px; }
.pp-thumb { max-width: 100%; border-radius: 4px; margin-bottom: 6px; max-height: 130px; }
.pp-links { font-size: 12px; margin: 6px 0; display: flex; gap: 10px; }
.pp-links a { color: var(--accent); }
.pp-check { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 6px 0 0;
  border-top: 1px solid #3a3020; cursor: pointer; }
.dgtag { color: var(--gold-dim); font-size: 10.5px; font-style: italic; }
.pp-dungeon { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--accent); margin: 4px 0 6px; padding: 6px 0;
  border-top: 1px solid #3a3020; border-bottom: 1px solid #3a3020; }
.pp-dg-clear { background: #322a1c; color: var(--gold); border: 1px solid var(--gold-dim);
  border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 11.5px; white-space: nowrap; }
.pp-dg-clear:hover { background: #3d331f; }
.pp-check input { width: 17px; height: 17px; accent-color: var(--gold); }
.pp-shop { margin: 6px 0; border-top: 1px solid #3a3020; padding-top: 6px; }
.pp-shop h4 { margin: 0 0 4px; font-size: 12px; color: var(--gold); }
.pp-shop table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.pp-shop td { padding: 2px 4px; border-bottom: 1px solid #2c2517; vertical-align: top; }
.pp-shop td:nth-child(2) { text-align: right; white-space: nowrap; color: var(--accent); }
.pp-shop .note { color: var(--text-dim); font-size: 10.5px; }
.pp-shop-wrap { max-height: 180px; overflow-y: auto; }
.pp-shop .shop-cb { width: 22px; text-align: center; }
.pp-shop .shop-check { width: 15px; height: 15px; accent-color: var(--gold); cursor: pointer; }
.pp-shop .shop-nocheck { color: var(--text-dim); font-size: 11px; }
.pp-shop .shop-count { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.pp-shop tr.shop-done td { opacity: .45; }
.pp-shop tr.shop-done td:nth-child(2) { text-decoration: line-through; }
.pp-shop tr.shop-hit td { background: rgba(255,217,122,.12); }
.pp-list { max-height: 240px; overflow-y: auto; }
.pp-list-item { display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-bottom: 1px solid #2c2517; }
.pp-list-item button { margin-left: auto; background: var(--panel2); border: 1px solid #3a3020;
  color: var(--accent); border-radius: 4px; cursor: pointer; font-size: 10.5px; padding: 2px 6px; }
.pp-list-item input { accent-color: var(--gold); }

/* context menu */
#ctxmenu { position: fixed; z-index: 4000; background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: 7px; box-shadow: 0 6px 22px rgba(0,0,0,.8); padding: 4px; display: flex;
  flex-direction: column; min-width: 190px; }
#ctxmenu button { background: none; border: none; color: var(--text); text-align: left;
  padding: 9px 12px; font-size: 13px; cursor: pointer; border-radius: 4px; }
#ctxmenu button:hover { background: #322a1c; color: var(--gold); }

/* scope list modal rows */
.lst-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid #2c2517; font-size: 13px; }
.lst-row input { width: 16px; height: 16px; accent-color: var(--gold); flex-shrink: 0; }
.lst-row span { flex: 1; }
.lst-row button { background: var(--panel2); border: 1px solid #3a3020; color: var(--accent);
  border-radius: 4px; cursor: pointer; font-size: 11px; padding: 3px 8px; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center; }
#modal[hidden] { display: none; }
#modal-box { background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 10px;
  max-width: 640px; width: 92%; max-height: 84vh; overflow-y: auto; padding: 18px 20px; position: relative; }
#modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; }
#modal-content h2 { color: var(--gold); margin: 0 0 10px; font-size: 17px; }
#modal-content table { width: 100%; border-collapse: collapse; font-size: 12px; }
#modal-content th, #modal-content td { padding: 4px 6px; border-bottom: 1px solid #2c2517; text-align: left; }
#modal-content th { color: var(--gold-dim); }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid #2c2517; gap: 12px; }
.set-row label { font-size: 13px; }
.set-row .hint { display: block; font-size: 11px; color: var(--text-dim); }
.set-row select, .set-row input[type=number] { background: var(--panel2); color: var(--text);
  border: 1px solid #3a3020; border-radius: 4px; padding: 4px 6px; width: 90px; }
.set-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); }

@media (max-width: 760px) {
  #sidebar { position: absolute; height: 100%; width: 84vw; min-width: 0; }
  #sidebar-toggle { left: calc(84vw + 8px); }
  #app.nosb #sidebar-toggle { left: 8px; }
  #btn-undo { left: calc(84vw + 8px); }
  #app.nosb #btn-undo { left: 8px; }
}
