.homework-annotation {
  margin: 0;
  display: grid;
  gap: 6px;
}

.homework-annotation__viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(22, 101, 52, 0.18);
  border-radius: 10px;
  background: #ffffff;
}

.homework-annotation__stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  overflow: visible;
  background: #ffffff;
  transform: translate(-50%, -50%) rotate(var(--homework-annotation-rotation, 0deg)) scale(var(--homework-annotation-scale, 1));
  transform-origin: center center;
}

.homework-annotation__stage img {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  user-select: none;
  -webkit-user-drag: none;
}

.homework-annotation[data-homework-annotation-label-rail="1"] .homework-annotation__stage img {
  width: 73.529412%;
}

.homework-annotation__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.homework-annotation figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  font-size: 12px;
}

.homework-annotation figcaption > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.homework-annotation__preview-btn {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 4px 8px;
  background: #ffffff;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.homework-annotation-preview {
  position: fixed;
  width: min(1120px, calc(100vw - 48px));
  max-width: none;
  max-height: min(88dvh, 920px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.32);
  overflow: hidden;
}

.homework-annotation-preview[open] {
  display: flex;
  flex-direction: column;
}

.homework-annotation-preview::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

.homework-annotation-preview__head {
  min-height: 50px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.homework-annotation-preview__head strong {
  min-width: 0;
  overflow: hidden;
  color: #0f172a;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.homework-annotation-preview__zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  white-space: nowrap;
}

.homework-annotation-preview__zoom[hidden] {
  display: none;
}

.homework-annotation-preview__zoom button {
  min-width: 34px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1e3a5f;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.homework-annotation-preview__zoom button:hover:not(:disabled),
.homework-annotation-preview__zoom button:focus-visible {
  border-color: #93b4df;
  background: #eff6ff;
}

.homework-annotation-preview__zoom button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

.homework-annotation-preview__zoom output {
  min-width: 48px;
  color: #334155;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.homework-annotation-preview__source {
  margin-left: auto;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 7px 10px;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.homework-annotation-preview__source:hover,
.homework-annotation-preview__source:focus-visible {
  background: #eff6ff;
}

.homework-annotation-preview__body {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #f8fafc;
}

.homework-annotation-preview__status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f8fafc;
  color: #475569;
  font-size: 16px;
  text-align: center;
  pointer-events: none;
}

.homework-annotation-preview__status[hidden] {
  display: none;
}

.homework-annotation--preview {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.homework-annotation-preview.is-paper-grading {
  width: calc(100vw - 20px);
  height: calc(100dvh - 20px);
  max-height: none;
}

.homework-annotation-preview.is-paper-grading .homework-annotation--preview {
  width: min(1800px, 100%);
  max-width: none;
}

.homework-annotation-preview.is-paper-grading .homework-annotation-preview__body {
  flex: 1;
  overscroll-behavior: contain;
}

.homework-annotation-preview.is-homework-review {
  width: calc(100vw - 24px);
  height: calc(100dvh - 24px);
  max-height: none;
}

.homework-annotation-preview.is-homework-review .homework-annotation--preview {
  width: min(1800px, 100%);
  max-width: none;
}

.homework-annotation-preview.is-homework-review .homework-admin__annotation-viewport {
  max-width: none;
}

.homework-annotation--preview .homework-annotation__viewport {
  border-color: rgba(37, 99, 235, 0.22);
}

@media (max-width: 720px) {
  .homework-annotation-preview {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 10px;
  }

  .homework-annotation-preview.is-homework-review {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  .homework-annotation-preview.is-paper-grading {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  .homework-annotation-preview.is-paper-grading .homework-annotation-preview__head {
    flex-wrap: wrap;
  }

  .homework-annotation-preview.is-paper-grading .homework-annotation-preview__zoom {
    order: 3;
    justify-content: center;
    width: 100%;
  }

  .homework-annotation-preview__body {
    padding: 10px;
  }
}
