:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f0eee7;
  --ink: #1d231f;
  --muted: #66706a;
  --line: #dcd8cc;
  --forest: #1f3a2c;
  --forest-2: #2f5842;
  --accent: #e3651d;
  --accent-ink: #ffffff;
  --accent-strong: #b9480f; /* knapper med hvit tekst; --accent beholdes til kartgrafikk */
  --sheet-min: 76px;
  --innmark: #e8b73a;
  --utmark: #4f8a5b;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 30, 25, .16);
  --panel-w: 380px;
  --top-h: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Topbar */
.topbar {
  height: var(--top-h); flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--forest); color: #fff; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.search { position: relative; flex: 1; max-width: 560px; display: flex; gap: 6px; }
.search select, .search input {
  height: 36px; border-radius: 8px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.1); color: #fff; padding: 0 10px;
}
.search select option { color: var(--ink); }
.search input { flex: 1; min-width: 0; }
.search input::placeholder { color: rgba(255,255,255,.6); }
.search input:focus, .search select:focus { outline: 2px solid var(--accent); outline-offset: 0; background: rgba(255,255,255,.16); }
.results {
  position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto; z-index: 1200;
}
.results li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.results li:hover, .results li.active { background: var(--surface-2); }
.results .kind { font-size: 11px; color: var(--muted); min-width: 64px; }
.results .none { color: var(--muted); cursor: default; }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.panel {
  width: var(--panel-w); flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; z-index: 900;
}
.map-wrap { position: relative; flex: 1; min-width: 0; }
.map { position: absolute; inset: 0; background: #dfe6e0; }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 12px 8px; font-size: 13px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--forest); border-bottom-color: var(--accent); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); font-size: 11px; line-height: 18px; text-align: center; }
.tab { display: none; padding: 14px 16px 24px; overflow: auto; flex: 1; }
.tab.active { display: block; }
.empty p { margin: 0 0 10px; line-height: 1.45; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 4px 8px; color: inherit; }
.only-mobile { display: none; }

/* Selected property */
.prop-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.prop-head .swatch { width: 14px; height: 14px; border-radius: 4px; margin-top: 6px; flex: none; }
.prop-title { font-size: 20px; font-weight: 650; line-height: 1.2; margin: 0; }
.prop-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface);
}
.owner-link { float: right; color: var(--forest-2); font-size: 12px; }
.field textarea { min-height: 64px; resize: vertical; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button.sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }

.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-2); margin: 8px 0; }
.split-bar div { height: 100%; }
.ar5-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.ar5-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.ar5-table td:not(:first-child) { text-align: right; }
.ar5-table tr.group td { font-weight: 650; }
.ar5-table tr.sub td:first-child { padding-left: 18px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.teig-list { list-style: none; padding: 0; margin: 6px 0; font-size: 13px; }
.teig-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.teig-list li:hover { background: var(--surface-2); }
.teig-list .tag { font-size: 11px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 8px 0; }

/* Lists */
.item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.item:hover { background: var(--surface-2); }
.item .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .eye { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px; }
.pin-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; }
#addPinBtn { margin-bottom: 10px; }
.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 12px; }
.group.hl { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(227,101,29,.18); }
.group.loose { border-style: dashed; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.group-head .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.group-head .main { flex: 1; min-width: 0; }
.group-head .name { font-weight: 650; }
.group-head .meta { font-size: 12px; color: var(--muted); line-height: 1.4; }
.group-actions { margin: 6px 2px 4px; }
.group-edit { background: var(--surface-2); border-radius: 8px; padding: 2px 10px 10px; margin: 6px 0; }
.group .item { padding: 8px; }
.bulk { background: var(--surface-2); border-radius: var(--radius); padding: 4px 12px 12px; margin-bottom: 12px; }

.sources { padding-left: 18px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.sources li { margin-bottom: 6px; }

/* Map tools */
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 800; display: flex; flex-direction: column; gap: 8px; }
.tool {
  width: 42px; height: 42px; border-radius: 10px; border: 0; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; color: var(--forest);
}
.tool svg { width: 22px; height: 22px; }
.tool.on { background: var(--accent-strong); color: #fff; }

.layer-panel {
  position: absolute; top: 12px; right: 64px; z-index: 850; width: 320px; max-height: calc(100% - 24px); overflow: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px 14px;
}
.lp-head { display: flex; justify-content: space-between; align-items: center; }
.opt { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: start; padding: 5px 0; font-size: 14px; cursor: pointer; line-height: 1.3; }
.opt input { margin-top: 2px; accent-color: var(--accent); grid-row: span 2; }
.opt small { grid-column: 2; color: var(--muted); font-size: 12px; }
.sub { margin: 2px 0 6px 24px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sub select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; height: 32px; padding: 0 8px; background: var(--surface); }
.sub .muted { flex-basis: 100%; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px; width: 100%; }

.leaflet-control-scale-line { border-color: var(--ink); color: var(--ink); background: rgba(255,255,255,.8); }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content .btn-row { margin-top: 8px; }
.prop-label {
  background: rgba(255,255,255,.92); border: 0; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  font-weight: 650; font-size: 12px; padding: 3px 7px; color: var(--ink);
}
.prop-label::before { display: none; }
.pin-marker { background: none; border: 0; }
.pin-marker .p {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; box-shadow: 0 2px 5px rgba(0,0,0,.35); border: 2px solid #fff;
}
.pin-marker .p span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 12px; }
.pin-marker .lbl {
  position: absolute; left: 34px; top: 4px; white-space: nowrap; background: rgba(255,255,255,.92);
  border-radius: 5px; padding: 1px 6px; font-size: 12px; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.measure-lbl { background: var(--forest); color: #fff; border: 0; border-radius: 6px; font-weight: 650; padding: 3px 8px; }
.measure-lbl::before { display: none; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35); }

/* Swipe */
.swipe { position: absolute; top: 0; bottom: 0; width: 0; z-index: 700; left: 50%; }
.swipe::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1.5px; width: 3px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.5); }
.swipe-handle {
  position: absolute; top: 50%; left: -20px; width: 40px; height: 40px; margin-top: -20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; cursor: ew-resize;
  font-weight: 700; color: var(--forest); touch-action: none;
}

/* Mode bar & toast */
.modebar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1300;
  background: var(--forest); color: #fff; border-radius: 12px; padding: 8px 8px 8px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.modebar .btn { background: #fff; color: var(--forest); border: 0; }
.modebar .btn.ghost { background: transparent; color: #fff; }
.toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 1400;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 14px; max-width: calc(100% - 32px);
}
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  .brand span { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .search select { max-width: 72px; padding: 0 4px; font-size: 13px; }
  .only-mobile { display: block; }
  .layout { position: relative; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 55%;
    border-right: 0; border-top-left-radius: 16px; border-top-right-radius: 16px;
    box-shadow: 0 -4px 16px rgba(0,0,0,.18); transform: translateY(calc(100% - 46px)); transition: transform .2s ease;
  }
  .panel.open { transform: none; }
  .tabs button { padding: 13px 6px; font-size: 12px; }
  .layer-panel { right: 60px; left: 10px; width: auto; max-height: calc(100% - 80px); }
  .map-tools { top: 10px; right: 10px; }
  .modebar { bottom: 60px; }
  .leaflet-bottom { bottom: 46px; }
}

/* Jakt: skjemarader, drev, spor, live */
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; margin: 6px 0; }
.pin-form .field { margin: 6px 0; }
.pin-form .field input, .pin-form .field select, .pin-form .field textarea { padding: 6px 8px; }
.post-mk {
  width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: #fff; border: 2px solid #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.post-mk.on { outline: 3px solid rgba(227,101,29,.35); }
.post-ico {
  width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: #fff; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.arrow-mk div { font-size: 16px; line-height: 20px; text-align: center; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.row-edit { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.row-edit input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.row-edit .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.row-edit .icon-btn { font-size: 15px; padding: 2px 6px; color: var(--muted); }
.t-actions { display: flex; align-items: center; gap: 2px; margin-top: 4px; }
.t-actions select { border: 1px solid var(--line); border-radius: 6px; height: 26px; font-size: 12px; background: var(--surface); }
.t-actions .icon-btn { font-size: 14px; padding: 2px 6px; color: var(--muted); }
#trackBtn.rec { background: var(--danger); border-color: var(--danger); }
.rec-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); margin-right: 6px; animation: blink 1.2s infinite; vertical-align: 1px; }
.rec-dot.live { background: #2e7d32; }
@keyframes blink { 50% { opacity: .25; } }
.live-mk {
  width: 30px; height: 30px; border-radius: 50%; color: #fff; border: 3px solid #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 11px; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.ok { color: #2e7d32; font-weight: 600; }
.warn { color: var(--danger); font-weight: 600; }
.play-lbl { background: rgba(255,255,255,.92); border: 0; border-radius: 5px; font-weight: 650; font-size: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.play-lbl::before { display: none; }
input[type=range] { accent-color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
@media (max-width: 760px) { .tabs button { padding: 13px 4px; font-size: 12px; } }

/* Stedsnavn med nøyaktig posisjon */
.navn-mk { background: none; border: 0; }
.navn-dot { position: absolute; left: 1px; top: 1px; width: 6px; height: 6px; border-radius: 50%; background: #3b3b3b; box-shadow: 0 0 0 1.5px #fff; }
.navn-dot.n-w { background: #1565c0; }
.navn-dot.n-t { background: #6d4c1f; }
.navn-lbl {
  position: absolute; left: 10px; top: -5px; white-space: nowrap; font: 600 12px/1.1 system-ui, sans-serif; color: #262626;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; pointer-events: auto;
}
.navn-lbl.n-w { color: #0d47a1; font-style: italic; }
.navn-lbl.n-t { color: #5d3a12; }
.navn-lbl.big { font-size: 14px; font-weight: 700; }

/* Nedlasting */
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.warn-box { background: #fff4e5; border-radius: 8px; padding: 8px 10px; color: #7a4a00; }

/* Fiske */
.cond { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.45; }
.cond .ci { width: 22px; flex: none; text-align: center; font-size: 16px; }
.cond > div { flex: 1; min-width: 0; }
.tide-svg { width: 100%; height: 70px; margin-top: 4px; display: block; }
.tide-fill { fill: rgba(45,108,223,.12); }
.tide-line { fill: none; stroke: #2d6cdf; stroke-width: 2; vector-effect: non-scaling-stroke; }
.tide-now { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.tide-lbl { font-size: 9px; fill: var(--muted); }
.fi-bars { display: flex; align-items: flex-end; gap: 1px; height: 70px; margin: 6px 0 16px; }
.fi-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.fi-bar.dark { background: rgba(31,58,44,.07); }
.fi-bar div { width: 100%; border-radius: 2px 2px 0 0; }
.fi-bar span { position: absolute; bottom: -15px; left: 0; font-size: 10px; color: var(--muted); }
.fi-best { padding-left: 20px; font-size: 13px; line-height: 1.5; margin: 6px 0; }
.fish-mk { width: 26px; height: 26px; border-radius: 50%; background: #0277bd; color: #fff; border: 2px solid #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.35); }

/* Flervalg */
.multi-card { border: 2px solid var(--accent); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; background: #fff8f3; }
.multi-card .post-ico { width: 20px; height: 20px; font-size: 11px; }
.tool { position: relative; }
.tool-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent-strong); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.tool.on .tool-badge { background: var(--forest); }
kbd { font: 600 11px system-ui; background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }

/* Regler */
.rule-warn { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: #fdecea; color: #8e0000; font-size: 12px; font-weight: 600; }
details.rules { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
details.rules summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
details.rules .ar5-table td:last-child { text-align: left; padding-left: 10px; }
.modebar #modeText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.modebar { width: max-content; }

/* Jakttider */
.jt-table td { vertical-align: top; }
.jt-table td:nth-child(2) { white-space: nowrap; text-align: left; padding-left: 8px; }
.jt-table td:last-child { width: 58px; }
.jt-group td { font-weight: 700; padding-top: 12px; color: var(--forest); border-bottom: 2px solid var(--line); }
.jt-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.jt-badge.on { background: #e3f1e5; color: #1b5e20; }

/* Vedlegg */
.affine-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; max-width: none !important; image-rendering: auto; }
.corner-mk { width: 22px; height: 22px; border-radius: 50%; background: var(--forest); color: #fff; border: 2px solid #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.4); cursor: move; }
.vdl-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.vdl-item { display: flex; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.vdl-thumb { width: 64px; height: 64px; flex: none; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; font-weight: 700; color: var(--muted); font-size: 12px; }
.vdl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.vdl-item .main { flex: 1; min-width: 0; }
.vdl-item .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vdl-item .meta { font-size: 12px; color: var(--muted); }
.vdl-op { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.vdl-op input { flex: 1; }

.mast-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 3px 0 4px; }


/* Kartlagpanel: grupper og ferdige oppsett */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.preset { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.preset:hover { background: var(--surface-2); }
.preset.on { background: var(--forest); color: #fff; border-color: var(--forest); }
.preset.ghost { color: var(--muted); }
details.lg-sec { border-top: 1px solid var(--line); padding: 2px 0; }
details.lg-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 2px; font-weight: 650; font-size: 14px; }
details.lg-sec > summary::-webkit-details-marker { display: none; }
details.lg-sec > summary::before { content: '›'; display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; font-size: 18px; line-height: 1; }
details.lg-sec[open] > summary::before { transform: rotate(90deg); }
details.lg-sec .cnt { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
details.lg-sec .cnt.on { color: #fff; background: var(--accent-strong); border-radius: 10px; padding: 1px 8px; }
details.lg-sec > .opt, details.lg-sec > .sub { margin-left: 4px; }
details.lg-sec[open] { padding-bottom: 6px; }

/* Tegnforklaring */
.legend-card {
  position: absolute; left: 12px; bottom: 34px; z-index: 840; width: 260px; max-height: calc(100% - 90px); overflow: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px 10px;
}
.lg-group { margin-top: 8px; }
.lg-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.lg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.lg-sym { width: 30px; flex: none; display: grid; place-items: center; }
.lg-sym svg { width: 28px; height: 16px; display: block; }
.lg-pin { width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 9px; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.lg-pin.sq { border-radius: 5px; }
.lg-grad { width: 28px; height: 12px; border-radius: 3px; display: block; }

/* Hva er her? */
.whathere-pop .leaflet-popup-content { margin: 10px 12px; max-height: min(60vh, 460px); overflow: auto; }
.wh-head { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.wh-head strong { font-size: 15px; }
.wh-sec { padding: 7px 0; border-bottom: 1px solid var(--line); }
.wh-t { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.wh-b { font-size: 13px; line-height: 1.45; }
.wh-b .btn-row { margin-top: 4px; }
.wh-row + .wh-row { margin-top: 6px; }
.wh-sub { padding-top: 6px; border-top: 1px dashed var(--line); }
.wh-skel { display: block; height: 12px; width: 70%; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), #e6e3da, var(--surface-2)); background-size: 200% 100%; animation: skel 1.2s infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.wh-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.wh-sw.round { border-radius: 50%; }
.wh-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; margin-left: 4px; }
.wh-tag.inn { background: #fff4d6; color: #8a6100; }
.wh-tag.ut { background: #e3f1e5; color: #1b5e20; }
.wh-foot { padding-top: 8px; }
.wh-empty { padding: 8px 0; }

@media (max-width: 760px) {
  .legend-card { left: 10px; right: 64px; width: auto; bottom: 60px; max-height: 45%; }
  .preset { padding: 7px 12px; }
  details.lg-sec > summary { padding: 12px 2px; }
}


/* ---------- Opprydding: lesbarhet, trykkflater, fokus, ikoner ---------- */
:root { --muted: #59625d; }
.ic { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; color: var(--forest-2); }
.cond .ci .ic { width: 18px; height: 18px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible, .tool:focus-visible { outline-offset: 1px; }
.small, .note, .meta { font-size: 12.5px; }

/* Intro */
.intro { position: fixed; inset: 0; z-index: 2000; background: rgba(20, 30, 25, .45); display: grid; place-items: center; padding: 16px; }
.intro-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); max-width: 380px; width: 100%; padding: 20px 20px 16px; }
.intro-t { margin: 10px 0 6px; font-size: 19px; }
.intro-b { margin: 0 0 16px; line-height: 1.5; color: var(--ink); }
.intro-dots { display: flex; gap: 6px; }
.intro-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.intro-dots span.on { background: var(--accent); }

/* Bunnpanel med håndtak (mobil) */
.sheet-handle { display: none; }
@media (max-width: 760px) {
  .panel { transform: none !important; height: var(--sheet-min); transition: height .2s ease; overflow: hidden; }
  .panel.dragging { transition: none; }
  .sheet-handle { display: grid; place-items: center; height: 30px; flex: none; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 3px; background: #c9c4b7; }
  .panel:not(.open):not(.full) .tab { display: none; }
  .panel { height: var(--sheet-min); }
  .panel.open { height: 55%; }
  .panel.full { height: 94%; }
  .leaflet-bottom { bottom: var(--sheet-min); }
  .modebar { bottom: calc(var(--sheet-min) + 12px); }
  .legend-card { bottom: calc(var(--sheet-min) + 12px); }

  /* Større trykkflater ute i felt */
  .btn { min-height: 42px; }
  .btn.small { min-height: 38px; padding: 0 12px; }
  .icon-btn, .item .eye, .t-actions .icon-btn, .row-edit .icon-btn { min-width: 40px; min-height: 40px; }
  .tool { width: 46px; height: 46px; }
  .opt { padding: 8px 0; }
  .tabs button { min-height: 44px; }
}


/* Leaflet sine kontroller og popuper i egen stablingskontekst, under panelene */
.map { z-index: 0; }
@media (max-width: 760px) {
  .layout:has(.panel.open) .leaflet-bottom, .layout:has(.panel.full) .leaflet-bottom { display: none; }
  .legend-card { bottom: 96px; }
}

/* ---------- Forbedringer: hurtigmeny, posisjon, koordinater, panel, uten nett, utskrift ---------- */
.ctx-menu { position: fixed; z-index: 1500; min-width: 200px; background: var(--surface); border-radius: 10px; box-shadow: 0 6px 24px rgba(20,30,25,.25); padding: 6px; }
.ctx-menu .ctx-h { font-size: 11.5px; color: var(--muted); padding: 4px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--surface-2); }
.me-wrap { position: relative; width: 16px; height: 16px; }
.me-cone { display: none; position: absolute; left: -12px; top: -24px; width: 40px; height: 40px; transform-origin: 20px 32px;
  background: radial-gradient(circle at 50% 100%, rgba(26,115,232,.45), rgba(26,115,232,0) 70%); clip-path: polygon(50% 80%, 15% 0, 85% 0); pointer-events: none; }
.me-wrap .me-dot { position: absolute; inset: 0; }
.tool.follow { background: #1a73e8; color: #fff; }
.cursor-coord { position: absolute; left: 12px; bottom: 28px; z-index: 790; background: rgba(255,255,255,.9); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink); pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.only-desktop { display: inline-flex; color: #fff; }
body.side-hidden .panel { display: none; }
.offline-banner { position: fixed; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 1350; background: #7a4a00; color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }
.modebar .btn.ghost { color: #fff; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; margin-bottom: 10px; }
.wake-opt { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.print-head { display: none; }
@media (max-width: 760px) { .only-desktop { display: none; } .cursor-coord { display: none; } }
@media print {
  @page { size: A4; margin: 12mm; }
  body.printing { display: block; overflow: visible; background: #fff; }
  body.printing .topbar, body.printing .panel, body.printing .map-tools, body.printing .layer-panel, body.printing .legend-card,
  body.printing .modebar, body.printing .toast, body.printing .offline-banner, body.printing .cursor-coord, body.printing .leaflet-control-zoom,
  body.printing .leaflet-popup-pane, body.printing .intro, body.printing .ctx-menu { display: none !important; }
  body.printing .print-head { display: block !important; font-family: system-ui, sans-serif; margin-bottom: 6mm; }
  body.printing .print-head h1 { font-size: 20pt; margin: 0 0 2mm; }
  body.printing .print-head p { margin: 0 0 1.5mm; font-size: 10.5pt; }
  body.printing .print-head .print-src { color: #555; font-size: 8.5pt; }
  body.printing .layout { display: block; height: auto; }
  body.printing .map-wrap { position: relative; height: 175mm; }
  body.printing .map { position: absolute; inset: 0; }
}

/* ---------- Runde 2: varsler, søk, verktøy, faner og eiendomsvisning ---------- */
/* Varsler med «Angre», og under «uten nett»-banneret når det vises */
.toast { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.toast.below-banner { top: calc(var(--top-h) + 50px); }
.toast-act { border: 0; background: none; color: #ffc59e; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 4px 6px; min-height: 32px; font-size: 14px; }

/* Spinner i søkefeltet */
.q-spin { position: absolute; right: 10px; top: 11px; border-color: rgba(255,255,255,.3); border-top-color: #fff; pointer-events: none; }

/* Arealfliser: siste flis fyller raden ved oddetall */
.stats .stat:last-child:nth-child(odd) { grid-column: span 2; }

/* Handlinger rett under tittelen; klebrig øverst på PC */
.prop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.prop-actions .more { margin-left: auto; }
.more { position: relative; }
.more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 220px; background: var(--surface); border-radius: 10px; box-shadow: 0 6px 24px rgba(20,30,25,.25); padding: 6px; }
.more-menu a, .more-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--ink); text-decoration: none; }
.more-menu a:hover, .more-menu button:hover, .more-menu a:focus-visible, .more-menu button:focus-visible { background: var(--surface-2); }
.more-menu .danger { color: var(--danger); }
.m-open { cursor: pointer; border-radius: 4px; }
.m-open:hover strong { text-decoration: underline; }
@media (min-width: 761px) {
  .prop-top { position: sticky; top: 0; z-index: 5; background: var(--surface); margin: -14px -16px 10px; padding: 14px 16px 8px; border-bottom: 1px solid var(--line); }
  .prop-top .prop-head { margin-bottom: 8px; }
  .prop-top .prop-actions { margin: 0; }
}

/* Sammenleggbare seksjoner i Jakt og Fiske */
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: '›'; display: inline-block; width: 12px; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s; }
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary h3 { margin: 16px 0 8px; }
details.sec:first-of-type > summary h3 { margin-top: 4px; }

/* Verktøyknapp (speed-dial) – bare på mobil; PC beholder kolonnen */
.tools-btn { display: none; }
.tool-dial, .tool-list { display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 760px) {
  .search select { max-width: 72px; }
  .colors { gap: 8px; }
  .colors button { width: 36px; height: 36px; }

  /* Ingen understrek på aktiv fane når panelet er lukket */
  .panel:not(.open):not(.full) .tabs button.active { border-bottom-color: transparent; }

  /* Posisjon og kartlag nederst til høyre over zoomknappene, verktøy samlet over dem */
  .map-tools { top: auto; bottom: calc(var(--sheet-min) + 104px); right: 10px; transition: bottom .2s ease; }
  .map-tools .tool-dial { order: 0; position: relative; }
  #layerBtn { order: 1; }
  #locateBtn { order: 2; }
  .tools-btn { display: grid; }
  .tools-btn svg { transition: transform .15s; }
  .tool-dial.open .tools-btn svg { transform: rotate(45deg); }
  .tool-list { display: none; position: absolute; right: 0; bottom: calc(100% + 10px); gap: 10px; align-items: flex-end; }
  .tool-dial.open .tool-list { display: flex; }
  .tool-list .tool::before {
    content: attr(data-lbl); position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%);
    white-space: nowrap; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600;
    padding: 5px 10px; border-radius: 8px; box-shadow: var(--shadow); pointer-events: none;
  }
  .layout:has(.panel.open) .map-tools { bottom: calc(55% + 12px); }
  .layout:has(.panel.full) .map-tools { display: none; }

  /* Zoomknappene vises igjen, over bunnpanelet */
  .leaflet-control-zoom { display: block; }

  /* Modusraden: full bredde, teksten på egen linje */
  .modebar { left: 8px; right: 8px; transform: none; width: auto; max-width: none; flex-wrap: wrap; padding: 10px; gap: 8px; }
  .modebar #modeText { flex-basis: 100%; font-size: 16px; font-weight: 700; white-space: normal; }
  .modebar .btn { flex: 1; }
  body:has(#modeBar:not([hidden])) .leaflet-bottom { bottom: calc(var(--sheet-min) + 112px); }
  body:has(#modeBar:not([hidden])) .map-tools { bottom: calc(var(--sheet-min) + 216px); }
}
