:root {
  --bg: #0f172a; --panel: #111827; --line: #1f2937; --text: #e5e7eb; --muted: #9ca3af; --accent: #f472b6;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; overflow: hidden; }

#panel { width: 320px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; z-index: 1000; }
#panel header { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 20px; margin: 0; background: linear-gradient(90deg, #f472b6, #fb923c); -webkit-background-clip: text; color: transparent; }

main { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0a2a3d; }

input[type=search] { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; color: var(--text); font-size: 15px; }
#results { list-style: none; margin: -6px 0 0; padding: 0; }
#results li { padding: 8px 10px; cursor: pointer; border-radius: 6px; display: flex; gap: 8px; }
#results li:hover { background: #1f2937; }
#results small { color: var(--muted); margin-left: auto; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bar { height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f472b6, #fb923c); transition: width .3s; }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #1f2937; color: var(--text); border-radius: 8px; padding: 8px 12px; }
button:hover { background: #374151; }
button.ghost { background: transparent; color: var(--muted); }
button.active { background: var(--accent); color: #111; border-color: var(--accent); }
.toggles button { flex: 1; }
.icon-btn { display: none; padding: 4px 10px; }

#cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#cats li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: #0b1220; cursor: pointer; user-select: none; border-left: 4px solid var(--c); }
#cats li.off { opacity: .4; }
#cats .count { margin-left: auto; color: var(--muted); font-size: 13px; }
#cats .mini { height: 3px; background: #1f2937; border-radius: 2px; margin-top: 4px; width: 100%; }
#cats .mini i { display: block; height: 100%; background: var(--c); }
#cats .name { flex: 1; }
#cats .expand { background: none; border: 0; color: var(--muted); padding: 2px 6px; font-size: 14px; cursor: pointer; }
#cats li.sub { margin-left: 18px; padding: 5px 10px; font-size: 13px; border-left-width: 2px; }
.list li.grp { list-style: none; margin-top: 18px; }
.list li.grp h2 { font-size: 18px; margin: 0 0 4px; }
.srcs { margin: 4px 0 0; padding-left: 18px; }
.srcs li { padding: 6px 0; }
.srcs a { display: inline-block; min-height: 24px; }

.check { display: flex; gap: 8px; align-items: center; color: var(--muted); cursor: pointer; }
.tools { display: flex; flex-direction: column; gap: 6px; }
.ad { border: 1px dashed #4b5563; color: #9ca3af; text-align: center; padding: 40px 8px; border-radius: 8px; font-size: 13px; }
.mobile-ad { display: none; }
.fine { color: #9ca3af; font-size: 11px; margin: 0; }

/* Markører */
.pin { background: none; border: none; }
.pin span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); font-size: 15px; transition: transform .15s; }
.pin span:hover { transform: scale(1.2); }
.pin.found span { filter: grayscale(1); opacity: .45; }
.pin.found span::after { content: "✓"; position: absolute; right: -4px; bottom: -4px; background: #22c55e; color: #fff; border-radius: 50%; width: 14px; height: 14px; font-size: 10px; display: grid; place-items: center; }
.pin.user span { border-style: dashed; }

.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 10px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.pop h3 { margin: 0 0 4px; font-size: 16px; }
.pop .tag { font-size: 12px; color: var(--muted); }
.pop p { margin: 8px 0; }
.pop .btns { display: flex; gap: 6px; }
.pop .btns button { flex: 1; padding: 6px 8px; font-size: 13px; }
.pop form { display: flex; flex-direction: column; gap: 6px; }
.pop input, .pop select, .pop textarea { font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: #0b1220; color: var(--text); }

#coords { position: absolute; left: 10px; bottom: 10px; z-index: 500; font: 12px ui-monospace, monospace; background: rgba(0,0,0,.6); padding: 4px 8px; border-radius: 6px; color: var(--muted); }
#addHint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 600; background: var(--accent); color: #111; padding: 8px 14px; border-radius: 20px; font-weight: 600; }
#addHint a { color: #111; }
.adding #map { cursor: crosshair; }

/* Knapper over kartet: «Tap to mark» (alle skjermer) og «Kategorier» (mobil) */
.fabs { position: absolute; top: 12px; right: 12px; z-index: 600; display: flex; gap: 8px; }
.fab { box-shadow: 0 2px 8px rgba(0,0,0,.4); font-weight: 600; }
#openPanel { display: none; }
#toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 700; background: #111827; border: 1px solid #374151;
  color: var(--text); padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: calc(100% - 24px); }
#toast[hidden] { display: none; }
#toast button { padding: 6px 12px; }
.free { margin: 0; font-size: 13px; color: #86efac; }
.chapsel { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.chapsel select, #cats select { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; color: var(--text); }
#cats li.missables { border-left-color: var(--c); background: #1c1406; }
#cats li.missables.on { background: #3b2a06; outline: 1px solid var(--c); }
#cats li small { display: block; color: var(--muted); font-size: 12px; }
#cats li.nm { flex-direction: column; align-items: stretch; cursor: default; gap: 4px; }
#cats li.nm label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.row.share button { flex: 1; }
.pin.miss span { box-shadow: 0 0 0 3px #f59e0b, 0 2px 6px rgba(0,0,0,.5); }
.missable { margin-top: 6px; font-size: 13px; color: #fbbf24; }
p.missable { font-size: 15px; }
.guidelinks { display: flex; flex-direction: column; gap: 4px; }
.guidelinks a { color: #f9a8d4; font-size: 13px; text-decoration: none; }
.guidelinks a.all { color: var(--muted); }

@media (max-width: 760px) {
  body.app { height: 100dvh; }
  /* Filtrene ligger i et bunnark; kartet fyller hele skjermen */
  #panel { position: fixed; inset: auto 0 0 0; width: 100%; max-height: 82dvh; border-radius: 16px 16px 0 0; border-right: none;
    transform: translateY(105%); transition: transform .25s; box-shadow: 0 -10px 30px rgba(0,0,0,.5); padding-top: 22px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: #4b5563; }
  .fabs { top: auto; right: 12px; left: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); justify-content: space-between; }
  .fab, #openPanel { display: block; min-height: 48px; padding: 12px 18px; font-size: 16px; border-radius: 24px; background: #111827; }
  #tapMode.active { background: #22c55e; color: #052e16; border-color: #22c55e; }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  /* Store trykkflater */
  #cats li { min-height: 48px; }
  #cats .expand { min-width: 44px; min-height: 44px; font-size: 18px; }
  #panel button, .chapsel select, #cats select { min-height: 44px; }
  #results li { min-height: 44px; align-items: center; }
  .pop .btns button { min-height: 48px; font-size: 15px; }
  .pop .btns button.big { flex: 2; }
  .check input { width: 22px; height: 22px; }
  body.panel-open #panel { transform: none; }
  .icon-btn { display: block; }
  #panel .ad { display: none; }
  #coords { display: none; }
}


.fine a { color: #9ca3af; }
.leaflet-control-attribution { background: rgba(17,24,39,.8) !important; color: #9ca3af !important; font-size: 11px; }
@media (max-width: 760px) { .leaflet-control-attribution { font-size: 9px; } }

/* Språkvalg og lenker */
#panel header #closePanel { margin-left: auto; }
.unverified { display: inline-block; margin-top: 6px; font-size: 12px; color: #fbbf24; }
.unverified::before { content: "⚠ "; }
.pop a.more { display: block; margin: 0 0 8px; color: #f9a8d4; font-weight: 600; text-decoration: none; }
.catlinks { display: flex; flex-wrap: wrap; gap: 6px; }
.catlinks a { font-size: 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 12px; padding: 3px 8px; }
.catlinks a:hover { color: var(--text); }

/* Stedssider og kategorisider */
body.page { display: block; overflow: auto; }
.page .wrap { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
.page .topbar { border-bottom: 1px solid var(--line); background: var(--panel); }
.page .topbar .inner { max-width: 980px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.page .topbar a { color: var(--text); text-decoration: none; }
.page .topbar .brand { font-weight: 800; background: linear-gradient(90deg, #f472b6, #fb923c); -webkit-background-clip: text; color: transparent; }
.page .topbar .switch { margin-left: auto; font-size: 13px; color: var(--muted); }
.page h1 { font-size: 28px; margin: 8px 0; background: none; color: var(--text); -webkit-background-clip: initial; }
.page h2 { font-size: 18px; margin: 24px 0 8px; }
.page p, .page li { line-height: 1.6; color: #d1d5db; }
.page a { color: #f9a8d4; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; background: var(--c); color: #111; font-size: 13px; font-weight: 700; }
.minimap { height: 340px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #01aac9; }
.cta { display: inline-block; margin-top: 12px; background: linear-gradient(90deg, #f472b6, #fb923c); color: #111 !important; font-weight: 700; padding: 10px 16px; border-radius: 10px; text-decoration: none; }
.side { display: flex; flex-direction: column; gap: 16px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.box h3 { margin: 0 0 8px; font-size: 15px; }
.box ul { margin: 0; padding-left: 18px; }
.aff small { color: #6b7280; display: block; margin-top: 8px; }
.list { list-style: none; padding: 0; display: grid; gap: 8px; }
.list a { display: block; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.list a:hover { border-color: #f472b6; }
.list small { color: var(--muted); }
.page footer { max-width: 980px; margin: 24px auto; padding: 0 16px; }
@media (max-width: 760px) { .page .wrap { grid-template-columns: 1fr; } .page h1 { font-size: 22px; } }

/* Mobil: zoomknappene nede til høyre, så de ikke dekker Kategorier-knappen */
@media (max-width: 760px) {
  .app .leaflet-top.leaflet-left { top: 12px; bottom: auto; left: auto; right: 0; }
  .app .leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; font-size: 22px; }
}

/* Samtykkebanner */
#consent { position: fixed; z-index: 5000; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(560px, calc(100% - 24px));
  background: var(--panel); border: 1px solid #374151; border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.6); color: var(--text); }
#consent p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
#consent a { color: #f9a8d4; }
.consent-btns { display: flex; gap: 8px; }
.consent-btns button { flex: 1; padding: 10px; font-weight: 600; }
.footlinks a { color: var(--muted); }
.legal table { border-collapse: collapse; width: 100%; font-size: 14px; }
.legal th, .legal td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; color: #d1d5db; }
.legal code { background: #1f2937; padding: 1px 4px; border-radius: 4px; }
.page.page footer .fine { margin: 4px 0; }
.intro { margin: -4px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* Spoilerfilter: innhold fra senere kapitler enn valgt (html[data-ch]) skjules til man trykker */
html[data-ch="1"] :is([data-chapter="2"], [data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed]),
html[data-ch="2"] :is([data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed]),
html[data-ch="3"] :is([data-chapter="4"], [data-chapter="5"]):not([data-revealed]),
html[data-ch="4"] [data-chapter="5"]:not([data-revealed]) { position: relative; cursor: pointer; min-height: 44px; }
html[data-ch="1"] :is([data-chapter="2"], [data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed]) > *,
html[data-ch="2"] :is([data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed]) > *,
html[data-ch="3"] :is([data-chapter="4"], [data-chapter="5"]):not([data-revealed]) > *,
html[data-ch="4"] [data-chapter="5"]:not([data-revealed]) > * { filter: blur(8px); user-select: none; pointer-events: none; }
html[data-ch="1"] :is([data-chapter="2"], [data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed])::before,
html[data-ch="2"] :is([data-chapter="3"], [data-chapter="4"], [data-chapter="5"]):not([data-revealed])::before,
html[data-ch="3"] :is([data-chapter="4"], [data-chapter="5"]):not([data-revealed])::before,
html[data-ch="4"] [data-chapter="5"]:not([data-revealed])::before {
  content: "Chapter " attr(data-chapter) " spoiler · tap to show"; position: sticky; top: 45vh; z-index: 2; display: table; margin: 8px auto -36px;
  padding: 8px 14px; border-radius: 18px; background: #111827; border: 1px solid #f59e0b; font-size: 14px; font-weight: 700; color: #fde68a; text-align: center; }
html[lang="no"] [data-chapter]::before { content: "Spoiler fra kapittel " attr(data-chapter) " · trykk for å vise"; }

/* Toppfelt: kapittelvelger */
.page .topbar .inner { flex-wrap: wrap; }
.page .topbar .chap { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.page .topbar .chap select { font: inherit; padding: 6px; border-radius: 6px; border: 1px solid var(--line); background: #0b1220; color: var(--text); min-height: 36px; }

/* Guider */
.guide .free { display: inline; }
.checklist { list-style: none; padding: 0; display: grid; gap: 10px; }
.checklist .item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.checklist .item.done { border-color: #166534; opacity: .75; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.checklist input { width: 26px; height: 26px; flex-shrink: 0; accent-color: #22c55e; margin: 0; }
.checklist .nochk { width: 26px; flex-shrink: 0; }
.checklist p { margin: 6px 0 4px 38px; }
.checklist small { display: block; margin-left: 38px; color: var(--muted); line-height: 1.8; }
.checklist small a { margin-right: 4px; }
.checklist b.no { color: #fbbf24; } .checklist b.yes { color: #86efac; }
.unc { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: #78350f; color: #fde68a; font-size: 12px; font-weight: 700; }
.guide table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.guide th, .guide td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; color: #d1d5db; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.list.guides a { padding: 14px; }
@media (max-width: 760px) { .checklist p, .checklist small { margin-left: 0; } .page .topbar .switch { margin-left: 0; } }
