:root {
  color-scheme: dark;
  --bg: #000;
  --card: #1c1c1e;
  --text: #f5f5f7;
  --muted: rgba(255, 255, 255, 0.55);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #007aff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100dvh;
}

body.page {
  overflow: auto;
}

body:not(.page) {
  overflow: hidden;
}

/* —— Shared chrome (host / join) —— */

.wrap {
  width: min(42rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

label,
input,
button {
  font: inherit;
}

input {
  width: 100%;
  height: 3.5rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--card);
  color: var(--text);
  padding: 0 1rem;
  font-size: 1.1rem;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--text);
  color: #111;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

button.ghost,
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.stack {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.error {
  color: #ff7b72;
}

.muted {
  color: var(--muted);
}

/* —— Present projector (16:9 or 9:16 composition) —— */

.present-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
}

.present-stage {
  width: 1920px;
  height: 1080px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--present-scale, 1));
  transform-origin: 50% 50%;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Content uses most of the stage so a faithful mini-TV still reads large. */
.present-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 64px 96px 72px;
  text-align: left;
  position: relative;
}

.present-frame.is-centered {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.present-frame .kicker {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.present-frame.has-timer .meta-row,
.present-frame.has-timer .headline {
  padding-right: 228px;
}

.present-frame .meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 28px;
}

.present-frame .meta-row .kicker {
  font-size: 26px;
}

.present-frame .meta-aside {
  font-size: 28px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.present-frame .headline {
  margin: 0;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.08;
  text-wrap: balance;
  max-width: 100%;
}

.present-frame.is-centered .headline {
  font-size: 96px;
  max-width: 1600px;
}

.present-frame .timer {
  position: absolute;
  top: 48px;
  right: 72px;
  width: 196px;
  height: 196px;
  margin: 0;
  color: var(--text);
}

.present-frame .timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.present-frame .timer-track,
.present-frame .timer-progress {
  fill: none;
  stroke-width: 10;
}

.present-frame .timer-track {
  stroke: rgba(255, 255, 255, 0.14);
}

.present-frame .timer-progress {
  stroke: var(--accent);
  stroke-linecap: round;
}

.present-frame .timer.is-low .timer-progress {
  stroke: #ff9f0a;
}

.present-frame .timer.is-critical .timer-progress {
  stroke: #ff453a;
}

.present-frame .timer-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.present-frame .code {
  margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 120px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.present-frame .qr {
  width: 480px;
  height: 480px;
  margin: 0 auto;
  padding: 18px;
  background: #fff;
  border-radius: 24px;
}

.present-frame .join-url {
  margin: 32px 0 0;
  font-size: 36px;
  color: rgba(255, 255, 255, 0.45);
  word-break: break-all;
}

.present-frame .options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: auto;
  padding-top: 40px;
  width: 100%;
}

.present-frame .options.cols-1 {
  grid-template-columns: 1fr;
}

.present-frame .bar {
  text-align: left;
  background: var(--card);
  border-radius: 24px;
  padding: 36px 40px;
  border: 1px solid transparent;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transform-origin: center;
  animation: present-option-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 75ms);
}

.present-stage:not(.is-portrait)
  .present-frame
  .options:not(.cols-1)
  .bar:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  width: calc((100% - 28px) / 2);
  justify-self: center;
}

@keyframes present-option-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .present-frame .bar {
    animation: none;
  }
}

.present-frame .bar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.present-frame .bar-label {
  margin: 0;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.25;
}

.present-frame .bar-pct {
  margin: 0;
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.present-frame .bar-track {
  margin-top: 20px;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.present-frame .bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  width: 0%;
}

.present-frame .footer-note {
  margin: 28px 0 0;
  text-align: center;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.4);
}

/* Portrait / Vertical 9:16 (1080×1920 stage) */
.present-stage.is-portrait .present-frame {
  padding: 80px 64px 96px;
}

.present-stage.is-portrait .present-frame .headline {
  font-size: 64px;
}

.present-stage.is-portrait .present-frame.is-centered .headline {
  font-size: 80px;
  max-width: 100%;
}

.present-stage.is-portrait .present-frame .code {
  font-size: 140px;
}

.present-stage.is-portrait .present-frame .qr {
  width: 640px;
  height: 640px;
  padding: 22px;
  border-radius: 28px;
}

.present-stage.is-portrait .present-frame .join-url {
  margin-top: 40px;
  font-size: 40px;
}

.present-stage.is-portrait .present-frame.has-timer .meta-row,
.present-stage.is-portrait .present-frame.has-timer .headline {
  padding-right: 196px;
}

.present-stage.is-portrait .present-frame .timer {
  width: 168px;
  height: 168px;
  top: 56px;
  right: 48px;
}

.present-stage.is-portrait .present-frame .timer-count {
  font-size: 60px;
}

.present-stage.is-portrait .present-frame .options {
  grid-template-columns: 1fr;
  gap: 24px;
  padding-top: 48px;
}

.present-stage.is-portrait .present-frame .bar {
  min-height: 168px;
  padding: 40px 44px;
}

/* Host/join pages still use the older compact stage helpers. */
.kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

h1 {
  margin: 0.4rem 0 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 700;
}

.code {
  margin: 1.25rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: 0.12em;
}

/* Host room: the live question, big enough to read aloud from a phone. */
.host-question {
  margin: 1.25rem 0 0;
  font-size: clamp(1.6rem, 5.5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.host-option {
  padding: 0.85rem 1rem;
  background: var(--card);
  border-radius: 0.9rem;
}

/* On a phone a long option list pushes the controls below the fold right
   when the host needs them, so keep them parked at the bottom edge. */
@media (max-width: 640px) {
  .host-controls {
    position: sticky;
    bottom: 0;
    margin-top: 1rem;
    padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 0.75rem);
  }
}

.qr {
  width: min(18rem, 70vw);
  height: auto;
  margin: 1.25rem auto 0;
  padding: 0.75rem;
  background: #fff;
  border-radius: 1rem;
}

.options {
  display: grid;
  gap: 0.7rem;
  width: min(40rem, 100%);
  margin-top: 1.5rem;
}

.option,
.bar {
  text-align: left;
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid transparent;
}

.option {
  width: 100%;
  color: var(--text);
}

.option[disabled] {
  opacity: 0.7;
  cursor: default;
}

.option.picked {
  border-color: var(--accent);
}

.bar-fill {
  height: 0.4rem;
  margin-top: 0.6rem;
  border-radius: 99px;
  background: var(--accent);
}

/* —— Account / form pages —— */

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1rem;
}

/* Two equal buttons sharing one row of a `.stack`. */
.row-actions.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0;
}

.poll-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
}

.poll-card .muted {
  margin: 0.25rem 0 0;
}

.editor-meta {
  display: grid;
  grid-template-columns: 1fr 11rem;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .editor-meta {
    grid-template-columns: 1fr;
  }
}

.question-block {
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
}

/* Fields sit on the card colour, so they need their own edge to read as inputs. */
.question-block input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}

.question-block > .row-actions,
.row-actions.between {
  justify-content: space-between;
  margin-top: 0;
}

.row-actions.compact {
  gap: 0.4rem;
  margin-top: 0;
}

button.icon {
  min-width: 2.6rem;
  padding: 0;
  font-size: 1.1rem;
}

button[disabled] {
  opacity: 0.35;
  cursor: default;
}

/* "Seconds [ 45 ]" beside Add option. */
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.inline-field input {
  width: 5.5rem;
  height: 3rem;
}

.option-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.1rem;
  border-radius: 0.9rem;
  background: var(--text);
  color: #111;
  font-weight: 650;
  text-decoration: none;
}

a.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
