:root {
  /* faglaro62.se site palette (teal + green) — matches the startsida */
  --bg: #0f2d33;
  --panel: #1c4a52;
  --panel-2: #123b41;
  --line: #2a5a62;
  --text: #eaf3f2;
  --muted: #8fb0ac;
  --accent: #8fce9b;
  --accent-dim: #5f9a6c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  /* Never let the whole page scroll — on iPad the document scroll would slide the
     panel's top up under Safari's toolbar. Only #panel scrolls. */
  overflow: hidden;
}
/* Use the dynamic viewport height (dvh) so the layout matches the *visible*
   viewport on iOS, where 100vh is taller than the area left by the browser
   chrome. Fallback to 100vh for browsers without dvh. */
#app { display: flex; height: 100vh; height: 100dvh; position: relative; }
#map { flex: 1; min-width: 0; }

/* Back-to-site link + collapsible menu */
#panel-actions { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
#btn-home {
  display: inline-flex; align-items: center; text-decoration: none;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 9px; font-size: 12px; font-weight: 600;
}
#btn-home:hover { border-color: var(--accent-dim); }
/* XBUAAA-2339: always-visible "share this view" button in the header so it is found
   without scrolling the long panel to the "Vyer" section. Accent-tinted to stand out. */
#btn-share-top {
  display: inline-flex; align-items: center; cursor: pointer;
  background: var(--accent); color: #0f2d33; border: 1px solid var(--accent);
  border-radius: 5px; padding: 5px 9px; font-size: 12px; font-weight: 700;
}
#btn-share-top:hover { filter: brightness(1.08); }
/* Language switcher (SV / EN) — segmented control in the header panel actions. */
#lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
#lang-toggle button {
  background: var(--panel-2); color: var(--muted); border: none; border-radius: 0;
  padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer;
}
#lang-toggle button + button { border-left: 1px solid var(--line); }
#lang-toggle button:hover:not(.active) { color: var(--text); }
#lang-toggle button.active { background: var(--accent); color: #0f2d33; }

#btn-menu-hide { font-size: 12px; padding: 5px 9px; margin-left: auto; }
#btn-menu-show {
  position: absolute; z-index: 5; display: none;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 11px; font-weight: 600;
  box-shadow: 0 1px 4px #0006; cursor: pointer;
}
#btn-menu-show:hover { border-color: var(--accent-dim); }
#app.panel-hidden #panel { display: none; }
#app.panel-hidden #btn-menu-show { display: inline-flex; }

#panel {
  width: 340px;
  flex: 0 0 340px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* In landscape the iPad's notch inset lands on the left edge, i.e. over this
     panel — pad it clear. Zero on devices without an inset. */
  padding-left: env(safe-area-inset-left);
}
#panel-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel);
  /* Pad the header down past the top safe-area inset so its top (← Till sajten /
     title / readout) is never hidden under the iPad toolbar. */
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--line);
}
#panel-head h1 { margin: 0 0 6px; font-size: 15px; letter-spacing: .3px; }
#readout {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px;
}
#readout b { color: var(--accent); font-weight: 600; }

details { border-bottom: 1px solid var(--line); }
summary {
  cursor: pointer; padding: 8px 12px; font-weight: 600;
  list-style: none; user-select: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸ "; color: var(--muted); }
details[open] > summary::before { content: "▾ "; }
.body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
label.file {
  flex-direction: row; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 8px; cursor: pointer; color: var(--text);
}
input[type=text], input[type=password], select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 6px 7px; font: inherit;
  width: 100%;
}
input[type=number] {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 6px 7px; font: inherit;
  width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] {
  width: 34px; height: 24px; padding: 0; border: 1px solid var(--line);
  border-radius: 4px; background: none; cursor: pointer;
}
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > select { flex: 1; }
button.active { background: var(--accent); border-color: var(--accent); color: #0f2d33; font-weight: 600; }
button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px;
  font: inherit; cursor: pointer;
}
button:hover { border-color: var(--accent-dim); }
button.primary { background: var(--accent); border-color: var(--accent); color: #0f2d33; font-weight: 600; }
button.primary:hover { filter: brightness(1.05); }
output { color: var(--accent); font-variant-numeric: tabular-nums; }
.status { color: var(--muted); font-size: 11px; margin: 2px 0 0; }
.status.err { color: #e58a6f; }
.status.ok { color: #8fbf7f; }
code { background: var(--panel-2); padding: 1px 4px; border-radius: 3px; font-size: 11px; }

/* Layer cards + reorder */
.layers-help { color: var(--muted); font-size: 11px; margin: 0 0 6px; }
.layer {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 8px; margin-bottom: 7px;
}
.layer.hidden { opacity: .5; }
.layer.overlay { border-style: dashed; }
.layer.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.layer.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; font-size: 13px; line-height: 1; flex: 0 0 auto; }
.drag-handle:active { cursor: grabbing; }
.arrows { display: flex; flex-direction: column; gap: 1px; flex: 0 0 auto; }
.arrows .arrow {
  padding: 0 3px; font-size: 7px; line-height: 9px; border-radius: 3px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.arrows .arrow:hover { border-color: var(--accent-dim); color: var(--text); }

/* Unified sortable feature list. Each feature is a <details> row;
   the ⠿ handle + ▲▼ arrows are injected into its <summary>. */
#features > details.feature > summary {
  display: flex; align-items: center; gap: 6px;
}
#features > details.feature > summary .drag-handle { font-size: 14px; }
#features > details.feature > summary .arrows { margin-right: 2px; }
#features > details.feature.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
#features > details.feature.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
#features-help { padding: 6px 12px 0; }

/* Rectangle inputs (Feature 2) */
.rect-grid { display: flex; gap: 8px; }
.rect-grid label { flex: 1; }
.layer-head { display: flex; align-items: center; gap: 6px; }
.layer-head .id { font-weight: 600; font-size: 12px; flex: 1; word-break: break-all; }
.layer-head .type {
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); background: var(--panel); padding: 1px 5px; border-radius: 3px;
}
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0006; flex: 0 0 auto; }
.props { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.prop { display: flex; align-items: center; gap: 7px; }
.prop .k { flex: 0 0 96px; color: var(--muted); font-size: 11px; }
.prop .v { flex: 1; display: flex; align-items: center; gap: 6px; }
.prop .v input[type=range] { flex: 1; }
.prop .num { width: 46px; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; font-size: 11px; }
.stops { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.stop { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.stop input[type=text] { width: 52px; padding: 3px 4px; }
.badge-interp { font-size: 10px; color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 3px; padding: 0 4px; }

/* Elevation heatmap legend (blue→red ramp; stops mirror HEAT_RAMP in app.js) */
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat-legend .heat-bar {
  flex: 1; height: 10px; border-radius: 3px; border: 1px solid var(--line);
  background: linear-gradient(to right, #2c7bb6 0%, #00b4c4 25%, #7fdb3a 50%, #fdae61 75%, #d7191c 100%);
}
/* Bathymetry depth legend — shallow→deep cyan→deep-blue */
.heat-legend .bathy-bar {
  background: linear-gradient(to right, #c6ecff 0%, #7fcdff 25%, #3aa0e0 50%, #1f6fb2 75%, #0b3d73 100%);
}
/* Heatmap min/max range inputs */
.heat-range { display: flex; gap: 8px; margin: 4px 0; }
.heat-range label { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
.heat-range input { width: 100%; box-sizing: border-box; }
.heat-range input:disabled { opacity: .5; }

/* Measurement readout */
.measure-readout {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 8px; font-variant-numeric: tabular-nums; color: var(--accent);
  font-weight: 600; min-height: 30px; display: flex; align-items: center;
}
#measure-modes { gap: 10px; }
#measure-modes > span { color: var(--muted); }

/* Elevation profile overlay (XBUAAA-2291) — a floating card over the map, white so the
   SVG profile reads like a printed cross-section. Positioned bottom-centre, responsive. */
#elevprofile-overlay {
  position: absolute; z-index: 7; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: #ffffff; color: #1a1a1a; border: 1px solid #c8c8c8; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); padding: 6px 8px 8px;
  max-width: calc(100vw - 24px);
}
#elevprofile-overlay[hidden] { display: none; }
#elevprofile-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 2px 4px; font-size: 13px; font-weight: 600; color: #1a1a1a;
}
#elevprofile-actions { display: flex; align-items: center; gap: 6px; }
#elevprofile-head button {
  background: #f2f2f2; color: #1a1a1a; border: 1px solid #c8c8c8; border-radius: 5px;
  padding: 2px 8px; font-size: 12px; cursor: pointer; line-height: 1.4;
}
#elevprofile-head button:hover { background: #e6e6e6; }
#elevprofile-scale { display: inline-flex; }
#elevprofile-scale button { border-radius: 0; margin-left: -1px; font-weight: 500; }
#elevprofile-scale button:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
#elevprofile-scale button:last-child { border-radius: 0 5px 5px 0; }
#elevprofile-scale button[aria-pressed="true"] {
  background: #e07a1f; border-color: #c96a16; color: #fff; font-weight: 600; position: relative; z-index: 1;
}
#elevprofile-scale button[aria-pressed="true"]:hover { background: #d4720f; }
#btn-profile-close { font-weight: 700; padding: 2px 7px; }
#elevprofile-body svg { display: block; }

/* Legend */
.legend-group { margin-bottom: 8px; }
.legend-group h4 { margin: 4px 0 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 7px; padding: 1px 0; font-size: 12px; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.token { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }

/* faglaro62.se Map Lab copy: hide the lab-only / removed sections so
   this stays a clean Fåglarö property viewer. The vector BASEMAP itself is gone at the
   data level (blank raster-only base style, styles/faglaro-blank.json) — these rules
   only hide leftover control panels, which have no map footprint. App.js wiring is left
   intact (elements still exist) so nothing null-crashes; un-hide by deleting a selector.
     sec-config   : Config (style/PMTiles/keys)      — founder: remove
     sec-hillshade: Hillshade & 3D terrain           — founder: remove hillshade
     sec-orto     : LM ortofoto (pilot)              — founder: remove
     sec-layers   : Basemap vector layers editor     — founder: remove (basemap now blank)
     sec-legend   : Object types (legend)            — founder: remove
     sec-views    : Saved views widget               — founder: remove (2026-09-17)
     sec-export   : Export style JSON / diff widget   — founder: remove (2026-09-17)
   NB sec-camera (Camera / 3D view) is intentionally NOT hidden — the founder asked to
   bring 3D back after it was removed alongside hillshade. */
#sec-config,
#sec-hillshade,
#sec-orto,
#sec-layers,
#sec-legend,
#sec-views,
#sec-export { display: none !important; }

/* Photo-position popups: the CMS image + optional article link. */
.photo-popup img { display:block; width:100%; height:auto; border-radius:6px; }
.photo-popup .pp-cap { display:block; margin-top:6px; font-weight:600; color:#b5670a; text-decoration:none; }
.photo-popup .pp-cap:hover { text-decoration:underline; }
.photo-popup .pp-when { margin-top:2px; font-size:12px; color:#666; }

/* Slideshow tour: on-map ▶ pill + the photo card shown at each stop. */
#demo-fab {
  position: absolute; z-index: 5;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 15px; font-weight: 600; font-size: 13px;
  box-shadow: 0 2px 6px #0007; cursor: pointer;
}
#demo-fab:hover { border-color: var(--accent-dim); }
#demo-fab.on { background: var(--accent); color: #0f2d33; border-color: var(--accent); }

#demo-photo {
  position: absolute; z-index: 6;
  right: calc(14px + env(safe-area-inset-right));
  top: calc(14px + env(safe-area-inset-top));
  width: min(340px, 82vw);
  background: #0f2d33ee; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; box-shadow: 0 6px 22px #0009;
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
}
#demo-photo.show { opacity: 1; transform: translateY(0); }
#demo-photo img { display: block; width: 100%; height: auto; max-height: 46vh; object-fit: cover; border-radius: 6px; }
#demo-photo .dp-cap { margin-top: 6px; font-weight: 700; font-size: 14px; color: var(--text); }
#demo-photo .dp-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
#demo-photo .dp-prog { margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--accent); }
#demo-photo .dp-hint { margin-top: 2px; font-size: 11px; color: var(--muted); }

/* ---- Screen-saver / kiosk mode ------------------------------
   Activated by body.screensaver (set when opened with ?screensaver=1). Strips
   every control so only the map + the flying photo tour remain, edge to edge.
   The photo card keeps showing — it IS the content of the saver. */
body.screensaver #panel,
body.screensaver #btn-menu-show,
body.screensaver #demo-fab,
body.screensaver .maplibregl-ctrl-group { display: none !important; }
/* Keep the map attribution (MapTiler/OSM/Lantmäteriet licensing) — just dim it. */
body.screensaver .maplibregl-ctrl-attrib { opacity: .5; }
body.screensaver #app { display: block; }
body.screensaver #map { position: fixed; inset: 0; width: 100vw; height: 100vh; }
body.screensaver #demo-photo { width: min(400px, 30vw); }
body.screensaver { cursor: none; }
