:root {
  color-scheme: light;
  --paper-fit: min(calc(100vw - 1rem), 52rem);
  --paper-zoom: 1;
}

* { box-sizing: border-box; }
body { margin: 0; color: #213947; background: #eae7e3; font-family: system-ui, sans-serif; }

.exam-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .3rem .9rem;
  padding: .35rem clamp(.5rem, 3vw, 1.25rem);
  background: #fffdfa;
  border-bottom: 1px solid #d9d3ca;
}
.exam-title, .exam-zoom { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.exam-title h1 { font-size: 1rem; margin: 0 .15rem; }
.exam-toolbar :is(a, button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .25rem .6rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  background: transparent;
  color: #075348;
  font: 650 .875rem/1.2 system-ui, sans-serif;
  text-decoration: none;
}
.exam-toolbar button { min-width: 44px; cursor: pointer; }
.exam-toolbar :is(a, button):hover { background: #edf8f4; border-color: #c4ded7; }
.exam-toolbar :is(a, button):focus-visible { outline: 2px solid #0f7063; outline-offset: 2px; }
.exam-toolbar button:disabled { color: #7b8587; cursor: default; }
.exam-toolbar button[data-zoom-reset] { min-width: 4.1rem; font-variant-numeric: tabular-nums; }

.exam-document { overflow-x: auto; padding: .55rem .5rem 1rem; }
.exam-sheet {
  display: block;
  width: calc(var(--paper-fit) * var(--paper-zoom));
  height: auto;
  margin: 0 auto .58rem;
  background: white;
  box-shadow: 0 2px 9px #2c34322e;
}
.exam-actions, .exam-downloads, .exam-dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
}
.exam-actions { justify-content: flex-end; min-width: 0; }
.exam-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem .65rem;
  min-width: 0;
  color: #213947;
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.65;
}
.exam-clock {
  padding: .13rem .45rem;
  border-radius: .35rem;
  background: #f3e8ee;
  color: #642a46;
  font-size: 1.125rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.exam-actions [hidden], .exam-confirmation [hidden] { display: none; }

.exam-toolbar .exam-primary, .exam-confirmation .exam-primary, .exam-toolbar .exam-downloads a {
  min-height: 46px;
  padding: .42rem .75rem;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.55;
}
.exam-toolbar .exam-primary:not(:disabled), .exam-confirmation .exam-primary:not(:disabled) {
  background: #843a59;
  border-color: #843a59;
  color: #fff;
}
.exam-toolbar .exam-primary:disabled, .exam-confirmation .exam-primary:disabled {
  border-color: #d8cfca;
  background: #efeae6;
  color: #3e4c54;
  opacity: 1;
}
.exam-toolbar .exam-downloads a {
  border-color: #dcb9c9;
  background: #fbf0f4;
  color: #642a46;
}
.exam-toolbar .exam-downloads a:last-child {
  background: transparent;
  border-color: transparent;
  color: #075348;
}
@media (hover: hover) {
  .exam-toolbar .exam-primary:hover:not(:disabled), .exam-confirmation .exam-primary:hover:not(:disabled) {
    background: #642a46;
  }
  .exam-toolbar .exam-downloads a:hover { background: #f3e1e9; }
}
.exam-confirmation {
  width: min(28rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 1rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid #e2c7d4;
  border-radius: .75rem;
  background: #fffdfa;
  color: inherit;
  line-height: 1.75;
}
.exam-confirmation::backdrop { background: #273b47a0; }
.exam-confirmation h2 { margin: 0; font-size: 1.05rem; }
.exam-dialog-actions { justify-content: flex-end; }
.exam-dialog-actions button {
  min-height: 46px;
  padding: .42rem .75rem;
  border: 1px solid #e2c7d4;
  border-radius: .45rem;
  background: #fff;
  color: #213947;
  font: 700 .95rem/1.55 system-ui, sans-serif;
  cursor: pointer;
}
.exam-dialog-actions button:focus-visible { outline: 2px solid #0f7063; outline-offset: 2px; }

@media (max-width: 38rem) {
  .exam-actions { flex: 1 1 100%; }
  .exam-progress { width: 100%; }
  .exam-actions > button, .exam-downloads { width: 100%; }
  .exam-downloads a { flex: 1 1 100%; }
  .exam-finished .exam-toolbar { position: static; }
}
@media (max-height: 420px) {
  .exam-toolbar { position: static; }
}
@media print {
  :root { background: white; }
  .exam-toolbar { display: none; }
  .exam-document { padding: 0; overflow: visible; }
  .exam-sheet { width: 100%; margin: 0; box-shadow: none; break-inside: avoid; break-after: page; }
  .exam-sheet:last-child { break-after: auto; }
  .predicted-exam:not(.exam-finished) .exam-document { display: none; }
}
