:root {
  --bg: #12100c;
  --panel: #1c1813;
  --panel2: #252018;
  --line: #3a3127;
  --text: #e9dfcb;
  --dim: #a99d86;
  --gold: #d4ae62;
  --gold2: #f0cf86;
  --red: #d9574a;
  --green: #74b06a;
  --blue: #6aa3d9;
  --purple: #b48ce0;
  --side: 400px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif; }
a { color: var(--gold2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: Georgia, "Palatino Linotype", serif; color: var(--gold2); font-weight: normal; margin: .6em 0 .35em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.08rem; } h4 { font-size: 1rem; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--gold); color: var(--gold2); }
button.on { background: #3b3220; border-color: var(--gold); color: var(--gold2); }
input[type=search], input[type=text], textarea, select { font: inherit; color: var(--text); background: #0f0d0a;
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input[type=checkbox] { accent-color: var(--gold); }

/* ---------- header */
#top { height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: linear-gradient(#211b13, #17130e); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 1.15rem; color: var(--gold2); white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
#tabs { display: flex; gap: 2px; }
#tabs a { padding: 6px 10px; border-radius: 6px; color: var(--dim); white-space: nowrap; }
#tabs a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
#tabs a.active { color: var(--gold2); background: #2d261a; }
.search { position: relative; flex: 1 1 160px; min-width: 110px; max-width: 460px; margin-left: auto; }
.search input { width: 100%; min-width: 0; }
@media (max-width: 1180px) { .brand span { display: none; } #tabs a { padding: 6px 7px; } #top { gap: 8px; } }
@media (max-width: 960px) { .toggle span, #quit { font-size: .8rem; } #tabs a { padding: 6px 5px; font-size: .85rem; } }
#qres { position: absolute; top: 34px; left: 0; right: 0; max-height: 70vh; overflow: auto; z-index: 2000;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px #000a; }
#qres .r { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; border-bottom: 1px solid #2a241b; }
#qres .r:hover, #qres .r.sel { background: #2d261a; }
#qres .r .k { font-size: .75rem; color: var(--dim); min-width: 74px; }
#qres .r .w { margin-left: auto; font-size: .8rem; color: var(--dim); text-align: right; }
#qres .grp { padding: 4px 10px; font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--gold); background: #17130e; }
.toggle { display: flex; align-items: center; gap: 4px; color: var(--dim); white-space: nowrap; cursor: pointer; user-select: none; }
.toggle:has(input:checked) { color: var(--gold2); }
#quit { white-space: nowrap; }

/* ---------- layout */
main { position: absolute; top: 48px; bottom: 0; left: 0; right: 0; display: flex; }
#side { width: var(--side); min-width: var(--side); background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 10px 14px 40px; line-height: 1.45; }
body.noside #side { display: none; }
#sidegrip { width: 12px; cursor: pointer; background: #17130e; color: var(--dim); display: flex; align-items: center;
  justify-content: center; font-size: 10px; border-right: 1px solid var(--line); user-select: none; }
#sidegrip:hover { color: var(--gold2); }
#stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #17130e; border-bottom: 1px solid var(--line); }
#crumbs { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumbs a { color: var(--gold2); }
#crumbs .sep { margin: 0 6px; color: #6b5f4d; }
#map { flex: 1; background: #0a0907; }
#page { flex: 1; overflow-y: auto; padding: 18px 26px 60px; line-height: 1.5; }
#page.wide { max-width: none; }
.leaflet-container { background: #0a0907; font: inherit; }

/* ---------- sidebar blocks */
.sec { margin: 12px 0; }
.sec > h3 { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.sec > h3 .cnt { margin-left: auto; font-size: .8rem; color: var(--dim); font-family: "Segoe UI", sans-serif; }
.sec.closed > :not(h3) { display: none; }
.sec > h3::before { content: "▾"; font-size: .8rem; color: var(--dim); }
.sec.closed > h3::before { content: "▸"; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.tag { font-size: .75rem; padding: 1px 7px; border-radius: 10px; background: #2d261a; color: var(--dim); border: 1px solid var(--line); }
.tag.g { color: var(--green); border-color: #3c5a37; }
.tag.r { color: var(--red); border-color: #6a2f29; }
.tag.b { color: var(--blue); border-color: #2f4a66; }
.box { padding: 8px 10px; border-radius: 8px; margin: 8px 0; background: var(--panel2); border: 1px solid var(--line); }
.box.warn { border-color: #7a3a2f; background: #2a1814; }
.box.warn::before { content: "⚠ Внимание"; display: block; color: var(--red); font-weight: 600; font-size: .85rem; margin-bottom: 3px; }
.box.tip { border-color: #4a5f37; background: #1b2215; }
.box.tip::before { content: "💡 Съвет"; display: block; color: var(--green); font-weight: 600; font-size: .85rem; margin-bottom: 3px; }
.box p { margin: .3em 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 3px 0; border-bottom: 1px solid #262017; display: flex; gap: 6px; align-items: baseline; }
ul.plain li:last-child { border-bottom: 0; }
ul.plain li .sub { color: var(--dim); font-size: .85rem; margin-left: auto; text-align: right; }
ul.plain li.done > .lbl { color: #7d725f; text-decoration: line-through; }
.lnk { cursor: pointer; color: var(--gold2); }
.lnk:hover { text-decoration: underline; }
ul.dots { margin: .3em 0; padding-left: 1.2em; }
ul.dots li { margin: .15em 0; }
.digest dt { color: var(--dim); font-size: .85rem; margin-top: 6px; }
.digest dd { margin: 0 0 0 0; }
.spoiler { filter: blur(5px); cursor: pointer; transition: filter .2s; }
.spoiler.shown, body.spoil .spoiler { filter: none; }
.big-check { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); margin: 6px 0; user-select: none; }
.big-check.on { border-color: #3c5a37; background: #1b2215; color: var(--green); }
.progress { height: 8px; background: #0f0d0a; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: linear-gradient(90deg, #6e9a4c, #9fc46b); }
.muted { color: var(--dim); }
.small { font-size: .85rem; }
kbd { background: #0f0d0a; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: .8rem; }

/* ---------- filters panel */
#filters { position: absolute; top: 52px; right: 10px; z-index: 1000; width: 240px; max-height: calc(100% - 70px); overflow: auto;
  background: #1c1813ee; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; box-shadow: 0 6px 24px #0009; }
#filters h4 { margin: 0 0 6px; display: flex; align-items: center; cursor: pointer; }
#filters h4 span { margin-left: auto; font-size: .8rem; color: var(--dim); font-family: "Segoe UI"; }
#filters.closed > :not(h4) { display: none; }
#filters label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; user-select: none; }
#filters label .c { margin-left: auto; color: var(--dim); font-size: .8rem; }
#filters .row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
#filters hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
#coords { position: absolute; left: 10px; bottom: 10px; z-index: 1000; background: #000a; padding: 2px 8px; border-radius: 6px; font-size: .8rem; color: var(--dim); }

/* ---------- markers */
.mk { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; border: 2px solid #000c; box-shadow: 0 1px 4px #000c; color: #fff; }
.mk.done { opacity: .38; filter: grayscale(.8); }
.mk.hl { outline: 3px solid #fff; animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.5); } }
.leaflet-marker-icon.mkw { background: none; border: 0; }
.legend-ico { width: 18px; height: 18px; font-size: 11px; border-width: 1px; }
.k-exit { background: #2f6fb1; } .k-loot { background: #b8892b; } .k-trap { background: #b3302a; }
.k-door { background: #c46a1d; } .k-boss { background: #5a0f0f; border-color: #ff6a5a; } .k-enemy { background: #8f2f2a; }
.k-npc { background: #4b6b45; } .k-companion { background: #7a4fb0; } .k-spawn { background: #6b5235; }
.k-info { background: #2c7a78; } .k-note { background: #9a8a2a; } .k-quest { background: #e0b020; color: #000; }
.k-tip { background: #3f8f3f; } .k-custom { background: #c2417e; } .k-generic { background: #3d4a3a; }

.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 12px; min-width: 240px; max-width: 380px; max-height: 420px; overflow-y: auto; line-height: 1.4; }
.leaflet-popup-content h4 { margin: 0 0 4px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--dim); }
.pop-items { margin: 6px 0; padding: 0; list-style: none; }
.pop-items li { padding: 3px 0; border-bottom: 1px solid #2a241b; }
.pop-items details summary { cursor: pointer; }
.pop-items details summary::marker { color: var(--dim); }
.itemdesc { white-space: pre-wrap; font-size: .8rem; color: var(--dim); max-height: 220px; overflow: auto; margin: 4px 0; padding: 6px; background: #0f0d0a; border-radius: 6px; }
.stat { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 1px 8px; font-size: .85rem; margin: 4px 0; }
.stat b { color: var(--dim); font-weight: normal; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.leaflet-tooltip.lbl { background: #000b; color: #f3e6c6; border: 0; box-shadow: none; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.leaflet-tooltip.lbl::before { display: none; }
.leaflet-tooltip.lbl.done { color: #9fd38f; }
.leaflet-tooltip.lbl.done::after { content: " ✓"; }
.wicon.done { filter: saturate(.3) brightness(.85) drop-shadow(0 0 4px #7fc66b); }
.wicon:hover { filter: drop-shadow(0 0 6px #ffe2a0); }
.travel-label { background: #000c; color: var(--gold2); border: 0; font-size: 11px; padding: 0 5px; }
.travel-label::before { display: none; }

/* ---------- pages */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.card.done { opacity: .6; }
.card h3 { margin: 0 0 4px; display: flex; align-items: baseline; gap: 8px; }
.card h3 .chk { margin-left: auto; }
.qfilters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 14px; position: sticky; top: -18px; background: var(--bg); padding: 8px 0; z-index: 5; }
.md table { border-collapse: collapse; margin: 8px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.md th { background: var(--panel2); color: var(--gold2); font-weight: normal; }
.md blockquote { border-left: 3px solid var(--gold); margin: 8px 0; padding: 4px 12px; background: var(--panel); }
.md code { background: #0f0d0a; padding: 0 4px; border-radius: 4px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.page-narrow { max-width: 1050px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2d261a; border: 1px solid var(--gold);
  color: var(--gold2); padding: 8px 16px; border-radius: 8px; z-index: 5000; box-shadow: 0 6px 24px #000a; }
.offline { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #000d; z-index: 9000; font-size: 1.2rem; text-align: center; }
.editform label { display: block; margin: 4px 0 2px; color: var(--dim); font-size: .85rem; }
.editform input, .editform select, .editform textarea { width: 100%; }
body.editing #map { cursor: crosshair; }
.nbr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: baseline; }
.dir { color: var(--dim); font-size: .8rem; }

/* ---------- future interactions / confirmation dialog */
.leaflet-tooltip.lbl.done.warn { color: #f0c46a; }
.leaflet-tooltip.lbl.done.warn::after { content: " ✓ ⚠"; }
.wicon.done.warn { filter: saturate(.5) brightness(.9) drop-shadow(0 0 5px #e0a640); }
ul.plain li .later { color: #e0a640; margin-left: 6px; font-weight: 600; cursor: help; }
.box.later { border-color: #6b5524; background: #241d10; }
ul.future { margin: 6px 0 0; }
ul.future li { display: block; padding: 3px 0; }
ul.future .tag { margin-right: 6px; }
#modal { position: fixed; inset: 0; z-index: 5000; background: #0009; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal .dlg { background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; box-shadow: 0 12px 40px #000c;
  width: min(520px, 100%); max-height: 85vh; display: flex; flex-direction: column; }
#modal h3 { margin: 0; padding: 12px 16px; color: var(--gold2); border-bottom: 1px solid var(--line); font-family: Georgia, serif; }
#modal .dlg-body { padding: 10px 16px; overflow-y: auto; line-height: 1.45; }
#modal .dlg-btns { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); }
#modal button.primary { background: #2d261a; border-color: var(--gold); color: var(--gold2); }

/* ---------- game switcher + start screen */
#gamechip { padding: 3px 9px; border: 1px solid var(--line); border-radius: 12px; color: var(--gold2); font-size: .8rem; white-space: nowrap; }
#gamechip:hover { border-color: var(--gold); text-decoration: none; }
body.start { overflow: auto; }
#startpage { max-width: 1100px; margin: 0 auto; padding: 32px 16px 60px; text-align: center; }
#startpage .sp-head { display: flex; align-items: center; justify-content: center; gap: 12px; }
#startpage .sp-head img { width: 48px; height: 48px; }
#startpage h1 { font-family: Georgia, serif; color: var(--gold2); margin: 0; }
.gcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 18px; text-align: left; }
.gcard { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); transition: transform .12s, border-color .12s; }
.gcard:hover { transform: translateY(-3px); border-color: var(--gold); text-decoration: none; }
.gcard.last { border-color: #8a6f3a; box-shadow: 0 0 0 1px #8a6f3a; }
.gcard.off { opacity: .5; cursor: not-allowed; }
.gcard .gimg { height: 230px; background: #111 center / cover no-repeat; }
.gcard .gtxt { padding: 12px 16px 16px; }
.gcard h2 { margin: 0 0 4px; font-family: Georgia, serif; color: var(--gold2); font-size: 1.25rem; }
#quit2 { margin-top: 28px; }
table.gtable { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .92rem; }
table.gtable th, table.gtable td { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; text-align: left; }
table.gtable th { background: var(--panel2); color: var(--gold2); }
ul.plain li.cur > .lbl { color: var(--gold2); font-weight: 600; }
/* PST dialog rewards in creature popups */
.dlg-sum { margin-top: 6px; }
.dlg-sum summary { cursor: pointer; }
.dlgrows { max-height: 240px; overflow: auto; margin: 4px 0; }
.dlgrows li { padding: 4px 0; border-bottom: 1px solid #2a241b; }
.dlgrows .tag { margin-right: 3px; display: inline-block; margin-bottom: 2px; }
.dlgline { font-size: .78rem; color: var(--dim); font-style: italic; margin-top: 2px; }
