:root {
  --bg: #FFFFFF;
  --ink: #000000;
  --muted: #5F5F5F;
  --line: #CCCCCC;
  --accent: #FBCF7C;          /* knapp, valgt-tilstand – overstyres per hus */
  --accent-ink: #000000;
  --accent-soft: color-mix(in srgb, var(--accent) 28%, #FFFFFF);
  --accent-strong: color-mix(in srgb, var(--accent) 80%, #B07400);
  --head: "Ubuntu", system-ui, sans-serif;
  --body: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: 30px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1 {
  margin: 0;
  font: 700 32px/1.2 var(--head);
  letter-spacing: -0.08em;
  word-spacing: 0.06em;
}

/* ── Rammeverk ─────────────────────────── */
.app {
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar { padding: 22px 20px 0; }
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  line-height: 1;
}
.house { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { font-variant-numeric: tabular-nums; }
.progress {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 10px;
}
.progress i {
  width: 25px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background .3s;
}
.progress i.on { background: var(--ink); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad);
  outline: none;
}

.step { flex: 1; display: flex; flex-direction: column; animation: stepIn .35s cubic-bezier(.2,.8,.2,1) both; }
.step.back { animation-name: stepBack; }
@keyframes stepIn   { from { opacity: 0; transform: translateX(18px); } }
@keyframes stepBack { from { opacity: 0; transform: translateX(-18px); } }

.footer {
  position: sticky;
  bottom: 0;
  padding: 16px 38px max(40px, calc(env(safe-area-inset-bottom) + 16px));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.next {
  display: block;
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 500 18px var(--body);
  cursor: pointer;
  transition: transform .1s, filter .15s;
}
.next:hover { filter: brightness(.97); }
.next:active { transform: scale(.98); }
.next:disabled { opacity: .6; cursor: default; }
.next:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.form-error { margin: 0 0 12px; color: #B3261E; font-size: 14px; text-align: center; }

/* ── Steg 1: totalvurdering ─────────────── */
.step-rating { text-align: center; }
.step-rating .top {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0 24px;
}
.step-rating h1 { margin-bottom: 40px; }
.rating-q { margin: 0 0 18px; font: 500 20px/1.3 var(--body); }
.rating-q:empty { display: none; }
.stars-card {
  margin: 0 auto;
  padding: 18px 20px 14px;
  border-radius: 20px;
  transition: background-color .25s;
}
.stars { display: flex; justify-content: center; align-items: center; gap: 14px; height: 60px; }
.star { position: relative; cursor: pointer; }
.star input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.star img, .star svg { display: block; width: 46px; height: 46px; transition: filter .15s, width .2s, height .2s, transform .2s cubic-bezier(.3,1.6,.5,1); }
.star img { filter: grayscale(1) opacity(.22); -webkit-user-drag: none; }
.star.on img, .star.preview img { filter: none; }
.stars.previewing .star.on:not(.preview) img { filter: grayscale(1) opacity(.22); }
.star svg { fill: transparent; stroke: var(--line); stroke-width: 1.4; stroke-linejoin: round; }
.star.on svg, .star.preview svg { fill: var(--accent-strong); stroke: var(--accent-strong); }
.stars.previewing .star.on:not(.preview) svg { fill: transparent; stroke: var(--line); }
.star.picked img, .star.picked svg { width: 60px; height: 60px; }
.star:hover img, .star:hover svg { transform: scale(1.08); }
.star.pop img, .star.pop svg { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.star input:focus-visible + * { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 6px; }
.star.intro img, .star.intro svg { animation: pop .45s cubic-bezier(.3,1.6,.5,1) var(--d, 0ms) both; }
@keyframes pop { 50% { transform: scale(1.22); } }
.rating-text { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 0 0; min-height: 26px; font-size: 16px; }
.rating-text:not(.set) { color: var(--muted); }
.rating-text.set { font-weight: 500; font-size: 18px; }
.rating-text .check {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #FFF; font-size: 13px; font-weight: 700;
}
.rating-text .of { color: var(--muted); font-weight: 400; font-size: 16px; }
.rating-hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.more-intro { padding-bottom: 8px; }
.more-intro h2 { margin: 0 0 12px; font: 500 20px/1.3 var(--body); }
.more-intro p { margin: 0; font-size: 16px; line-height: 1.4; }

/* ── Spørsmålssteg ──────────────────────── */
.step-q { padding-top: 92px; padding-bottom: 24px; }
.step-q h1 { margin-bottom: 8px; }
.hint { margin: 0; color: var(--muted); font-size: 16px; }
.answers { margin-top: 36px; }

/* Emoji-skala */
.emoji-list { display: flex; flex-direction: column; gap: 8px; margin-left: -10px; margin-right: -10px; }
.emoji-opt { position: relative; }
.emoji-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.emoji-opt .row {
  display: flex;
  align-items: center;
  gap: 38px;
  padding: 8px 10px;
  border-radius: 18px;
  cursor: pointer;
  transition: background .15s;
}
.emoji-opt img {
  width: 57px; height: 57px;
  flex: none;
  transition: transform .25s cubic-bezier(.3,1.6,.5,1);
  -webkit-user-drag: none;
}
.emoji-opt .lbl { font: 500 18px var(--body); }
@media (hover: hover) { .emoji-opt:hover .row { background: #F6F6F6; } }
.emoji-opt input:checked + .row { background: var(--accent-soft); }
.emoji-opt input:checked + .row img { transform: scale(1.06); }
.emoji-opt input:focus-visible + .row { outline: 2px solid var(--ink); outline-offset: -2px; }

/* Avkrysning / ett valg */
.check-list { display: flex; flex-direction: column; gap: 4px; margin-left: -8px; }
.check-opt { position: relative; }
.check-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check-opt .row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 8px;
  border-radius: 10px;
  font: 400 22px/1.3 var(--body);
  cursor: pointer;
}
.box {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: #FFF;
  transition: border-color .15s, background .15s;
}
.check-opt.radio .box { border-radius: 50%; }
.box svg { width: 14px; height: 14px; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .2s cubic-bezier(.3,1.6,.5,1); }
.check-opt input:checked + .row .box { border-color: var(--accent-strong); background: #FFFBF0; }
.check-opt input:checked + .row .box svg { opacity: 1; transform: none; }
.check-opt.radio .box i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); opacity: 0; transform: scale(.4); transition: opacity .15s, transform .2s; }
.check-opt.radio input:checked + .row .box i { opacity: 1; transform: none; }
.check-opt input:focus-visible + .row { outline: 2px solid var(--ink); outline-offset: -2px; }
@media (hover: hover) { .check-opt:hover .row { background: #F6F6F6; } }

/* Fritekst */
textarea {
  display: block;
  width: 100%;
  height: 176px;
  padding: 22px 22px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: #FFF;
  color: var(--ink);
  font: 16px/1.45 var(--body);
  resize: none;
}
textarea::placeholder { color: var(--ink); }
textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--accent); }

/* 0–10 */
.nps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.nps label { position: relative; }
.nps input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.nps span {
  display: grid; place-items: center;
  height: 52px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  font: 500 18px var(--body);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.nps input:checked + span { background: var(--accent); border-color: var(--accent-strong); }
.nps input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.nps-ends { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 14px; }

/* ── Lagringsstatus ─────────────────────── */
.save-status {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translate(-50%, 6px);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #F2F2F2;
  color: var(--muted);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.save-status.show { opacity: 1; transform: translate(-50%, 0); }
.save-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #3BA55C; }
.save-status.pending::before { background: #E5A93B; }
.save-status.error::before { background: #D9534F; }

/* ── Takk ───────────────────────────────── */
.thanks {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 460px;
  margin: 0 auto;
  overflow: hidden;
  outline: none;
}
.thanks-body { position: relative; padding: 262px 30px 40px; text-align: center; }
.thanks-emoji { font-size: 64px; line-height: 1; margin-bottom: 26px; animation: wave 1s .3s ease both; }
.thanks h1 { margin-bottom: 16px; }
.thanks p { margin: 0 auto; max-width: 22em; font-size: 18px; line-height: 1.4; }
.thanks-link { display: inline-block; margin-top: 28px; color: var(--ink); font-weight: 500; }
@keyframes wave { 0% { opacity: 0; transform: scale(.4) rotate(-12deg); } 60% { opacity: 1; transform: scale(1.1) rotate(6deg); } 100% { transform: none; } }

.confetti { position: absolute; inset: 0 0 auto; height: 240px; pointer-events: none; }
.confetti i {
  position: absolute;
  top: 0;
  display: block;
  animation: fall var(--d) cubic-bezier(.25,.6,.4,1) var(--delay) both;
}
@keyframes fall {
  from { transform: translate(var(--x0), -60px) rotate(0deg); opacity: 0; }
  15%  { opacity: 1; }
  to   { transform: translate(0, var(--y)) rotate(var(--r)); opacity: 1; }
}

/* Lavere skjermer (mobil med nettleserlinjer): krymp luft og emoji så alt får plass uten scrolling */
@media (max-height: 800px) {
  h1 { font-size: 30px; }
  .step-q { padding-top: 40px; padding-bottom: 12px; }
  .answers { margin-top: 20px; }
  .emoji-list { gap: 2px; }
  .emoji-opt .row { padding: 5px 10px; gap: 32px; }
  .emoji-opt img { width: 50px; height: 50px; }
  .check-list { gap: 0; }
  .check-opt .row { font-size: 20px; padding: 5px 8px; }
  .step-rating .top { padding: 16px 0; }
  .step-rating h1 { margin-bottom: 28px; }
  .footer { padding-top: 12px; padding-bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px)); }
  .thanks-body { padding-top: 200px; }
}
@media (max-height: 600px) {
  h1 { font-size: 26px; }
  .rating-hint { display: none; }
  .stars-card { padding: 12px 16px 10px; }
  .topbar { padding-top: 16px; }
  .step-q { padding-top: 16px; }
  .answers { margin-top: 14px; }
  .emoji-list { gap: 0; }
  .emoji-opt .row { padding: 2px 10px; }
  .emoji-opt img { width: 40px; height: 40px; }
  .check-opt .row { font-size: 18px; padding: 3px 8px; }
  textarea { height: 140px; }
  .next { height: 52px; }
  .thanks-body { padding-top: 150px; }
}

@media (min-width: 600px) {
  .app { margin-top: 4vh; margin-bottom: 4vh; min-height: min(880px, 92vh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition: none !important; }
}
