body {
  min-width: 1024px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.login {
  max-width: 380px;
  margin: 12vh auto;
}

.login form > * + * {
  margin-top: 12px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: var(--accent-soft);
}

.num {
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--border);
  white-space: nowrap;
}

.badge-scheduled {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-running {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-finished {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-published {
  background: var(--ok-soft);
  color: var(--ok);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  border: none;
  background: none;
  padding: 10px 16px;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  color: var(--muted);
}

.tab[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.savebar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 0 0 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.dirty {
  color: var(--warn);
  font-weight: 600;
}

.question {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface);
}

.question.has-problem {
  border-color: var(--bad);
}

.question-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.question-head h3 {
  margin: 0;
  flex: 1;
  font-size: 1rem;
}

.icon-btn {
  min-height: 32px;
  padding: 2px 10px;
  font-size: 0.9rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.option-row input[type='text'] {
  flex: 1;
}

.option-row .correct-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 0.9rem;
}

.thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.thumb {
  position: relative;
}

.thumb img {
  display: block;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  min-height: 24px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.problems {
  margin: 8px 0 0;
  padding-left: 1.2em;
  color: var(--bad);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.segmented label {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.92rem;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label.on {
  background: var(--accent);
  color: var(--accent-text);
}

.qr-box {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.qr-box img {
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.join-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

.stat-big {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: flex;
  gap: 40px;
}

.meter {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}

.meter > div {
  height: 100%;
  background: var(--accent);
}

.option-stat.correct {
  color: var(--ok);
  font-weight: 600;
}

.print-invite {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 20mm;
  }

  body {
    min-width: 0;
    background: #fff;
    color: #000;
  }

  /* Print only the invitation. Everything that neither is nor contains it is removed from the layout,
     so the rest of the panel cannot add blank pages. */
  body *:not(:has(.print-invite)):not(.print-invite):not(.print-invite *) {
    display: none !important;
  }

  #root,
  .page {
    margin: 0;
    padding: 0;
    max-width: none;
  }

  .print-invite {
    display: block;
    text-align: center;
    color: #000;
  }

  .print-invite h1 {
    font-size: 26pt;
    margin: 0 0 4mm;
  }

  .print-invite .when {
    font-size: 15pt;
    margin: 0 0 6mm;
  }

  .print-invite .quiz-qr {
    width: 100mm;
    height: 100mm;
  }

  .print-invite .app-box {
    display: flex;
    gap: 6mm;
    align-items: center;
    margin-top: 8mm;
    padding: 5mm;
    border: 0.4mm solid #000;
    border-radius: 3mm;
    text-align: left;
    break-inside: avoid;
  }

  .print-invite .app-qr {
    flex: none;
    width: 38mm;
    height: 38mm;
  }

  .print-invite .app-text h2 {
    font-size: 14pt;
    margin: 0 0 2mm;
  }

  .print-invite .app-text p,
  .print-invite .app-text li {
    font-size: 10.5pt;
    line-height: 1.35;
    margin: 0 0 1.5mm;
  }

  .print-invite .app-text ul {
    margin: 0 0 1.5mm;
    padding-left: 5mm;
  }

  .print-invite .url {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12pt;
    margin: 2mm 0 0;
    word-break: break-all;
  }

  .print-invite .hint {
    font-size: 12pt;
    margin: 4mm 0 0;
  }
}
