/* Quizzes (apps.quizzes): the staff subject page's Quizzes section, the quiz
   builder and "Preview as a student" (boards Q3-LecturerQuizzes, Q3-Builder,
   Q3-StudentQuestion, Q3-StudentQuestionMultiAr). The question itself
   (.quiz-question, .quiz-choice, .quiz-timer) is what the student's own page
   draws too. Tokens only; logical properties, so Arabic mirrors by itself. */

@layer components {
  /* --- The Quizzes section of a subject (the list) ------------------------------- */

  .quiz-tab {
    margin-block-start: var(--space-5);
  }

  .quiz-tab__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
  }

  .quiz-tab__title {
    font-size: var(--text-body);
  }

  .quiz-tab__table {
    margin-block-start: var(--space-4);
  }

  .quiz-tab__done {
    margin-block-start: var(--space-4);
  }

  .quiz-table td {
    block-size: 52px;
  }

  .quiz-table td:first-child,
  .quiz-table td:nth-child(5) {
    white-space: nowrap;
  }

  /* Why a quiz is still a draft, under its chip. */
  .quiz-table__reason {
    display: block;
    margin-inline-start: 0;
    margin-block-start: var(--space-1);
  }

  /* --- The bar above the builder: the way back, the state, the preview ----------- */

  .quiz-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    margin-block: var(--space-5) var(--space-3);
  }

  .quiz-bar__back {
    margin-inline-start: calc(-1 * var(--space-3));
    padding-inline: var(--space-3) var(--space-4);
  }

  .quiz-bar__end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }

  .quiz-bar__state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .quiz-state {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
  }

  /* --- The quiz's own settings ---------------------------------------------------- */

  .quiz-settings__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--space-5) var(--space-6);
  }

  .quiz-settings__title {
    margin-block-end: var(--space-4);
    font-size: var(--text-body);
  }

  .quiz-settings__legend {
    margin-block-end: var(--space-2);
  }

  .quiz-settings__errors:not(:empty) {
    margin-block-start: var(--space-4);
  }

  .quiz-settings .actions {
    margin-block-start: var(--space-5);
  }

  /* "Archive quiz" at the card's end, apart from the settings that save by themselves. */
  .quiz-settings__more {
    display: flex;
    justify-content: flex-end;
    margin-block-start: var(--space-4);
    padding-block-start: var(--space-3);
    border-block-start: 1px solid var(--attend-border);
  }

  .quiz-seconds {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  input.quiz-number {
    inline-size: 88px;
  }

  @media (min-width: 768px) {
    .quiz-settings__grid {
      grid-template-columns: minmax(0, 1fr) auto auto;
    }
  }

  /* --- The questions -------------------------------------------------------------- */

  .quiz-questions__error {
    margin-block-start: var(--space-4);
  }

  .quiz-list {
    margin: var(--space-4) 0 0;
    padding: 0;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
    list-style: none;
  }

  .quiz-item + .quiz-item {
    border-block-start: 1px solid var(--attend-border);
  }

  /* The open question: a brand edge on the side reading starts from. */
  .quiz-item--open {
    border-inline-start: 3px solid var(--attend-brand);
  }

  .quiz-item:first-child.quiz-item--open {
    border-start-start-radius: var(--r-lg);
  }

  .quiz-item:last-child.quiz-item--open {
    border-end-start-radius: var(--r-lg);
  }

  .quiz-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 60px;
    padding: var(--space-2) var(--space-4);
  }

  .quiz-item--open > .quiz-row,
  .quiz-item--open > .quiz-editor,
  .quiz-item--open > .quiz-confirm {
    padding-inline-start: calc(var(--space-4) - 3px);
  }

  .quiz-row__n {
    flex: none;
    min-inline-size: 2ch;
    color: var(--attend-text-muted);
    font-weight: var(--weight-strong);
    font-variant-numeric: tabular-nums;
    text-align: center;
  }

  .quiz-row__body {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .quiz-row__title {
    display: block;
    overflow: hidden;
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quiz-row__meta {
    margin-block-start: var(--space-05);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .quiz-row__warning {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-inline-start: var(--space-3);
    color: var(--attend-warning-text);
    font-weight: var(--weight-bold);
  }

  .quiz-grip {
    flex: none;
    color: var(--attend-text-muted);
    cursor: grab;
    touch-action: none;
  }

  .quiz-row__form {
    flex: none;
  }

  .quiz-row__action {
    flex: none;
    padding-inline: var(--space-3);
  }

  /* A question being dragged, and the place it would land. */
  .quiz-item--moving {
    background: var(--attend-row-selected);
  }

  .quiz-item--moving .quiz-grip {
    cursor: grabbing;
  }

  /* A phone has no room for four worded row actions: the words stay for a
     screen reader, the icons carry the row. */
  @media (max-width: 599px) {
    .quiz-row {
      gap: var(--space-1);
      padding-inline: var(--space-2);
    }

    .quiz-row__body {
      margin-inline: var(--space-2);
    }

    .quiz-row__word {
      position: absolute;
      inline-size: 1px;
      block-size: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    .quiz-row__action {
      justify-content: center;
      min-inline-size: var(--touch);
      padding-inline: 0;
    }

    /* Two lines of the question instead of a few words of it. */
    .quiz-row__title {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      overflow-wrap: anywhere;
      white-space: normal;
    }

    .quiz-row__warning {
      display: flex;
      margin-inline-start: 0;
    }
  }

  .quiz-questions__add {
    margin-block-start: var(--space-4);
  }

  .quiz-confirm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    padding: var(--space-2) var(--space-4) var(--space-4);
  }

  /* --- The open question's form --------------------------------------------------- */

  .quiz-editor {
    padding-block: var(--space-2) var(--space-5);
    padding-inline: var(--space-4);
  }

  .quiz-editor__top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-5) var(--space-6);
  }

  .segmented.quiz-editor__kinds {
    max-inline-size: none;
    grid-auto-columns: auto;
  }

  .quiz-editor__kinds .segmented__option {
    white-space: nowrap;
  }

  .quiz-editor__main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--space-5) var(--space-6);
  }

  .quiz-editor__ask {
    display: grid;
    gap: var(--space-5);
  }

  @media (min-width: 1024px) {
    .quiz-editor__main {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    }
  }

  /* Three answer types do not fit one row of a narrow phone: they stack. */
  @media (max-width: 479px) {
    .segmented.quiz-editor__kinds {
      display: grid;
      grid-auto-flow: row;
      border-radius: var(--r-md);
    }
  }

  .quiz-picture {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .quiz-picture__thumb,
  .quiz-choices__thumb {
    flex: none;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-sm);
    background: var(--attend-inactive-bg);
    object-fit: contain;
  }

  .quiz-picture__thumb {
    inline-size: 96px;
    block-size: 72px;
  }

  .quiz-choices__thumb {
    inline-size: 56px;
    block-size: 44px;
  }

  .quiz-picture__text {
    min-inline-size: 0;
  }

  .quiz-picture__actions {
    margin-inline-start: calc(-1 * var(--space-3));
  }

  .quiz-picture__actions .btn {
    padding-inline: var(--space-3);
  }

  /* A label that is the button of its own (visually hidden) file field. */
  .quiz-upload {
    cursor: pointer;
  }

  .quiz-upload:focus-within {
    outline: 2px solid var(--attend-focus);
    outline-offset: 3px;
  }

  .quiz-choices {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-2);
  }

  .quiz-col {
    color: var(--attend-text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    letter-spacing: var(--tracking-label);
    line-height: var(--leading-label);
  }

  .quiz-col--tick {
    text-align: center;
  }

  .quiz-choices__tick {
    display: grid;
    place-items: center;
  }

  .quiz-choices__text {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
  }

  .quiz-choices__text input {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .quiz-choices__fixed {
    color: var(--attend-text-strong);
    font-weight: var(--weight-bold);
  }

  .quiz-choices__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    margin-block-start: var(--space-2);
  }

  .quiz-choices__add {
    margin-inline-start: calc(-1 * var(--space-3));
    padding-inline: var(--space-3) var(--space-4);
  }

  @media (min-width: 768px) {
    .quiz-choices {
      grid-template-columns: 72px minmax(0, 1fr) auto auto;
    }
  }

  /* On a phone the words get the width: no column headings (the line under
     the choices says what the tick means), and a choice's picture sits above
     its words. */
  @media (max-width: 599px) {
    .quiz-item--open > .quiz-editor {
      padding-inline: var(--space-3);
    }

    .quiz-choices {
      grid-template-columns: var(--touch) minmax(0, 1fr) auto auto;
      gap: var(--space-1);
    }

    .quiz-col {
      display: none;
    }

    .quiz-choices__text {
      flex-wrap: wrap;
    }

    .quiz-choices__text input {
      flex-basis: 100%;
    }
  }

  /* --- Preview as a student: a phone-wide frame ----------------------------------- */

  .quiz-preview__note {
    margin-block-end: var(--space-4);
  }

  .quiz-phone {
    display: flex;
    flex-direction: column;
    max-inline-size: 420px;
    margin-inline: auto;
    overflow: hidden;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-ground);
  }

  .quiz-phone__head {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-block-size: 56px;
    padding: var(--space-2) var(--space-5);
    border-block-end: 1px solid var(--attend-border);
  }

  .quiz-phone__title {
    overflow: hidden;
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quiz-phone__body {
    padding: var(--space-5) var(--space-5) var(--space-6);
  }

  .quiz-phone__actions {
    justify-content: center;
    margin-block-start: var(--space-4);
  }

  .quiz-phone__foot {
    padding: var(--space-3) var(--space-5) var(--space-5);
    border-block-start: 1px solid var(--attend-border);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-bar);
  }

  .quiz-phone__rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-block-end: var(--space-3);
  }

  /* --- One question, as a student sees it ----------------------------------------- */

  .quiz-question__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }

  .quiz-question__progress {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .section-label.quiz-question__count {
    margin: 0;
  }

  .quiz-steps {
    display: flex;
    gap: var(--space-1);
    margin-block-start: var(--space-3);
  }

  .quiz-step {
    flex: 1 1 0;
    block-size: 6px;
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
  }

  .quiz-step--done {
    background: var(--attend-accent);
  }

  /* The current question: a ring, not a colour alone. */
  .quiz-step--now {
    outline: 2px solid var(--attend-accent);
    outline-offset: 1px;
  }

  .quiz-timer {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--space-2);
  }

  .quiz-timer__ring {
    position: relative;
    inline-size: 64px;
    block-size: 64px;
  }

  .ring.quiz-timer__svg {
    inline-size: 64px;
    block-size: 64px;
  }

  .quiz-timer__n {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-size: var(--text-num-m);
    font-weight: var(--weight-display);
    line-height: 1;
  }

  .quiz-timer__word {
    max-inline-size: 7ch;
    color: var(--attend-text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-bold);
    line-height: var(--leading-label);
  }

  /* The picture's box comes from its width and height attributes, so the
     choices and "Send answer" never move when it arrives. */
  .quiz-question__picture {
    margin: var(--space-5) 0 0;
    overflow: hidden;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-inactive-bg);
  }

  /* A tall picture is fitted into the box, so the choices stay on the screen. */
  .quiz-question__picture img {
    display: block;
    inline-size: 100%;
    block-size: auto;
    max-block-size: 45vh;
    object-fit: contain;
  }

  .quiz-question__set {
    margin-block-start: var(--space-6);
  }

  .quiz-question__picture + .quiz-question__set {
    margin-block-start: var(--space-5);
  }

  .quiz-question__text {
    inline-size: 100%;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-num-m);
    font-weight: var(--weight-h2);
    letter-spacing: var(--tracking-h2);
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .quiz-question__note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-block-start: var(--space-2);
    color: var(--attend-text);
  }

  .quiz-question__note .icon {
    flex: none;
    margin-block-start: var(--space-05);
    color: var(--attend-info-text);
  }

  .quiz-answers {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-block-start: var(--space-5);
  }

  .quiz-question__note + .quiz-answers {
    margin-block-start: var(--space-4);
  }

  .quiz-choice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-sizing: border-box;
    min-block-size: 64px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
    color: var(--attend-text-strong);
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    line-height: var(--leading-body);
    cursor: pointer;
  }

  /* The chosen answer: a heavier frame and weight as well as the tint. */
  .quiz-choice:has(input:checked) {
    border-color: var(--attend-accent);
    outline: 1px solid var(--attend-accent);
    background: var(--attend-row-selected);
    font-weight: var(--weight-strong);
  }

  .quiz-choice:has(input:focus-visible) {
    outline: 2px solid var(--attend-focus);
    outline-offset: 3px;
  }

  /* A larger box for a thumb; the whole 64px row is the target. */
  .quiz-choice input[type="checkbox"],
  .quiz-choice input[type="radio"] {
    inline-size: 22px;
    block-size: 22px;
  }

  /* The author's words take their own direction (an Arabic choice in an
     English page starts from the right). */
  .quiz-choice > span {
    flex: 1 1 auto;
    min-inline-size: 0;
    overflow-wrap: anywhere;
    unicode-bidi: plaintext;
  }

  /* A choice's picture: its width is set, so its height follows from the
     stored width and height before the file arrives. */
  .quiz-choice__picture {
    flex: none;
    inline-size: min(45%, 160px);
    block-size: auto;
    border-radius: var(--r-xs);
  }

  /* --- The quiz list's row action ------------------------------------------------- */

  .quiz-table__actions {
    text-align: end;
  }

  .quiz-table__actions .btn {
    white-space: nowrap;
  }

  /* Phone: each quiz is a card (table--cards), so nothing is cut off sideways. */
  @media (max-width: 767px) {
    .quiz-table td {
      block-size: auto;
    }

    .quiz-table td:first-child,
    .quiz-table td:nth-child(5) {
      white-space: normal;
    }

    .quiz-table__actions:empty {
      display: none;
    }
  }

  /* --- The Start dialog (board Q3-StartDialog) ----------------------------------- */

  /* The ready quizzes, one under the other. */
  .quiz-start .quiz-start__options {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
  }

  .quiz-start__option > label {
    align-items: flex-start;
    padding-block: var(--space-2);
  }

  .quiz-start__option > label > input {
    margin-block-start: 2px;
  }

  .quiz-start__name,
  .quiz-start__meta,
  .quiz-start__count-main,
  .quiz-start__count .small,
  .quiz-start__close-help {
    display: block;
  }

  .quiz-start__name {
    color: var(--attend-text-strong);
    font-size: var(--text-body);
    font-weight: var(--weight-strong);
  }

  /* A quiz that has already run: its warning shows while it is the chosen one. */
  .quiz-start__warning {
    display: none;
    margin-block: var(--space-1) var(--space-2);
  }

  .quiz-start__option:has(input:checked) .quiz-start__warning {
    display: flex;
  }

  .quiz-start__join {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .quiz-start__join input {
    inline-size: 88px;
  }

  .quiz-start__count {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .quiz-start__count .icon {
    flex: none;
    margin-block-start: 1px;
    color: var(--attend-brand-text);
  }

  .quiz-start__count-main {
    color: var(--attend-text-strong);
    font-weight: var(--weight-bold);
  }

  /* --- The run page (board Q3-Run) ------------------------------------------------ */

  /* The count and its bar beside the five numbers; one column on a phone. */
  .quiz-run__main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: var(--space-6) var(--space-10);
  }

  @media (min-width: 760px) {
    .quiz-run__main {
      grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    }
  }

  /* How many have reached each of their questions: as many tiles as fit a row. */
  .quiz-reach-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
  }

  .quiz-reach {
    box-sizing: border-box;
    min-inline-size: 0;
    padding: var(--space-3);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-surface);
  }

  .quiz-reach__label {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    white-space: nowrap;
  }

  .quiz-reach__count {
    color: var(--attend-text-strong);
    font-size: var(--text-num-m);
    font-weight: var(--weight-num-m);
    line-height: var(--leading-num-m);
    font-variant-numeric: tabular-nums;
  }

  .quiz-reach .round-progress {
    max-inline-size: none;
    margin-block-start: var(--space-2);
  }

  /* --- The quiz results (board Q3-Results) ---------------------------------------- */

  .quiz-results__summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: var(--space-5) var(--space-8);
  }

  .quiz-results__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--space-6);
    margin-block-start: var(--space-6);
  }

  @media (min-width: 900px) {
    .quiz-results__summary {
      grid-template-columns: minmax(0, 1fr) minmax(300px, 356px);
    }

    .quiz-results__body {
      grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    }
  }

  .quiz-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-10);
    margin: 0;
  }

  .quiz-stat__label {
    color: var(--attend-text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    letter-spacing: var(--tracking-label);
    line-height: var(--leading-label);
  }

  .quiz-stat__value {
    margin-block-start: var(--space-1);
    margin-inline: 0;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .quiz-stat__value small {
    color: var(--attend-text-muted);
    font-family: var(--font-body);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
  }

  .quiz-results__send-button {
    inline-size: 100%;
  }

  .quiz-results__send > p,
  .quiz-results__send > form + form {
    margin-block-start: var(--space-2);
  }

  .quiz-results__sent {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--attend-text-strong);
    font-weight: var(--weight-bold);
  }

  .quiz-results__sent .icon {
    flex: none;
    color: var(--attend-brand-text);
  }

  .quiz-results__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .quiz-results__title {
    font-size: var(--text-body);
  }

  .quiz-results__table {
    margin-block-start: var(--space-4);
  }

  .quiz-results__note {
    margin-block-start: var(--space-1);
  }

  .quiz-hard-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin: var(--space-5) 0 0;
  }

  .quiz-hard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    align-items: center;
    gap: var(--space-1) var(--space-3);
  }

  .quiz-hard__text {
    color: var(--attend-text-strong);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    line-height: var(--leading-small);
    text-wrap: pretty;
  }

  .quiz-hard__pct {
    grid-row: span 2;
    color: var(--attend-text-strong);
    font-size: var(--text-body);
    font-weight: var(--weight-strong);
    font-variant-numeric: tabular-nums;
    text-align: end;
  }

  .quiz-hard .round-progress {
    max-inline-size: none;
    margin-block-start: 0;
  }

  /* --- The student's quiz page (boards Q3-StudentQuestion, Q3-StudentQuestionMultiAr) --
     Its own slim header, the question, and "Send answer" held at the foot of
     the screen. The page is the phone: the frame of the preview without its
     border. */

  .quiz-take-page {
    background: var(--attend-ground);
  }

  .quiz-take {
    display: flex;
    flex-direction: column;
    max-inline-size: 560px;
    min-block-size: 100vh;
    min-block-size: 100dvh;
    margin-inline: auto;
  }

  .quiz-take__head {
    padding-block-start: max(var(--space-2), env(safe-area-inset-top));
  }

  .quiz-take__main {
    flex: 1 1 auto;
  }

  .quiz-take__state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-block-size: 50vh;
  }

  .quiz-take__state--wait {
    align-items: center;
  }

  .quiz-take__actions {
    margin-block-start: var(--space-5);
  }

  .quiz-take__foot {
    position: sticky;
    inset-block-end: 0;
    padding-block-end: max(var(--space-5), env(safe-area-inset-bottom));
  }

  /* One line for "Sending…", "Saved" and the late note; its height is kept, so
     the button under the thumb never moves. */
  .quiz-take__note {
    display: flex;
    align-items: center;
    justify-content: center;
    min-block-size: var(--leading-small);
    margin-block-end: var(--space-2);
    color: var(--attend-text);
    font-weight: var(--weight-bold);
  }

  .quiz-take__note > span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }

  .quiz-take__note > span[hidden] {
    display: none;
  }

  .quiz-take__late {
    color: var(--attend-danger-text);
  }

  /* The last ten seconds: a heavier ring and a frame round the number, as well
     as the colour (never colour alone). Nothing moves. */
  .quiz-timer[data-low] .ring__value {
    stroke: var(--attend-warning-text);
    stroke-width: 9;
  }

  .quiz-timer[data-low] .quiz-timer__n {
    inset: 14px;
    border: 2px solid var(--attend-warning-text);
    border-radius: 50%;
    font-weight: var(--weight-strong);
  }

  .quiz-timer[data-low] .quiz-timer__word {
    color: var(--attend-text-strong);
  }

  /* A question's time is over or its answer is on its way: the choices stay
     readable and cannot be changed. */
  .quiz-question[data-locked] .quiz-choice {
    cursor: default;
    box-shadow: none;
  }

  /* --- Today: "Quiz open now" (board Q3-StudentJoin) ---------------------------------- */

  .quiz-card {
    margin-block-end: var(--space-6);
    border-radius: var(--r-xl);
  }

  .quiz-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
  }

  .quiz-card__left {
    color: var(--attend-text-strong);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
  }

  /* The clock keeps its width as its digits change. */
  .quiz-card__clock {
    display: inline-block;
    min-inline-size: 4ch;
  }

  .quiz-card__subject {
    margin-block-start: var(--space-4);
    font-weight: var(--weight-bold);
  }

  .quiz-card__title {
    margin-block-start: var(--space-1);
    font-size: var(--text-h1);
    font-weight: var(--weight-h1);
    line-height: var(--leading-h1);
    letter-spacing: var(--tracking-h1);
    overflow-wrap: anywhere;
  }

  .quiz-card__facts {
    margin-block-start: var(--space-2);
  }

  .quiz-card__join {
    margin-block-start: var(--space-5);
  }

  .quiz-card__rule {
    margin-block-start: var(--space-3);
    text-align: center;
  }

  /* --- Finished: the score (board Q3-StudentFinish) ----------------------------------- */

  .quiz-finish {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-6) var(--space-5);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-xl);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
    text-align: center;
  }

  .quiz-finish__disc {
    display: grid;
    place-items: center;
    inline-size: 72px;
    block-size: 72px;
    border-radius: 50%;
    background: var(--attend-positive-solid);
    color: var(--attend-on-brand);
  }

  .quiz-finish__disc .icon {
    inline-size: 36px;
    block-size: 36px;
    stroke-width: 3;
  }

  .quiz-finish h1 {
    margin-block-start: var(--space-4);
  }

  .quiz-finish__what,
  .quiz-finish__facts {
    margin-block-start: var(--space-1);
  }

  .section-label.quiz-finish__label {
    margin: var(--space-6) 0 0;
  }

  .quiz-finish__next {
    margin-block: var(--space-5);
  }

  /* A mark out of its full mark: the number strong, "/ 8" quieter. */
  .quiz-score {
    margin-block-start: var(--space-1);
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-display);
    font-weight: var(--weight-display);
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-num-xl);
  }

  .quiz-score--xl {
    font-size: var(--text-num-xl);
    font-weight: var(--weight-num-xl);
    line-height: var(--leading-num-xl);
  }

  .quiz-score__of {
    color: var(--attend-text-muted);
    font-weight: var(--weight-h2);
  }

  /* --- The answers, after the close (board Q3-StudentReview) ------------------------- */

  .quiz-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }

  .section-label.quiz-result__label {
    margin: 0;
  }

  .quiz-result__counts {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* A verdict in words with its own shape of icon: never colour alone. */
  .quiz-word {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-label);
    font-weight: var(--weight-strong);
    line-height: var(--leading-label);
    white-space: nowrap;
  }

  .quiz-word .icon {
    inline-size: 14px;
    block-size: 14px;
  }

  .quiz-word--ok {
    color: var(--attend-positive-text);
  }

  .quiz-word--no {
    color: var(--attend-danger-text);
  }

  .quiz-word--part {
    color: var(--attend-warning-text);
  }

  .quiz-rev {
    padding: var(--space-4);
    border: 1px solid var(--attend-card-edge);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .quiz-rev + .quiz-rev {
    margin-block-start: var(--space-3);
  }

  .quiz-rev__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-block-size: 28px;
  }

  .quiz-rev__n {
    color: var(--attend-text-muted);
    font-family: var(--font-body);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    line-height: var(--leading-label);
    letter-spacing: var(--tracking-label);
  }

  .quiz-rev__end {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .quiz-rev__mark {
    color: var(--attend-text-strong);
    font-size: var(--text-small);
    font-weight: var(--weight-strong);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .quiz-rev__q {
    margin-block-start: var(--space-2);
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
    overflow-wrap: anywhere;
    unicode-bidi: plaintext;
  }

  .quiz-rev__picture {
    margin: var(--space-3) 0 0;
    overflow: hidden;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-sm);
    background: var(--attend-inactive-bg);
  }

  .quiz-rev__picture img {
    display: block;
    inline-size: 100%;
    block-size: auto;
    max-block-size: 200px;
    object-fit: contain;
  }

  .quiz-rev__thumb {
    flex: none;
    inline-size: min(40%, 120px);
    block-size: auto;
    border-radius: var(--r-xs);
  }

  .quiz-rev__ans {
    display: grid;
    grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
    gap: var(--space-2) var(--space-3);
    margin: var(--space-3) 0 0;
  }

  .quiz-rev__ans dt {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-body);
  }

  .quiz-rev__ans dd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    color: var(--attend-text-strong);
    overflow-wrap: anywhere;
  }

  .quiz-rev__ans dd > .icon {
    flex: none;
    color: var(--attend-positive-text);
  }

  .quiz-rev__note {
    margin-block-start: var(--space-3);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .quiz-rev__opts {
    margin: var(--space-1) 0 0;
    padding: 0;
    list-style: none;
  }

  .quiz-rev__opt {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-sizing: border-box;
    min-block-size: 36px;
    padding-block: var(--space-1);
  }

  .quiz-rev__text {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
    color: var(--attend-text-strong);
    overflow-wrap: anywhere;
  }

  /* What the student ticked: a filled box with a tick, an empty box otherwise. */
  .quiz-tick {
    display: grid;
    flex: none;
    place-items: center;
    box-sizing: border-box;
    inline-size: 20px;
    block-size: 20px;
    border: 1.5px solid var(--attend-border-strong);
    border-radius: var(--r-check);
    background: var(--attend-surface);
    color: var(--attend-on-brand);
  }

  .quiz-tick--on {
    border-color: var(--attend-accent);
    background: var(--attend-accent);
  }

  .quiz-tick .icon {
    inline-size: 14px;
    block-size: 14px;
    stroke-width: 3;
  }

  /* --- The student's Quizzes section of a subject (board Q3-SubjectQuizzes) ----------- */

  .quiz-mine-list {
    margin-block-start: var(--space-4);
  }

  .quiz-mine {
    position: relative;
    flex-wrap: nowrap;
    align-items: center;
  }

  .quiz-mine__main {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .quiz-mine__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-block-start: var(--space-2);
  }

  .quiz-new {
    display: inline-flex;
    align-items: center;
    min-block-size: 24px;
    padding-inline: var(--space-2);
    border-radius: var(--r-pill);
    background: var(--attend-info-bg);
    color: var(--attend-info-text);
    font-size: var(--text-label);
    font-weight: var(--weight-strong);
    line-height: var(--leading-label);
    white-space: nowrap;
  }

  .quiz-mine__end {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
  }

  .quiz-mine__mark {
    color: var(--attend-text-strong);
    font-size: var(--text-num-m);
    font-weight: var(--weight-num-m);
    line-height: var(--leading-num-m);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* The whole row opens the answers. */
  .quiz-mine .day-link::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .quiz-mine__about {
    margin-block-start: var(--space-4);
  }

  /* --- The quiz on the projector (boards Q3-ProjectorOpen, Q3-ProjectorClosed) ---
     The page reuses the check-in presenter's frame and tools (.presenter,
     .presenter__tools, .presenter__brand, .presenter__hint in lecturer.css);
     these rules add the progress card and the bars. */

  .quiz-projector__layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6) clamp(32px, 5vw, 80px);
    align-content: center;
  }

  .quiz-projector__card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(24px, 4vw, 48px);
    border-radius: var(--r-xl);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-raised);
  }

  .quiz-projector__count {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: clamp(96px, 18vw, 176px);
    line-height: 0.95;
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-num-xl);
  }

  .quiz-projector__of {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-block-start: var(--space-3);
    color: var(--attend-text);
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.3;
    font-weight: var(--weight-bold);
  }

  .quiz-projector__of .icon {
    flex: none;
    inline-size: 1em;
    block-size: 1em;
    margin-block-start: 0.15em;
    color: var(--attend-positive-text);
  }

  .quiz-projector__progress {
    flex: none;
    block-size: 16px;
    margin-block-start: var(--space-8);
  }

  .quiz-projector__timer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-block-start: var(--space-6);
  }

  .quiz-projector__timer-label {
    color: var(--attend-text);
    font-size: clamp(20px, 2.6vw, 26px);
    line-height: 1.3;
    font-weight: var(--weight-bold);
  }

  .quiz-projector__time {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: clamp(48px, 7vw, 80px);
    line-height: 1;
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-num-xl);
  }

  /* The words beside the card take the code presenter's billboard sizes
     (lecturer.css: --gap and the hint's clamps). */
  .quiz-projector__info {
    --gap: clamp(12px, 2.4vw, 24px);

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }

  .quiz-projector__title {
    margin-block-start: var(--space-8);
    color: var(--attend-text-strong);
    font-size: clamp(22px, 2.6vw, 28px);
    line-height: 1.2;
    font-weight: var(--weight-h2);
    letter-spacing: var(--tracking-h1);
    overflow-wrap: anywhere;
  }

  /* Closed: the question, a bar per choice, Previous / Question n of m / Next. */
  .quiz-projector__closed {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .quiz-projector__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
  }

  .quiz-projector__head .presenter__brand {
    font-size: 28px;
  }

  .quiz-projector__quiz {
    color: var(--attend-text-strong);
    font-size: clamp(18px, 2vw, 22px);
    line-height: 1.2;
    font-weight: var(--weight-h2);
    overflow-wrap: anywhere;
  }

  .quiz-projector__question {
    max-inline-size: 65rem;
    margin-block-start: clamp(20px, 5dvh, 44px);
    color: var(--attend-text-strong);
    font-size: clamp(26px, 3.4vw, 40px);
    line-height: 1.15;
    font-weight: var(--weight-h1);
    letter-spacing: var(--tracking-h1);
    overflow-wrap: anywhere;
    text-align: start;
    unicode-bidi: plaintext;
  }

  .quiz-projector__picture {
    margin-block-start: var(--space-4);
  }

  .quiz-projector__picture img {
    display: block;
    inline-size: auto;
    max-inline-size: min(100%, 40rem);
    block-size: auto;
    max-block-size: 28dvh;
    border-radius: var(--r-md);
  }

  .quiz-projector__few {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-block-start: var(--space-6);
    color: var(--attend-text-muted);
    font-size: clamp(18px, 2vw, 22px);
  }

  .quiz-projector__bars {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: var(--space-8) 0 0;
    padding: 0;
    list-style: none;
  }

  .quiz-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2) var(--space-6);
    min-height: 60px;
    margin: 0;
  }

  .quiz-bar__name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-4);
    color: var(--attend-text-strong);
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.2;
    font-weight: var(--weight-strong);
    overflow-wrap: anywhere;
  }

  .quiz-bar__picture {
    inline-size: auto;
    block-size: 56px;
    border-radius: var(--r-sm);
  }

  /* "Correct" in words and an icon, not in colour alone. */
  .quiz-bar__correct {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 36px;
    padding-inline: var(--space-3) var(--space-4);
    border-radius: var(--r-pill);
    background: var(--attend-positive-bg);
    color: var(--attend-positive-text);
    font-size: clamp(16px, 1.8vw, 20px);
    line-height: 1.2;
    font-weight: var(--weight-strong);
  }

  .quiz-bar__track {
    display: block;
    inline-size: 100%;
    block-size: 28px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
    overflow: hidden;
    appearance: none;
  }

  .quiz-bar__track::-webkit-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
  }

  /* A choice's fill in the quiet status colour (an indicator, 3:1 on the page);
     the correct choices' in the accent. */
  .quiz-bar__track::-webkit-progress-value {
    border-radius: var(--r-pill);
    background: var(--attend-inactive-text);
  }

  .quiz-bar__track::-moz-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-inactive-text);
  }

  .quiz-bar--correct .quiz-bar__track::-webkit-progress-value {
    background: var(--attend-accent);
  }

  .quiz-bar--correct .quiz-bar__track::-moz-progress-bar {
    background: var(--attend-accent);
  }

  .quiz-bar__pct {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1;
    font-weight: var(--weight-display);
    text-align: end;
  }

  .quiz-bar--none .quiz-bar__name,
  .quiz-bar--none .quiz-bar__pct {
    color: var(--attend-text-muted);
    font-weight: var(--weight-medium);
  }

  .quiz-projector__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    margin-block-start: auto;
    padding-block-start: var(--space-6);
  }

  .quiz-projector__nav-gap {
    min-inline-size: 7rem;
  }

  .quiz-projector__step {
    color: var(--attend-text-strong);
    font-size: clamp(18px, 2vw, 24px);
    line-height: 1.2;
    font-weight: var(--weight-h2);
  }

  /* A landscape screen: the card and the words side by side, the bars in a row
     with the name, the track and the share; the closed question scrolls inside
     the window if eight long choices do not fit. */
  @media (min-width: 900px) and (min-aspect-ratio: 1/1) {
    .quiz-projector__layout {
      --u: min(1dvh, 0.55vw);

      grid-template-columns: minmax(0, 36rem) minmax(0, 1fr);
      block-size: 100%;
      padding: 10dvh clamp(24px, 4vw, 56px);
    }

    .quiz-projector__info {
      --gap: calc(var(--u) * 3);
    }

    .quiz-projector__info .presenter__brand {
      font-size: clamp(32px, calc(var(--u) * 6), 64px);
    }

    .quiz-projector__info .presenter__hint {
      font-size: clamp(28px, calc(var(--u) * 5), 48px);
    }

    /* Beside the wordmark, behind a rule (on a phone it wraps below it, without one). */
    .quiz-projector__quiz {
      padding-inline-start: var(--space-4);
      border-inline-start: 1px solid var(--attend-border-strong);
    }

    .quiz-projector__closed {
      box-sizing: border-box;
      block-size: 100%;
      padding: var(--space-6) clamp(24px, 4vw, 56px) var(--space-6);
      overflow-y: auto;
    }

    .quiz-bar {
      grid-template-columns: minmax(0, 25rem) minmax(0, 1fr) 6.5rem;
    }
  }
}
