.replay-viewer {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: var(--border);
  color: inherit;
  background-color: var(--color-bg);
  overflow: visible;
  padding: unset;
  margin: unset;
  width: min(784px, 100% - 20px);

  &::backdrop {
    background-color: var(--color-backdrop)
  }

  & .replay-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;

    & .replay-volume {
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 2;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      width: 34px;
      height: 34px;
      padding: 9px;
      flex: none;
      border: none;
      background-color: transparent;
      color: inherit;
      cursor: pointer;

      &:hover,
      &:focus-visible {
        color: inherit;
        background-color: transparent
      }
    }

    & .replay-floating-label {
      padding: 2px 6px;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.2;
      white-space: nowrap;
      color: var(--color-bg);
      background-color: var(--color-text);
      border-radius: 2px;
      pointer-events: none
    }

    & .replay-stage-top-actions {
      position: absolute;
      top: 8px;
      right: 8px;
      z-index: 2;
      display: flex;
      flex-direction: row;
      column-gap: 4px;
      pointer-events: none;

      & button {
        pointer-events: auto
      }

      & .replay-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        flex: none;
        padding: 0;
        border: none;
        background-color: transparent;
        color: inherit;
        cursor: pointer;

        &:hover,
        &:focus-visible {
          color: inherit;
          background-color: transparent
        }

        & svg {
          height: 20px
        }
      }

      & .replay-share-stack {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;

        & .replay-floating-label {
          position: absolute;
          bottom: 100%;
          left: 50%;
          transform: translate(-50%, 4px);
          opacity: 0;
          transition: opacity .12s ease, transform .12s ease
        }

        & .replay-floating-label[data-visible] {
          opacity: 1;
          transform: translate(-50%, 0);
        }


        & .replay-icon-btn {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          width: 34px;
          height: 34px;
          flex: none;
          padding: 0;
          border: none;
          background-color: transparent;
          color: inherit;
          cursor: pointer;

          & svg {
            height: 16px
          }
        }
      }
    }

    & canvas {
      display: block;
      width: 100%;
      height: auto
    }

    &:fullscreen {
      box-sizing: border-box;
      width: 100%;
      height: 100%;
      min-height: 100%
    }

    &:fullscreen canvas {
      flex: 1 1 0;
      min-height: 0;
      width: 100%;
      height: 100%;
      max-height: 100%
    }

    &:fullscreen .controls {
      padding: 0 40px 12px
    }

    & .controls {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      grid-template-rows: auto auto;
      align-items: center;
      gap: 12px;
      padding: 0 18px 9px;
      pointer-events: none;

      & button,
      & .replay-track,
      & .replay-playhead {
        pointer-events: auto
      }

      & .replay-timeline {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: -14px;

        & .replay-viewer-meta {
          display: block;
          margin-bottom: 3px;
          font-size: 14px;
          text-align: end;
          opacity: .9;

          & .replay-tick-sep {
            margin-inline: 4px
          }
        }

        & .replay-track-wrap {
          position: relative;
          height: 28px;
          touch-action: none;

          &[data-scrubbing] {
            cursor: grabbing;

            & .replay-playhead {
              cursor: grabbing
            }
          }

          & .replay-track {
            position: absolute;
            left: 0;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            height: 3px;
            background-color: var(--color-tp);
            cursor: pointer;
            overflow: visible;

            &::before {
              content: '';
              position: absolute;
              left: 0;
              top: 50%;
              transform: translateY(-50%);
              width: 100%;
              height: 16px;
              cursor: pointer;
            }

            & .replay-track-fill {
              display: block;
              height: 100%;
              width: 0%;
              background-color: var(--color-accent, #fff);
              pointer-events: none
            }

            & .replay-rip-markers {
              position: absolute;
              inset: 0;
              pointer-events: none;

              & .replay-rip-marker {
                position: absolute;
                top: -10px;
                bottom: -10px;
                width: 2px;
                margin-left: -1px;
                background-color: var(--color-error);
                pointer-events: auto;
                cursor: default;

                &::before {
                  content: '';
                  position: absolute;
                  left: 50%;
                  top: -5px;
                  bottom: -5px;
                  width: 12px;
                  transform: translateX(-50%);
                  pointer-events: auto
                }

                & .replay-floating-label {
                  position: absolute;
                  bottom: calc(100% + 6px);
                  left: 50%;
                  transform: translate(-50%, 4px);
                  opacity: 0;
                  transition: opacity .12s ease, transform .12s ease
                }

                &:hover .replay-floating-label {
                  opacity: 1;
                  transform: translate(-50%, 0)
                }
              }
            }
          }

          & .replay-playhead {
            position: absolute;
            top: 50%;
            left: 0%;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: var(--color-text);
            transform: translate(-50%, -50%);
            cursor: grab;
            z-index: 2;
          }
        }
      }

      & .replay-icon-btn:not([hidden]) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        padding: 0;
        border: none;
        background-color: transparent;
        color: inherit;
        cursor: pointer;

        &:hover,
        &:focus-visible {
          background-color: transparent
        }

        & svg {
          height: 20px
        }
      }

      & .controls-transport {
        grid-row: 2;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        justify-content: flex-start
      }

      & .controls-follow {
        --player-name-width: 178px;
        grid-row: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: var(--player-name-width);

        & .replay-follow-name {
          font-size: 14px;
          width: calc(var(--player-name-width) - 30px * 2);
          overflow: hidden;
          text-overflow: ellipsis;
          margin-inline: auto;
          white-space: nowrap;
          text-align: center
        }
      }

      & .controls-fullscreen {
        grid-row: 2;
        justify-self: end
      }
    }
  }
}