:root {
  --bg: #fff8f0;
  --surface: #ffffff;
  --surface-2: #fdf1e4;
  --ink: #2b2d42;
  --ink-soft: #5c5f77;
  --line: #efdfcc;
  --teal: #2a9d8f;
  --teal-soft: #d7f0ec;
  --teal-ink: #1d6f65;
  --coral: #f2704e;
  --coral-soft: #fde3da;
  --coral-ink: #b4462a;
  --sun: #f4b942;
  --sun-soft: #fdf0cf;
  --good: #2e9e5b;
  --good-soft: #dcf3e5;
  --bad: #d4513b;
  --bad-soft: #fbe2dc;
  --shadow: 0 2px 0 rgba(43, 45, 66, .06), 0 8px 24px rgba(43, 45, 66, .07);
  --radius: 20px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1b22;
    --surface: #27252e;
    --surface-2: #302d38;
    --ink: #f4efe9;
    --ink-soft: #b9b3c4;
    --line: #3b3844;
    --teal: #4cc1b1;
    --teal-soft: #1f3a37;
    --teal-ink: #8fe0d4;
    --coral: #ff8a68;
    --coral-soft: #44291f;
    --coral-ink: #ffb39c;
    --sun: #f6c661;
    --sun-soft: #3d3420;
    --good: #5ccb88;
    --good-soft: #1f3a2a;
    --bad: #ff7d66;
    --bad-soft: #44231d;
    --shadow: 0 2px 0 rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100dvh;
}
main { outline: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; background: url(/favicon.svg) center/contain no-repeat; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 16px;
}
.tabs a[aria-current="page"] { background: var(--teal-soft); color: var(--teal-ink); }
.stats { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 800; font-size: 15px; white-space: nowrap;
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand span:last-child { display: none; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .tabs a { white-space: nowrap; padding: 6px 12px; }
  .speech .kvik, .greeting .kvik { width: 60px; height: 60px; }
  .stats { margin-left: auto; }
}

/* ---------- Layout ---------- */
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 80px; }
.narrow { max-width: 640px; }
h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.15; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 24px; margin: 0 0 4px; }
h3 { font-size: 19px; margin: 0 0 4px; }
.muted { color: var(--ink-soft); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 24px; border-radius: 16px; border: 0;
  background: var(--teal); color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 0 var(--teal-ink); transition: transform .08s, box-shadow .08s;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--teal-ink); }
.btn[disabled] { background: var(--line); color: var(--ink-soft); box-shadow: none; cursor: not-allowed; }
.btn.coral { background: var(--coral); box-shadow: 0 4px 0 var(--coral-ink); }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; border: 2px solid var(--line); }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; padding: 8px; font-size: 16px; }

/* ---------- Kvik ---------- */
.kvik { width: 84px; height: 84px; flex: none; }
.kvik.big { width: 150px; height: 150px; }
.kvik .eye { animation: blink 5s infinite; transform-origin: center; transform-box: fill-box; }
.kvik .antenna-ball { animation: glow 2.4s ease-in-out infinite; }
.kvik.happy .body-group { animation: hop .6s ease; }
.kvik.think .antenna-ball { animation: glow .5s ease-in-out infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes glow { 50% { opacity: .55; } }
@keyframes hop { 40% { transform: translateY(-8px); } }

.speech { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.bubble {
  position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 20px 20px 20px 6px;
  padding: 14px 18px; flex: 1;
}
.bubble h2 { margin-bottom: 6px; }

/* ---------- Velkomst ---------- */
.hero { text-align: center; padding-top: 32px; }
.hero .kvik { margin: 0 auto 8px; display: block; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 20px 0; }
.choice {
  text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow);
}
.choice[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }
.choice .emoji { font-size: 34px; line-height: 1; }
.choice b { display: block; font-size: 19px; }
.field { display: block; margin: 14px 0; text-align: left; }
.field span { display: block; font-weight: 700; margin-bottom: 6px; }
.input, .textarea {
  width: 100%; border: 2px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px; min-height: 52px;
}
.input:focus, .textarea:focus { border-color: var(--teal); outline: none; }
.textarea { min-height: 120px; resize: vertical; }
.team-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.team-btn { padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; }
.team-btn[aria-pressed="true"] { border-color: var(--coral); background: var(--coral-soft); }
.hint { font-size: 15px; color: var(--ink-soft); }
.error { color: var(--bad); font-weight: 700; font-size: 16px; }

/* ---------- Kort ---------- */
.greeting { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.level-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 28px; }
.level-badge {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 26px;
  background: var(--sun-soft); color: var(--ink); border: 3px solid var(--sun);
}
.bar { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sun); border-radius: 999px; transition: width .6s ease; }
.bar.teal > i { background: var(--teal); }
.bar.coral > i { background: var(--coral); }

.track { margin-bottom: 36px; }
.track-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.track-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.track-dot.teal { background: var(--teal); }
.track-dot.coral { background: var(--coral); }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lesson {
  display: flex; flex-direction: column; gap: 6px; text-align: left; text-decoration: none; color: inherit;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform .12s;
}
a.lesson:hover { transform: translateY(-2px); border-color: var(--teal); }
a.lesson.coral:hover { border-color: var(--coral); }
.choice .muted { display: block; font-size: 16px; }
.lesson .icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; background: var(--teal-soft);
}
.lesson.coral .icon { background: var(--coral-soft); }
.lesson.soon { opacity: .6; box-shadow: none; }
.lesson .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; font-size: 15px; color: var(--ink-soft); font-weight: 700; }
.stars { letter-spacing: 2px; color: var(--sun); font-size: 18px; }
.stars .off { color: var(--line); }
.pill { font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); }
.pill.done { background: var(--good-soft); color: var(--good); }

/* ---------- Bane ---------- */
.player { max-width: 680px; margin: 0 auto; padding: 16px 16px 140px; min-height: 100dvh; display: flex; flex-direction: column; }
.player-top { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.close { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 22px; color: var(--ink-soft); flex: none; }
.player-top .bar { flex: 1; }
.player-top .bar > i { background: var(--good); }
.step { animation: slidein .35s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.question { font-size: 23px; font-weight: 800; margin: 0 0 18px; line-height: 1.3; }
.options { display: grid; gap: 10px; }
.option {
  text-align: left; padding: 16px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 600; box-shadow: 0 3px 0 var(--line); min-height: 56px;
}
.option:hover:not([disabled]) { border-color: var(--teal); }
.option.right { border-color: var(--good); background: var(--good-soft); box-shadow: 0 3px 0 var(--good); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); }
.option[disabled] { cursor: default; }
.option.dim { opacity: .5; }

.sentence { font-size: 26px; font-weight: 800; text-align: center; padding: 26px 16px; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 18px; }
.prob { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; margin: 8px 0; font-weight: 700; }
.prob .bar > i { background: var(--teal); }
.prob.picked { color: var(--teal-ink); }

.sort-card {
  font-size: 22px; font-weight: 800; text-align: center; padding: 34px 20px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); margin-bottom: 16px; min-height: 140px;
  display: grid; place-items: center; animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.sort-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sort-count { text-align: center; color: var(--ink-soft); font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.btn.no { background: var(--bad); box-shadow: 0 4px 0 color-mix(in srgb, var(--bad) 60%, #000); }
.btn.yes { background: var(--good); box-shadow: 0 4px 0 color-mix(in srgb, var(--good) 60%, #000); }

.original { background: var(--sun-soft); border-left: 5px solid var(--sun); padding: 14px 16px; border-radius: 12px; margin-bottom: 14px; font-style: italic; }
.feedback-card { margin-top: 14px; padding: 16px; border-radius: 16px; background: var(--surface-2); animation: pop .3s ease; }
.feedback-card .stars { font-size: 28px; }

.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 18px; white-space: pre-wrap; animation: pop .25s ease; }
.msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 2px solid var(--line); border-bottom-left-radius: 6px; }
.msg.typing { color: var(--ink-soft); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.suggestion { padding: 8px 14px; border-radius: 999px; border: 2px solid var(--teal); background: transparent; color: var(--teal-ink); font-weight: 700; font-size: 16px; }
.chat-form { display: flex; gap: 8px; }
.chat-form .input { flex: 1; }
.chat-form .btn { min-height: 52px; padding: 0 18px; }
.demo-note { font-size: 14px; color: var(--ink-soft); margin-top: 8px; }

.remember { padding-left: 22px; margin: 6px 0 0; }
.remember li { margin-bottom: 8px; }

/* Feedback-skuffe i bunden */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 2px solid var(--line);
}
.dock-inner { max-width: 680px; margin: 0 auto; display: flex; gap: 14px; align-items: center; justify-content: space-between; }
.dock.good { background: var(--good-soft); border-color: var(--good); }
.dock.bad { background: var(--bad-soft); border-color: var(--bad); }
.dock .verdict { font-weight: 800; font-size: 19px; }
.dock.good .verdict { color: var(--good); }
.dock.bad .verdict { color: var(--bad); }
.dock .why { font-size: 16px; margin-top: 2px; }
.dock .btn { flex: none; min-width: 140px; }
@media (max-width: 560px) {
  .dock-inner { flex-direction: column; align-items: stretch; }
  .dock .btn { width: 100%; }
}

/* ---------- Færdig ---------- */
.finish { text-align: center; padding-top: 28px; }
.finish .stars { font-size: 52px; display: block; margin: 8px 0; }
.finish .stars span { display: inline-block; animation: starpop .5s ease backwards; }
.finish .stars span:nth-child(2) { animation-delay: .2s; }
.finish .stars span:nth-child(3) { animation-delay: .4s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.3); } }
.reward-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.reward { background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 14px 18px; min-width: 130px; }
.reward b { display: block; font-size: 26px; }
.new-badge { background: var(--sun-soft); border-color: var(--sun); }

/* ---------- Profil ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 18px 12px; }
.badge .b-icon { font-size: 40px; display: block; margin-bottom: 4px; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge small { display: block; color: var(--ink-soft); font-size: 14px; line-height: 1.3; margin-top: 4px; }

/* ---------- Leder ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 18px 0 24px; }
.kpi { padding: 16px 18px; }
.kpi b { display: block; font-size: 32px; line-height: 1.1; }
.kpi span { color: var(--ink-soft); font-weight: 700; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.team-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; margin: 14px 0; }
.team-row .rank { font-weight: 900; font-size: 20px; text-align: center; }
.team-row .name { font-weight: 800; display: flex; justify-content: space-between; margin-bottom: 4px; }
.team-row .val { font-weight: 800; font-size: 15px; color: var(--ink-soft); }
.you { background: var(--sun-soft); border-radius: 6px; padding: 0 6px; font-size: 13px; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-soft); font-size: 14px; }
td.ok { color: var(--good); font-weight: 900; }
td.no { color: var(--line); }
.notice { background: var(--sun-soft); border: 1px solid var(--sun); border-radius: 14px; padding: 12px 16px; font-size: 16px; margin-bottom: 18px; }
.section-gap { margin-top: 16px; }

/* ---------- Toasts & konfetti ---------- */
.toast-wrap { position: fixed; top: 76px; left: 0; right: 0; display: grid; justify-items: center; gap: 8px; z-index: 30; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800; box-shadow: var(--shadow);
  animation: toast 3.2s ease forwards; max-width: calc(100% - 32px);
}
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

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