:root {
  --ink: #24303d;        /* skifer/tag-grå — primær tekst */
  --ink-soft: #6b6156;   /* dæmpet mørtel-brun */
  --paper: #f5f1e8;      /* varm kalk/mørtel baggrund */
  --card: #ffffff;
  --line: #e4ddd0;
  --brick: #b6502f;      /* tegltag terracotta — primær handling */
  --brick-dark: #98401f;
  --moss: #5c7a52;       /* algebehandlings-grøn — sekundær/resultat */
  --moss-soft: #eef3ea;
  --amber: #b4791f;
  --radius: 14px;
  --shadow: 0 3px 14px rgba(36,48,61,0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%; margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app-header {
  position: relative;
  padding: 34px 20px 22px;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
}
/* Signatur: overlappende tagsten-striber, dæmpet, kun i headeren */
.app-header::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    -8deg,
    rgba(182,80,47,0.35) 0px, rgba(182,80,47,0.35) 3px,
    transparent 3px, transparent 26px
  );
  opacity: 0.55;
}
.app-header-inner { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; }
.app-header h1 {
  margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -0.01em;
  font-family: "Avenir Next", "Century Gothic", -apple-system, sans-serif;
}
.app-header p {
  margin: 8px 0 0; font-size: 13.5px; line-height: 1.5; color: rgba(255,255,255,0.78); max-width: 440px;
}

.content { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; }

.pc-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}

.pc-lbl {
  display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--ink-soft); margin: 14px 0 5px; text-transform: uppercase;
}
.pc-lbl:first-child { margin-top: 0; }

.pc-sel, .pc-inp {
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 16px; box-sizing: border-box; background: #fff; color: var(--ink);
  font-family: inherit; transition: border-color .15s;
}
.pc-sel:focus, .pc-inp:focus { outline: none; border-color: var(--brick); }
.pc-sel:disabled { background: #f7f4ee; color: #a89e8f; }

.pc-row {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px; margin-top: 12px;
  background: var(--paper); position: relative;
}
.pc-row-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 9px;
}
.pc-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-row-grid.pc-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.pc-row-remove {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: #fbe3db; color: var(--brick-dark); font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.pc-add-row {
  width: 100%; margin-top: 11px; padding: 11px; border-radius: 10px; border: 1.5px dashed var(--brick);
  background: rgba(182,80,47,0.06); color: var(--brick-dark); font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: inherit;
}
.pc-extras {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px;
  padding-top: 12px; border-top: 1px dashed var(--line);
}
.pc-extras .pc-lbl { grid-column: 1 / -1; margin-top: 0; }

.pc-area-result {
  margin-top: 16px; padding: 13px; background: var(--moss-soft); border: 1px solid rgba(92,122,82,0.25);
  border-radius: 10px; text-align: center; font-size: 14px; color: var(--ink);
}
.pc-area-result strong { color: var(--moss); font-size: 16px; }

.pc-calc-btn {
  width: 100%; margin-top: 16px; padding: 15px; border: none; border-radius: 12px;
  background: var(--brick); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  font-family: inherit; letter-spacing: 0.01em; transition: background .15s;
}
.pc-calc-btn:active { background: var(--brick-dark); }

.pc-result {
  margin-top: 18px; padding: 17px; background: var(--moss-soft);
  border: 1.5px solid rgba(92,122,82,0.3); border-radius: 12px;
}
.pc-result-line { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; font-size: 14px; color: var(--ink); gap: 12px; }
.pc-result-line.pc-total {
  font-weight: 800; font-size: 18px; color: var(--moss);
  border-top: 1.5px solid rgba(92,122,82,0.3); margin-top: 6px; padding-top: 12px;
}
.pc-minprice-note {
  font-size: 12.5px; color: #7a5310; background: #fbf1de; border: 1px solid rgba(180,121,31,0.3);
  border-radius: 9px; padding: 10px 11px; margin-bottom: 10px; line-height: 1.5;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 99;
  max-width: 88%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.app-footer {
  text-align: center; padding: 22px 0 4px; font-size: 12.5px; color: var(--ink-soft);
}
.app-footer a { color: var(--brick); text-decoration: none; font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }

@media (max-width: 380px) {
  .pc-row-grid.pc-row-3 { grid-template-columns: 1fr 1fr; }
  .pc-extras { grid-template-columns: 1fr 1fr; }
}

/* ── PWA installér-knap (kun i browser, skjult i app) ── */
.pc-install-btn {
  display: none; margin: 12px auto 0; padding: 9px 16px; border-radius: 10px;
  border: 1.5px solid var(--brick); background: rgba(182,80,47,0.06); color: var(--brick-dark);
  font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ── Stigetillæg checkboks ── */
.pc-checkbox-row {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 12px;
  padding: 12px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 13.5px; color: var(--ink); cursor: pointer; line-height: 1.4;
}
.pc-checkbox-row input[type="checkbox"] {
  width: 20px; height: 20px; flex-shrink: 0; margin: 1px 0 0; accent-color: var(--brick);
}
.pc-checkbox-row strong { color: var(--brick-dark); }

/* ═══════════════ NAVI TOOLS — skærme, kort, værktøjer ═══════════════ */
.screen { display: none; }
.screen.active { display: block; }

/* Topbar på værktøjs-skærme */
.topbar {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 16px 16px 14px;
  background: var(--ink); color: #fff;
  overflow: hidden;
}
.topbar::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(-8deg,
    rgba(182,80,47,0.35) 0px, rgba(182,80,47,0.35) 3px,
    transparent 3px, transparent 26px);
  opacity: 0.5;
}
.topbar h1 {
  position: relative; z-index: 1;
  margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
  font-family: "Avenir Next", "Century Gothic", -apple-system, sans-serif;
}
.topbar .back {
  position: relative; z-index: 1;
  background: rgba(255,255,255,0.14); border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; font-size: 24px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.topbar .back:active { background: rgba(255,255,255,0.28); }

/* Forsidens kort-grid */
.home-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 20px;
}
.home-card {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px; box-shadow: var(--shadow);
  cursor: pointer; text-align: left; font-family: inherit;
  transition: transform .08s, box-shadow .12s;
  min-height: 118px;
}
.home-card:active { transform: scale(0.97); box-shadow: 0 1px 6px rgba(36,48,61,0.10); }
.home-card .ic {
  font-size: 30px; line-height: 1; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 13px;
  background: var(--moss-soft); border: 1px solid var(--line);
}
.home-card .t { font-size: 15.5px; font-weight: 800; color: var(--ink); }
.home-card .d { font-size: 12px; color: var(--ink-soft); margin-top: 3px; line-height: 1.4; }

.tool-intro { font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); margin: 4px 0 16px; }

/* Adresse-søgefelt + autocomplete (Skråfoto/BBR) */
.search-input {
  width: 100%; padding: 13px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--brick); }
.addr-suggest {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); max-height: 260px; overflow: auto; margin-top: 2px;
}
.addr-suggest.show { display: block; }
.addr-suggest .opt {
  padding: 11px 14px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--line); color: var(--ink);
}
.addr-suggest .opt:last-child { border-bottom: 0; }
.addr-suggest .opt:active { background: var(--moss-soft); }

/* Knapper */
.btn {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 700; font-family: inherit;
  border: 1px solid var(--brick); border-radius: var(--radius);
  background: var(--brick); color: #fff; cursor: pointer; margin-top: 10px;
}
.btn:active { background: var(--brick-dark); }
.btn.green { background: var(--moss); border-color: var(--moss); }

/* Kort-frame (iframe) */
.map-frame {
  margin-top: 12px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #eee; height: 340px;
}
.map-frame-tall { height: 460px; }
.map-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* BBR resultat-kort */
.bbr-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.bbr-card h4 { margin: 0 0 8px; font-size: 15px; color: var(--ink); font-weight: 800; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13.5px; }
.kv .k { color: var(--ink-soft); }
.kv .v { color: var(--ink); font-weight: 600; text-align: right; }
.empty { text-align: center; color: var(--ink-soft); padding: 20px; font-size: 14px; }
.spinner { text-align: center; color: var(--ink-soft); padding: 18px; font-size: 14px; }

/* BBR-kort med markør */
.bbr-map {
  width: 100%; height: 240px; border-radius: var(--radius);
  border: 1px solid var(--line); margin-bottom: 10px; overflow: hidden;
  background: #e5e7eb;
}
.bbr-map .leaflet-container { height: 100%; width: 100%; border-radius: var(--radius); }

/* Find hældning — skitse-canvas */
.hl-canvas-wrap {
  position: relative; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.hl-canvas-wrap canvas { display: block; width: 100%; }
.hl-sketch-labels {
  text-align: center; margin-top: 10px; font-size: 13.5px; color: var(--ink); line-height: 1.9;
}
.hl-sketch-labels .angle-label { font-weight: 700; color: var(--brick); }
.hl-sketch-labels .side-label { font-weight: 700; color: var(--ink); }
.hl-canvas-wrap .canvas-point-label {
  position: absolute; transform: translate(-50%,-50%);
  font-weight: 800; font-size: 14px; color: var(--brick);
  background: var(--card); padding: 0 3px; border-radius: 4px;
}
.hl-canvas-wrap .canvas-side-label {
  position: absolute; transform: translate(-50%,-50%);
  font-weight: 700; font-size: 13px; color: var(--ink-soft);
}

/* Isolerings-beregnere (hulmur / loft) — rækker med vandret/lodret/årstal osv. */
.iso-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.iso-row-labeled { margin-bottom: 4px; }
.iso-lbl { font-size: 11px; color: var(--ink-soft); text-align: center; }
.iso-inp { margin: 0; }
.iso-del {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: #b91c1c;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.iso-del:active { background: #fee2e2; }
