/* V3: chat-bobla nede i høyre hjørne (som V2), i V1-utseendet. */
.chat-knapp {
  position: fixed; right: 24px; bottom: 24px; z-index: 46;
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--aksent); color: #fff; display: grid; place-items: center;
  box-shadow: var(--skygge-hoy);
}
.chat-knapp:hover { background: var(--aksent-mork); }
.chat-knapp .ikon { width: 24px; height: 24px; grid-area: 1 / 1; }
.chat-knapp .ikon + .ikon { display: none; }
.chat-knapp.apen .ikon:first-child { display: none; }
.chat-knapp.apen .ikon + .ikon { display: block; }
.chat-knapp .teller { position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--rod); color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--flate); }
.chat-knapp .teller[hidden] { display: none; }
body.mek .chat-knapp { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; width: 50px; height: 50px; }

.chat-panel {
  position: fixed; right: 24px; bottom: 92px; z-index: 45;
  width: 400px; max-width: calc(100vw - 32px); height: min(640px, calc(100vh - 130px)); height: min(640px, calc(100dvh - 130px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--flate); border: 1px solid var(--kant); border-radius: 16px; box-shadow: var(--skygge-hoy);
  animation: chat-inn .18s ease-out;
}
.chat-panel[hidden] { display: none; }
body.mek .chat-panel { right: 16px; bottom: calc(136px + env(safe-area-inset-bottom)); height: min(560px, calc(100vh - 200px)); }
@keyframes chat-inn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 520px) { .chat-panel { right: 8px; left: 8px; width: auto; max-width: none; } }

.chat-visning { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-topp { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .6rem; }
.chat-topp h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.chat-topp-navn { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chat-topp-navn b, .chat-under { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-under { font-size: .82rem; color: var(--tekst-3); }
.chat-rund { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: var(--flate-2); color: var(--tekst); cursor: pointer; }
.chat-rund:hover { background: var(--kant); }
.chat-rund .ikon { width: 18px; height: 18px; }
.chat-segment { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 0 1rem .4rem; padding: 3px; border-radius: 10px; background: var(--flate-2); }
.chat-segment button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--tekst-2); font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; }
.chat-segment .aktiv { background: var(--flate); color: var(--tekst); font-weight: 650; box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.chat-segment .teller, .chat-rad-side .teller { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--rod); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.chat-innhold { flex: 1; min-height: 0; overflow-y: auto; padding: 0 1rem .8rem; }
.chat-liste { list-style: none; margin: 0; padding: 0; }
.chat-rad { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem .2rem; border: 0; border-bottom: 1px solid var(--kant); background: none; color: var(--tekst); font: inherit; text-align: left; cursor: pointer; }
.chat-rad:hover { background: var(--flate-2); }
.chat-rad.ulest b { color: var(--aksent-mork); }
.chat-rad-tekst { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-rad-tekst b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-rad-side { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex: none; }
.chat-tid { font-size: .75rem; color: var(--tekst-3); white-space: nowrap; }
.chat-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--aksent-lys); color: var(--aksent-mork); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.chat-avatar.kunde { background: var(--blaa-bg); color: var(--blaa); }
.chat-avatar-ramme { position: relative; flex: none; }
.chat-prikk { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--kant-sterk); border: 2px solid var(--flate); }
.chat-prikk.inne { background: var(--gronn); }
.chat-tom { color: var(--tekst-3); text-align: center; padding: 2rem 1rem; font-size: .92rem; }
.chat-tråd { display: flex; flex-direction: column; gap: .5rem; padding-top: .4rem; }
.chat-boble { max-width: 82%; padding: .55rem .8rem; border-radius: 14px; font-size: .93rem; line-height: 1.4; overflow-wrap: anywhere; }
.chat-boble p { margin: 0; }
.chat-boble.meg { align-self: flex-end; background: var(--aksent); color: #fff; border-bottom-right-radius: 4px; }
.chat-boble.dem { align-self: flex-start; background: var(--flate-2); border: 1px solid var(--kant); border-bottom-left-radius: 4px; }
.chat-meta { display: block; font-size: .72rem; opacity: .75; margin-top: .2rem; }
.chat-skriv { display: flex; gap: .5rem; align-items: flex-end; padding: .6rem .8rem .8rem; border-top: 1px solid var(--kant); }
.chat-skriv textarea { flex: 1; min-height: 40px; max-height: 140px; resize: none; border-radius: 20px; padding: .55rem .9rem; }
.chat-send { background: var(--aksent); color: #fff; width: 40px; height: 40px; }
.chat-send:hover { background: var(--aksent-mork); }
@media print { .chat-knapp, .chat-panel { display: none !important; } }
