:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --panel-glass: rgba(255,255,255,0.97);
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1c7ed6;
  --accent-hover: #1868b5;
  --accent-soft: #e7f1fc;
  --accent-ink: #0b4f9c;
  --hover: #f1f3f5;
  --chip: #eeeeee;
  --bar-bg: #eceff1;
  --off: #a0a4ab;
  --up-bg: #e3f6e8; --up-ink: #1a7f3c;
  --down-bg: #fde8e8; --down-ink: #b42318;
  --overlay: rgba(255,255,255,0.6);
  --shadow: rgba(0,0,0,0.25);
  --good: #1a9641;
  --bad: #b2182b;
  --topbar-h: 48px;
  color-scheme: light;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417; --panel: #1b1f24; --panel-glass: rgba(27,31,36,0.96); --ink: #e6e8eb; --muted: #9aa3ad; --line: #2e343b;
    --accent: #4dabf7; --accent-hover: #74c0fc; --accent-soft: #1c2f45; --accent-ink: #9ec5ff; --hover: #262c33; --chip: #2a3037;
    --bar-bg: #2e343b; --off: #6b7280; --up-bg: #14351f; --up-ink: #7bd88f; --down-bg: #3b1a1a; --down-ink: #ff8a80;
    --overlay: rgba(0,0,0,0.5); --shadow: rgba(0,0,0,0.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121417; --panel: #1b1f24; --panel-glass: rgba(27,31,36,0.96); --ink: #e6e8eb; --muted: #9aa3ad; --line: #2e343b;
  --accent: #4dabf7; --accent-hover: #74c0fc; --accent-soft: #1c2f45; --accent-ink: #9ec5ff; --hover: #262c33; --chip: #2a3037;
  --bar-bg: #2e343b; --off: #6b7280; --up-bg: #14351f; --up-ink: #7bd88f; --down-bg: #3b1a1a; --down-ink: #ff8a80;
  --overlay: rgba(0,0,0,0.5); --shadow: rgba(0,0,0,0.6); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
#app { display: grid; grid-template-rows: var(--topbar-h) auto 1fr; grid-template-columns: 400px 1fr; height: 100dvh; }
#searchbar { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px 16px; align-items: start; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 25; }
#searchbar .addr label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
#searchbar .addr .row { display: flex; gap: 6px; flex-wrap: nowrap; }
#searchbar .addr .row input { flex: 1; min-width: 0; }
#searchbar .privacy { color: var(--muted); align-self: center; padding-top: 14px; max-width: 320px; }
#search-toggle, #drawer-bg { display: none; }
.btn.small { padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#pickbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 6; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.wnote { margin-top: 6px; color: var(--muted); }
.wnote.on { color: var(--accent-ink); font-weight: 600; }
svg.face { vertical-align: middle; flex: 0 0 auto; }
#sidebar h2 .info { vertical-align: middle; margin-left: 4px; }
#detail details.sect { border-top: 1px solid var(--line); padding: 4px 0; }
#detail details.sect summary { cursor: pointer; font-weight: 600; padding: 5px 0; list-style: none; display: flex; align-items: center; gap: 6px; }
#detail details.sect summary::before { content: "▸"; color: var(--muted); font-size: 12px; }
#detail details.sect[open] summary::before { content: "▾"; }
#detail details.sect summary b { margin-left: auto; font-variant-numeric: tabular-nums; }
#detail .qrow, #quick .qrow { display: grid; grid-template-columns: 22px auto 1fr auto auto; gap: 4px 8px; align-items: center; padding: 2px 0; }
#detail .qrow b, #quick .qrow b { font-variant-numeric: tabular-nums; min-width: 2em; text-align: right; }
#toplist .facewrap { display: inline-flex; }
#topbar .pill { cursor: pointer; }
button, input, select { font: inherit; }
input, select { background: var(--panel); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------------------------------------------------------------- top bar */
#topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 30; }
#brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
#brand .logo { font-size: 18px; }
.pill { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 3px 10px; font-size: 12px; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.spacer { flex: 1; }
.addr { position: relative; flex: 1; max-width: 420px; }
.addr input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.addr .suggest { position: absolute; top: 36px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px var(--shadow); max-height: 260px; overflow-y: auto; z-index: 45; }
.addr .suggest div { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.addr .suggest div:hover { background: var(--hover); }
.addr .suggest div span { color: var(--muted); font-size: 12px; margin-left: 6px; }
#detail .addr-actions { display: flex; gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; }
.iconbtn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; height: 32px; min-width: 36px; padding: 0 8px; cursor: pointer; font-size: 15px; }
.iconbtn:hover { border-color: var(--accent); }
#menu-btn { display: none; }

/* ---------------------------------------------------------------- sidebar */
#sidebar { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
.side-inner { padding: 14px 16px 30px; }
#sidebar .sub { margin: 0 0 12px; color: var(--muted); line-height: 1.45; }
#sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
a.btn { text-decoration: none; display: inline-block; }

.factor { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 8px; margin-bottom: 10px; background: var(--panel); }
.frow, .irow { display: flex; align-items: center; gap: 8px; }
.frow label { flex: 1; font-weight: 600; font-size: 15px; cursor: pointer; }
.irow label { flex: 1; font-size: 13px; line-height: 1.25; }
.val { min-width: 2.4em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.frow .val { font-weight: 600; color: var(--ink); }
button.expand { border: 0; background: transparent; font-size: 15px; width: 24px; height: 24px; cursor: pointer; color: var(--muted); padding: 0; }
button.dir { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; width: 26px; height: 24px; cursor: pointer; font-size: 10px; color: var(--muted); padding: 0; flex: 0 0 auto; }
button.dir.flipped { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button.info { border: 0; background: var(--accent-soft); color: var(--accent-ink); border-radius: 50%; width: 20px; height: 20px; font-size: 11px; font-weight: 700; cursor: pointer; padding: 0; flex: 0 0 auto; }
input[type=range] { width: 100%; margin: 6px 0 4px; accent-color: var(--accent); height: 22px; background: transparent; }
.fslider { accent-color: var(--ink); }
.subs { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--line); }
.subs h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.ind { padding: 2px 0 2px 2px; }
.ind input[type=range] { margin: 2px 0 0; height: 18px; }

#points .point { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin-bottom: 6px; }
#points .point { flex-wrap: wrap; }
#points .point .pname { flex: 1; min-width: 0; }
#points .point .pweight { flex: 1 1 100%; order: 10; margin-top: 2px; }
#points .point .pweight .irow { display: flex; justify-content: space-between; align-items: center; }
#points .point .pweight .q { font-size: 11.5px; color: var(--muted); }
#points .point .pdyn { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
#points .point .pweight .val { font-size: 12px; font-weight: 600; }
#points .point .pweight input[type=range] { width: 100%; margin: 2px 0 0; }
#points .point .pname b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#points .point .pname span { font-size: 11.5px; color: var(--muted); }
#points .point select, #points .point input[type=number] { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
#points .point.home { border-color: var(--accent); background: var(--accent-soft); }
#points .point .x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; }
.backend { padding-left: 14px; position: relative; }
.backend::before { content: ""; position: absolute; left: 0; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #bbb; }
.backend.on::before { background: #1a9641; }
.backend.busy::before { background: #f59f00; animation: spin 1s linear infinite; }

#options .optrow { display: flex; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
#options .optrow > span { color: var(--muted); min-width: 90px; }
#options input[type=range] { flex: 1; width: auto; margin: 0; }

#toplist { list-style: none; margin: 0; padding: 0; }
#toplist li { display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
#toplist li:hover { background: var(--hover); }
#toplist .rank { color: var(--muted); min-width: 1.6em; font-variant-numeric: tabular-nums; }
#toplist .body { flex: 1; line-height: 1.3; min-width: 0; }
#toplist .name { font-weight: 600; }
#toplist .by { color: var(--muted); font-size: 12px; margin-left: 6px; }
#toplist b { font-variant-numeric: tabular-nums; }
#attrib { margin-top: 24px; font-size: 11px; color: var(--muted); line-height: 1.4; }
#attrib a { color: var(--muted); }
.print-only { display: none; }
#disclaimer { margin: 0 0 8px; }
.disc { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11px; line-height: 1.4; color: var(--muted); }
#wizard .disc { border-top: 0; padding-top: 0; margin: 6px 0 2px; }
/* "Om tallene": a neutral tab on the legend (and a small link under the area panel / comparison) that opens the note */
.ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 10px; font-weight: 700; font-style: normal; flex: 0 0 auto; }
.about-open { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; padding: 0; margin: 0; font: inherit; color: var(--muted); cursor: pointer; }
.about-open:hover { color: var(--accent); }
#about-tab { position: absolute; left: 0; bottom: 100%; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px 0 8px; border: 0; border-radius: 9px 9px 0 0; background: var(--panel-glass); color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; box-shadow: 0 -1px 3px var(--shadow); clip-path: inset(-8px -8px 0 -8px); }
#about-tab:hover, #about-tab[aria-expanded="true"] { color: var(--accent); }
#legend { border-top-left-radius: 0; }
#about { position: fixed; left: 12px; bottom: 28px; z-index: 62; width: 360px; max-width: calc(100vw - 24px); background: var(--panel); color: var(--ink); border-radius: 10px; box-shadow: 0 4px 16px var(--shadow); padding: 12px 14px; font-size: 12.5px; line-height: 1.45; }
#about h4 { margin: 0 0 6px; padding-right: 24px; font-size: 13.5px; }
#about p { margin: 0 0 7px; }
#about p:last-child { margin-bottom: 0; }
#about a { color: var(--accent); }
#about .links { color: var(--muted); }
#about .close { position: absolute; right: 6px; top: 6px; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 16px; padding: 2px 6px; }

/* ---------------------------------------------------------------- map */
#mapwrap { position: relative; min-width: 0; min-height: 0; background: var(--bg); }
#map { position: absolute; inset: 0; }
#legend { position: absolute; left: 12px; bottom: 28px; background: var(--panel-glass); border-radius: 10px; padding: 8px 12px; box-shadow: 0 1px 4px var(--shadow); font-size: 12px; z-index: 2; width: 220px; }
#legend .ramp { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #b2182b, #ef8a62, #fddb6d, #a6d96a, #1a9641); }
#legend .labels { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); }
#legend .hint { margin-top: 6px; color: var(--muted); font-size: 11px; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--overlay); z-index: 5; font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* quick overview (hover) */
#quick { position: absolute; top: 12px; right: 12px; background: var(--panel-glass); border-radius: 12px; box-shadow: 0 2px 10px var(--shadow); padding: 10px 12px; z-index: 3; width: 300px; font-size: 13px; pointer-events: none; }
#quick h3 { margin: 0; font-size: 15px; }
#quick .qsub { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
#quick .qtotal { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
#quick .qtotal .big { font-size: 26px; font-weight: 700; }
.delta { font-size: 11.5px; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.delta.up { background: var(--up-bg); color: var(--up-ink); }
.delta.down { background: var(--down-bg); color: var(--down-ink); }
.delta.home { background: var(--accent-soft); color: var(--accent-ink); }

/* detail panel */
#detail { position: absolute; top: 12px; right: 12px; width: 380px; max-height: calc(100% - 24px); overflow-y: auto; background: var(--panel-glass); border-radius: 12px; box-shadow: 0 2px 12px var(--shadow); padding: 12px 14px 16px; z-index: 4; font-size: 13px; }
#detail .dtools { float: right; display: flex; gap: 6px; align-items: center; }
#detail .dhead h3 { margin: 0; font-size: 17px; }
#detail .dhead h3 small { font-weight: 400; color: var(--muted); font-size: 13px; }
#detail .dsub { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
#detail .close { border: 0; background: var(--chip); color: var(--ink); border-radius: 6px; cursor: pointer; font-size: 13px; padding: 4px 8px; }
#detail .score { display: flex; align-items: center; gap: 12px; margin: 6px 0 8px; }
#detail .score .big { font-size: 32px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#detail table { width: 100%; border-collapse: collapse; }
#detail td { padding: 2px 4px 2px 0; vertical-align: middle; }
#detail td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-right: 6px; }
#detail td.face { width: 22px; font-size: 14px; }
#detail tr.off td { color: var(--off); }
#detail td:nth-child(2) { width: 46%; }
#detail .srow { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#detail .slabel { color: var(--muted); min-width: 86px; max-width: 96px; font-size: 12px; line-height: 1.2; }
#detail .sname { flex: 1; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
#detail .srating { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0 6px; max-width: 150px; white-space: nowrap; }
#detail .srating .bar { width: 48px; }
#detail .srating b { font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; }
.bar { display: inline-block; width: 60px; height: 8px; background: var(--bar-bg); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; }
.bar.empty { background: repeating-linear-gradient(45deg, var(--bar-bg), var(--bar-bg) 3px, var(--panel) 3px, var(--panel) 6px); }
.marker-point { background: #111; color: #fff; font-weight: 700; font-size: 11px; padding: 3px 7px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.4); white-space: nowrap; }
.marker-point.home { background: #1c7ed6; }
.maplibregl-popup-content { font-size: 12px; line-height: 1.4; background: var(--panel); color: var(--ink); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--panel); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.maplibregl-popup-close-button { color: var(--ink); }

/* info / share popover */
#infopop { position: fixed; z-index: 60; background: var(--panel); color: var(--ink); border-radius: 10px; box-shadow: 0 4px 16px var(--shadow); padding: 10px 12px; width: 300px; max-width: calc(100vw - 24px); font-size: 12.5px; line-height: 1.4; }
#infopop h4 { margin: 0 0 4px; font-size: 13px; }
#infopop .src a { color: var(--accent); }
#infopop .close { float: right; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 16px; }
#infopop label.chk { display: block; margin: 4px 0; cursor: pointer; }
#infopop #sh-url { width: 100%; margin-top: 6px; font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }

/* wizard */
#wizard { position: fixed; inset: 0; z-index: 50; background: rgba(20,24,30,0.55); display: flex; align-items: center; justify-content: center; padding: 12px; }
#wizard .card { background: var(--panel); border-radius: 16px; width: 560px; max-width: 100%; max-height: 100%; overflow-y: auto; padding: 22px 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
#wizard h2 { margin: 0 0 4px; font-size: 20px; }
#wizard .steps { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
#wizard .field { margin: 10px 0; }
#wizard label.lbl { display: block; font-weight: 600; margin-bottom: 4px; }
#wizard input[type=text], #wizard select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 15px; }
#wizard .suggest { border: 1px solid var(--line); border-radius: 8px; max-height: 180px; overflow-y: auto; margin-top: 4px; }
#wizard .suggest div { padding: 7px 10px; cursor: pointer; }
#wizard .suggest div:hover { background: var(--hover); }
#wizard .chips { display: flex; flex-wrap: wrap; gap: 8px; }
#wizard .chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; cursor: pointer; background: var(--panel); }
#wizard .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#wizard .presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#wizard .preset { border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; }
#wizard .preset.on { border-color: var(--accent); background: var(--accent-soft); }
#wizard .preset b { display: block; }
#wizard .preset span { font-size: 12px; color: var(--muted); }
#wizard .nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
#wizard .plist .point { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
#wizard .plist .point b { flex: 1; font-size: 13px; }

/* pages (om, vilkår, personvern) */
.page { max-width: 760px; margin: 0 auto; padding: 24px 18px 60px; line-height: 1.55; background: var(--panel); color: var(--ink); }
.page h1 { font-size: 26px; margin: 8px 0 4px; }
.page h2 { font-size: 18px; margin: 22px 0 6px; }
.page a { color: var(--accent); }
.page .back { display: inline-block; margin-bottom: 12px; }

/* switches, solo, fixed direction, basis line */
.sw { width: 30px; height: 16px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; flex: 0 0 auto; margin: 0; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.sw:checked { background: var(--accent); }
.sw:checked::after { left: 16px; }
.factor.off, .ind.off { opacity: 0.45; }
.factor.off .subs { display: none; }
.factor.solo { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
span.dir.fixed { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px; font-size: 10px; color: var(--muted); flex: 0 0 auto; }
button.solo { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; font-size: 11px; padding: 2px 8px; cursor: pointer; white-space: nowrap; }
button.solo.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#basis { margin-top: 5px; color: var(--ink); line-height: 1.3; }
#basis a { color: var(--accent); margin-left: 4px; }

.ends { display: flex; gap: 4px; margin: 3px 0 0 38px; flex-wrap: wrap; }
.ends .end { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; font-size: 11px; padding: 2px 9px; cursor: pointer; }
.ends .end.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.ends .end:first-child::before { content: "◀ "; }
.ends .end:last-child::after { content: " ▶"; }

.wends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin: -2px 2px 2px; }
.simple { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); }
.simple .irow label { font-size: 13px; font-weight: 600; flex: 1; }
.simple input[type=range] { margin: 4px 0 2px; }
.simple .wends { font-size: 11.5px; color: var(--ink); }
#points .point.cand { border-color: #d6336c; }
.marker-point.cand { background: #d6336c; }

/* modal dialogs (place editor, link) */
#modal { position: fixed; inset: 0; z-index: 58; background: rgba(20,24,30,0.5); display: flex; align-items: center; justify-content: center; padding: 12px; }
#modal .mcard { background: var(--panel); color: var(--ink); border-radius: 14px; width: 440px; max-width: 100%; max-height: 100%; overflow-y: auto; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
#modal h3 { margin: 0 0 10px; font-size: 18px; }
#modal .field { margin: 10px 0; }
#modal label.lbl { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
#modal input[type=text], #modal select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 15px; }
#modal .types label { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; margin: 5px 0; cursor: pointer; }
#modal .types label.on { border-color: var(--accent); background: var(--accent-soft); }
#modal .mnav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
#modal .mnav .btn.danger { margin-right: auto; color: var(--down-ink); border-color: var(--down-ink); }
.marker-point { cursor: pointer; }
#points .point .pname { cursor: pointer; }

/* headline on the map: best area + basis */
#headline { position: absolute; top: 12px; left: 12px; z-index: 2; background: var(--panel-glass); border-radius: 12px; padding: 8px 12px; box-shadow: 0 1px 4px var(--shadow); max-width: 380px; font-size: 13px; }
#headline #best-area { font-weight: 600; cursor: pointer; }
#headline #best-area b { color: var(--accent); }
#headline #basis { margin-top: 3px; color: var(--muted); line-height: 1.3; }
#points .point.cand.off { opacity: 0.55; }
#points .point .act { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; font-size: 11px; padding: 2px 8px; cursor: pointer; white-space: nowrap; }
#points .point .act.on { background: #d6336c; color: #fff; border-color: #d6336c; }
.marker-point.cand.off { opacity: 0.55; }
.cmpscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 6px; }
table.cmp { min-width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.cmp th:not(:first-child), table.cmp td:not(:first-child) { min-width: 150px; }
table.cmp .srating { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
table.cmp tr.sub td { font-size: 11.5px; padding-top: 2px; padding-bottom: 2px; }
table.cmp tr.sub td.lbl { padding-left: 16px; }
table.cmp tr.grp td { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-bottom: 0; padding-bottom: 0; }
#modal label.chk, #wizard label.chk { display: block; margin: 6px 0; cursor: pointer; }
table.cmp th, table.cmp td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.cmp th { font-size: 12px; }
table.cmp td.lbl { color: var(--muted); white-space: nowrap; }
table.cmp .bar { width: 46px; }
#modal .mcard.wide { width: 760px; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; }
  body.print-map #app { display: block; height: auto; }
  body.print-map #mapwrap { position: relative; height: 180mm; }
  body.print-profile #app { display: block; height: auto; }
  body.print-profile #mapwrap { position: static; }
  body.print-profile #detail { position: static; width: auto; max-height: none; overflow: visible; box-shadow: none; background: #fff; }
  body.print-profile #detail .dtools, body.print-profile #detail .addr-actions { display: none !important; }
  body.print-cmp #app > *:not(#modal) { display: none !important; }
  body.print-cmp #modal { position: static; background: none; display: block; padding: 0; }
  body.print-cmp #modal .mcard { box-shadow: none; width: auto; max-height: none; overflow: visible; }
  body.print-cmp #modal .mnav { display: none !important; }
  .disc, #disclaimer { color: #333; }
  .print-only { display: block; }
  #about-tab, #about, .about-open { display: none !important; }
}

.city-label { background: var(--panel-glass); color: var(--ink); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: 0 1px 3px var(--shadow); white-space: nowrap; }
.city-label:hover { color: var(--accent); }
#detail .dplace { margin: 4px 0 2px; font-size: 13px; }
table.cmp .sep { border-left: 3px double var(--line); }
table.cmp th.homecol, table.cmp td.homecol { background: var(--accent-soft); }
#wizard .wf { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
#wizard .wf .irow label { font-weight: 600; flex: 1; }

.yn { display: flex; align-items: center; gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; }
.yn .q { flex: 1 1 100%; font-size: 13px; }
.yn button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 3px 14px; cursor: pointer; }
.yn button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#wizard .wf .subs { margin-top: 6px; }
#wizard .wf .btn.small { margin-top: 6px; }

table.cmp td.best { background: rgba(255, 196, 0, 0.14); }
table.cmp .crown { font-size: 13px; }
.fnote { color: var(--muted); font-size: 11.5px; margin: 2px 0 4px; line-height: 1.3; }
.fnote a { color: var(--accent); margin-left: 4px; }
.factor.off .fnote { opacity: 1; }
#modal .sugwrap { position: relative; }
#modal .sugwrap .suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px var(--shadow); max-height: 200px; overflow-y: auto; }
#modal .sugwrap .suggest div { padding: 8px 10px; cursor: pointer; font-size: 13px; }
#modal .sugwrap .suggest div:hover { background: var(--hover); }
#modal .sugwrap .suggest div span { color: var(--muted); font-size: 12px; margin-left: 6px; }

.ind .nv { font-size: 10.5px; color: #e8590c; margin-left: 4px; white-space: nowrap; }
.ind.novar input[type=range] { opacity: 0.45; }

.backend.beta { color: var(--muted); }
.badge { display: inline-block; background: #e8590c; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border-radius: 999px; padding: 1px 7px; margin-right: 5px; vertical-align: middle; }
a.maps { font-size: 11px; white-space: nowrap; margin-left: 4px; }

#cmp-hint { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 7px 14px; border-radius: 999px; font-size: 13px; z-index: 6; pointer-events: none; opacity: 0; transition: opacity 0.25s; max-width: calc(100% - 40px); text-align: center; }
#cmp-hint.on { opacity: 0.94; }
@media (max-width: 860px) { #cmp-hint { bottom: 48px; font-size: 12px; } }

/* ---------------------------------------------------------------- embed mode (landing pages) */
body.embed #app { grid-template-rows: 1fr; grid-template-columns: 1fr; height: 100dvh; }
body.embed #topbar, body.embed #searchbar, body.embed #drawer-bg, body.embed #points-sect, body.embed #options, body.embed #top, body.embed #sources, body.embed #sidebar .sub, body.embed #sidebar h2 { display: none !important; }
body.embed #headline { display: none !important; }
body.embed #legend { left: auto; right: 10px; bottom: 28px; width: 190px; }
body.embed #detail { width: 340px; }
body.embed #sidebar { position: absolute; top: 10px; left: 10px; bottom: auto; max-height: calc(100% - 20px); width: 280px; z-index: 5; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 12px var(--shadow); transform: none; padding: 0; }
body.embed #sidebar .side-inner { padding: 8px 10px; }
body.embed .factor { margin-bottom: 0; }
body.embed .factor { margin-bottom: 6px; }
body.embed .factor .frow > button.expand, body.embed .factor .frow > button.solo, body.embed .factor .frow > .sw, body.embed .fnote { display: none; }
body.embed #embed-bar { position: absolute; right: 10px; top: 10px; z-index: 6; display: flex; gap: 6px; }
body.embed #embed-bar a, body.embed #embed-bar button { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; text-decoration: none; cursor: pointer; }
body.embed #embed-bar #embed-weights { display: none; }
body.embed .ehint { font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }
@media (max-width: 860px) {
  body.embed #sidebar { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 46%; border-radius: 14px 14px 0 0; transform: translateY(110%); transition: transform 0.2s; }
  body.embed #sidebar.eopen { transform: none; }
  body.embed #embed-bar #embed-weights { display: inline-block; }
  body.embed #legend { display: none; }
}

/* mobile: one clearly labelled button for the settings drawer, with a one-time hint for new visitors */
#fab { display: none; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 7; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; padding: 10px 18px; box-shadow: 0 3px 12px rgba(0,0,0,0.3); cursor: pointer; white-space: nowrap; }
#fabhint { display: none; position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 8; background: var(--ink); color: var(--panel); padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.35; max-width: min(320px, calc(100% - 32px)); box-shadow: 0 4px 16px rgba(0,0,0,0.3); cursor: pointer; }
#fabhint::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
#fabhint .x { position: absolute; right: 4px; top: 2px; border: 0; background: transparent; color: var(--panel); font-size: 14px; cursor: pointer; padding: 4px; }
#fabhint span { display: block; padding-right: 18px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: var(--topbar-h) auto 1fr; }
  #topbar { gap: 6px; padding: 0 8px; }
  #brand .name { display: none; }
  .pill { max-width: 26vw; }
  #print-btn { display: none; }
  .iconbtn { height: 36px; min-width: 36px; padding: 0 6px; }
  #menu-btn { display: inline-block; }
  /* search: one collapsed row that shows the chosen places; tap to open the two fields */
  #searchbar { grid-template-columns: 1fr; gap: 8px; padding: 6px 10px; }
  #search-toggle { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 9px 10px; font-size: 14px; cursor: pointer; min-height: 40px; }
  #search-toggle .sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #search-toggle .sum.empty { color: var(--muted); }
  #search-toggle .caret { color: var(--muted); transition: transform 0.15s; }
  #searchbar:not(.collapsed) #search-toggle .caret { transform: rotate(180deg); }
  #searchbar.collapsed .addr, #searchbar.collapsed .privacy { display: none; }
  #searchbar .privacy { padding: 0; max-width: none; }
  .addr { max-width: none; }
  .addr input { font-size: 16px; padding: 9px 10px; }
  .addr .row .btn.small { padding: 7px 10px; font-size: 13px; }
  /* drawer: below the topbar, closes on the backdrop */
  #sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(90vw, 400px); z-index: 40; box-shadow: 0 0 30px rgba(0,0,0,0.3); transform: translateX(0); transition: transform 0.2s; padding-bottom: env(safe-area-inset-bottom); }
  #sidebar.hidden-mobile { transform: translateX(-110%); box-shadow: none; }
  #drawer-bg { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.35); z-index: 39; }
  body.drawer-open #drawer-bg { display: block; }
  /* map overlays */
  #headline { left: 8px; right: 8px; top: 8px; max-width: none; padding: 6px 10px; font-size: 12.5px; line-height: 1.3; }
  #headline #basis { font-size: 10.5px; }
  #legend { left: 8px; right: auto; bottom: 8px; top: auto; width: 168px; padding: 5px 8px; font-size: 10.5px; }
  #legend .ramp { height: 7px; }
  #legend .hint { display: none; }
  #pickbar { top: 8px; left: 8px; right: 8px; transform: none; justify-content: space-between; }
  #quick { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; pointer-events: auto; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #detail { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 75dvh; border-radius: 16px 16px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  #detail::before { content: ""; display: block; width: 44px; height: 4px; background: var(--line); border-radius: 2px; margin: -4px auto 8px; }
  /* sticky at the very top of the sheet: -12px cancels the sheet's top padding so nothing scrolls past above the bar */
  #detail .dtools { position: sticky; top: -12px; z-index: 2; float: none; justify-content: flex-end; background: var(--panel); padding: 6px 0; margin: 0 0 4px; }
  /* sheets: the wizard fills the screen, the modal is a bottom sheet; footer buttons always visible */
  #wizard { align-items: stretch; padding: 0; }
  #wizard .card { border-radius: 0; width: 100%; max-width: none; max-height: none; height: 100dvh; padding: 16px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
  #wizard .card .nav { position: sticky; bottom: 0; z-index: 3; margin-top: auto; background: var(--panel); padding: 10px 0 0; border-top: 1px solid var(--line); }
  #modal { align-items: flex-end; padding: 0; }
  #modal .mcard { border-radius: 16px 16px 0 0; width: 100%; max-width: none; max-height: 92dvh; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #modal .mnav { position: sticky; bottom: 0; z-index: 3; background: var(--panel); padding: 10px 0 0; border-top: 1px solid var(--line); }
  #modal input[type=text], #wizard input[type=text], #modal select, #wizard select { font-size: 16px; }
  table.cmp th:not(:first-child), table.cmp td:not(:first-child) { min-width: 118px; }
  table.cmp td.lbl, table.cmp th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; max-width: 130px; font-size: 12px; }
  #infopop { left: 8px !important; right: 8px !important; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto !important; max-width: none; max-height: 70dvh; overflow-y: auto; z-index: 70; }
  #about { left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-width: none; max-height: 70dvh; overflow-y: auto; z-index: 70; font-size: 13px; padding: 14px 14px calc(12px + env(safe-area-inset-bottom)); }
  #about-tab { height: 24px; font-size: 11px; padding: 0 9px 0 7px; }
  .frow { gap: 6px; }
  .frow label { font-size: 14px; white-space: normal; line-height: 1.2; }
  .frow .val { flex: 0 0 auto; min-width: 2em; text-align: right; }
  .frow button.solo { width: 32px; height: 28px; padding: 0; font-size: 0; flex: 0 0 auto; }
  .frow button.solo::before { content: "◎"; font-size: 16px; line-height: 1; }
  .frow button.solo.on::before { content: "◉"; }
  /* touch targets */
  button.info { width: 26px; height: 26px; font-size: 12px; }
  .sw { width: 38px; height: 22px; }
  .sw::after { width: 18px; height: 18px; }
  .sw:checked::after { left: 18px; }
  .ind .irow > button.dir, .ind .irow > span.dir.fixed, button.end, .factor .frow > button.expand { min-width: 28px; min-height: 28px; }
  input[type=range] { height: 32px; }
  .btn, .iconbtn, button.solo, .act, .chip, .preset { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  #fab:not(.hidden), #fabhint:not(.hidden) { display: block; }
  #fab { bottom: calc(14px + env(safe-area-inset-bottom)); }
  #quick:not(.hidden) ~ #fab, #detail:not(.hidden) ~ #fab, #quick:not(.hidden) ~ #fabhint, #detail:not(.hidden) ~ #fabhint, body.drawer-open #fab, body.drawer-open #fabhint, body.sheet-open #fab, body.sheet-open #fabhint, body.embed #fab, body.embed #fabhint { display: none; }
  #legend { bottom: 60px; }
  .city-label { font-size: 11px; }
}
