/* =========================================================================
   Region Norrbottens grafiska profil (Grafiska riktlinjer, 2022-11-07):
   primär #141f69, sekundär #00abe1, accent #fe6426, ljus bas = primär 10 %,
   typsnitt Source Sans Pro (här Source Sans 3, samma familj), logotyp högerställd.
   Textfärger följer riktlinjernas godkända kombinationer för text och bakgrund.
   ========================================================================= */

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* =========================================================================
   Tokens. Ljus bas som standard; marinblått tema för mörkt läge (D i
   presentatörsvyn) och för välkomst- och avslutningsbilden (.navy).
   ========================================================================= */

:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --raised: #ffffff;
  --tint: #e8e9f0;          /* ljus bas: primär 10 % */
  --heading: #141f69;
  --hl: #141f69;            /* andra rubrikfärgen */
  --ink: #0d0d0d;           /* svart 95 % */
  --ink-2: #44465a;
  --muted: #5f6380;
  --grid: #dcdeea;
  --axis: #b9bdd3;
  --track: #e8e9f0;
  --border: rgba(20, 31, 105, 0.16);
  --btn-bg: #141f69;
  --btn-ink: #ffffff;
  --btn-hover: #0c1452;
  --accent: #141f69;
  --accent-soft: #e8e9f0;
  --focus: #00abe1;
  --sun: #fe6426;
  --logo: #141f69;
  --bar: #141f69;
  --word-1: #5a6296;
  --word-2: #3a4380;
  --word-3: #141f69;
  --word-4: #141f69;
  --critical: #c62828;
  --warn-bg: #ffe8de;
  --warn-ink: #6b2507;
  --shadow: 0 1px 2px rgba(20, 31, 105, 0.06), 0 6px 20px rgba(20, 31, 105, 0.06);

  --radius: 12px;
  --font: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #141f69;
    --surface: #1a2675;
    --raised: #212d7e;
    --tint: rgba(255, 255, 255, 0.09);
    --heading: #ffffff;
    --hl: #00abe1;
    --ink: #ffffff;
    --ink-2: #d4d7ea;
    --muted: #a9aed0;
    --grid: rgba(255, 255, 255, 0.12);
    --axis: rgba(255, 255, 255, 0.3);
    --track: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.18);
    --btn-bg: #ffffff;
    --btn-ink: #141f69;
    --btn-hover: #e8e9f0;
    --accent: #00abe1;
    --accent-soft: rgba(0, 171, 225, 0.16);
    --logo: #ffffff;
    --bar: #00abe1;
    --word-1: #00abe1;
    --word-2: #00abe1;
    --word-3: #ffffff;
    --word-4: #ffffff;
    --critical: #ff9e94;
    --shadow: none;
  }
}

:root[data-theme="dark"],
.navy {
  color-scheme: dark;
  --page: #141f69;
  --surface: #1a2675;
  --raised: #212d7e;
  --tint: rgba(255, 255, 255, 0.09);
  --heading: #ffffff;
  --hl: #00abe1;
  --ink: #ffffff;
  --ink-2: #d4d7ea;
  --muted: #a9aed0;
  --grid: rgba(255, 255, 255, 0.12);
  --axis: rgba(255, 255, 255, 0.3);
  --track: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.18);
  --btn-bg: #ffffff;
  --btn-ink: #141f69;
  --btn-hover: #e8e9f0;
  --accent: #00abe1;
  --accent-soft: rgba(0, 171, 225, 0.16);
  --logo: #ffffff;
  --bar: #00abe1;
  --word-1: #00abe1;
  --word-2: #00abe1;
  --word-3: #ffffff;
  --word-4: #ffffff;
  --critical: #ff9e94;
  --shadow: none;
}

/* =========================================================================
   Bas
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}

h1, h2, p { margin: 0; }
/* Långa sammansatta ord avstavas eller bryts i stället för att sticka ut. */
h1, h2 { color: var(--heading); font-weight: 700; overflow-wrap: break-word; hyphens: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Logotypen: solen är alltid orange (i SVG-filen), resten följer temat. */
.logo { display: block; width: auto; aspect-ratio: 20 / 3; fill: var(--logo); flex: none; }

/* Det orange strecket – profilens grafiska element under rubriker. */
.streck::after {
  content: "";
  display: block;
  width: 2.2em;
  height: 0.14em;
  min-height: 3px;
  margin-top: 0.35em;
  border-radius: 2px;
  background: var(--sun);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0 1.1em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--raised);
  color: var(--heading);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--axis); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.btn-primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--critical); background: transparent; }
.btn-block { width: 100%; min-height: 56px; font-size: 1.15rem; }

.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
  font-size: 1.1rem; /* minst 16px så att iOS inte zoomar */
}
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 130px; resize: vertical; line-height: 1.4; }

.q-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em 0.9em;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill {
  padding: 0.1em 0.7em;
  border-radius: 999px;
  background: var(--tint);
  color: var(--heading);
  letter-spacing: 0.05em;
}
.pill-locked { display: inline-flex; align-items: center; gap: 0.45em; background: var(--btn-bg); color: var(--btn-ink); }
.pill-locked::before { content: ""; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--sun); }

.hint { color: var(--muted); font-size: 0.95rem; }
.error { color: var(--critical); font-size: 1rem; }
.error:empty { display: none; }

.offline-pill {
  display: none;
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.9rem;
  font-weight: 600;
}
body.offline .offline-pill { display: block; }

.key-form {
  display: grid;
  gap: 12px;
  width: min(420px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.key-form .logo { height: 24px; justify-self: end; margin-bottom: 12px; }
.key-form h1 { font-size: 1.6rem; margin-bottom: 4px; }
.key-form label { font-weight: 600; }

/* =========================================================================
   Deltagare (mobil)
   ========================================================================= */

.participant { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* Friyta runt logotypen: minst logotypens höjd (22 px) åt alla håll. */
.p-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 22px 22px 16px;
  padding-top: max(22px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.p-title { min-width: 0; color: var(--heading); font-size: 0.95rem; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; hyphens: auto; }
.p-header .logo { height: 22px; }
.p-main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 28px 16px 32px; }
.p-footer { padding: 16px 16px max(16px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 0.85rem; text-align: center; }

.participant .q-meta { margin-bottom: 10px; }
.participant .q-title { font-size: clamp(1.6rem, 6.5vw, 2.1rem); line-height: 1.15; }
.participant .q-sub { margin-top: 10px; color: var(--ink-2); font-size: 1.05rem; }

.answer-form { display: grid; gap: 16px; margin-top: 24px; }

.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.option-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--axis);
  border-radius: 50%;
}
.multi .option-mark { border-radius: 6px; }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-pressed="true"] .option-mark { border-color: var(--accent); background: var(--accent); }
.option[aria-pressed="true"] .option-mark::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.scale-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 8px; }
.scale-btn {
  min-height: 56px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
  color: var(--heading);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.scale-btn[aria-pressed="true"] { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-ink); }
.scale-labels { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; color: var(--ink-2); font-size: 0.9rem; }

.words { display: grid; gap: 10px; }
.counter { margin-top: 4px; color: var(--muted); font-size: 0.85rem; text-align: right; }

.notice { display: grid; justify-items: center; gap: 12px; padding: 48px 8px; text-align: center; }
.notice h1 { font-size: 1.8rem; }
.notice p { max-width: 32ch; color: var(--ink-2); font-size: 1.05rem; }

/* Pulsen är "solen" ur logotypen. */
.pulse {
  width: 18px;
  height: 18px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--sun);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(254, 100, 38, 0.45); }
  50% { box-shadow: 0 0 0 14px rgba(254, 100, 38, 0); }
}

.check, .check-small {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 700;
}
.check { width: 60px; height: 60px; font-size: 28px; }
.check-small { width: 28px; height: 28px; font-size: 15px; flex: none; }

.answered {
  display: grid;
  gap: 14px;
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.answered-head { display: flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 700; font-size: 1.05rem; }
.my-answer { padding: 12px 14px; border-radius: 8px; background: var(--tint); font-size: 1.1rem; overflow-wrap: anywhere; }
.answered .btn { justify-self: start; }

/* =========================================================================
   Presentatör (storbild). --u skalar allt efter skärmens storlek.
   ========================================================================= */

.host-page { overflow: hidden; }

.host {
  --u: min(1vw, 1.78vh);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--page);
  color: var(--ink);
}

.qr-small {
  position: absolute;
  top: calc(var(--u) * 2);
  right: calc(var(--u) * 5);
  z-index: 1;
  width: calc(var(--u) * 8);
  height: auto;
  padding: 4px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
[data-phase="waiting"] .qr-small,
[data-phase="finished"] .qr-small,
[data-phase="waiting"] .join-text,
[data-phase="finished"] .join-text { visibility: hidden; }

.local-warning {
  margin: 8px calc(var(--u) * 15) 0 calc(var(--u) * 5);
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 15px;
}

.stage { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: calc(var(--u) * 2.4) calc(var(--u) * 5) calc(var(--u) * 1.5); }

/* Sidfot som i profilens presentationsmall: adress till vänster, logotyp till höger. */
.slide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--u) * 3);
  padding: 0 calc(var(--u) * 5) calc(var(--u) * 2);
}
.slide-foot .logo { height: calc(var(--u) * 2.6); }
.join-text { color: var(--ink-2); font-size: calc(var(--u) * 1.5); }
.join-text strong { color: var(--heading); }

.question { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.host .q-meta { font-size: calc(var(--u) * 1.25); margin-bottom: calc(var(--u) * 1); }
/* Fast bredd (inte ch), så att en krympt rubrik får plats med fler ord per rad. Slutar före QR-koden. */
.host .q-title { max-width: calc(var(--u) * 74); font-size: calc(var(--u) * 3.6 * var(--fit, 1)); line-height: 1.1; }
.host .q-sub { margin-top: calc(var(--u) * 0.8); color: var(--ink-2); font-size: calc(var(--u) * 1.8); }

.host .results { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-top: calc(var(--u) * 2.4); overflow: hidden; }
.host .results > * { margin-block: auto; } /* centrerar, men klipper aldrig toppen */
.host .results[data-type="open"] > * { margin-block: 0; }

.results-hidden { display: grid; place-content: center; flex: 1; color: var(--ink-2); font-size: calc(var(--u) * 2); text-align: center; }
.big-count { color: var(--heading); font-size: calc(var(--u) * 9); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

.welcome { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: calc(var(--u) * 6); flex: 1; padding: 0 calc(var(--u) * 1); }
.eyebrow { color: var(--hl); font-size: calc(var(--u) * 1.6); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.welcome h1 { margin: calc(var(--u) * 1) 0 calc(var(--u) * 4); font-size: calc(var(--u) * 5.2 * var(--fit, 1)); line-height: 1.05; }
/* Under mätningen i host.js (fitTitle) bryts inga ord, så att för långa ord syns. */
.fitting { overflow-wrap: normal !important; hyphens: manual !important; }
.welcome-join { color: var(--ink-2); font-size: calc(var(--u) * 2); }
.welcome-url { color: var(--hl); font-size: calc(var(--u) * 3); font-weight: 700; overflow-wrap: anywhere; }
.welcome-count { margin-top: calc(var(--u) * 3); color: var(--ink-2); font-size: calc(var(--u) * 1.8); }
.welcome-count span { color: var(--ink); font-weight: 700; }
.qr-big { width: min(calc(var(--u) * 34), 56vh); height: auto; aspect-ratio: 1; padding: calc(var(--u) * 1.2); border-radius: 12px; background: #fff; }

.finished { display: grid; place-content: center; justify-items: center; gap: calc(var(--u) * 2.5); flex: 1; text-align: center; }
.finished h1 { font-size: calc(var(--u) * 5.5); }
.finished h1::after { margin-inline: auto; }
.finished p { color: var(--ink-2); font-size: calc(var(--u) * 2); }

.host-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  transition: opacity 0.3s;
}
.bar-group { display: flex; align-items: center; gap: 8px; }
.btn-bar { min-height: 36px; padding: 0 0.9em; font-size: 15px; }
.bar-select { max-width: 260px; min-height: 36px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); }
.bar-stats { margin-right: 6px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
body.idle { cursor: none; }
body.idle .host-bar { opacity: 0; }

.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 15px;
}

/* =========================================================================
   Resultat – delas av storbild och sammanställning
   ========================================================================= */

.bars { display: grid; gap: calc(var(--u) * 1.3); width: 100%; }
.bar-label { margin-bottom: calc(var(--u) * 0.4); color: var(--ink); font-size: calc(var(--u) * 1.8); font-weight: 600; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.bar-line { display: flex; align-items: center; gap: calc(var(--u) * 1.4); }
.bar-track { flex: 1; height: calc(var(--u) * 2.3); border-radius: 3px; background: var(--track); overflow: hidden; }
.bar-fill { width: 0; height: 100%; border-radius: 0 3px 3px 0; background: var(--bar); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar-value { display: flex; align-items: baseline; gap: 0.4em; min-width: calc(var(--u) * 9); color: var(--heading); line-height: 1; font-size: calc(var(--u) * 2.3); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-pct { color: var(--ink-2); font-size: 0.65em; font-weight: 600; }

.bars-dense { gap: calc(var(--u) * 1.1); }
.bars-dense .bar-row { display: grid; grid-template-columns: minmax(0, 30%) minmax(0, 1fr); align-items: center; gap: calc(var(--u) * 1.6); }
.bars-dense .bar-label { margin: 0; font-size: calc(var(--u) * 1.7); }
.bars-dense .bar-track { height: calc(var(--u) * 2.1); }
.bars-dense .bar-value { font-size: calc(var(--u) * 2); }

.scale { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: calc(var(--u) * 5); width: 100%; height: 100%; max-height: calc(var(--u) * 34); }
.scale-avg-value { color: var(--heading); font-size: calc(var(--u) * 10); font-weight: 700; line-height: 0.9; font-variant-numeric: tabular-nums; }
.scale-avg-label { max-width: 16ch; margin-top: calc(var(--u) * 1.2); color: var(--ink-2); font-size: calc(var(--u) * 1.7); white-space: pre-line; }
.scale-chart { display: flex; flex-direction: column; height: 100%; min-height: calc(var(--u) * 20); padding-top: calc(var(--u) * 3); }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: calc(var(--u) * 1.2); flex: 1; }
.col { --h: 0%; display: flex; flex-direction: column; min-height: 0; }
.col-track { position: relative; flex: 1; border-bottom: 1px solid var(--axis); }
.col-fill { position: absolute; right: 0; bottom: 0; left: 0; height: var(--h); border-radius: 3px 3px 0 0; background: var(--bar); transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.col-value { position: absolute; right: 0; bottom: calc(var(--h) + calc(var(--u) * 0.6)); left: 0; color: var(--heading); font-size: calc(var(--u) * 1.9); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; transition: bottom 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.col-label { margin-top: calc(var(--u) * 0.8); color: var(--ink-2); font-size: calc(var(--u) * 1.9); font-weight: 600; text-align: center; }
.scale-ends { display: flex; justify-content: space-between; gap: 1em; margin-top: calc(var(--u) * 0.6); color: var(--muted); font-size: calc(var(--u) * 1.5); }

.cloud { display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center; gap: calc(var(--u) * 0.4) calc(var(--u) * 2.2); height: 100%; padding: calc(var(--u) * 1); }
.word {
  padding: 0;
  border: 0;
  background: none;
  color: var(--word-1);
  max-width: 100%;
  font-size: calc(var(--u) * (1.9 + var(--s) * 5.4) * var(--cloud, 1));
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.word.tier-2 { color: var(--word-2); }
.word.tier-3 { color: var(--word-3); }
.word.tier-4 { color: var(--word-4); }
button.word, button.card-answer { cursor: pointer; }
button.word:hover, button.card-answer:hover { opacity: 0.55; text-decoration: line-through; }

.cards { columns: 3 calc(var(--u) * 24); column-gap: calc(var(--u) * 1.5); }
.card-answer {
  display: block;
  width: 100%;
  margin: 0 0 calc(var(--u) * 1.5);
  padding: calc(var(--u) * 1.3) calc(var(--u) * 1.7);
  border: 0;
  border-radius: 8px;
  background: var(--tint);
  color: var(--ink);
  font-size: calc(var(--u) * 1.75);
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  break-inside: avoid;
}
.more { margin-top: calc(var(--u) * 0.5); color: var(--muted); font-size: calc(var(--u) * 1.5); }
.empty { padding: calc(var(--u) * 4); color: var(--muted); font-size: calc(var(--u) * 2); text-align: center; }

/* =========================================================================
   Sammanställning
   ========================================================================= */

.summary { --u: 8px; max-width: 1000px; margin: 0 auto; padding: 24px 16px 64px; }
.sum-brand { display: flex; justify-content: flex-end; padding: 4px 0 28px; }
.sum-brand .logo { height: 28px; }
.sum-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.sum-head h1 { margin-top: 4px; font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.1; }
.sum-meta { margin-top: 8px; color: var(--ink-2); }
.sum-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sum-actions .btn { min-height: 40px; font-size: 1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 16px 20px; border-radius: var(--radius); background: var(--tint); }
.kpi-value { color: var(--heading); font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--ink-2); font-size: 0.95rem; }

.sum-q { margin-bottom: 16px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); break-inside: avoid; }
.sum-q h2 { margin: 6px 0 22px; font-size: 1.45rem; line-height: 1.2; }
.sum-q .hint { margin-top: 12px; }
.summary .scale { height: 240px; max-height: none; }
.summary .cloud { min-height: 140px; }
.summary .cards { columns: 2 260px; }

.word-table { width: 100%; max-width: 420px; margin-top: 20px; border-collapse: collapse; font-size: 1rem; }
.word-table caption { padding-bottom: 6px; color: var(--muted); font-size: 0.9rem; text-align: left; }
.word-table th, .word-table td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: left; }
.word-table th { color: var(--heading); font-weight: 600; }
.word-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================================================
   Admin: projektlista och frågeredigerare
   ========================================================================= */

.admin { --u: 8px; max-width: 1000px; margin: 0 auto; padding: 24px 16px 64px; }
.admin .sum-brand { align-items: center; justify-content: space-between; }
.admin .sum-brand .logo { margin-left: auto; }
.back-link { color: var(--heading); font-weight: 600; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.admin-head h1 { margin-top: 4px; font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.1; }
.admin .btn { min-height: 40px; font-size: 1rem; }
.admin .input { min-height: 46px; font-size: 1.05rem; }

.admin .storage-warning { margin: 0 0 16px; font-size: 1rem; }
.project-list { display: grid; gap: 12px; }
/* QR-koden till vänster över två rader; titel och knappar linjerar till höger om den. */
.project {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px 20px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--sun);
  border-radius: var(--radius);
  background: var(--surface);
}
.project .qr-thumb { grid-row: span 2; align-self: start; }
.project-main { min-width: 0; }
.project h2 { font-size: 1.3rem; line-height: 1.25; overflow-wrap: anywhere; }
.project h2 a { color: inherit; text-decoration: none; }
.project h2 a:hover { text-decoration: underline; }
.project-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; color: var(--ink-2); font-size: 0.95rem; }
.project-actions { display: flex; flex-wrap: wrap; grid-column: 2; gap: 8px; }
.empty-state { display: grid; justify-items: center; gap: 12px; padding: 32px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--ink-2); text-align: center; }

.editor { padding-bottom: 120px; }
.edit-head { display: grid; gap: 8px; margin-bottom: 24px; }
.title-input { color: var(--heading); font-weight: 700; }
.admin .title-input { min-height: 60px; font-size: clamp(1.4rem, 3.5vw, 2rem); }
.edit-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--ink-2); }
.edit-links strong { color: var(--heading); overflow-wrap: anywhere; }

.q-list { display: grid; gap: 16px; }
.q-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--sun);
  border-radius: var(--radius);
  background: var(--surface);
}
.q-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.q-card-tools { display: flex; gap: 6px; margin-left: auto; }
.admin .btn-icon { min-width: 40px; padding: 0; font-size: 1.15rem; }
.admin .btn-small { justify-self: start; min-height: 36px; font-size: 0.95rem; }
.admin .input-select { width: auto; min-height: 40px; padding: 6px 10px; color: var(--heading); font-size: 1rem; font-weight: 600; }
.type-fields { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { color: var(--ink-2); font-size: 0.9rem; font-weight: 600; }
.field-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; }
.field-row .field { flex: 1 1 180px; }
.field-row .field-inline { flex: 0 0 auto; }
.admin .input-number { width: 120px; }
.option-list { display: grid; gap: 8px; }
.option-row { display: flex; align-items: center; gap: 8px; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 46px; font-weight: 600; cursor: pointer; }
.check-field input { width: 20px; height: 20px; accent-color: var(--heading); }

.add-question { display: grid; gap: 10px; margin-top: 20px; padding: 20px; border: 2px dashed var(--border); border-radius: var(--radius); }
.add-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.save-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
  padding: 12px max(16px, calc((100vw - 1000px) / 2 + 16px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.save-status { margin-right: auto; color: var(--ink-2); }
.save-status.dirty { color: var(--heading); font-weight: 600; }
.save-status.dirty::before { content: ""; display: inline-block; width: 0.55em; height: 0.55em; margin-right: 0.5em; border-radius: 50%; background: var(--sun); }
.save-bar .btn { min-width: 120px; min-height: 44px; }

/* Krock: en kollega har sparat samma projekt */
.conflict {
  position: fixed;
  bottom: 84px;
  left: 50%;
  z-index: 6;
  display: grid;
  gap: 10px;
  width: min(760px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink);
  box-shadow: 0 8px 30px rgba(20, 31, 105, 0.2);
  transform: translateX(-50%);
}
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conflict .btn { background: var(--raised); }

/* QR-kod: miniatyr i listan och redigeraren, dialog med nedladdning */
.qr-thumb {
  flex: none;
  width: 76px;
  height: 76px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.qr-thumb img { display: block; width: 100%; height: 100%; }
.qr-thumb:hover { border-color: var(--heading); }
.edit-links .qr-thumb { width: 56px; height: 56px; }

.qr-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 28px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 20px 60px rgba(20, 31, 105, 0.25);
}
.qr-dialog::backdrop { background: rgba(20, 31, 105, 0.5); }
.qr-dialog h2 { margin: 0 36px 18px; font-size: 1.4rem; line-height: 1.2; overflow-wrap: anywhere; }
.qr-dialog h2::after { margin-inline: auto; }
.qr-dialog-close { position: absolute; top: 12px; right: 12px; }
.qr-dialog-img { display: block; width: 100%; max-width: 320px; height: auto; aspect-ratio: 1; margin: 0 auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.qr-dialog-url { margin: 14px 0 18px; color: var(--heading); font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }
.qr-dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Startsidan där deltagare anger kod */
.join-form { display: grid; gap: 14px; }
.code-input { min-height: 64px; font-size: 1.7rem; font-weight: 700; letter-spacing: 0.15em; text-align: center; text-transform: lowercase; }

@media (max-width: 640px) {
  .summary .scale { grid-template-columns: 1fr; height: auto; gap: 20px; }
  .summary .scale-chart { height: 200px; }
  .bars-dense .bar-row { display: block; }
  .bars-dense .bar-label { margin-bottom: 4px; }
}

@media print {
  body { background: #fff; }
  .sum-actions { display: none; }
  .sum-q { border-color: #ccc; }
  *, *::before, *::after { transition: none !important; }
}

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