/* ── Chatvinduet (20. nov 2026) ─────────────────────────────
   Etter mønsteret til de store chatverktøyene (Intercom, Crisp): et hjemmebilde
   med de tre i teamet øverst og svartiden, to valg (melding til oss eller
   KI-assistenten), snarveier, og faner nederst. Merket vårt: svart topp,
   hvite kort, turkis bare som detalj. Ingen grønn «online»-prikk og ingen
   glødende piller (Andreas, 15. okt: det så ut som en ferdig mal).
   Stilarket lenkes fra <head> på hver side, så vinduet aldri blinker ustylet. */

/* ── Knappen ── */
#cw-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--blekk, #0B0B0B);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1.5px rgba(250,250,247,.6), 0 2px 6px rgba(11,11,11,.08), 0 14px 34px rgba(11,11,11,.16);
  transition: transform .18s ease, box-shadow .18s ease;
}
@media (max-width: 760px) { #cw-bubble { transition: transform .18s ease, box-shadow .18s ease, opacity .25s ease, visibility .25s; } #cw-bubble.cw-vik:not(.open) { opacity: 0; visibility: hidden; pointer-events: none; } }
#cw-bubble:hover { transform: scale(1.04); }
#cw-bubble:focus-visible { outline: 2px solid var(--blekk, #0B0B0B); outline-offset: 4px; box-shadow: 0 0 0 4px #FAFAF7; }
#cw-bubble .cw-icon-chat, #cw-bubble .cw-icon-close { display: flex; align-items: center; justify-content: center; transition: transform .25s ease, opacity .2s ease; }
#cw-bubble .cw-icon-chat img { width: 30px; height: 30px; display: block; filter: invert(1); }
#cw-bubble .cw-icon-close { position: absolute; width: 24px; height: 24px; opacity: 0; transform: rotate(-90deg) scale(.7); fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; }
#cw-bubble.open .cw-icon-chat { opacity: 0; transform: rotate(90deg) scale(.7); }
#cw-bubble.open .cw-icon-close { opacity: 1; transform: none; }

/* ── Vinduet ── */
#cw-window {
  position: fixed; bottom: 92px; right: 24px; z-index: 8999;
  width: 384px; height: min(660px, calc(100vh - 116px));
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  background: #fff; color: var(--blekk, #0B0B0B);
  border-radius: 22px; overflow: hidden;
  font-family: 'Geist', 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  box-shadow: 0 0 0 1px rgba(11,11,11,.06), 0 2px 6px rgba(11,11,11,.05), 0 30px 70px rgba(11,11,11,.22);
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right; pointer-events: none;
  transition: opacity .22s ease, transform .3s cubic-bezier(.22, 1, .36, 1);
}
#cw-window.open { opacity: 1; transform: none; pointer-events: all; }
#cw-window svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cw-view { display: none; min-height: 0; }
#cw-window[data-view="hjem"] .cw-hjem,
#cw-window[data-view="ki"] .cw-ki,
#cw-window[data-view="melding"] .cw-melding { display: flex; flex-direction: column; animation: cwInn .26s ease; }
@keyframes cwInn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Ansiktene: tre runde bilder som overlapper */
.cw-ansikter { display: inline-flex; flex: none; }
.cw-ansikter img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; background: #ddd; }
.cw-ansikter img + img { margin-left: -9px; }
.cw-ansikter-stor img { width: 46px; height: 46px; border-color: #0B0B0B; }
.cw-ansikter-stor img + img { margin-left: -12px; }
.cw-ansikter-liten img { width: 22px; height: 22px; }
.cw-ansikter-liten img + img { margin-left: -7px; }
.cw-ansikter-hode img { width: 28px; height: 28px; }

/* Lukk og tilbake */
.cw-lukk, .cw-tilbake {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
.cw-lukk svg, .cw-tilbake svg { width: 18px; height: 18px; }
.cw-lukk:hover, .cw-tilbake:hover { background: rgba(11,11,11,.06); }

/* ── Hjem ── */
.cw-hjem { overflow-y: auto; background: #F4F5F7; }
.cw-topp {
  position: relative; padding: 18px 18px 76px 22px; color: #fff; flex: none;
  background: radial-gradient(120% 90% at 85% 0%, rgba(127,232,245,.22), transparent 55%), #0B0B0B;
}
.cw-topp-rad { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.cw-merke { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; letter-spacing: -.055em; }
.cw-merke img { filter: invert(1); }
.cw-topp .cw-lukk { color: #fff; }
.cw-topp .cw-lukk:hover { background: rgba(255,255,255,.1); }
.cw-hei { margin: 16px 0 6px; font-size: 27px; line-height: 1.12; font-weight: 500; letter-spacing: -.035em; color: #fff; }
.cw-svartid { margin: 0; font-size: 14px; color: #A9AEB4; }

.cw-kort-liste { display: grid; gap: 10px; padding: 0 14px 16px; margin-top: -54px; position: relative; }
.cw-kort {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 16px 16px 18px; border: 0; border-radius: 16px;
  background: #fff; color: inherit; font: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(11,11,11,.06), 0 4px 14px rgba(11,11,11,.06); transition: box-shadow .2s ease, transform .2s ease;
}
.cw-kort:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(11,11,11,.1), 0 10px 24px rgba(11,11,11,.1); }
.cw-kort-tekst { display: grid; gap: 3px; flex: 1; min-width: 0; }
.cw-kort-tekst strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.cw-kort-tekst span { font-size: 13.5px; color: #686D73; line-height: 1.4; }
.cw-kort-pil { width: 34px; height: 34px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #F1F2F4; transition: background .2s ease, color .2s ease; }
.cw-kort-pil svg { width: 16px; height: 16px; }
.cw-kort-hoved .cw-kort-pil { background: #0B0B0B; color: #fff; }
.cw-kort:hover .cw-kort-pil { background: var(--farge, #7FE8F5); color: #0B0B0B; }
.cw-kort-ikon { width: 38px; height: 38px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #F1F2F4; }
.cw-kort-ikon img { width: 22px; height: 22px; }
.cw-snarveier { background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px rgba(11,11,11,.06); overflow: hidden; }
.cw-snarveier a { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 18px; color: inherit; text-decoration: none; font-size: 14.5px; }
.cw-snarveier a + a { border-top: 1px solid rgba(11,11,11,.07); }
.cw-snarveier a span { flex: 1; }
.cw-snarveier svg { width: 18px; height: 18px; color: #686D73; }
.cw-snarveier a svg:last-child { width: 15px; height: 15px; transition: transform .2s ease; }
.cw-snarveier a:hover svg:last-child { transform: translateX(3px); color: #0B0B0B; }

/* ── Topp i KI og melding ── */
.cw-hode { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 8px; border-bottom: 1px solid rgba(11,11,11,.08); flex: none; }
.cw-hode .cw-lukk { margin-left: auto; }
.cw-hode-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #0B0B0B; flex: none; }
.cw-hode-avatar img { width: 20px; height: 20px; filter: invert(1); }
.cw-hode-tekst { display: grid; gap: 1px; min-width: 0; }
.cw-hode-tekst strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; }
.cw-prikk { width: 8px; height: 8px; border-radius: 50%; background: #1FA855; flex: none; }
.cw-hode-tekst span { font-size: 12.5px; color: #686D73; }

/* ── KI-assistenten ── */
.cw-ki { background: #fff; }
#cw-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 18px 10px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.cw-msg { display: flex; flex-direction: column; animation: cwInn .24s ease; }
.cw-bubble-msg { max-width: 88%; padding: 10px 14px; border-radius: 4px 16px 16px 16px; background: #F1F2F4; font-size: 14.5px; line-height: 1.55; text-wrap: pretty; }
.cw-bubble-msg a { color: inherit; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.cw-msg.cw-user { align-items: flex-end; }
.cw-msg.cw-user .cw-bubble-msg { background: #0B0B0B; color: #fff; border-radius: 16px 4px 16px 16px; }
.cw-typing { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; }
.cw-dot { width: 6px; height: 6px; border-radius: 50%; background: #8A8F95; animation: cwDot 1.1s infinite ease-in-out; }
.cw-dot:nth-child(2) { animation-delay: .15s; } .cw-dot:nth-child(3) { animation-delay: .3s; }
@keyframes cwDot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
#cw-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 18px 10px; }
#cw-buttons:empty { display: none; }
.cw-btn { padding: 9px 14px; border: 1px solid rgba(11,11,11,.14); border-radius: 999px; background: #fff; color: inherit; font: inherit; font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s; }
.cw-btn:hover { border-color: #0B0B0B; background: #F7F7F8; }
.cw-menneske { display: flex; align-items: center; gap: 10px; margin: 0 14px 8px; padding: 9px 12px; border: 0; border-radius: 12px; background: #F4F5F7; color: #3F4449; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.cw-menneske[hidden] { display: none; }
.cw-menneske:hover { background: #ECEEF1; color: #0B0B0B; }
.cw-menneske .cw-ansikter img { border-color: #F4F5F7; }
#cw-inputrow { display: flex; align-items: center; gap: 8px; margin: 0 14px; padding: 6px 6px 6px 16px; border: 1px solid rgba(11,11,11,.14); border-radius: 999px; transition: border-color .15s, box-shadow .15s; }
#cw-inputrow:focus-within { border-color: #0B0B0B; box-shadow: 0 0 0 3px rgba(127,232,245,.45); }
#cw-input { flex: 1; min-width: 0; padding: 8px 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 16px; outline: none; }
#cw-input::placeholder { color: #8A8F95; }
#cw-send { width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: #0B0B0B; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s, transform .12s; }
#cw-send svg { width: 16px; height: 16px; stroke-width: 2.2; }
#cw-send:hover { background: var(--farge, #7FE8F5); color: #0B0B0B; }
#cw-send:active { transform: scale(.95); }
#cw-send:disabled { opacity: .4; cursor: default; }
.cw-fot { margin: 8px 14px 10px; font-size: 11.5px; color: #8A8F95; text-align: center; }
.cw-fot a { color: inherit; }

/* ── Melding ── */
.cw-melding { background: #fff; overflow-y: auto; }
.cw-skjema { display: grid; gap: 12px; padding: 18px 18px 6px; }
.cw-skjema label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: #3F4449; }
.cw-skjema label em { font-style: normal; font-weight: 400; color: #8A8F95; }
.cw-skjema input:not([type="checkbox"]), .cw-skjema textarea {
  width: 100%; box-sizing: border-box; padding: 11px 13px; border: 1px solid rgba(11,11,11,.14); border-radius: 12px; background: #fff;
  color: #0B0B0B; font: inherit; font-size: 16px; font-weight: 400; outline: none; transition: border-color .15s, box-shadow .15s; resize: vertical;
}
.cw-skjema input:focus, .cw-skjema textarea:focus { border-color: #0B0B0B; box-shadow: 0 0 0 3px rgba(127,232,245,.45); }
.cw-skjema .cw-legg-ved { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.cw-skjema .cw-legg-ved[hidden] { display: none; }
.cw-gjerde { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.cw-feil { margin: 0; padding: 10px 12px; border-radius: 10px; background: #FFF1F0; color: #8A1C12; font-size: 13.5px; }
.cw-feil a { color: inherit; }
.cw-send-melding { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 0; border-radius: 999px; background: #0B0B0B; color: #fff; font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .2s, color .2s; }
.cw-send-melding svg { width: 16px; height: 16px; }
.cw-send-melding:hover { background: var(--farge, #7FE8F5); color: #0B0B0B; }
.cw-send-melding.sender { opacity: .6; cursor: progress; }
.cw-takk { padding: 34px 22px; text-align: center; display: grid; justify-items: center; gap: 8px; }
.cw-takk[hidden] { display: none; }
.cw-takk .cw-ansikter-stor img { border-color: #fff; }
.cw-takk h3 { margin: 12px 0 0; font-size: 21px; font-weight: 500; letter-spacing: -.02em; }
.cw-takk p { margin: 0 0 14px; color: #686D73; font-size: 14.5px; }
.cw-kort-enkel { box-shadow: 0 0 0 1px rgba(11,11,11,.08); }

/* ── Faner ── */
.cw-faner { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(11,11,11,.08); background: #fff; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.cw-faner button { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border: 0; border-radius: 12px; background: none; color: #8A8F95; font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; transition: color .15s, background .15s; }
.cw-faner button svg { width: 21px; height: 21px; }
.cw-faner button img { width: 21px; height: 21px; opacity: .5; transition: opacity .15s; }
.cw-faner button:hover { background: #F4F5F7; color: #3F4449; }
.cw-faner button[aria-current="page"] { color: #0B0B0B; }
.cw-faner button[aria-current="page"] img { opacity: 1; }
#cw-window :focus-visible { outline: 2px solid #0B0B0B; outline-offset: 2px; }
.cw-topp :focus-visible { outline-color: #fff; }

/* ── Mobil: hele skjermen ── */
@media (max-width: 480px) {
  #cw-window { inset: 0; width: 100%; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; transform-origin: center bottom; }
  #cw-bubble { right: 12px; bottom: 12px; width: 48px; height: 48px; }
  #cw-window.open ~ #cw-bubble { opacity: 0; pointer-events: none; }
  .cw-topp { padding-top: calc(16px + env(safe-area-inset-top)); }
  .cw-hode { padding-top: calc(10px + env(safe-area-inset-top)); }
  .cw-lukk, .cw-tilbake { width: 44px; height: 44px; }
  html.cw-open, html.cw-open body { overflow: hidden; }
  html.cw-open .kd-nav, html.cw-open .hero-nav { opacity: 0; visibility: hidden; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) { #cw-window, .cw-view, .cw-msg { transition: none; animation: none !important; } }
#cw-window input:focus-visible, #cw-window textarea:focus-visible { outline: none; }

#cw-bubble { transition: transform .45s cubic-bezier(.22, 1, .36, 1), opacity .3s ease, box-shadow .18s ease; }

/* 23. nov 2026 (Andreas: «chatboten dukker opp over menyen og Book møte i navbar»): på lavere skjermer gikk vinduet
   helt opp under menylinja. Nå slutter det alltid under den, og chatten skjules mens menyen er åpen. */
@media (min-width: 641px) {
  #cw-window { height: min(660px, calc(100vh - 92px - 118px)); height: min(660px, calc(100svh - 92px - 118px)); }
}
body.menu-open #cw-bubble, body.menu-open #cw-window { opacity: 0 !important; visibility: hidden; pointer-events: none !important; }
