.student-preferences {
  --student-prefs-edge: max(0.75rem, env(safe-area-inset-right, 0px));
  --student-prefs-panel-gap: 0.65rem;
  --student-prefs-launcher-block-size: 3.25rem;
  --student-prefs-panel-top-space: 0.5rem;
  position: fixed;
  z-index: 2147483000;
  inset-inline-end: var(--student-prefs-edge);
  bottom: max(var(--student-prefs-bottom-inset, 0.75rem), env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--student-prefs-panel-gap);
  max-inline-size: calc(100vw - 1.5rem);
  color: #f7f7fb;
  font: inherit;
  pointer-events: none;
  isolation: isolate;
}

.student-preferences *,
.student-preferences *::before,
.student-preferences *::after {
  box-sizing: border-box;
}

.student-preferences__button {
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  border: 1px solid #86d8ff;
  border-radius: 0.75rem;
  padding: 0.55rem 0.8rem;
  background: #14283a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
}

.student-preferences__button:hover:not(:disabled) {
  background: #1c3a53;
}

.student-preferences__button:focus-visible {
  outline: 3px solid #ffdc67;
  outline-offset: 3px;
}

.student-preferences__button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.student-preferences__launcher {
  min-inline-size: 3.25rem;
  min-block-size: var(--student-prefs-launcher-block-size);
  border-radius: 999px;
  padding-inline: 0.9rem;
  background: #075985;
  box-shadow: 0 4px 18px rgb(0 0 0 / 32%);
}

.student-preferences__panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + var(--student-prefs-panel-gap));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  inline-size: min(23rem, calc(100vw - 1.5rem));
  max-block-size: max(
    0px,
    calc(
      100vh
      - max(var(--student-prefs-bottom-inset, 0.75rem), env(safe-area-inset-bottom, 0px))
      - var(--student-prefs-launcher-block-size)
      - var(--student-prefs-panel-gap)
      - env(safe-area-inset-top, 0px)
      - var(--student-prefs-panel-top-space)
    )
  );
  max-block-size: max(
    0px,
    calc(
      100dvh
      - max(var(--student-prefs-bottom-inset, 0.75rem), env(safe-area-inset-bottom, 0px))
      - var(--student-prefs-launcher-block-size)
      - var(--student-prefs-panel-gap)
      - env(safe-area-inset-top, 0px)
      - var(--student-prefs-panel-top-space)
    )
  );
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  border: 1px solid rgb(134 216 255 / 70%);
  border-radius: 1rem;
  background: #101923;
  color: #f7f7fb;
  box-shadow: 0 12px 36px rgb(0 0 0 / 42%);
  pointer-events: auto;
  min-inline-size: 0;
}

.student-preferences__panel[hidden] {
  display: none;
}

.student-preferences__header,
.student-preferences__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-inline-size: 0;
  max-inline-size: 100%;
}

.student-preferences__heading {
  margin: 0;
  font-size: 1.1em;
  line-height: 1.25;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.student-preferences__group {
  display: grid;
  gap: 0.45rem;
  min-inline-size: 0;
  inline-size: 100%;
  max-inline-size: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.student-preferences__legend {
  margin-block-end: 0.15rem;
  font-weight: 700;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.student-preferences__stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-inline-size: 0;
  inline-size: 100%;
  max-inline-size: 100%;
}

.student-preferences__stepper .student-preferences__step:last-child {
  justify-self: end;
}

.student-preferences__step {
  min-inline-size: 2.75rem;
  padding-inline: 0.5rem;
  font-size: 1.25em;
}

.student-preferences__value {
  min-inline-size: 3.6em;
  max-inline-size: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.student-preferences__storage-status {
  margin: 0;
  color: #ffe082;
  font-size: 0.9em;
  line-height: 1.4;
}

.student-preferences__storage-status[hidden] {
  display: none;
}

.student-preferences__reset {
  inline-size: 100%;
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

html[data-student-preferences] body :is(
  a.portal-activity__link,
  a.focus-weekly-activity-link,
  .portal-timer-btn
):not([data-student-preferences-control]) {
  zoom: var(--student-prefs-control-scale, 1);
  font-size: var(--student-prefs-control-font-size, 1em);
}

html[data-student-preferences] body .course-progress-donut__graphic {
  zoom: var(--student-prefs-control-zoom, 1);
}

html[data-student-preferences] body .course-progress-donut__graphic strong {
  font-size: calc(1.55rem * var(--student-prefs-font-compensation, 1));
}

html[data-student-preferences] body .course-progress-donut--compact .course-progress-donut__graphic strong {
  font-size: calc(0.92rem * var(--student-prefs-font-compensation, 1));
}

html[data-student-preferences] body .portal-activity__name {
  font-size: calc(var(--student-prefs-control-font-size, 1rem) * 1.125);
}

@media (max-width: 48rem) {
  html[data-student-preferences] body .focus-weekly-activity-name {
    font-size: calc(var(--student-prefs-control-font-size, 1rem) * 0.6875);
  }

  html[data-student-preferences] body .focus-weekly-activity-number {
    font-size: calc(var(--student-prefs-control-font-size, 1rem) * 0.5625);
  }
}

@media (max-width: 28rem) {
  .student-preferences {
    inset-inline-start: max(0.75rem, env(safe-area-inset-left, 0px));
    max-inline-size: none;
  }

  .student-preferences__launcher {
    align-self: flex-end;
  }

  .student-preferences__panel {
    inline-size: min(23rem, 100%);
    padding: 0.875rem;
  }

  html[data-student-preferences] body .course-progress-donut {
    flex-wrap: wrap;
  }
}

@media (max-width: 18rem) {
  html[data-student-preferences] body select:not([data-student-preferences-control]) {
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  html[data-student-preferences] body a.portal-activity__link {
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  html[data-student-preferences] body a.portal-activity__link > span:last-child {
    flex: 1 1 0;
    min-inline-size: 0;
    max-inline-size: 100%;
    overflow-wrap: anywhere;
  }

  .student-preferences__header {
    flex-wrap: wrap;
  }

  .student-preferences__heading {
    flex: 1 1 100%;
  }

  .student-preferences__stepper {
    grid-template-columns: minmax(0, 1fr);
  }

  .student-preferences__stepper .student-preferences__step,
  .student-preferences__stepper .student-preferences__step:last-child {
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    justify-self: stretch;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .student-preferences__value {
    grid-column: 1;
    grid-row: 1;
    min-inline-size: 0;
    padding-block: 0.2rem;
  }

  .student-preferences__stepper,
  .student-preferences__stepper .student-preferences__step,
  .student-preferences__value,
  .student-preferences__storage-status,
  .student-preferences__footer {
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  html[data-student-preferences] body .course-progress-donut__graphic {
    inline-size: min(50vw, 100%);
    block-size: auto;
    max-inline-size: 100%;
    aspect-ratio: 1;
    flex: 0 1 min(50vw, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .student-preferences *,
  .student-preferences *::before,
  .student-preferences *::after {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
  }
}
