/* Självintervjun: chatt till vänster, utkastet till höger. */

body.iv {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background:
    radial-gradient(60vmax 50vmax at 85% -10%, rgba(91, 192, 235, 0.16), transparent 60%),
    radial-gradient(50vmax 40vmax at 0% 110%, rgba(91, 110, 235, 0.12), transparent 60%),
    var(--bg);
}

.iv-head {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 64px;
  padding-inline: clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 20, 40, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.iv-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  max-width: 420px;
  margin-inline: auto;
  color: var(--mut);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.iv-bar {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--line-2);
  overflow: hidden;
}
.iv-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ice), var(--ice-2));
  box-shadow: 0 0 12px var(--ice);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform 0.8s var(--ease);
}
.iv-exit {
  color: var(--mut);
  font-size: 0.9rem;
  text-decoration: none;
}
.iv-exit:hover {
  color: var(--ink);
}
.iv-tabs {
  display: none;
}

.iv-main {
  display: grid;
  grid-template-columns: minmax(340px, 0.72fr) minmax(0, 1.28fr);
  min-height: 0;
}

.iv-main > section {
  padding: 0;
}

/* Chatten */
.iv-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(7, 20, 40, 0.5);
}
.iv-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.iv-log > :first-child {
  margin-top: auto;
}
.msg {
  display: flex;
  gap: 0.7rem;
  align-items: flex-end;
  max-width: 92%;
  animation: bubble-in 0.5s var(--ease) both;
}
.msg .who {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(91, 192, 235, 0.5);
  background: rgba(91, 192, 235, 0.12);
  color: var(--ice);
}
.msg .who svg {
  width: 12px;
  height: 12px;
}
.msg p {
  padding: 0.8rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.02rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.me {
  align-self: flex-end;
}
.msg.me p {
  border-color: transparent;
  border-radius: 18px 18px 6px 18px;
  background: var(--ice);
  color: var(--ice-ink);
  font-weight: 500;
}
.typing p {
  display: flex;
  gap: 5px;
  padding: 1.05rem 1.1rem;
}
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mut);
  animation: blink 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes blink {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: none;
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Svarsrutan */
.iv-composer {
  display: grid;
  gap: 0.7rem;
  padding: 0.9rem clamp(1.2rem, 3vw, 2rem) 0.4rem;
  border-top: 1px solid var(--line);
  background: rgba(7, 20, 40, 0.75);
}
.iv-composer[hidden] {
  display: none;
}
.iv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.iv-chips[hidden] {
  display: none;
}
.chip {
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.3s var(--ease);
}
.chip:hover {
  border-color: var(--ice);
  transform: translateY(-1px);
}
.chip[aria-pressed="true"] {
  background: var(--ice);
  border-color: var(--ice);
  color: var(--ice-ink);
}
.iv-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.35rem 0.35rem 0.35rem 0.4rem;
  border: 1px solid var(--line-2);
  border-radius: 26px;
  background: rgba(0, 0, 0, 0.3);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.iv-row:focus-within {
  border-color: var(--ice);
  box-shadow: 0 0 0 4px rgba(91, 192, 235, 0.16);
}
.iv-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 0.6rem 0.7rem;
  border: 0;
  background: none;
  box-shadow: none;
  resize: none;
  font-size: 1.02rem;
  line-height: 1.45;
}
.iv-row textarea:focus {
  box-shadow: none;
  background: none;
}
.iv-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--ice);
  color: var(--ice-ink);
  cursor: pointer;
  transition: transform 0.3s var(--ease), background-color 0.2s, opacity 0.2s;
}
.iv-send:hover {
  transform: translateY(-2px);
  background: var(--ice-2);
}
.iv-send:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}
.iv-send svg {
  width: 20px;
  height: 20px;
}
.iv-hint {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  min-height: 1.4rem;
  color: var(--dim);
  font-size: 0.82rem;
}
.iv-hint .bad {
  color: var(--danger);
}
.iv-hint button,
.textlink {
  padding: 0;
  border: 0;
  background: none;
  color: var(--mut);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.iv-hint button:hover,
.textlink:hover {
  color: var(--ink);
}
.iv-hint button[hidden] {
  display: none;
}
.iv-legal {
  padding: 0 clamp(1.2rem, 3vw, 2rem) 0.8rem;
  background: rgba(7, 20, 40, 0.75);
  color: var(--dim);
  font-size: 0.75rem;
}

/* Kort i chatten: kontaktuppgifter och resultat */
.card {
  display: grid;
  gap: 1rem;
  padding: 1.3rem;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  animation: bubble-in 0.6s var(--ease) both;
}
.card form {
  gap: 0.8rem;
}
.card .fine {
  margin: 0;
  font-size: 0.8rem;
}
.card .btn {
  width: 100%;
}
.card .textlink {
  justify-self: center;
  font-size: 0.9rem;
}
.result h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
}
.result > p {
  color: var(--mut);
}
.rec {
  display: grid;
  gap: 0.3rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(91, 192, 235, 0.45);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(91, 192, 235, 0.14), rgba(91, 192, 235, 0.04));
}
.rec small {
  color: var(--ice);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.rec b {
  font: 500 1.7rem/1.1 var(--serif);
}
.rec b span {
  margin-left: 0.5rem;
  color: var(--mut);
  font: 400 0.95rem var(--sans);
}
.rec p {
  color: var(--mut);
  font-size: 0.95rem;
}
.actions {
  display: grid;
  gap: 0.6rem;
}
.building {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--mut);
  font-size: 0.95rem;
}
.building::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--ice);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* Utkastet */
.iv-preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.iv-ptop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1.2rem, 3vw, 2.4rem);
}
.iv-ptop .eyebrow {
  letter-spacing: 0.14em;
}
.iv-device {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.iv-device button {
  min-height: 34px;
  padding: 0.3rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--mut);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.iv-device button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}
.iv-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.4rem clamp(1.2rem, 3vw, 2.4rem) 2.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.iv-stage .pv-window {
  position: relative;
  max-width: 980px;
  margin-inline: auto;
  transition: max-width 0.7s var(--ease);
}
.iv-stage.mobile .pv-window {
  max-width: 390px;
  border-radius: 28px;
}
/* Ljussvep över utkastet när den färdiga texten skrivs */
.iv-stage .pv-window::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(165, 225, 250, 0.35) 50%, transparent 70%);
  transform: translateX(-100%);
  pointer-events: none;
}
.iv-stage.polish .pv-window::after {
  animation: sweep 1.4s ease-in-out infinite;
}
@keyframes sweep {
  to {
    transform: translateX(100%);
  }
}
.iv-stage.done .pv-window {
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(91, 192, 235, 0.5), 0 0 60px rgba(91, 192, 235, 0.18);
}

/* Checklistan */
.iv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.4rem clamp(1.2rem, 3vw, 2.4rem) 2.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.iv-list[hidden] {
  display: none;
}
.iv-list-note {
  max-width: 44rem;
  margin: 0 auto 1rem;
  color: var(--mut);
  font-size: 0.92rem;
}
.iv-list dl {
  display: grid;
  gap: 1px;
  max-width: 44rem;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
  overflow: hidden;
}
.iv-list .f {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.8rem;
  padding: 0.7rem 1rem;
  background: var(--bg-2);
}
.iv-list .f i {
  grid-row: span 2;
  width: 9px;
  height: 9px;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
.iv-list .f.has i {
  background: #6ee7a8;
}
.iv-list .f.gap i {
  background: #ffd98a;
}
.iv-list dt {
  color: var(--mut);
  font-size: 0.8rem;
}
.iv-list .f.req dt::after {
  content: " *";
  color: var(--ice);
}
.iv-list dd {
  margin: 0;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.iv-list dd.none {
  color: var(--dim);
}
#issue-box {
  max-width: 44rem;
  margin: 1.4rem auto 0;
}
#issue-box h3 {
  font: 600 0.95rem/1.3 var(--sans);
  letter-spacing: 0;
}
#issue-box ul {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}
#issue-box li {
  padding-left: 0.8rem;
  border-left: 2px solid #ffd98a;
  color: var(--mut);
}

/* Startkortet och sammanfattningen */
.start h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
}
.start ul {
  display: grid;
  gap: 0.55rem;
  padding: 0;
  list-style: none;
  color: var(--mut);
  font-size: 0.97rem;
}
.start li {
  position: relative;
  padding-left: 1.7rem;
}
.start li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.4em;
  width: 0.8rem;
  height: 0.42rem;
  border-left: 2px solid var(--ice);
  border-bottom: 2px solid var(--ice);
  transform: rotate(-45deg);
}
.consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: start;
  padding: 1rem;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--mut);
  font-size: 0.88rem;
  font-weight: 400;
  cursor: pointer;
}
.consent input {
  width: 22px;
  height: 22px;
  min-height: 0;
  margin-top: 0.1rem;
  padding: 0;
  accent-color: var(--ice);
}
.consent b {
  color: var(--ink);
  font-weight: 600;
}
.sum dl {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.92rem;
}
.sum dt {
  color: var(--mut);
  font-size: 0.78rem;
}
.sum dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.note-line {
  align-self: center;
  max-width: 100%;
  padding: 0.55rem 1rem;
  border: 1px dashed rgba(91, 192, 235, 0.5);
  border-radius: 999px;
  color: var(--ice-2);
  font-size: 0.88rem;
  text-align: center;
  animation: bubble-in 0.6s var(--ease) both;
}

.iv-noscript {
  position: fixed;
  inset: 64px 0 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
  text-align: center;
}

/* Mobil: en vy i taget, växla med flikarna */
@media (max-width: 860px) {
  body.iv {
    grid-template-rows: auto auto 1fr;
  }
  .iv-head {
    height: 56px;
    gap: 0.8rem;
  }
  .iv-progress span {
    display: none;
  }
  .iv-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 20, 40, 0.8);
  }
  .iv-tabs button {
    position: relative;
    min-height: 44px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--mut);
    font-weight: 600;
    cursor: pointer;
  }
  .iv-tabs button[aria-selected="true"] {
    color: var(--ink);
    border-bottom-color: var(--ice);
  }
  .iv-tabs .dot {
    display: none;
    width: 8px;
    height: 8px;
    margin-left: 0.5rem;
    border-radius: 50%;
    background: var(--ice);
    box-shadow: 0 0 0 0 rgba(91, 192, 235, 0.7);
    animation: ping 1.4s ease-out infinite;
  }
  .iv-tabs .dot.on {
    display: inline-block;
  }
  @keyframes ping {
    to {
      box-shadow: 0 0 0 10px rgba(91, 192, 235, 0);
    }
  }
  .iv-main {
    grid-template-columns: 1fr;
  }
  body[data-view="chat"] .iv-preview,
  body[data-view="preview"] .iv-chat,
  body[data-view="list"] .iv-chat {
    display: none;
  }
  .iv-tabs {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .iv-ptop {
    display: none;
  }
  .iv-stage,
  .iv-list {
    padding-top: 1.2rem;
  }
  .iv-chat {
    border-right: 0;
  }
  .iv-device {
    display: none;
  }
  .msg p {
    font-size: 1rem;
  }
}
