/*
 * Live poll, Kapernikov style.
 * Colours, fonts and logo come from the Kapernikov slides theme
 * (Bruges-ai-lectures: tools/slides/kapernikov-slides-theme.css):
 * Agenda for headings, Avenir LT Std for text, --kpv-primary for accents.
 *
 * Two layouts share this file:
 *   html.phone    the student page, built for 320-480 px wide phones
 *   html.present  the presenter screen and the replay: a 16:9 "slide"
 */

/* ---------- Fonts (only the weights we use) ---------- */

@font-face {
  font-family: 'Agenda';
  src: url('fonts/Agenda-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Agenda';
  src: url('fonts/Agenda-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Avenir LT Std';
  src: url('fonts/AvenirLTStd-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Avenir LT Std';
  src: url('fonts/AvenirLTStd-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Kapernikov colours (from the slides theme) ---------- */

:root {
  --kpv-primary: #ba2415;
  --kpv-red-light: #D4734F;
  --kpv-red-lighter: #dd977a;
  --kpv-black: #000000;
  --kpv-dark-grey: #484847;
  --kpv-medium-grey: #818281;
  --kpv-light-grey: #bfc0c0;
  --kpv-very-light-grey: #ececec;
  --kpv-beige: #e2d7cd;
  --kpv-burgundy: #5a322b;
  --kpv-crimson: #901C1D;
  --kpv-tangerine: #DD8028;
  --kpv-amber: #FFB31B;
  --kpv-emerald: #1E9F49;
  --kpv-jade: #36b191;
  --kpv-petrol: #1D6E88;
  --kpv-cyan: #1F92A6;

  --tint: #f8ebe9;           /* selected option: a whisper of the primary red */
  --heading: 'Agenda', 'Segoe UI', Roboto, Arial, sans-serif;
  --text: 'Avenir LT Std', 'Avenir', 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: #fff;
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--heading); font-weight: 500; }
strong, b { font-weight: 500; }
a { color: var(--kpv-primary); }
button { font: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Buttons (both layouts) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: 0;
  border-radius: 12px;
  font-family: var(--heading);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, opacity .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--kpv-amber); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-primary { background: var(--kpv-primary); color: #fff; }
.btn-primary:hover { background: var(--kpv-crimson); }
.btn-outline { background: #fff; color: var(--kpv-primary); box-shadow: inset 0 0 0 2px var(--kpv-primary); }
.btn-outline:hover { background: var(--tint); }
.btn-ghost { background: transparent; color: var(--kpv-medium-grey); }
.btn-ghost:hover { color: var(--kpv-dark-grey); background: var(--kpv-very-light-grey); }

/* ======================================================================
   PHONE
   ====================================================================== */

html.phone { font-size: 18px; }
html.phone body { min-height: 100vh; min-height: 100dvh; line-height: 1.4; overflow-x: hidden; }

.phone-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: var(--kpv-primary);
  color: #fff;
}
.phone-logo { width: 34px; height: 34px; flex: none; }
.phone-title {
  font-family: var(--heading);
  font-weight: 500;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px calc(32px + env(safe-area-inset-bottom));
}

.screen { min-width: 0; }

.progress {
  margin: 0 0 6px;
  color: var(--kpv-primary);
  font-weight: 500;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.question {
  margin: 0 0 18px;
  color: var(--kpv-dark-grey);
  font-size: 1.65rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.hint { color: var(--kpv-medium-grey); font-size: .9rem; margin: 14px 0; }
.hint-top { margin: -8px 0 12px; }

/* Options: big tap targets with a custom radio/checkbox mark */
.options { display: grid; gap: 10px; }
.option {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 13px 16px;
  border: 2px solid #e2e2e2;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .12s, background-color .12s;
}
.option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.option .label { overflow-wrap: anywhere; line-height: 1.25; }
.option .mark {
  width: 26px;
  height: 26px;
  border: 2px solid var(--kpv-light-grey);
  border-radius: 50%;
  background: #fff;
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.option input[type=checkbox] + .mark { border-radius: 7px; position: relative; }
.option:has(input:checked) { border-color: var(--kpv-primary); background: var(--tint); }
.option input:checked + .mark {
  border-color: var(--kpv-primary);
  background: var(--kpv-primary);
  box-shadow: inset 0 0 0 5px #fff;
}
.option input[type=checkbox]:checked + .mark { box-shadow: none; }
.option input[type=checkbox]:checked + .mark::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 2px;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.option input:focus-visible + .mark { outline: 3px solid var(--kpv-amber); outline-offset: 2px; }
@media (hover: hover) { .option:hover { border-color: var(--kpv-light-grey); } }

/* "Other": the text field appears when Other is picked */
.other-field { display: none; margin-top: 12px; }
.answer:has(.option-other input:checked) .other-field,
.other-field.is-open { display: block; }
.other-field label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; }

input[type=text], textarea {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--kpv-light-grey);
  border-radius: 12px;
  background: #fff;
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 300;
  font-size: 1rem;  /* 18px: no zoom-on-focus on iOS */
  line-height: 1.4;
}
textarea { resize: vertical; min-height: 150px; }
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--kpv-primary); }
.count { margin: 6px 2px 0; text-align: right; font-size: .8rem; color: var(--kpv-medium-grey); }

.error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--kpv-primary);
  background: var(--tint);
  color: var(--kpv-crimson);
  font-weight: 500;
  font-size: .95rem;
}

.answer .btn-primary {
  width: 100%;
  min-height: 58px;
  margin-top: 20px;
  font-size: 1.15rem;
}
.screen .btn-ghost { min-height: 48px; padding: 0 14px; margin-left: -14px; color: var(--kpv-primary); font-size: 1rem; }

/* Answered: the theme's grey box with a red left bar */
.answered {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--kpv-very-light-grey);
  border-left: 4px solid var(--kpv-primary);
}
.answered .badge { width: 44px; height: 44px; margin: 0; }
.answered-title { margin: 0; font-family: var(--heading); font-weight: 500; font-size: 1.2rem; color: var(--kpv-dark-grey); }
.answered-value { margin: 2px 0 0; overflow-wrap: anywhere; font-size: .95rem; }

/* Kapernikov wordmark under the lobby and thanks screens */
.phone-brand { display: block; width: 116px; margin: 56px auto 0; opacity: .9; }

/* Lobby, closed, thanks */
.notice { text-align: center; padding-top: 12vh; }
.notice h1 { margin: 18px 0 8px; font-size: 2rem; line-height: 1.1; color: var(--kpv-dark-grey); }
.notice p { margin: 0 auto; max-width: 22em; color: var(--kpv-medium-grey); font-size: 1.05rem; }

.badge {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto;
  border-radius: 50%;
  color: #fff;
  flex: none;
}
.badge svg { width: 60%; height: 60%; }
.badge-done { background: var(--kpv-primary); }
.badge-closed { background: var(--kpv-medium-grey); }

.pulse { display: flex; justify-content: center; gap: 10px; height: 76px; align-items: center; }
.pulse span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--kpv-primary);
  animation: pulse 1.4s ease-in-out infinite;
}
.pulse span:nth-child(2) { animation-delay: .2s; }
.pulse span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: .2; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .pulse span { animation: none; opacity: .6; } }

/* Shown while the connection is gone (set by app.js) */
.offline {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 150%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--kpv-dark-grey);
  color: #fff;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: transform .25s, opacity .25s;
  pointer-events: none;
}
body.is-offline .offline { transform: translate(-50%, 0); opacity: 1; }

/* ======================================================================
   PRESENTER (and replay): a 16:9 slide, 80rem x 45rem.
   1rem = 16px on a 1280x720 screen, 24px on 1920x1080; the whole slide
   scales with the window and is letterboxed in white.
   ====================================================================== */

html.present { font-size: min(1.25vw, 2.2222vh); }
html.present body {
  height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
  line-height: 1.3;
}

.deck {
  position: relative;
  width: 80rem;
  height: 45rem;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}
.deck .btn { font-size: 1.45rem; min-height: 3.6rem; padding: 0 2rem; border-radius: .55rem; }
.deck .btn-outline { box-shadow: inset 0 0 0 .14rem var(--kpv-primary); }
.deck .btn-next { min-width: 12rem; }
.deck .btn-show, .deck .slot-center .btn { min-width: 13rem; }

/* Red header bar with the white logo, like the default slide */
.deck-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1.9rem;
  height: 6.875rem;
  padding: 0 2.5rem;
  background: var(--kpv-primary);
  color: #fff;
}
.deck-logo { width: 3.625rem; height: 3.625rem; flex: none; }
.deck-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 2.625rem;
  line-height: 1.1;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.deck-title-long { font-size: 2.1rem; }
.deck-bar-right { flex: none; display: flex; align-items: center; gap: 1.2rem; }
.deck-progress { font-size: 1.3rem; opacity: .92; white-space: nowrap; }
.chip-test {
  padding: .3rem .85rem;
  border-radius: 999px;
  background: var(--kpv-amber);
  color: #3b2a00;
  font-weight: 500;
  font-size: .95rem;
  white-space: nowrap;
}

/* Small menu (Reset, test answers, CSV) in the header */
.menu { position: relative; }
.menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .22rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  cursor: pointer;
  opacity: .75;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { opacity: 1; background: rgba(255, 255, 255, .16); }
.menu summary span { width: .32rem; height: .32rem; border-radius: 50%; background: #fff; }
.menu-items {
  position: absolute;
  right: 0;
  top: 3.2rem;
  z-index: 10;
  min-width: 19rem;
  padding: .5rem;
  background: #fff;
  border-radius: .6rem;
  box-shadow: 0 .6rem 2rem rgba(0, 0, 0, .18);
}
.menu-items a, .menu-items button {
  display: block;
  width: 100%;
  padding: .7rem 1rem;
  border: 0;
  border-radius: .4rem;
  background: none;
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 500;
  font-size: 1.05rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-items a:hover, .menu-items button:hover { background: var(--kpv-very-light-grey); }
.menu-items .danger { color: var(--kpv-primary); }
.menu-items hr { border: 0; border-top: 1px solid var(--kpv-very-light-grey); margin: .4rem 0; }

.deck-body { flex: 1; min-height: 0; padding: 2.4rem 3.125rem 0; }

/* Controls: Previous left, Show results centre, Next right. Next is never
   where Show results was, so a double click can't skip a question. */
.deck-controls {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 6.4rem;
  padding: 0 3.125rem .6rem;
}
.slot-left { justify-self: start; }
.slot-center { justify-self: center; }
.slot-right { justify-self: end; }
.btn-prev { font-size: 1.2rem !important; padding: 0 1.2rem !important; }
.poller { display: none; }

/* Lobby */
.lobby {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 27rem;
  gap: 4rem;
  align-items: center;
}
.lobby p { margin: 0; }
.lobby-kicker { font-family: var(--heading); font-weight: 500; font-size: 4.4rem; line-height: 1; color: var(--kpv-dark-grey); }
.lobby-or { margin-top: 1.6rem !important; font-size: 1.6rem; color: var(--kpv-medium-grey); }
.lobby-url {
  margin-top: .2rem !important;
  font-family: var(--heading);
  font-weight: 500;
  font-size: 2.7rem;
  line-height: 1.1;
  color: var(--kpv-primary);
  overflow-wrap: anywhere;
}
.lobby-count { margin-top: 2.8rem !important; font-size: 1.8rem; color: var(--kpv-dark-grey); }
.lobby-count strong {
  font-family: var(--heading);
  font-weight: 700;
  font-size: 3.4rem;
  color: var(--kpv-primary);
  margin-right: .3rem;
}
.lobby-meta { margin-top: .6rem !important; font-size: 1.2rem; color: var(--kpv-medium-grey); }
.lobby-qr { width: 27rem; height: 27rem; padding: .8rem; border: .14rem solid var(--kpv-very-light-grey); border-radius: .8rem; }
.qr { display: block; width: 100%; height: 100%; }

/* Question */
.q-layout {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14rem;
  gap: 3rem;
}
/* Content is vertically centred like on the slides; auto margins (not
   justify-content) so a long list of cards still scrolls from the top. */
.q-main { min-height: 0; overflow-y: auto; scrollbar-width: thin; padding-bottom: 1rem; display: flex; flex-direction: column; }
.q-main > * { flex: none; }
.q-main > :first-child { margin-top: auto; }
.q-main > :last-child { margin-bottom: auto; }
.results-text { min-height: 100%; }
.q-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: .4rem 0 1rem;
  border-left: .14rem solid var(--kpv-very-light-grey);
  padding-left: 2.4rem;
}
.counter { text-align: center; }
.counter-n {
  display: block;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 6.4rem;
  line-height: .95;
  color: var(--kpv-primary);
  font-variant-numeric: tabular-nums;
}
.counter-l { display: block; font-size: 1.5rem; color: var(--kpv-medium-grey); }
.side-qr { text-align: center; }
.side-qr .qr { width: 10.5rem; height: 10.5rem; margin: 0 auto; }
.side-qr p { margin: .5rem 0 0; font-size: .8rem; color: var(--kpv-medium-grey); white-space: nowrap; line-height: 1.2; }
.replay-note { margin: 0; text-align: center; font-size: 1.05rem; color: var(--kpv-medium-grey); }

.q-hint {
  margin: 0 0 1rem;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--kpv-primary);
}
.q-options { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.q-options li {
  padding: .75rem 1.3rem;
  background: var(--kpv-very-light-grey);
  border-left: .35rem solid var(--kpv-primary);
  font-size: 1.7rem;
  line-height: 1.2;
}
.q-waiting { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.q-waiting-big { margin: 0; font-family: var(--heading); font-weight: 500; font-size: 3.2rem; line-height: 1.1; color: var(--kpv-dark-grey); }
.q-waiting-small { margin: 1rem 0 0; font-size: 1.6rem; color: var(--kpv-medium-grey); }

/* Results: bars */
.bars {
  display: grid;
  grid-template-columns: fit-content(24rem) minmax(0, 1fr) 7.2rem;
  column-gap: 1.6rem;
  row-gap: 1.15rem;
  align-items: center;
}
.bar-row { display: contents; }
.bar-label { font-size: 1.5rem; line-height: 1.15; color: var(--kpv-dark-grey); overflow-wrap: anywhere; }
.bar-track { height: 2.6rem; background: var(--kpv-very-light-grey); border-radius: .3rem; overflow: hidden; }
.bar-fill {
  height: 100%;
  min-width: 0;
  background: var(--kpv-primary);
  border-radius: .3rem;
  transition: width .6s cubic-bezier(.2, .7, .2, 1);
}
.bar-num { display: flex; align-items: baseline; gap: .6rem; white-space: nowrap; }
.bar-num strong {
  min-width: 2.2rem;
  text-align: right;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--kpv-dark-grey);
  font-variant-numeric: tabular-nums;
}
.bar-num span { font-size: 1.3rem; color: var(--kpv-medium-grey); }
.bars-note { margin: 1.1rem 0 0; font-size: 1.05rem; color: var(--kpv-medium-grey); }

/* "Other" texts under the bars */
.others { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1.3rem; }
.others-title { font-weight: 500; font-size: 1.15rem; margin-right: .3rem; }
.chip {
  padding: .35rem .95rem;
  border: 0;
  border-radius: 999px;
  background: var(--kpv-beige);
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 300;
  font-size: 1.2rem;
}

/* Results: text cards (grey, red top bar, like the lecture diagrams) */
.cards { column-gap: 1.2rem; }
.card {
  display: block;
  width: 100%;
  margin: 0 0 1.2rem;
  padding: .9rem 1.15rem 1rem;
  break-inside: avoid;
  border: 0;
  border-top: .3rem solid var(--kpv-primary);
  border-radius: .2rem .2rem .45rem .45rem;
  background: var(--kpv-very-light-grey);
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 300;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
}
.cards-l { column-count: 2; }
.cards-l .card { font-size: 1.75rem; }
.cards-m { column-count: 3; }
.cards-m .card { font-size: 1.3rem; }
.cards-s { column-count: 4; }
.cards-s .card { font-size: 1.02rem; padding: .7rem .9rem .8rem; margin-bottom: .9rem; }
.cards-empty { font-size: 1.6rem; color: var(--kpv-medium-grey); }

/* Click to hide: only on the presenter screen */
.hideable { position: relative; cursor: pointer; transition: opacity .15s; }
.hideable:hover { opacity: .5; }
.hideable:hover::after {
  content: 'Hide';
  position: absolute;
  top: .35rem;
  right: .45rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  background: var(--kpv-dark-grey);
  color: #fff;
  font-size: .8rem;
  font-weight: 500;
}
.chip.hideable:hover::after { top: -.9rem; right: -.3rem; }

/* Finished */
.finished {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 4rem;
  align-items: center;
}
.finished-thanks { margin: 0; font-family: var(--heading); font-weight: 500; font-size: 7rem; line-height: 1; color: var(--kpv-primary); }
.finished-sub { margin: 1.2rem 0 0; font-size: 1.9rem; line-height: 1.25; }
.finished-sub strong { font-family: var(--heading); font-weight: 700; }
.finished-actions { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: 2.4rem; }
.finished-actions .btn { font-size: 1.25rem; min-height: 3.2rem; padding: 0 1.5rem; }
.summary { list-style: none; margin: 0; padding: 0; }
.summary li {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: .1rem solid var(--kpv-very-light-grey);
  font-size: 1.2rem;
}
.summary-num {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--kpv-primary);
  color: #fff;
  font-family: var(--heading);
  font-weight: 500;
  font-size: 1.05rem;
}
.summary-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-n { font-family: var(--heading); font-weight: 700; font-size: 1.35rem; color: var(--kpv-dark-grey); font-variant-numeric: tabular-nums; }

/* ======================================================================
   STAFF PAGES (landing, dashboard, new poll, API tokens, notices)
   Light pages in the phone's style: red bar, Agenda headings, grey cards
   with a red edge. Built mobile first.
   ====================================================================== */

html.staff { font-size: 17px; }
html.staff body { min-height: 100vh; min-height: 100dvh; line-height: 1.45; overflow-x: hidden; background: #fafafa; }
html.staff code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  min-height: 58px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--kpv-primary);
  color: #fff;
}
.top-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.top-brand img { width: 34px; height: 34px; flex: none; }
.top-brand span { font-family: var(--heading); font-weight: 500; font-size: 1.15rem; white-space: nowrap; }
.top-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  font-size: .95rem;
  opacity: .88;
}
.top-nav a:hover { opacity: 1; background: rgba(255, 255, 255, .14); }
.top-nav a[aria-current] { opacity: 1; background: rgba(255, 255, 255, .22); }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-name { font-size: .9rem; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 16em; }
.top-logout {
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  padding: 4px 12px;
  background: transparent;
  color: #fff;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
}
.top-logout:hover { background: rgba(255, 255, 255, .14); }
@media (max-width: 560px) {
  .top-nav { order: 3; width: 100%; margin: 2px -8px 0; }
  .top-name { max-width: 9em; }
}

.page { max-width: 1040px; margin: 0 auto; padding: 26px 16px 56px; }
.page-narrow { max-width: 560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page h1 { margin: 0; font-size: 2rem; line-height: 1.1; color: var(--kpv-dark-grey); }
.page .btn { min-height: 46px; padding: 0 20px; font-size: 1rem; }
.page .btn-s, .page .btn.btn-s { min-height: 36px; padding: 0 14px; font-size: .9rem; border-radius: 9px; }
.lead { margin: 6px 0 22px; max-width: 46em; color: var(--kpv-dark-grey); }
.section-title { margin: 34px 0 12px; font-size: 1.3rem; color: var(--kpv-dark-grey); }
.section-note { margin: -6px 0 14px; color: var(--kpv-medium-grey); font-size: .92rem; }
.count-note { font-family: var(--text); font-weight: 300; font-size: .9rem; color: var(--kpv-medium-grey); margin-left: 6px; }
.empty { color: var(--kpv-medium-grey); }
.optional { font-weight: 300; color: var(--kpv-medium-grey); }

.flash, .ok {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--kpv-emerald);
  background: #eaf6ee;
  color: #165c2e;
}

/* Landing */
.landing { text-align: center; }
.landing-join { padding-top: 6vh; }
.landing h1 { font-size: 2.4rem; }
.landing p { color: var(--kpv-medium-grey); }
.landing-fine { font-size: .9rem; }
.landing-staff { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--kpv-very-light-grey); }
.landing-staff h2 { margin: 0 0 4px; font-size: 1.25rem; color: var(--kpv-dark-grey); }
.code-form { display: flex; gap: 10px; margin: 18px auto 6px; max-width: 420px; }
.code-form input[type=text] { flex: 1; min-width: 0; font-family: var(--heading); font-size: 1.3rem; text-align: center; letter-spacing: .04em; }
.code-form .btn { min-height: 56px; padding: 0 24px; font-size: 1.1rem; }
.landing .error, .notice-card .error { text-align: left; }

/* Notices (403, 404, login problems) */
.notice-card { margin-top: 8vh; padding: 26px 22px; background: #fff; border-top: 4px solid var(--kpv-primary); border-radius: 4px 4px 12px 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, .05); }
.notice-card h1 { font-size: 1.8rem; margin-bottom: 10px; }
.notice-card p { color: var(--kpv-dark-grey); }
.notice-card .code-form { margin-left: 0; }

/* Dashboard */
.poll-list { display: grid; gap: 12px; }
.poll-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-left: 4px solid var(--kpv-primary);
  border-radius: 4px 12px 12px 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .05);
  scroll-margin-top: 16px;
}
.poll-card.is-new { box-shadow: 0 0 0 3px var(--kpv-amber); }
.poll-qr { display: block; width: 84px; height: 84px; border: 1px solid var(--kpv-very-light-grey); border-radius: 6px; overflow: hidden; background: #fff; }
.poll-qr img { display: block; width: 100%; height: 100%; }
.poll-title { margin: 0; font-size: 1.2rem; line-height: 1.2; color: var(--kpv-dark-grey); overflow-wrap: anywhere; }
.poll-link { margin: 2px 0 6px; font-family: var(--heading); font-weight: 500; overflow-wrap: anywhere; }
.poll-link a { text-decoration: none; }
.poll-meta { margin: 0; font-size: .9rem; color: var(--kpv-medium-grey); }
.poll-meta-small { margin-top: 2px; font-size: .82rem; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--kpv-very-light-grey); color: var(--kpv-dark-grey); font-weight: 500; font-size: .8rem; }
.pill-question { background: var(--tint); color: var(--kpv-primary); }
.pill-finished { background: #eaf6ee; color: #165c2e; }
.pill-test { background: var(--kpv-amber); color: #3b2a00; }
.poll-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.more { position: relative; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  min-width: 15rem;
  padding: 6px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}
.more-items a, .more-items button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--kpv-dark-grey);
  font-family: var(--text);
  font-weight: 500;
  font-size: .95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.more-items a:hover, .more-items button:hover { background: var(--kpv-very-light-grey); }
.danger, .more-items .danger { color: var(--kpv-primary); }
@media (max-width: 700px) {
  .poll-card { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; }
  .poll-qr { width: 64px; height: 64px; }
  .poll-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* New poll */
.form label { display: block; margin: 18px 0 6px; font-weight: 500; }
.form label:first-child { margin-top: 0; }
textarea.yaml {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  line-height: 1.5;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 2;
}
.errors {
  margin: 14px 0 0;
  padding: 12px 16px;
  border-left: 4px solid var(--kpv-primary);
  background: var(--tint);
  color: var(--kpv-crimson);
}
.errors p { margin: 0 0 6px; font-weight: 500; }
.errors ul { margin: 0; padding-left: 20px; }
.errors li { margin: 3px 0; overflow-wrap: anywhere; }
.code-input { display: flex; align-items: stretch; max-width: 560px; border: 2px solid var(--kpv-light-grey); border-radius: 12px; background: #fff; overflow: hidden; }
.code-input:focus-within { border-color: var(--kpv-primary); }
.code-prefix { flex: none; display: flex; align-items: center; padding: 0 0 0 14px; color: var(--kpv-medium-grey); white-space: nowrap; font-size: .95rem; }
.code-input input[type=text] { flex: 1 1 auto; width: auto; min-width: 5em; border: 0; border-radius: 0; padding-left: 1px; }
.code-input input[type=text]:focus { border: 0; }
@media (max-width: 420px) { .code-prefix { font-size: .8rem; padding-left: 10px; } }
.form .hint { margin: 6px 0 0; font-size: .88rem; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
.format { margin-top: 30px; padding: 12px 16px; background: #fff; border-radius: 10px; }
.format summary { cursor: pointer; font-weight: 500; }
.format li { margin: 4px 0; }

/* API tokens */
.token-new { margin: 0 0 22px; padding: 16px 18px; background: #fff; border-top: 4px solid var(--kpv-emerald); border-radius: 4px 4px 12px 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, .06); }
.token-new h2 { margin: 0 0 4px; font-size: 1.2rem; color: var(--kpv-dark-grey); }
.token-new p { margin: 4px 0; }
.token-box { display: flex; gap: 10px; align-items: center; margin: 10px 0; padding: 10px 12px; background: var(--kpv-very-light-grey); border-radius: 8px; }
.token-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .9rem; user-select: all; }
.token-form-row { display: flex; gap: 10px; max-width: 620px; }
.token-form-row input { flex: 1; min-width: 0; }
.token-form-row .btn { min-height: 54px; white-space: nowrap; }
.token-form label { display: block; margin: 0 0 6px; font-weight: 500; }
.token-list { display: grid; gap: 8px; }
.token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-left: 4px solid var(--kpv-light-grey);
  border-radius: 4px 10px 10px 4px;
}
.token-name { font-weight: 500; overflow-wrap: anywhere; }
.token-dates { grid-column: 1; font-size: .85rem; color: var(--kpv-medium-grey); }
.token-row .btn { grid-column: 2; grid-row: 1 / 3; }
@media (max-width: 480px) {
  .token-form-row { flex-direction: column; }
  .code-form .btn { padding: 0 16px; }
}

/* ======================================================================
   PUBLIC RESULTS (change 1): after Finish, the join link shows the
   results. The phone page reuses the presenter's bars, cards and chips,
   laid out for a narrow screen.
   ====================================================================== */

.pub-title { margin: 0 0 4px; font-size: 2rem; line-height: 1.1; color: var(--kpv-dark-grey); }
.pub-sub { margin: 0; color: var(--kpv-medium-grey); }
.pub-sub strong { font-family: var(--heading); font-weight: 700; color: var(--kpv-dark-grey); }
.pub-q { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--kpv-very-light-grey); }
.pub-num { margin: 0 0 4px; color: var(--kpv-medium-grey); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 500; }
.pub-qtext { margin: 0 0 12px; font-size: 1.3rem; line-height: 1.2; color: var(--kpv-dark-grey); overflow-wrap: anywhere; }
.pub-n { margin: 10px 0 0; font-size: .85rem; color: var(--kpv-medium-grey); }

html.phone .bars { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; }
html.phone .bar-label { grid-column: 1 / -1; margin-top: 14px; font-size: .95rem; line-height: 1.25; }
html.phone .bar-label:first-child { margin-top: 0; }
html.phone .bar-track { height: 20px; border-radius: 5px; }
html.phone .bar-fill { border-radius: 5px; transition: none; }
html.phone .bar-num { gap: 6px; justify-content: flex-end; min-width: 5.2em; }
html.phone .bar-num strong { min-width: 0; font-size: 1.15rem; }
html.phone .bar-num span { min-width: 2.7em; text-align: right; font-size: .85rem; }
html.phone .bars-note { margin: 10px 0 0; font-size: .8rem; }
html.phone .others { margin-top: 12px; gap: 6px; }
html.phone .others-title { font-size: .9rem; }
html.phone .chip { max-width: 100%; padding: 3px 12px; font-size: .9rem; overflow-wrap: anywhere; }
.pub-cards .card { margin: 0 0 10px; padding: 10px 14px 12px; border-top-width: 4px; font-size: 1rem; }
.pub .phone-brand { margin-top: 40px; }

/* Presenter: finished screen and replay */
.finished-public { margin: 1.4rem 0 0; padding: .7rem 1rem; max-width: 34rem; border-left: .3rem solid var(--kpv-light-grey); background: var(--kpv-very-light-grey); font-size: 1.15rem; line-height: 1.3; color: var(--kpv-dark-grey); }
.finished-public.is-public { border-left-color: var(--kpv-emerald); background: #eaf6ee; }
.summary li:has(.summary-img) { grid-template-columns: 2.2rem minmax(0, 1fr) auto auto; }
.summary-img { display: flex; gap: .3rem; }
.summary-img a { padding: .1rem .45rem; border-radius: .3rem; font-size: .85rem; font-weight: 500; text-decoration: none; color: var(--kpv-medium-grey); box-shadow: inset 0 0 0 .08rem var(--kpv-light-grey); }
.summary-img a:hover { color: var(--kpv-primary); box-shadow: inset 0 0 0 .08rem var(--kpv-primary); }
.replay .slot-center { display: flex; gap: .4rem; }
.replay .slot-center .btn { min-width: 0; padding: 0 1.2rem; font-size: 1.2rem; }

/* Dashboard */
.poll-public { display: flex; align-items: center; gap: 6px; }
.pub-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--kpv-light-grey); }
.pub-dot.is-on { background: var(--kpv-emerald); }
.pub-dot.is-later { background: transparent; box-shadow: inset 0 0 0 2px var(--kpv-emerald); }
.more-images { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--kpv-very-light-grey); max-height: 16rem; overflow-y: auto; }
.more-head { margin: 2px 12px 4px; font-size: .78rem; color: var(--kpv-medium-grey); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.more-image { display: flex; align-items: center; gap: 4px; padding: 0 0 0 12px; }
.more-image-q { flex: 1; min-width: 0; max-width: 14rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .88rem; color: var(--kpv-dark-grey); }
.more-items .more-image a { width: auto; padding: 6px 8px; font-size: .85rem; color: var(--kpv-primary); }
